多商户配置

This commit is contained in:
2023-08-15 17:04:56 +08:00
parent d4adac696e
commit 804853024b
4 changed files with 18 additions and 5 deletions

View File

@@ -599,7 +599,7 @@ public class MemberService {
* @return
*/
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) {
// 获取支付信息
// 获取支付配置
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getAppId());
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
@@ -624,7 +624,7 @@ public class MemberService {
createAdaPaymentParam.setDescription(JSON.toJSONString(map));
try {
log.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam), dto.getAppId());
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam), config.getWechatAppId());
log.info("创建汇付支付参数反参:{}", JSONObject.toJSONString(response));
if (response != null && !response.isEmpty()) {
JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());

View File

@@ -113,7 +113,7 @@ public class InitializeAdapayConfig implements CommandLineRunner {
merConfig.setApiKey(apiKey);
merConfig.setApiMockKey(mockApiKey);
merConfig.setRSAPrivateKey(rsaPrivateKey);
// 定义一个商户的B的唯一标识交易发起时用于定位是哪个商户发起交易
// 定义一个商户的B的唯一标识交易发起时用于定位是哪个商户发起交易使用微信小程序appId作为merchantKey
configPathMap.put(config.getWechatAppId(), merConfig);
}

View File

@@ -51,6 +51,11 @@ public class PayOrderDTO {
private OrderBasicInfo orderBasicInfo;
/**
* 微信小程序appId
*/
private String appId;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)

View File

@@ -14,6 +14,8 @@ import com.huifu.adapay.model.Payment;
import com.huifu.adapay.model.PaymentConfirm;
import com.jsowell.adapay.common.CreateAdaPaymentParam;
import com.jsowell.adapay.common.DivMember;
import com.jsowell.adapay.config.AbstractAdapayConfig;
import com.jsowell.adapay.factory.AdapayConfigFactory;
import com.jsowell.adapay.response.BalancePaymentResponse;
import com.jsowell.adapay.response.PaymentConfirmResponse;
import com.jsowell.adapay.response.PaymentReverseResponse;
@@ -2770,6 +2772,12 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
return cacheObject;
}
// 获取支付配置
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getAppId());
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
}
OrderBasicInfo orderInfo = dto.getOrderBasicInfo();
if (orderInfo == null) {
// 订单为空重新查询
@@ -2787,7 +2795,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
createAdaPaymentParam.setOrder_no(orderInfo.getOrderCode());
createAdaPaymentParam.setPay_amt(amount);
createAdaPaymentParam.setApp_id(ADAPAY_APP_ID);
createAdaPaymentParam.setApp_id(config.getAdapayAppId());
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
createAdaPaymentParam.setGoods_title("充电费用");
createAdaPaymentParam.setGoods_desc("充电桩预付款金额"); // 这个字段是微信支付凭证的商品名
@@ -2805,7 +2813,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
createAdaPaymentParam.setPay_mode(payMode);
try {
logger.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam));
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam), config.getWechatAppId());
if (response != null && !response.isEmpty()) {
JSONObject expend = JSONObject.parseObject(response.get("expend").toString());
JSONObject pay_info = expend.getJSONObject("pay_info");