update 支付时获取对应的支付配置

This commit is contained in:
2023-08-17 11:55:14 +08:00
parent 85d49e3be8
commit ae5f0d8faf
8 changed files with 42 additions and 15 deletions

View File

@@ -13,6 +13,9 @@ import java.util.Objects;
* adapay配置工厂类
*/
public class AdapayConfigFactory {
/*
key为微信小程序appId, value为对应的汇付支付配置
*/
private static Map<String, AbstractAdapayConfig> configMap = Maps.newHashMap();
/**
@@ -29,11 +32,11 @@ public class AdapayConfigFactory {
/**
* 获取
* @param name
* @return
* @param wechatAppId 微信小程序appId
* @return 对应的汇付支付配置
*/
public static AbstractAdapayConfig getConfig(String name) {
return configMap.get(name);
public static AbstractAdapayConfig getConfig(String wechatAppId) {
return configMap.get(wechatAppId);
}
/**

View File

@@ -7,9 +7,11 @@ import com.google.common.collect.Maps;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.*;
import com.jsowell.adapay.common.DivMember;
import com.jsowell.adapay.config.AbstractAdapayConfig;
import com.jsowell.adapay.dto.SettleAccountDTO;
import com.jsowell.adapay.dto.UpdateAccountConfigDTO;
import com.jsowell.adapay.dto.WithdrawDTO;
import com.jsowell.adapay.factory.AdapayConfigFactory;
import com.jsowell.adapay.response.*;
import com.jsowell.adapay.vo.AdapayAccountBalanceVO;
import com.jsowell.adapay.vo.AdapayCorpMemberVO;
@@ -659,19 +661,25 @@ public class AdapayMemberService {
/**
* 创建交易撤销请求
* 延迟分账未确认, 调交易撤销接口退款
* @param wechatAppId 微信小程序appId
*/
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt, String merchantKey) {
public PaymentReverseResponse createPaymentReverseRequest(String paymentId, BigDecimal reverseAmt, String wechatAppId) {
PaymentReverseResponse response;
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
}
// 延迟分账未确认调撤销调撤销接口退款
Map<String, Object> reverseParams = Maps.newHashMap();
reverseParams.put("app_id", ADAPAY_APP_ID);
reverseParams.put("app_id", config.getAdapayAppId());
reverseParams.put("payment_id", paymentId);
reverseParams.put("reverse_amt", AdapayUtil.formatAmount(reverseAmt));
reverseParams.put("order_no", IdUtils.fastSimpleUUID());
reverseParams.put("notify_url", ADAPAY_CALLBACK_URL);
reverseParams.put("", "");
Map<String, Object> paymentReverse = null;
try {
paymentReverse = PaymentReverse.create(reverseParams, merchantKey);
paymentReverse = PaymentReverse.create(reverseParams, config.getWechatAppId());
} catch (BaseAdaPayException e) {
log.error("汇付支付创建交易撤销对象error", e);
}

View File

@@ -54,7 +54,7 @@ public class PayOrderDTO {
/**
* 微信小程序appId
*/
private String appId;
private String wechatAppId;
@Override
public String toString() {

View File

@@ -22,7 +22,10 @@ public class WeixinPayDTO extends BaseMemberDTO{
*/
private String attach;
private String appId;
/**
* 微信小程序appId
*/
private String wechatAppId;
@Override
public String toString() {

View File

@@ -2779,7 +2779,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
}
// 获取支付配置
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getAppId());
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getWechatAppId());
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
}