diff --git a/mallinkAdmin/src/main/resources/db/migration/V20220801000001_cashout.sql b/mallinkAdmin/src/main/resources/db/migration/V20220801000001_cashout.sql
index b3ae8cb4a..00b634cf1 100644
--- a/mallinkAdmin/src/main/resources/db/migration/V20220801000001_cashout.sql
+++ b/mallinkAdmin/src/main/resources/db/migration/V20220801000001_cashout.sql
@@ -97,4 +97,7 @@ alter table wx_cash_out_95 ADD COLUMN `real_name` varchar(32) COMMENT '实
alter table wx_cash_out_96 ADD COLUMN `real_name` varchar(32) COMMENT '实名姓名,超2000需实名';
alter table wx_cash_out_97 ADD COLUMN `real_name` varchar(32) COMMENT '实名姓名,超2000需实名';
alter table wx_cash_out_98 ADD COLUMN `real_name` varchar(32) COMMENT '实名姓名,超2000需实名';
-alter table wx_cash_out_99 ADD COLUMN `real_name` varchar(32) COMMENT '实名姓名,超2000需实名';
\ No newline at end of file
+alter table wx_cash_out_99 ADD COLUMN `real_name` varchar(32) COMMENT '实名姓名,超2000需实名';
+
+alter table wx_pay_account add COLUMN `merchant_key_path` varchar(100) COMMENT '商户key证书路径';
+alter table wx_pay_account add COLUMN `merchant_apiv3_key` varchar(100) COMMENT '商户apiV3Key';
\ No newline at end of file
diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java
index 5ba30326d..66b3631e2 100644
--- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java
+++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java
@@ -30,6 +30,10 @@ public class WxPayAccount extends TenantEntity {
private String certPath;
@io.swagger.annotations.ApiModelProperty(value="商户自己的证书",name="merchantCertPath")
private String merchantCertPath;
+ @io.swagger.annotations.ApiModelProperty(value="商户自己的密钥文件",name="merchantKeyPath")
+ private String merchantKeyPath;
+ @io.swagger.annotations.ApiModelProperty(value="商户自己的apiv3密钥",name="merchantApiv3Key")
+ private String merchantApiv3Key;
@io.swagger.annotations.ApiModelProperty(value="商户模式-0:普通商户模式1:服务商模式",name="type")
private Integer type;
@io.swagger.annotations.ApiModelProperty(value="是否开启分账(0:未开启分账1:开启分账)",name="type")
@@ -56,13 +60,13 @@ public class WxPayAccount extends TenantEntity {
private String serviceId;
@io.swagger.annotations.ApiModelProperty(value="微信支付分回调地址",name="payScoreNotifyUrl")
private String payScoreNotifyUrl;
- @io.swagger.annotations.ApiModelProperty(value="apiV3秘钥",name="apiV3Key")
+ @io.swagger.annotations.ApiModelProperty(value="平台apiV3秘钥",name="apiV3Key")
private String apiV3Key;
- @io.swagger.annotations.ApiModelProperty(value="证书序列号",name="certSerialNo")
+ @io.swagger.annotations.ApiModelProperty(value="平台证书序列号",name="certSerialNo")
private String certSerialNo;
- @io.swagger.annotations.ApiModelProperty(value="apiv3 商户apiclient_key.pem 商户私钥",name="privateKeyPath")
+ @io.swagger.annotations.ApiModelProperty(value="平台私钥文件",name="privateKeyPath")
private String privateKeyPath;
- @io.swagger.annotations.ApiModelProperty(value="apiv3 商户apiclient_cert.pem",name="privateCertPath")
+ @io.swagger.annotations.ApiModelProperty(value="平台证书文件,同certPath",name="privateCertPath")
private String privateCertPath;
// @io.swagger.annotations.ApiModelProperty(value="app平台 EnumAppPlat ",name="plat")
diff --git a/mallinkService/src/main/java/com/iformall/pay/WxPay.java b/mallinkService/src/main/java/com/iformall/pay/WxPay.java
index 7879ea763..dbd3f0149 100644
--- a/mallinkService/src/main/java/com/iformall/pay/WxPay.java
+++ b/mallinkService/src/main/java/com/iformall/pay/WxPay.java
@@ -8,9 +8,11 @@ import java.util.Map;
import javax.crypto.IllegalBlockSizeException;
import com.alibaba.fastjson.JSON;
+import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
+import com.iformall.domain.po.WxPayAccount;
import com.iformall.utils.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java
index 353b0daf3..be2f2c73d 100644
--- a/mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java
+++ b/mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java
@@ -204,17 +204,17 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
@Override
public CashOutAdapterResult cashOut(WxAppinfo appInfo, WxPayAccount payAccount, WxCashOut cashOut) {
- if (StringUtils.isBlank(payAccount.getPrivateCertPath())) {
- return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。证书PrivateCertPath为空。请联系管理员配置。", null);
+ if (StringUtils.isBlank(payAccount.getMerchantCertPath())) {
+ return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户证书为空。请联系管理员配置。", null);
}
- if (StringUtils.isBlank(payAccount.getPrivateKeyPath())) {
- return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。密钥PrivateKeyPath为空。请联系管理员配置。", null);
+ if (StringUtils.isBlank(payAccount.getMerchantKeyPath())) {
+ return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户密钥为空。请联系管理员配置。", null);
}
- if (StringUtils.isBlank(payAccount.getApiV3Key())) {
- return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。密钥ApiV3Key为空。请联系管理员配置。", null);
+ if (StringUtils.isBlank(payAccount.getMerchantApiv3Key())) {
+ return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户密钥ApiV3为空。请联系管理员配置。", null);
}
- WxPayService payService = maUtil.getWxPayService(appInfo,payAccount);
+ WxPayService payService = maUtil.getWxPayServiceBySelfModel(appInfo,payAccount);
if (null == payService) {
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。当前小程序未查询到payService。", null);
}
@@ -279,7 +279,7 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
if (StringUtils.isBlank(payAccount.getApiV3Key())) {
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。密钥ApiV3Key为空。请联系管理员配置。", null);
}
- WxPayService payService = maUtil.getWxPayService(appInfo,payAccount);
+ WxPayService payService = maUtil.getWxPayServiceBySelfModel(appInfo,payAccount);
if (null == payService) {
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。当前小程序未查询到payService。", null);
}
diff --git a/mallinkService/src/main/java/com/iformall/utils/MaUtil.java b/mallinkService/src/main/java/com/iformall/utils/MaUtil.java
index 124d3ec73..d0e8269fe 100644
--- a/mallinkService/src/main/java/com/iformall/utils/MaUtil.java
+++ b/mallinkService/src/main/java/com/iformall/utils/MaUtil.java
@@ -92,6 +92,16 @@ public class MaUtil {
}
public WxPayService getWxPayService(WxAppinfo appinfo, WxPayAccount payAccount) {
+ return getWxPayService(appinfo,payAccount,true);
+ }
+
+ //自研非服务商模式
+ public WxPayService getWxPayServiceBySelfModel(WxAppinfo appinfo, WxPayAccount payAccount) {
+ return getWxPayService(appinfo,payAccount,false);
+ }
+
+ //@isService 是否服务商模式
+ private WxPayService getWxPayService(WxAppinfo appinfo, WxPayAccount payAccount,boolean isService) {
WxPayConfig config = new WxPayConfig();
config.setAppId(appinfo.getAppId());
config.setMchId(payAccount.getMchId());
@@ -103,20 +113,31 @@ public class MaUtil {
//以下是apiv3以及支付分相关
// config.setServiceId(payAccount.getServiceId());
// config.setPayScoreNotifyUrl(payAccount.getPayScoreNotifyUrl());
+ //服务商,取平台的
+ int iss = 0;
+ if (isService) {
+ iss = 1;
+ config.setPrivateKeyPath(payAccount.getPrivateKeyPath());
+ config.setPrivateCertPath(payAccount.getPrivateCertPath());
+ //config.setCertSerialNo(payAccount.getCertSerialNo());
+ config.setApiV3Key(payAccount.getApiV3Key());
+ }else {
+ config.setPrivateKeyPath(payAccount.getMerchantKeyPath());
+ config.setPrivateCertPath(payAccount.getMerchantCertPath());
+ //config.setCertSerialNo(payAccount.getCertSerialNo());
+ config.setApiV3Key(payAccount.getMerchantApiv3Key());
+ }
+
+ String key = new StringBuffer(appinfo.getAppId()).append("_").append(iss).toString();
- config.setPrivateKeyPath(payAccount.getPrivateKeyPath());//apiv3 商户apiclient_key.pem 商户私钥
- config.setPrivateCertPath(payAccount.getPrivateCertPath());//apiv3 商户apiclient_cert.pem
- config.setCertSerialNo(payAccount.getCertSerialNo());//证书序列号
- config.setApiV3Key(payAccount.getApiV3Key());//apiV3秘钥
-
- WxPayService service = payServiceMap.get(appinfo.getAppId());
+ WxPayService service = payServiceMap.get(key);
if ( null == service ) {
- synchronized("getWxPayServiceBlock"+appinfo.getAppId()) {
- service = payServiceMap.get(appinfo.getAppId());
+ synchronized("getWxPayServiceBlock"+key) {
+ service = payServiceMap.get(key);
if (null == service) {
service = new WxPayServiceImpl();
service.setConfig(config);
- payServiceMap.put(appinfo.getAppId(), service);
+ payServiceMap.put(key, service);
}
}
}
diff --git a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml
index dc8105d8c..7a90cde46 100644
--- a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml
@@ -10,6 +10,8 @@
+
+
@@ -31,7 +33,7 @@
`id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`,`api_key`,`merchant_api_key`,`notify_url`,`notify_token`,`cert_path`,
`merchant_cert_path`,`type`,`share`,`rate`,`real_rate`,
- `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_path`
+ `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_path`,`merchant_key_path`,`merchant_apiv3_key`