## 在线支付回调添加上锁处理;
This commit is contained in:
parent
01d51e34ac
commit
74f319a657
|
@ -475,4 +475,9 @@ public class CacheConstants {
|
|||
*/
|
||||
public final static String DELIVER_MERGE_KEY = CACHE_PREFIX + "deliver:merge";
|
||||
|
||||
/**
|
||||
* 在线支付回调上锁
|
||||
*/
|
||||
public final static String ONLINE_PAYE_KEY = CACHE_PREFIX + "online:payment:";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.hzs.third.pay.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.hzs.activity.base.IActivityServiceApi;
|
||||
import com.hzs.common.core.constant.CacheConstants;
|
||||
import com.hzs.common.core.constant.MagicNumberConstants;
|
||||
import com.hzs.common.core.constant.RabbitMqConstants;
|
||||
import com.hzs.common.core.domain.R;
|
||||
import com.hzs.common.core.enums.*;
|
||||
import com.hzs.common.core.service.RedisService;
|
||||
import com.hzs.common.domain.third.pay.TOnlinePayment;
|
||||
import com.hzs.member.account.IMemberTradeServiceApi;
|
||||
import com.hzs.sale.order.ISaOrderServiceApi;
|
||||
|
@ -31,6 +34,8 @@ public class PayServiceImpl implements IPayService {
|
|||
private ITOnlinePaymentService itOnlinePaymentService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@DubboReference
|
||||
ISaOrderServiceApi iSaOrderServiceApi;
|
||||
|
@ -56,6 +61,9 @@ public class PayServiceImpl implements IPayService {
|
|||
public boolean notifyHandle(String businessType, String businessCode, String originalOrder,
|
||||
String payNumber, Date payTime, BigDecimal payMoney,
|
||||
EPayChannel ePayChannel, String channelNumber) {
|
||||
Long pkId = null;
|
||||
String redisKey = CacheConstants.ONLINE_PAYE_KEY + businessCode;
|
||||
|
||||
try {
|
||||
// 校验支付信息状态、业务与支付金额是否一致等
|
||||
TOnlinePayment onlinePayment = itOnlinePaymentService.queryByBusiness(Integer.valueOf(businessType), businessCode, null);
|
||||
|
@ -63,6 +71,7 @@ public class PayServiceImpl implements IPayService {
|
|||
log.error("支付信息不存在或已支付");
|
||||
return false;
|
||||
}
|
||||
pkId = onlinePayment.getPkId();
|
||||
|
||||
if (!PayUtil.checkAmount(onlinePayment.getBusinessMoney(), payMoney)) {
|
||||
// 业务金额 大于 实际支付金额
|
||||
|
@ -91,6 +100,17 @@ public class PayServiceImpl implements IPayService {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
log.error("在线支付信息回调处理异常", e);
|
||||
|
||||
if (null != pkId) {
|
||||
// 更新业务处理信息
|
||||
itOnlinePaymentService.update(Wrappers.<TOnlinePayment>lambdaUpdate()
|
||||
.eq(TOnlinePayment::getPkId, pkId)
|
||||
.set(TOnlinePayment::getCallbackStatus, ECallbackStatus.FAIL.getValue())
|
||||
.set(TOnlinePayment::getCallbackInfo, e.getMessage())
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
redisService.unlock(redisKey);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue