|
@@ -121,6 +121,9 @@ public class TaOrgOrderServiceImpl extends ServiceImpl<TaOrgOrderMapper, TaOrgOr
|
121
|
121
|
if (CommConstant.ITEM_TYPE_RECHARGE.equals(orderType) || CommConstant.ITEM_TYPE_REFUND.equals(orderType)) {
|
122
|
122
|
result = taOrgOrderMapper.orderListByRechargeOrRefund(pg, orderType, orgId, tradeNo, isOffline, tradingStatus, startDate, endDate, miniAppName, auditStatus, payStartDate, payEndDate);
|
123
|
123
|
result.getRecords().forEach(e -> {
|
|
124
|
+ if (CommConstant.ITEM_TYPE_REFUND.equals(orderType)){
|
|
125
|
+ e.setAvailableBalance(calculateAvailableAmount(e.getOrgId()));
|
|
126
|
+ }
|
124
|
127
|
e.setCertificateUrlList(getCertificateByOrderId(e.getOrderId()));
|
125
|
128
|
});
|
126
|
129
|
return result;
|
|
@@ -159,6 +162,20 @@ public class TaOrgOrderServiceImpl extends ServiceImpl<TaOrgOrderMapper, TaOrgOr
|
159
|
162
|
return urlList;
|
160
|
163
|
}
|
161
|
164
|
|
|
165
|
+ public Integer calculateAvailableAmount(Integer orgId){
|
|
166
|
+ TaOrgAccount taOrgAccount = taOrgAccountMapper.getOrgAccountById(orgId);
|
|
167
|
+
|
|
168
|
+ //查询总充值金额
|
|
169
|
+ Integer totalRechargeAmount = taOrgOrderMapper.countTotalRechargeAmount(orgId);
|
|
170
|
+
|
|
171
|
+ //查询退款冻结额
|
|
172
|
+ Integer totalBlockAmount = taOrgAccountBlockedMapper.countTotalBlockAmount(orgId);
|
|
173
|
+
|
|
174
|
+ //账户余额=总充值金额-已消费金额-已退款额-退款冻结额
|
|
175
|
+ Integer balance = totalRechargeAmount - taOrgAccount.getPurchaseAmount() - taOrgAccount.getTotalRefund() - totalBlockAmount;
|
|
176
|
+
|
|
177
|
+ return balance;
|
|
178
|
+ }
|
162
|
179
|
/**
|
163
|
180
|
* 微信支付
|
164
|
181
|
*
|
|
@@ -593,23 +610,16 @@ public class TaOrgOrderServiceImpl extends ServiceImpl<TaOrgOrderMapper, TaOrgOr
|
593
|
610
|
TaOrgRefundApplication updateRefundApplication = assembleRefundApplication(userId, CommConstant.ITEM_TYPE_REJECT, refundApplication);
|
594
|
611
|
QueryWrapper<TaOrgRefundApplication> taOrgRefundApplicationQueryWrapper = new QueryWrapper<>();
|
595
|
612
|
taOrgRefundApplicationQueryWrapper.eq("order_id", id);
|
596
|
|
- int taOrgRefundApplicationUpdateResult = taOrgRefundApplicationMapper.update(updateRefundApplication, taOrgRefundApplicationQueryWrapper);
|
|
613
|
+ taOrgRefundApplicationMapper.update(updateRefundApplication, taOrgRefundApplicationQueryWrapper);
|
597
|
614
|
|
598
|
615
|
//更新账户冻结记录
|
599
|
|
- int taOrgAccountBlockedUpdateResult = updateOrgAccountBlock(refundApplication, selectRefundApplication.getBlockedId());
|
|
616
|
+ updateOrgAccountBlock(refundApplication, selectRefundApplication.getBlockedId());
|
600
|
617
|
|
601
|
618
|
//更新订单状态
|
602
|
619
|
TaOrgOrder taOrgOrder = new TaOrgOrder();
|
603
|
620
|
taOrgOrder.setOrderId(id);
|
604
|
621
|
taOrgOrder.setTradingStatus(CommConstant.TRADING_STATUS_FAIL);
|
605
|
|
- int taOrgOrderUpdateResult = taOrgOrderMapper.updateById(taOrgOrder);
|
606
|
|
-
|
607
|
|
- if (taOrgAccountBlockedUpdateResult < 1 ||
|
608
|
|
- taOrgRefundApplicationUpdateResult < 1 ||
|
609
|
|
- taOrgOrderUpdateResult < 1) {
|
610
|
|
- responseBean.addError("驳回失败");
|
611
|
|
- return responseBean;
|
612
|
|
- }
|
|
622
|
+ taOrgOrderMapper.updateById(taOrgOrder);
|
613
|
623
|
|
614
|
624
|
return responseBean;
|
615
|
625
|
|