From ab0eee51d03653bd5bcbb560842d8b2f1b2d36f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=85=95=E4=B8=8B?= <484014559@qq.com> Date: Mon, 26 Aug 2024 10:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=A8=A1=E5=9D=97=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pay/service/order/PayOrderServiceImpl.java | 5 +++++ .../wallet/PayWalletRechargeServiceImpl.java | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java index 75d859c..6a6dbb9 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java @@ -33,6 +33,7 @@ import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; import cn.iocoder.yudao.module.pay.service.app.PayAppService; import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -49,6 +50,7 @@ import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.RECHARGE; /** * 支付订单 Service 实现类 @@ -78,6 +80,8 @@ public class PayOrderServiceImpl implements PayOrderService { private PayNotifyService notifyService; @Resource private PayWalletRechargeMapper walletRechargeMapper; + @Resource + private PayWalletService payWalletService; @Override public PayOrderDO getOrder(Long id) { @@ -264,6 +268,7 @@ public class PayOrderServiceImpl implements PayOrderService { walletRechargeDO.setPayStatus(true); walletRechargeDO.setPayTime(LocalDateTime.now()); walletRechargeMapper.updateById(walletRechargeDO); + payWalletService.addWalletBalance(walletRechargeDO.getWalletId(),walletRechargeDO.getPayOrderId().toString(),RECHARGE,walletRechargeDO.getTotalPrice()); } } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java index ba479b2..3d6493a 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java @@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +35,7 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.RECHARGE; /** * 钱包充值 Service 实现类 @@ -61,6 +63,8 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { private PayRefundService payRefundService; @Resource private PayWalletRechargePackageService payWalletRechargePackageService; + @Resource + private PayWalletTransactionService payWalletTransactionService; @Override @Transactional(rollbackFor = Exception.class) @@ -91,6 +95,15 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { // 2.2 更新钱包充值记录中支付订单 walletRechargeMapper.updateById(new PayWalletRechargeDO().setId(recharge.getId()).setPayOrderId(payOrderId)); recharge.setPayOrderId(payOrderId); +// WalletTransactionCreateReqBO reqBO = new WalletTransactionCreateReqBO(); +// reqBO.setBalance(wallet.getBalance()+recharge.getTotalPrice()); +// reqBO.setBizId(recharge.getPayOrderId().toString()); +// reqBO.setBizType(1); +// reqBO.setPrice(recharge.getTotalPrice()); +// reqBO.setTitle("充值"); +// reqBO.setWalletId(recharge.getWalletId()); +// payWalletTransactionService.createWalletTransaction(reqBO); +// payWalletService.addWalletBalance(recharge.getWalletId(),recharge.getPayOrderId().toString(),RECHARGE,recharge.getTotalPrice()); return recharge; } @@ -125,7 +138,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; // TODO 需要钱包中加个可提现余额 payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), - PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); + RECHARGE, walletRecharge.getTotalPrice()); } @Override