Merge pull request 'khy1' (#75) from khy1 into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #75
This commit is contained in:
commit
eac7fc313d
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<TradeOrderDO, PayOrderRespDTO> 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());
|
||||
|
@ -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