diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index b318e84..c8285e9 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -76,8 +76,10 @@ public class AppTradeOrderController { @Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob @PermitAll public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { + System.out.println("进入回调notify:"+ notifyReqDTO); tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayOrderId()); + System.out.println("订单更新完成"); return success(true); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradePaidMemberUserService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradePaidMemberUserService.java index 823c807..0a92857 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradePaidMemberUserService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradePaidMemberUserService.java @@ -32,6 +32,6 @@ public interface TradePaidMemberUserService { - TradePaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId); + TradePaidMemberUserDO getByPayOrderId(Long payOrderId); } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradeTradePaidMemberUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradeTradePaidMemberUserServiceImpl.java index 34c5b17..6580529 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradeTradePaidMemberUserServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/member/TradeTradePaidMemberUserServiceImpl.java @@ -85,10 +85,12 @@ public class TradeTradePaidMemberUserServiceImpl implements TradePaidMemberUserS @Override - public TradePaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId) { + public TradePaidMemberUserDO getByPayOrderId(Long payOrderId) { TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserMapper.selectOne( - new LambdaQueryWrapperX().eqIfPresent(TradePaidMemberUserDO::getId,id) - .eqIfPresent(TradePaidMemberUserDO::getPayOrderId,payOrderId)); + new LambdaQueryWrapperX().eqIfPresent(TradePaidMemberUserDO::getPayOrderId,payOrderId)); + if (tradePaidMemberUserDO == null) { + throw exception(PAID_MEMBER_ORDER_NOT_EXISTS); + } return tradePaidMemberUserDO; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 7c2e0c7..880d53a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -330,14 +330,16 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Transactional(rollbackFor = Exception.class) @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PAY) public void updateOrderPaid(Long id, Long payOrderId) { + System.out.println("进入校验"); // 1. 校验并获得交易订单(可支付) KeyValue orderResult = validateOrderPayable(id, payOrderId); + System.out.println("校验成功"); TradeOrderDO order = orderResult.getKey(); PayOrderRespDTO payOrder = orderResult.getValue(); System.out.println("交易订单成功id:"+id+"和payOrderId:"+payOrderId); //会员用户信息,支付状态修改 TradeMemberUserDO tradeMemberUserDO = tradeMemberUserService.getUser(getLoginUserId()); - TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserService.getByIdAndPayOrderId(id,payOrderId); + TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserService.getByPayOrderId(payOrderId); if(tradePaidMemberUserDO != null && tradeMemberUserDO != null){ System.out.println("进入会员支付修改操作paid:"+tradePaidMemberUserDO+"和member:"+tradeMemberUserDO); tradePaidMemberUserDO.setPayTime(LocalDateTime.now()); diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserService.java index 67ada52..6561e8b 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserService.java @@ -84,6 +84,6 @@ public interface PaidMemberUserService { */ PageResult getMemberUserPage(PaidMemberUserPageReqVO pageReqVO); - PaidMemberUserDO getByIdAndPayOrderId(Long id,Long payOrderId); + PaidMemberUserDO getByPayOrderId(Long payOrderId); } \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserServiceImpl.java index b9fa2d1..256fbde 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/PaidMemberUserServiceImpl.java @@ -186,10 +186,12 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService { } @Override - public PaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId) { + public PaidMemberUserDO getByPayOrderId(Long payOrderId) { PaidMemberUserDO paidMemberUserDO = paidMemberUserMapper.selectOne( - new LambdaQueryWrapperX().eqIfPresent(PaidMemberUserDO::getId,id) - .eqIfPresent(PaidMemberUserDO::getPayOrderId,payOrderId)); + new LambdaQueryWrapperX().eqIfPresent(PaidMemberUserDO::getPayOrderId,payOrderId)); + if(paidMemberUserDO == null){ + throw exception(PAID_MEMBER_ORDER_NOT_EXISTS); + } return paidMemberUserDO; } 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 8c76ad8..6011c8d 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 @@ -154,17 +154,6 @@ public class PayOrderServiceImpl implements PayOrderService { // 1.32 校验支付渠道是否有效 PayChannelDO channel = validateChannelCanSubmit(order.getAppId(), reqVO.getChannelCode()); PayClient client = channelService.getPayClient(channel.getId()); - // 如果订单扩展里面已经存在该订单号的订单扩展(正在等待),则关闭已有的订单扩展,然后再创建(解决先点击微信支付,然后再使用余额支付会产生两个扩展订单的bug) - LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX<>(); - wrapperX.eq(PayOrderExtensionDO::getOrderId, order.getId()).eq(PayOrderExtensionDO::getStatus, PayOrderStatusEnum.WAITING.getStatus()); - List existOrderExtensionList = orderExtensionMapper.selectList(wrapperX); - if (existOrderExtensionList != null){ - // 考虑到这种重复的扩展订单一般就一个(最大值取决与支付方式个数),所以不使用批处理插入 - for (PayOrderExtensionDO payOrderExtensionDO : existOrderExtensionList) { - payOrderExtensionDO.setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - orderExtensionMapper.updateById(payOrderExtensionDO); - } - } // 2. 插入 PayOrderExtensionDO String no = noRedisDAO.generate(payProperties.getOrderNoPrefix()); PayOrderExtensionDO orderExtension = PayOrderConvert.INSTANCE.convert(reqVO, userIp) @@ -277,12 +266,7 @@ public class PayOrderServiceImpl implements PayOrderService { PayChannelDO channel = channelService.validPayChannel(channelId); // 更新支付订单为已支付 TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyOrder(channel, notify)); - // 获取订单扩展 PayOrderExtensionDO payOrderExtensionDO = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - // 判断订单是否更新为已支付 - if (Objects.equals(PayOrderStatusEnum.SUCCESS.getStatus(), orderMapper.selectById(payOrderExtensionDO.getOrderId()).getStatus())){ - - // 充值判断 PayWalletRechargeDO walletRechargeDO = walletRechargeMapper.selectOne("pay_order_id", payOrderExtensionDO.getOrderId()); if (walletRechargeDO != null){ walletRechargeDO.setPayStatus(true); @@ -291,7 +275,6 @@ public class PayOrderServiceImpl implements PayOrderService { payWalletService.addWalletBalance(walletRechargeDO.getWalletId(),walletRechargeDO.getPayOrderId().toString(),RECHARGE,walletRechargeDO.getTotalPrice()); } } - } /** * 通知并更新订单的支付结果