mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-11 18:59:51 +08:00
update 超时关闭订单退款处理
This commit is contained in:
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import com.jsowell.adapay.common.AdaPayment;
|
|
||||||
import com.jsowell.adapay.dto.QueryConfirmReverseDTO;
|
import com.jsowell.adapay.dto.QueryConfirmReverseDTO;
|
||||||
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
import com.jsowell.adapay.dto.QueryPaymentConfirmDTO;
|
||||||
import com.jsowell.adapay.operation.PaymentReverseOperation;
|
import com.jsowell.adapay.operation.PaymentReverseOperation;
|
||||||
@@ -2070,38 +2069,56 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
*/
|
*/
|
||||||
private void checkUnpaidOrder(OrderBasicInfo orderBasicInfo) {
|
private void checkUnpaidOrder(OrderBasicInfo orderBasicInfo) {
|
||||||
String orderCode = orderBasicInfo.getOrderCode();
|
String orderCode = orderBasicInfo.getOrderCode();
|
||||||
List<AdaPayment> adaPayments = null;
|
|
||||||
String memberId = orderBasicInfo.getMemberId();
|
String memberId = orderBasicInfo.getMemberId();
|
||||||
String merchantId = orderBasicInfo.getMerchantId();
|
String merchantId = orderBasicInfo.getMerchantId();
|
||||||
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
|
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
|
||||||
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(wechatAppId);
|
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(wechatAppId);
|
||||||
try {
|
// List<AdaPayment> adaPayments = null;
|
||||||
adaPayments = adapayService.queryPaymentByOrderNo(orderCode, wechatAppId);
|
// try {
|
||||||
} catch (BaseAdaPayException e) {
|
// adaPayments = adapayService.queryPaymentByOrderNo(orderCode, wechatAppId);
|
||||||
throw new RuntimeException(e);
|
// } catch (BaseAdaPayException e) {
|
||||||
}
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(adaPayments)) {
|
// if (CollectionUtils.isEmpty(adaPayments)) {
|
||||||
return;
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 如果超时关闭的订单,存在支付信息,都退款处理
|
||||||
|
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
||||||
|
logger.info("校验未支付订单orderCode:{}, 支付信息:{}", orderCode, JSON.toJSONString(orderPayRecordList));
|
||||||
|
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||||
|
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord());
|
||||||
|
for (PaymentInfo paymentInfo : paymentInfos) {
|
||||||
|
String paymentId = paymentInfo.getPaymentId();
|
||||||
|
BigDecimal payAmt = new BigDecimal(paymentInfo.getAmount());
|
||||||
|
if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
|
||||||
|
// 延时分账商户,创建交易撤销请求
|
||||||
|
adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
||||||
|
} else {
|
||||||
|
// 实时分账商户,创建交易退款请求
|
||||||
|
adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退款
|
// 退款
|
||||||
for (AdaPayment adaPayment : adaPayments) {
|
// for (AdaPayment adaPayment : adaPayments) {
|
||||||
String status = adaPayment.getStatus();
|
// String status = adaPayment.getStatus();
|
||||||
if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(status)) {
|
// if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(status)) {
|
||||||
// 不是交易完成状态,就跳过
|
// // 不是交易完成状态,就跳过
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
String paymentId = adaPayment.getId();
|
// String paymentId = adaPayment.getId();
|
||||||
BigDecimal payAmt = new BigDecimal(adaPayment.getPay_amt());
|
// BigDecimal payAmt = new BigDecimal(adaPayment.getPay_amt());
|
||||||
if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
|
// if (MerchantDelayModeEnum.DELAY.getMode().equals(delayMode)) {
|
||||||
// 延时分账商户,创建交易撤销请求
|
// // 延时分账商户,创建交易撤销请求
|
||||||
adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
// adapayService.createPaymentReverseRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
||||||
} else {
|
// } else {
|
||||||
// 实时分账商户,创建交易退款请求
|
// // 实时分账商户,创建交易退款请求
|
||||||
adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
// adapayService.createRefundRequest(paymentId, payAmt, wechatAppId, memberId, ScenarioEnum.ORDER.getValue(), orderCode);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user