定时任务处理未分帐订单

This commit is contained in:
Guoqs
2025-04-17 14:12:52 +08:00
parent 23e28f11f3
commit d1d45ed6b3
2 changed files with 10 additions and 8 deletions

View File

@@ -407,4 +407,9 @@ public class CacheConstants {
public static final String DELAYED_PAYMENT_CONFIRM_QUEUE = "delayed_payment_confirm_queue:"; public static final String DELAYED_PAYMENT_CONFIRM_QUEUE = "delayed_payment_confirm_queue:";
public static final String FAILED_PAYMENT_CONFIRM_LIST = "failed_payment_confirm_list:"; public static final String FAILED_PAYMENT_CONFIRM_LIST = "failed_payment_confirm_list:";
/**
* 控制处理未分帐订单频率
*/
public static final String PROCESS_UNSPLIT_ORDERS = "processUnsplitOrders";
} }

View File

@@ -351,12 +351,9 @@ public class JsowellTask {
public void processUnSettledOrder() { public void processUnSettledOrder() {
String startTime = "2023-01-01 00:00:00"; String startTime = "2023-01-01 00:00:00";
String endTime = "2023-12-31 23:59:59"; String endTime = "2023-12-31 23:59:59";
String adapayMemberId = "0";
String wechatAppId1 = "wxbb3e0d474569481d"; // 万车充
// 使用redis控制请求api // 使用redis控制请求api
String key = "processUnsplitOrders"; Boolean setnx = redisCache.setnx(CacheConstants.PROCESS_UNSPLIT_ORDERS, Constants.ONE, 65);
Boolean setnx = redisCache.setnx(key, "1", 65);
if (!setnx) { if (!setnx) {
return; return;
} }
@@ -373,7 +370,7 @@ public class JsowellTask {
BigDecimal confirmAmt = orderUnsplitRecord.getSettleAmount(); BigDecimal confirmAmt = orderUnsplitRecord.getSettleAmount();
DivMember divMember = new DivMember(); DivMember divMember = new DivMember();
divMember.setMemberId(adapayMemberId); divMember.setMemberId(Constants.ZERO); // 若是商户本身时传入0
divMember.setAmount(AdapayUtil.formatAmount(confirmAmt)); divMember.setAmount(AdapayUtil.formatAmount(confirmAmt));
divMember.setFeeFlag(Constants.Y); divMember.setFeeFlag(Constants.Y);
@@ -382,7 +379,7 @@ public class JsowellTask {
.divMemberList(Lists.newArrayList(divMember)) .divMemberList(Lists.newArrayList(divMember))
.confirmAmt(confirmAmt) .confirmAmt(confirmAmt)
.orderCode(orderCode) .orderCode(orderCode)
.wechatAppId(wechatAppId1) .wechatAppId(Constants.DEFAULT_APP_ID) // 默认使用万车充的appId
.build(); .build();
// 延时分账使用确认交易API // 延时分账使用确认交易API
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param); PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param);
@@ -396,8 +393,8 @@ public class JsowellTask {
} else { } else {
// error_type:api_error, error_code:confirm_amt_over_limit, error_msg当前确认金额 > 支付金额 - 已支付确认金额 - 已支付撤销金额 // error_type:api_error, error_code:confirm_amt_over_limit, error_msg当前确认金额 > 支付金额 - 已支付确认金额 - 已支付撤销金额
if (paymentConfirmResponse.getError_code().equals("confirm_amt_over_limit")) { if (paymentConfirmResponse.getError_code().equals("confirm_amt_over_limit")) {
// TODO 查询paymentId的总分账金额 // 查询paymentId的总分账金额
BigDecimal totalSplitAmount = BigDecimal.ZERO; BigDecimal totalSplitAmount;
try { try {
totalSplitAmount = adapayService.getTotalSplitAmountByPaymentId(paymentId); totalSplitAmount = adapayService.getTotalSplitAmountByPaymentId(paymentId);
} catch (BaseAdaPayException e) { } catch (BaseAdaPayException e) {