khy1 #75
@ -76,8 +76,10 @@ public class AppTradeOrderController {
|
||||
@Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) {
|
||||
System.out.println("进入回调notify:"+ notifyReqDTO);
|
||||
tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()),
|
||||
notifyReqDTO.getPayOrderId());
|
||||
System.out.println("订单更新完成");
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,6 @@ public interface TradePaidMemberUserService {
|
||||
|
||||
|
||||
|
||||
TradePaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId);
|
||||
TradePaidMemberUserDO getByPayOrderId(Long payOrderId);
|
||||
|
||||
}
|
@ -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<TradePaidMemberUserDO>().eqIfPresent(TradePaidMemberUserDO::getId,id)
|
||||
.eqIfPresent(TradePaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
new LambdaQueryWrapperX<TradePaidMemberUserDO>().eqIfPresent(TradePaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
if (tradePaidMemberUserDO == null) {
|
||||
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
|
||||
}
|
||||
return tradePaidMemberUserDO;
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
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());
|
||||
|
@ -84,6 +84,6 @@ public interface PaidMemberUserService {
|
||||
*/
|
||||
PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO);
|
||||
|
||||
PaidMemberUserDO getByIdAndPayOrderId(Long id,Long payOrderId);
|
||||
PaidMemberUserDO getByPayOrderId(Long payOrderId);
|
||||
|
||||
}
|
@ -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<PaidMemberUserDO>().eqIfPresent(PaidMemberUserDO::getId,id)
|
||||
.eqIfPresent(PaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
new LambdaQueryWrapperX<PaidMemberUserDO>().eqIfPresent(PaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
if(paidMemberUserDO == null){
|
||||
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
|
||||
}
|
||||
return paidMemberUserDO;
|
||||
}
|
||||
|
||||
|
@ -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<PayOrderExtensionDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||
wrapperX.eq(PayOrderExtensionDO::getOrderId, order.getId()).eq(PayOrderExtensionDO::getStatus, PayOrderStatusEnum.WAITING.getStatus());
|
||||
List<PayOrderExtensionDO> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知并更新订单的支付结果
|
||||
|
Loading…
Reference in New Issue
Block a user