This commit is contained in:
parent
a7ee37083c
commit
5a9abe6a2c
|
|
@ -13,4 +13,5 @@ public class WalletBalanceOperation {
|
|||
private Integer tradeType;
|
||||
private Integer payChannel;
|
||||
private Integer payType;
|
||||
private Long orderNo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
|||
walletUpdateDTO.getPayChannelEnum().getKey(),
|
||||
walletUpdateDTO.getPayTypeEnum().getKey());
|
||||
operation.setOperationType(WalletBalanceOperationEnum.ADD_BAL.getKey());
|
||||
operation.setOrderNo(walletUpdateDTO.getOrderNo());
|
||||
acWalletBalanceOperation(operation);
|
||||
log.info("新增钱包结束");
|
||||
} finally {
|
||||
|
|
@ -219,6 +220,7 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
|||
walletUpdateDTO.getPayChannelEnum().getKey(),
|
||||
walletUpdateDTO.getPayTypeEnum().getKey());
|
||||
operation.setOperationType(WalletBalanceOperationEnum.REDUCE_BAL.getKey());
|
||||
operation.setOrderNo(walletUpdateDTO.getOrderNo());
|
||||
acWalletBalanceOperation(operation);
|
||||
log.info("扣减钱包结束");
|
||||
} finally {
|
||||
|
|
@ -278,6 +280,9 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
|||
if(Objects.nonNull(sysUser)) {
|
||||
accTrade.setDeptId(sysUser.getDeptId());
|
||||
}
|
||||
if(Objects.nonNull(operation.getOrderNo())) {
|
||||
accTrade.setOrderNo(operation.getOrderNo().toString());
|
||||
}
|
||||
this.accTradeService.insertAccTrade(accTrade);
|
||||
|
||||
AccTradeWalletDetail accTradeWalletDetail = new AccTradeWalletDetail();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
throw new ServiceException("钱包余额不足");
|
||||
}
|
||||
|
||||
deductFromWallets(orderInfo, subsidyWalletBal, personalWalletBal);
|
||||
deductFromWallets(orderInfo, subsidyWalletBal);
|
||||
} catch (Exception ex) {
|
||||
OrderInfo failOrderInfo = new OrderInfo();
|
||||
failOrderInfo.setOrderId(orderInfo.getOrderId());
|
||||
|
|
@ -126,19 +126,20 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
.orElse(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
private void deductFromWallets(OrderInfo orderInfo, BigDecimal subsidyWalletBal, BigDecimal personalWalletBal) {
|
||||
private void deductFromWallets(OrderInfo orderInfo, BigDecimal subsidyWalletBal) {
|
||||
Long orderNo = orderInfo.getOrderId();
|
||||
if (orderInfo.getRealAmount().compareTo(subsidyWalletBal) <= 0) {
|
||||
deductWalletBalance(orderInfo.getRealAmount(), orderInfo.getUserId(), AccWalletIdEnum.SUBSIDY);
|
||||
deductWalletBalance(orderInfo.getRealAmount(), orderInfo.getUserId(), AccWalletIdEnum.SUBSIDY, orderNo);
|
||||
} else if (subsidyWalletBal.compareTo(BigDecimal.ZERO) > 0) {
|
||||
deductWalletBalance(subsidyWalletBal, orderInfo.getUserId(), AccWalletIdEnum.SUBSIDY);
|
||||
deductWalletBalance(subsidyWalletBal, orderInfo.getUserId(), AccWalletIdEnum.SUBSIDY, orderNo);
|
||||
BigDecimal remainAmount = orderInfo.getRealAmount().subtract(subsidyWalletBal);
|
||||
deductWalletBalance(remainAmount, orderInfo.getUserId(), AccWalletIdEnum.WALLET);
|
||||
deductWalletBalance(remainAmount, orderInfo.getUserId(), AccWalletIdEnum.WALLET, orderNo);
|
||||
} else {
|
||||
deductWalletBalance(orderInfo.getRealAmount(), orderInfo.getUserId(), AccWalletIdEnum.WALLET);
|
||||
deductWalletBalance(orderInfo.getRealAmount(), orderInfo.getUserId(), AccWalletIdEnum.WALLET, orderNo);
|
||||
}
|
||||
}
|
||||
|
||||
private void deductWalletBalance(BigDecimal amount, Long userId, AccWalletIdEnum walletIdEnum) {
|
||||
private void deductWalletBalance(BigDecimal amount, Long userId, AccWalletIdEnum walletIdEnum, Long orderNo) {
|
||||
WalletUpdateDTO walletUpdateDTO = new WalletUpdateDTO();
|
||||
walletUpdateDTO.setAmount(amount);
|
||||
walletUpdateDTO.setUserId(userId);
|
||||
|
|
@ -146,6 +147,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
walletUpdateDTO.setAccTradeTypeEnum(AccTradeTypeEnum.CONSUME);
|
||||
walletUpdateDTO.setPayChannelEnum(PayChannelEnum.ACC);
|
||||
walletUpdateDTO.setPayTypeEnum(PayTypeEnum.MEAL_CARD);
|
||||
walletUpdateDTO.setOrderNo(orderNo);
|
||||
accWalletInfoService.clearAccWalletBalance(walletUpdateDTO);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue