parent
f76208c2db
commit
209ee68153
|
|
@ -37,7 +37,7 @@ public class NotifyController {
|
|||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
||||
log.info("支付回调数据为:{}", czg);
|
||||
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class OrderPayment implements Serializable {
|
|||
*/
|
||||
private String tradeNumber;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
@Column(onUpdateValue = "now()")
|
||||
private LocalDateTime payTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public interface OrderInfoService extends IService<OrderInfo> {
|
|||
|
||||
CzgResult<Object> mergeOrder(MergeOrderDTO param);
|
||||
|
||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson,int retryCount);
|
||||
|
||||
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ import java.math.BigDecimal;
|
|||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.MAX_RETRIES;
|
||||
|
||||
/**
|
||||
* 订单表 服务层实现。
|
||||
|
|
@ -106,6 +111,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
private ShopCouponService couponService;
|
||||
@DubboReference
|
||||
private ShopActivateCouponRecordService couponRecordService;
|
||||
// 延迟 5 秒
|
||||
private static final long DELAY = 5;
|
||||
//重试次数
|
||||
private static final int MAX_RETRIES = 3;
|
||||
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2);
|
||||
|
||||
@Override
|
||||
public Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param) {
|
||||
|
|
@ -604,11 +614,16 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson) {
|
||||
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson, int retryCount) {
|
||||
CzgPayNotifyDTO czgCallBackDto = JSONObject.parseObject(resultJson.toString(), CzgPayNotifyDTO.class);
|
||||
OrderPayment payment = paymentService.queryChain().eq(OrderPayment::getOrderNo, orderNo).one();
|
||||
if (payment == null) {
|
||||
log.error("订单支付回调失败,支付记录不存在,payment:{}", payment);
|
||||
if (retryCount < MAX_RETRIES) {
|
||||
log.info("支付记录不存在,第 {} 次重试,将在 {} 秒后进行", retryCount + 1, DELAY);
|
||||
executorService.schedule(() -> payCallBackOrder(orderNo, resultJson, retryCount + 1), DELAY, TimeUnit.SECONDS);
|
||||
} else {
|
||||
log.error("订单支付回调失败, 达到最大重试次数, 支付记录不存在, orderNo: {}", orderNo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isNotBlank(payment.getTradeNumber())) {
|
||||
|
|
|
|||
|
|
@ -772,14 +772,15 @@ public class PayServiceImpl implements PayService {
|
|||
|
||||
private CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
|
||||
AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试");
|
||||
if (bizData.getAuthCode().length() > 26) {
|
||||
throw new CzgException("支付失败,不支持的条码");
|
||||
}
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
|
||||
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
|
||||
|
||||
// 将截取的字符串转换为整数
|
||||
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
|
||||
|
||||
// 判断范围
|
||||
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
|
||||
//微信支付
|
||||
|
|
|
|||
Loading…
Reference in New Issue