Skip to content

Commit 4c41a5d

Browse files
committed
【修改】修复后台管理账户余额小于需要支付的订单金额但是支付后显示支付成功的问题
1 parent f17cd56 commit 4c41a5d

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

CoreCms.Net.IRepository/IBaseRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace CoreCms.Net.IRepository
3232
T QueryById(object pkValue, bool blUseNoLock = false);
3333

3434
/// <summary>
35-
/// 根据主值查询单条数据
35+
/// 根据主值查询单条数据1
3636
/// </summary>
3737
/// <param name="objId"></param>
3838
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>

CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ public async Task<WebApiCallBack> ToUpdate(string paymentId, int status, string
627627
var orderServices = container.ServiceProvider.GetService<ICoreCmsOrderServices>();
628628

629629
var jm = new WebApiCallBack();
630-
630+
631631
var billPaymentInfo = await _dal.QueryByClauseAsync(p =>
632632
p.paymentId == paymentId && p.money == money &&
633633
p.status != (int)GlobalEnumVars.BillPaymentsStatus.Payed);
@@ -643,14 +643,15 @@ public async Task<WebApiCallBack> ToUpdate(string paymentId, int status, string
643643
billPaymentInfo.payedMsg = payedMsg;
644644
billPaymentInfo.tradeNo = tradeNo;
645645
billPaymentInfo.updateTime = DateTime.Now;
646-
646+
647647
await _dal.UpdateAsync(billPaymentInfo);
648648
if (status == (int)GlobalEnumVars.BillPaymentsStatus.Payed)
649649
{
650650
if (billPaymentInfo.type == (int)GlobalEnumVars.BillPaymentsType.Order)
651651
{
652652
//如果是订单类型,做支付后处理
653-
await orderServices.Pay(billPaymentInfo.sourceId, paymentCode, billPaymentInfo);
653+
jm= await orderServices.Pay(billPaymentInfo.sourceId, paymentCode, billPaymentInfo);
654+
654655
}
655656
else if (billPaymentInfo.type == (int)GlobalEnumVars.BillPaymentsType.Recharge)
656657
{
@@ -674,6 +675,11 @@ public async Task<WebApiCallBack> ToUpdate(string paymentId, int status, string
674675
//::todo 其他业务逻辑
675676
}
676677
}
678+
679+
if (jm.status == false)
680+
{
681+
return jm;
682+
}
677683
jm.status = true;
678684
jm.data = paymentId;
679685
jm.msg = "支付成功";
@@ -766,7 +772,8 @@ private async Task<string> PayTitle(CoreCmsBillPayments entity)
766772
/// <returns></returns>
767773
public async Task<WebApiCallBack> ToPay(string orderId, int type, string paymentCode)
768774
{
769-
using (var container = _serviceProvider.CreateScope())
775+
using (
776+
var container = _serviceProvider.CreateScope())
770777
{
771778
var orderServices = container.ServiceProvider.GetService<ICoreCmsOrderServices>();
772779

CoreCms.Net.Services/Order/CoreCmsOrderServices.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace CoreCms.Net.Services
4545
public class CoreCmsOrderServices : BaseServices<CoreCmsOrder>, ICoreCmsOrderServices
4646
{
4747
private readonly ICoreCmsOrderRepository _dal;
48+
private readonly ICoreCmsUserRepository _Userdal;
4849

4950
private readonly IHttpContextAccessor _httpContextAccessor;
5051
private readonly ICoreCmsShipServices _shipServices;
@@ -100,11 +101,11 @@ public CoreCmsOrderServices(ICoreCmsOrderRepository dal
100101
, ICoreCmsPaymentsServices paymentsServices
101102
, ICoreCmsBillRefundServices billRefundServices
102103
, ICoreCmsBillLadingServices billLadingServices
103-
, ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository)
104+
, ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserRepository Userdal)
104105
{
105106
this._dal = dal;
106107
base.BaseDal = dal;
107-
108+
this._Userdal = Userdal;
108109
_httpContextAccessor = httpContextAccessor;
109110
_shipServices = shipServices;
110111
_cartServices = cartServices;
@@ -1311,6 +1312,18 @@ public async Task<WebApiCallBack> Pay(string orderId, string paymentCode, CoreCm
13111312

13121313
//获取订单
13131314
var order = await _dal.QueryByClauseAsync(p => p.orderId == orderId && p.status == (int)GlobalEnumVars.OrderStatus.Normal);
1315+
//获取余额
1316+
var balanceMoney = await _Userdal.QueryByIdAsync(order.userId);
1317+
1318+
//若余额小于待付款金额
1319+
if (order.goodsAmount > balanceMoney.balance)
1320+
{
1321+
jm.msg = "余额不足订单支付失败";
1322+
jm.status = false;
1323+
1324+
return jm;
1325+
}
1326+
13141327
if (order == null)
13151328
{
13161329
return jm;
@@ -1345,6 +1358,11 @@ public async Task<WebApiCallBack> Pay(string orderId, string paymentCode, CoreCm
13451358
order.payStatus = (int)GlobalEnumVars.OrderPayStatus.Yes;
13461359
jm.status = true;
13471360
jm.msg = "订单支付成功";
1361+
var newMoney = balanceMoney.balance - order.goodsAmount;
1362+
//支付成功后
1363+
//更改余额信息
1364+
var up = await _Userdal.UpdateAsync(p => new CoreCmsUser() { balance = newMoney }, p => p.id == order.userId);
1365+
13481366

13491367
//发票存储
13501368
if (order.taxType != (int)GlobalEnumVars.OrderTaxType.No)

CoreShop - 快捷方式.lnk

883 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)