update 创建撤销请求,放入扩展字段

This commit is contained in:
2023-08-17 12:05:21 +08:00
parent ae5f0d8faf
commit 8caab85abe
4 changed files with 18 additions and 7 deletions

View File

@@ -663,7 +663,7 @@ public class AdapayMemberService {
* 延迟分账未确认, 调交易撤销接口退款
* @param wechatAppId 微信小程序appId
*/
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt, String wechatAppId) {
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt, String wechatAppId, String memberId, String scenarioType, String orderCode) {
PaymentReverseResponse response;
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
if (config == null) {
@@ -676,7 +676,15 @@ public class AdapayMemberService {
reverseParams.put("reverse_amt", AdapayUtil.formatAmount(reverseAmt));
reverseParams.put("order_no", IdUtils.fastSimpleUUID());
reverseParams.put("notify_url", ADAPAY_CALLBACK_URL);
reverseParams.put("", "");
// expand 为扩展域
Map<String, String> expendMap = Maps.newHashMap();
expendMap.put("memberId", memberId);
expendMap.put("scenarioType", scenarioType);
if (StringUtils.isNotBlank(orderCode)) {
expendMap.put("orderCode", orderCode);
}
reverseParams.put("expand", expendMap);
// reverseParams.put("reason", "reason");
Map<String, Object> paymentReverse = null;
try {
paymentReverse = PaymentReverse.create(reverseParams, config.getWechatAppId());

View File

@@ -45,5 +45,5 @@ public class ApplyRefundDTO {
/**
* 汇付需要merchantKey取小程序appId传给它
*/
private String merchantKey;
private String wechatAppId;
}

View File

@@ -941,7 +941,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 汇付退款需要一级运营商的小程序appId, 否则会退款失败
PileMerchantInfo pileMerchantInfo = pileMerchantInfoService.selectPileMerchantInfoById(orderBasicInfo.getMerchantId());
if (pileMerchantInfo != null) {
applyRefundDTO.setMerchantKey(pileMerchantInfo.getAppId());
applyRefundDTO.setWechatAppId(pileMerchantInfo.getAppId());
}
this.refundOrderWithAdapay(applyRefundDTO);
}
@@ -2393,7 +2393,9 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
adapayMemberService.createRefundRequest(paymentId, refundAmount);
} else {
// 延迟分账未确认调撤销调撤销接口退款
PaymentReverseResponse response = adapayMemberService.createPaymentReverseRequest(paymentId, refundAmount, dto.getMerchantKey());
PaymentReverseResponse response = adapayMemberService.createPaymentReverseRequest(
paymentId, refundAmount, dto.getWechatAppId(), dto.getMemberId(), ScenarioEnum.ORDER.getValue(),
dto.getOrderCode());
if (response != null) {
MemberAdapayRecord record = memberAdapayRecordService.selectByPaymentId(paymentId);
BigDecimal reverseAmt = new BigDecimal(response.getReverse_amt());
@@ -2436,7 +2438,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
BigDecimal deductionAmount = vo.getDeductionAmount();
// 调汇付的交易撤销接口
adapayMemberService.createPaymentReverseRequest(paymentId, deductionAmount, dto.getMerchantKey());
adapayMemberService.createPaymentReverseRequest(paymentId, deductionAmount, dto.getWechatAppId(),
dto.getMemberId(), ScenarioEnum.BALANCE.getValue(), null);
// 更新这笔交易的剩余金额
MemberAdapayRecord record = memberAdapayRecordService.selectByPaymentId(paymentId);