同步物流 扣费
This commit is contained in:
1 parent
69b39196f5
commit
2f21292b3c
5 files changed
+8
-8
No files matched your search
@@ -70,8 +70,8 @@ namespace KJD_Web.Controllers
|
||||
[HttpPost]
|
||||
public IHttpActionResult GetUserMarkups( GetUserMarkupsRequest request)
|
||||
{
|
||||
//if (!ValidateSign(request)) return Ok(ApiResult.Fail("校验失败", 999));
|
||||
//if (!ModelState.IsValid) return Ok(ApiResult.Fail("请求参数格式错误", ResultCode.ValidationError));
|
||||
if (!ValidateSign(request)) return Ok(ApiResult.Fail("校验失败", 999));
|
||||
if (!ModelState.IsValid) return Ok(ApiResult.Fail("请求参数格式错误", ResultCode.ValidationError));
|
||||
try
|
||||
{
|
||||
return Ok(ApiResult.Success(data: _userService.GetUserMarkups(request.UserName, request.PaymentType)));
|
||||
|
||||
@@ -471,14 +471,14 @@ namespace KJD_Web.Services.Users
|
||||
/// <param name="type"></param>
|
||||
/// <param name="consumeAmount"></param>
|
||||
/// <returns></returns>
|
||||
public bool CanAfford(string userName, UserPaymentTypes type, decimal consumeAmount)
|
||||
public bool CanAfford(string userName, UserPaymentTypes type)
|
||||
{
|
||||
var user = GetUserByUserName(userName);
|
||||
if (user == null) return false;
|
||||
// 消费金额必须大于 0
|
||||
if (user.Balance <= 0) return false;
|
||||
if (type != UserPaymentTypes.同步物流) return false;
|
||||
consumeAmount = (user.SyncLogisticsPerOrder ?? 0m) + consumeAmount;
|
||||
decimal consumeAmount = GetUserFinalPrice(userName, UserPaymentTypes.同步物流) / 100m; //(user.SyncLogisticsPerOrder ?? 0m) + consumeAmount;
|
||||
return user.Balance >= consumeAmount;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface IUserService
|
||||
int GetUserFinalPrice(string userName, UserPaymentTypes paymentType);
|
||||
/// <summary>批量查询四种最终价格,返回用户名到消费类型、价格(分)的映射。</summary>
|
||||
Dictionary<string, Dictionary<UserPaymentTypes, int>> GetUserFinalPrices(IEnumerable<UserEntity> users);
|
||||
bool CanAfford(string userName, UserPaymentTypes type, decimal consumeAmount);
|
||||
bool CanAfford(string userName, UserPaymentTypes type);
|
||||
OEMEntity GetOEMByOemId(string oemId, bool isCache = true);
|
||||
OEMEntity GetOEMByUserName(string userName, bool isCache = true);
|
||||
List<UserEntity> GetOEMUsers(string oemId, bool includeSu = true);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class VirtualLogisticsService : ITransientDependency
|
||||
/// <summary>
|
||||
/// 固定费用1.7元->1.9元(260927涨价啦)
|
||||
/// </summary>
|
||||
const decimal FIXEDFEES = 1.9m;
|
||||
//const decimal FIXEDFEES = 1.9m;
|
||||
private IFreeSql _freeSql;
|
||||
private readonly ILoggerFacade _logger;
|
||||
private readonly IUserService _userService;
|
||||
@@ -82,7 +82,7 @@ public class VirtualLogisticsService : ITransientDependency
|
||||
}
|
||||
var user = _userService.GetUserByUserName(userName);
|
||||
if (user == null) throw new Exception("错误的账号");
|
||||
if (_userService.CanAfford(userName, Contracts.User.Enums.UserPaymentTypes.同步物流, FIXEDFEES) == false)
|
||||
if (_userService.CanAfford(userName, Contracts.User.Enums.UserPaymentTypes.同步物流) == false)
|
||||
{
|
||||
throw new Exception("余额不足");
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ internal class GiftLogisticsTest
|
||||
public void BuyTest()
|
||||
{
|
||||
var logisticsService = _container.Resolve<VirtualLogisticsService>();
|
||||
var ret = logisticsService.Buy("16603999396", "260924-061299770880192", "4439386298687207168");
|
||||
var ret = logisticsService.Buy("19826590224", "260924-061299770880192", "4439386298687207168");
|
||||
if (ret != null)
|
||||
{
|
||||
Console.WriteLine(string.Join(" ", ret.Select(a => $"{a.OrderId}:{a.TrackingNumber}")));
|
||||
|
||||
Reference in new issue
Block a user