@@ -45,6 +45,7 @@ namespace CoreCms.Net.Services
45
45
public class CoreCmsOrderServices : BaseServices < CoreCmsOrder > , ICoreCmsOrderServices
46
46
{
47
47
private readonly ICoreCmsOrderRepository _dal ;
48
+ private readonly ICoreCmsUserRepository _Userdal ;
48
49
49
50
private readonly IHttpContextAccessor _httpContextAccessor ;
50
51
private readonly ICoreCmsShipServices _shipServices ;
@@ -100,11 +101,11 @@ public CoreCmsOrderServices(ICoreCmsOrderRepository dal
100
101
, ICoreCmsPaymentsServices paymentsServices
101
102
, ICoreCmsBillRefundServices billRefundServices
102
103
, 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 )
104
105
{
105
106
this . _dal = dal ;
106
107
base . BaseDal = dal ;
107
-
108
+ this . _Userdal = Userdal ;
108
109
_httpContextAccessor = httpContextAccessor ;
109
110
_shipServices = shipServices ;
110
111
_cartServices = cartServices ;
@@ -1311,6 +1312,18 @@ public async Task<WebApiCallBack> Pay(string orderId, string paymentCode, CoreCm
1311
1312
1312
1313
//获取订单
1313
1314
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
+
1314
1327
if ( order == null )
1315
1328
{
1316
1329
return jm ;
@@ -1345,6 +1358,11 @@ public async Task<WebApiCallBack> Pay(string orderId, string paymentCode, CoreCm
1345
1358
order . payStatus = ( int ) GlobalEnumVars . OrderPayStatus . Yes ;
1346
1359
jm . status = true ;
1347
1360
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
+
1348
1366
1349
1367
//发票存储
1350
1368
if ( order . taxType != ( int ) GlobalEnumVars . OrderTaxType . No )
0 commit comments