交易撤销重构

This commit is contained in:
2023-08-26 18:38:00 +08:00
parent 7529dd80b2
commit da47be42f9
3 changed files with 95 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ import com.jsowell.adapay.config.AbstractAdapayConfig;
import com.jsowell.adapay.dto.*;
import com.jsowell.adapay.factory.AdapayConfigFactory;
import com.jsowell.adapay.operation.PaymentConfirmOperation;
import com.jsowell.adapay.operation.PaymentReverseOperation;
import com.jsowell.adapay.response.*;
import com.jsowell.adapay.vo.*;
import com.jsowell.common.constant.CacheConstants;
@@ -952,10 +953,27 @@ public class AdapayService {
/**
* 创建交易撤销请求
* 延迟分账未确认, 调交易撤销接口退款
*
* delay模式的商户使用
*/
public PaymentReverseResponse createPaymentReverseRequest(PaymentReverseOperation paymentReverseOperation) {
String wechatAppId = paymentReverseOperation.getMerchantKey();
String paymentId = paymentReverseOperation.getPaymentId();
BigDecimal reverseAmt = paymentReverseOperation.getReverseAmt();
String memberId = paymentReverseOperation.getMemberId();
String scenarioType = paymentReverseOperation.getScenarioType();
String orderCode = paymentReverseOperation.getOrderCode();
return createPaymentReverseRequest(paymentId, reverseAmt, wechatAppId, memberId, scenarioType, orderCode);
}
/**
* 创建交易撤销请求
* 延迟分账未确认, 调交易撤销接口退款
* delay模式的商户使用
* @param wechatAppId 微信小程序appId
*/
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt, String wechatAppId, String memberId, String scenarioType, String orderCode) {
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt,
String wechatAppId, String memberId, String scenarioType,
String orderCode) {
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
@@ -967,6 +985,7 @@ public class AdapayService {
reverseParams.put("reverse_amt", AdapayUtil.formatAmount(reverseAmt));
reverseParams.put("order_no", IdUtils.fastSimpleUUID());
reverseParams.put("notify_url", ADAPAY_CALLBACK_URL);
// expand 为扩展域
Map<String, String> expendMap = Maps.newHashMap();
expendMap.put("memberId", memberId);
@@ -976,6 +995,7 @@ public class AdapayService {
}
reverseParams.put("expand", expendMap);
reverseParams.put("reason", expendMap);
Map<String, Object> paymentReverse = null;
try {
paymentReverse = PaymentReverse.create(reverseParams, config.getWechatAppId());