This commit is contained in:
gaowdong 2025-04-14 17:38:59 +08:00
parent a7ee37083c
commit 5a9abe6a2c
3 changed files with 15 additions and 7 deletions

View File

@ -13,4 +13,5 @@ public class WalletBalanceOperation {
private Integer tradeType; private Integer tradeType;
private Integer payChannel; private Integer payChannel;
private Integer payType; private Integer payType;
private Long orderNo;
} }

View File

@ -194,6 +194,7 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
walletUpdateDTO.getPayChannelEnum().getKey(), walletUpdateDTO.getPayChannelEnum().getKey(),
walletUpdateDTO.getPayTypeEnum().getKey()); walletUpdateDTO.getPayTypeEnum().getKey());
operation.setOperationType(WalletBalanceOperationEnum.ADD_BAL.getKey()); operation.setOperationType(WalletBalanceOperationEnum.ADD_BAL.getKey());
operation.setOrderNo(walletUpdateDTO.getOrderNo());
acWalletBalanceOperation(operation); acWalletBalanceOperation(operation);
log.info("新增钱包结束"); log.info("新增钱包结束");
} finally { } finally {
@ -219,6 +220,7 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
walletUpdateDTO.getPayChannelEnum().getKey(), walletUpdateDTO.getPayChannelEnum().getKey(),
walletUpdateDTO.getPayTypeEnum().getKey()); walletUpdateDTO.getPayTypeEnum().getKey());
operation.setOperationType(WalletBalanceOperationEnum.REDUCE_BAL.getKey()); operation.setOperationType(WalletBalanceOperationEnum.REDUCE_BAL.getKey());
operation.setOrderNo(walletUpdateDTO.getOrderNo());
acWalletBalanceOperation(operation); acWalletBalanceOperation(operation);
log.info("扣减钱包结束"); log.info("扣减钱包结束");
} finally { } finally {
@ -278,6 +280,9 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
if(Objects.nonNull(sysUser)) { if(Objects.nonNull(sysUser)) {
accTrade.setDeptId(sysUser.getDeptId()); accTrade.setDeptId(sysUser.getDeptId());
} }
if(Objects.nonNull(operation.getOrderNo())) {
accTrade.setOrderNo(operation.getOrderNo().toString());
}
this.accTradeService.insertAccTrade(accTrade); this.accTradeService.insertAccTrade(accTrade);
AccTradeWalletDetail accTradeWalletDetail = new AccTradeWalletDetail(); AccTradeWalletDetail accTradeWalletDetail = new AccTradeWalletDetail();

View File

@ -101,7 +101,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
throw new ServiceException("钱包余额不足"); throw new ServiceException("钱包余额不足");
} }
deductFromWallets(orderInfo, subsidyWalletBal, personalWalletBal); deductFromWallets(orderInfo, subsidyWalletBal);
} catch (Exception ex) { } catch (Exception ex) {
OrderInfo failOrderInfo = new OrderInfo(); OrderInfo failOrderInfo = new OrderInfo();
failOrderInfo.setOrderId(orderInfo.getOrderId()); failOrderInfo.setOrderId(orderInfo.getOrderId());
@ -126,19 +126,20 @@ public class OrderInfoServiceImpl implements IOrderInfoService
.orElse(BigDecimal.ZERO); .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) { 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) { } 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); BigDecimal remainAmount = orderInfo.getRealAmount().subtract(subsidyWalletBal);
deductWalletBalance(remainAmount, orderInfo.getUserId(), AccWalletIdEnum.WALLET); deductWalletBalance(remainAmount, orderInfo.getUserId(), AccWalletIdEnum.WALLET, orderNo);
} else { } 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 walletUpdateDTO = new WalletUpdateDTO();
walletUpdateDTO.setAmount(amount); walletUpdateDTO.setAmount(amount);
walletUpdateDTO.setUserId(userId); walletUpdateDTO.setUserId(userId);
@ -146,6 +147,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
walletUpdateDTO.setAccTradeTypeEnum(AccTradeTypeEnum.CONSUME); walletUpdateDTO.setAccTradeTypeEnum(AccTradeTypeEnum.CONSUME);
walletUpdateDTO.setPayChannelEnum(PayChannelEnum.ACC); walletUpdateDTO.setPayChannelEnum(PayChannelEnum.ACC);
walletUpdateDTO.setPayTypeEnum(PayTypeEnum.MEAL_CARD); walletUpdateDTO.setPayTypeEnum(PayTypeEnum.MEAL_CARD);
walletUpdateDTO.setOrderNo(orderNo);
accWalletInfoService.clearAccWalletBalance(walletUpdateDTO); accWalletInfoService.clearAccWalletBalance(walletUpdateDTO);
} }