Просмотр исходного кода

fix cashout

release_toaliyun_real
zhengfangyuan 3 лет назад
Родитель
Сommit
5a9b890fd7
6 измененных файлов: 55 добавлений и 23 удалений
  1. +4
    -1
      mallinkAdmin/src/main/resources/db/migration/V20220801000001_cashout.sql
  2. +8
    -4
      mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/pay/WxPay.java
  4. +8
    -8
      mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java
  5. +30
    -9
      mallinkService/src/main/java/com/iformall/utils/MaUtil.java
  6. +3
    -1
      mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml

+ 4
- 1
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需实名';
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';

+ 8
- 4
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")


+ 2
- 0
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;


+ 8
- 8
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);
}


+ 30
- 9
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);
}
}
}


+ 3
- 1
mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml Просмотреть файл

@@ -10,6 +10,8 @@
<result column="sub_app_id" jdbcType="VARCHAR" property="subAppId"/>
<result column="api_key" jdbcType="VARCHAR" property="apiKey"/>
<result column="merchant_api_key" jdbcType="VARCHAR" property="merchantApiKey"/>
<result column="merchant_key_path" jdbcType="VARCHAR" property="merchantKeyPath"/>
<result column="merchant_apiv3_key" jdbcType="VARCHAR" property="merchantApiv3Key"/>
<result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/>
<result column="notify_token" jdbcType="VARCHAR" property="notifyToken"/>

@@ -31,7 +33,7 @@
<sql id="allColumns">
`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`
</sql>

<sql id="dynamicWhereConditions">


Загрузка…
Отмена
Сохранить