Commit 843f4682 by ping.wu

Merge branches 'feature/20220112_银行周周惠_wuping' and 'master' of…

Merge branches 'feature/20220112_银行周周惠_wuping' and 'master' of http://gitlab.freemud.com/order-group-application/order-group
parents 93a63e89 88bab9aa
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
<dependency> <dependency>
<artifactId>assortment-data-manager</artifactId> <artifactId>assortment-data-manager</artifactId>
<groupId>com.freemud.sdk.api.assortment</groupId> <groupId>com.freemud.sdk.api.assortment</groupId>
<version>5.5.31-RELEASE</version> <version>5.5.40-RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.freemud.commons</groupId> <groupId>cn.freemud.commons</groupId>
...@@ -217,6 +217,17 @@ ...@@ -217,6 +217,17 @@
<!-- <artifactId>open-store-open-platform-sdk</artifactId>--> <!-- <artifactId>open-store-open-platform-sdk</artifactId>-->
<!-- <version>1.3.5-SNAPSHOT</version>--> <!-- <version>1.3.5-SNAPSHOT</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.github.wechatpay-apiv3</groupId>-->
<!-- <artifactId>wechatpay-apache-httpclient</artifactId>-->
<!-- <version>0.4.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.squareup.okhttp3</groupId>-->
<!-- <artifactId>okhttp</artifactId>-->
<!-- <version>3.6.0</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
......
...@@ -16,4 +16,13 @@ public class PaymentConfigVo { ...@@ -16,4 +16,13 @@ public class PaymentConfigVo {
@NotEmpty(message = "商户号不能为空") @NotEmpty(message = "商户号不能为空")
private String partnerId; private String partnerId;
@ApiModelProperty("门店号")
private String shopId;
/**
* 插件类型 1=爱心餐 2= 周周惠
*/
@ApiModelProperty("插件类型 1=爱心餐 2= 周周惠")
private Integer plugInType;
} }
...@@ -5,8 +5,31 @@ import lombok.Data; ...@@ -5,8 +5,31 @@ import lombok.Data;
@Data @Data
public class PlugInParameter { public class PlugInParameter {
/**---------------爱心捐插件参数-----------------*/
private String mchCode; private String mchCode;
private String subMchCode; private String subMchCode;
/**---------------周周惠插件参数-----------------*/
/**
* 报名商户号
*/
private String applyMchid;
/**
* 签名商户号
*/
private String signMchid;
/**
* 报名的支付门店id
*/
private String storeId;
/**
* HMAC-SHA256签名
*/
private String sign;
/**--------------------------------*/
} }
...@@ -383,13 +383,18 @@ public class OrderAdapterServiceImpl { ...@@ -383,13 +383,18 @@ public class OrderAdapterServiceImpl {
public BaseResponse<PlugInParameter> getPaymentConfig(PaymentConfigVo createOrderVo){ public BaseResponse<PlugInParameter> getPaymentConfig(PaymentConfigVo paymentConfigVo){
AssortmentCustomerInfoVo assortmentCustomerInfoVo = assortmentCustomerInfoManager.getCustomerInfoByObject(createOrderVo.getSessionId()); AssortmentCustomerInfoVo assortmentCustomerInfoVo = assortmentCustomerInfoManager.getCustomerInfoByObject(paymentConfigVo.getSessionId());
if (assortmentCustomerInfoVo == null || StringUtils.isEmpty(assortmentCustomerInfoVo.getMemberId())) { if (assortmentCustomerInfoVo == null || StringUtils.isEmpty(assortmentCustomerInfoVo.getMemberId())) {
return ResponseUtil.error(ResponseResult.NOT_LOGIN); return ResponseUtil.error(ResponseResult.NOT_LOGIN);
} }
//周周惠插件要返回参数
if(paymentConfigVo.getPlugInType() != null && paymentConfigVo.getPlugInType() == 2){
return ResponseUtil.success(payService.getPlugInParameter(paymentConfigVo.getPartnerId(),assortmentCustomerInfoVo.getWxAppId(),paymentConfigVo.getShopId()));
}
//1元插件要返回参数 //1元插件要返回参数
return ResponseUtil.success(payService.getPaymentAuth(createOrderVo.getPartnerId(),assortmentCustomerInfoVo.getWxAppId())); return ResponseUtil.success(payService.getPlugInParameter(paymentConfigVo.getPartnerId(),assortmentCustomerInfoVo.getWxAppId()));
} }
......
...@@ -36,10 +36,7 @@ import cn.freemud.service.thirdparty.ComPayClient; ...@@ -36,10 +36,7 @@ import cn.freemud.service.thirdparty.ComPayClient;
import cn.freemud.service.thirdparty.PaymentNewClient; import cn.freemud.service.thirdparty.PaymentNewClient;
import cn.freemud.service.thirdparty.SvcAppClient; import cn.freemud.service.thirdparty.SvcAppClient;
import cn.freemud.service.thirdparty.SvcComPayClient; import cn.freemud.service.thirdparty.SvcComPayClient;
import cn.freemud.utils.AppLogUtil; import cn.freemud.utils.*;
import cn.freemud.utils.RedisUtil;
import cn.freemud.utils.ResponseUtil;
import cn.freemud.utils.ValidationCode;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.*; import com.freemud.api.assortment.datamanager.entity.db.*;
...@@ -1275,14 +1272,51 @@ public class PayServiceImpl { ...@@ -1275,14 +1272,51 @@ public class PayServiceImpl {
} }
} }
//1元捐插件需要参数 /**
public PlugInParameter getPaymentAuth(String partnerId, String appId) { * 1元捐插件需要参数
*/
public PlugInParameter getPlugInParameter(String partnerId, String appId) {
PlugInParameter plugInParameter = new PlugInParameter();
List<AssortmentOpenPlatformPartnerPaymentConfig> openPlatformPartnerPaymentConfigs = openPlatformPartnerPaymentConfigManager.queryPartnerPaymentConfigs(partnerId, appId);
if (CollectionUtils.isNotEmpty(openPlatformPartnerPaymentConfigs)) {
plugInParameter.setMchCode(openPlatformPartnerPaymentConfigs.get(0).getUnitMchId());
plugInParameter.setSubMchCode(openPlatformPartnerPaymentConfigs.get(0).getSubMchid());
}
return plugInParameter;
}
/**
* 周周惠插件需要参数
*/
public PlugInParameter getPlugInParameter(String partnerId, String appId,String storeId) {
PlugInParameter plugInParameter = new PlugInParameter(); PlugInParameter plugInParameter = new PlugInParameter();
List<AssortmentOpenPlatformPartnerPaymentConfig> openPlatformPartnerPaymentAuths = openPlatformPartnerPaymentConfigManager.queryPartnerPaymentConfigs(partnerId, appId); List<AssortmentOpenPlatformPartnerPaymentConfig> openPlatformPartnerPaymentConfigs = openPlatformPartnerPaymentConfigManager.queryPartnerPaymentConfigs(partnerId, appId);
if (CollectionUtils.isNotEmpty(openPlatformPartnerPaymentAuths)) { if (CollectionUtils.isEmpty(openPlatformPartnerPaymentConfigs)) {
plugInParameter.setMchCode(openPlatformPartnerPaymentAuths.get(0).getUnitMchId()); return plugInParameter;
plugInParameter.setSubMchCode(openPlatformPartnerPaymentAuths.get(0).getSubMchid()); }
AssortmentOpenPlatformPaymentStore assortmentOpenPlatformPaymentStore = openPlatformPartnerPaymentConfigManager.queryPlatformPaymentStore(openPlatformPartnerPaymentConfigs.get(0).getId().toString(), storeId);
if (assortmentOpenPlatformPaymentStore == null || assortmentOpenPlatformPaymentStore.getStatus() != 1) {
return plugInParameter;
}
AssortmentOpenPlatformPartnerPaymentAuth assortmentOpenPlatformPartnerPaymentAuth = openPlatformPartnerPaymentConfigManager.queryPartnerPaymentAuth(openPlatformPartnerPaymentConfigs.get(0).getAuthId());
if (assortmentOpenPlatformPartnerPaymentAuth == null) {
return plugInParameter;
} }
String applyMchid = assortmentOpenPlatformPartnerPaymentAuth.getSp_mchid();
String signMchid = openPlatformPartnerPaymentConfigs.get(0).getSubMchid();
String thirdStoreId = assortmentOpenPlatformPaymentStore.getThirdStoreId();
plugInParameter.setApplyMchid(applyMchid);
plugInParameter.setSignMchid(signMchid);
plugInParameter.setStoreId(thirdStoreId);
String encryptKey = assortmentOpenPlatformPartnerPaymentAuth.getSignKey();
String message = "apply_mchid="+applyMchid+"&sign_mchid="+signMchid+"&store_id="+thirdStoreId + "&key="+encryptKey;
String sign = HMacSHA256.encrypt(message,encryptKey);
plugInParameter.setSign(sign);
return plugInParameter; return plugInParameter;
} }
......
package cn.freemud.utils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class HMacSHA256 {
/**
* HMacSHA256 类型签名
* @param message 签名字符串
* @param secret 私钥
* @return 加密后字符串
*/
public static String encrypt(String message, String secret) {
String hash = "";
try {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
byte[] bytes = sha256_HMAC.doFinal(message.getBytes());
hash = byteArrayToHexString(bytes);
// System.out.println(hash);
} catch (Exception e) {
System.out.println("Error HmacSHA256 ===========" + e.getMessage());
}
return hash;
}
/**
* 将加密后的字节数组转化成字符串
* @param b
* @return
*/
private static String byteArrayToHexString(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp;
for (int n = 0; b != null && n < b.length; n++) {
stmp = Integer.toHexString(b[n] & 0XFF);
if (stmp.length() == 1)
hs.append('0');
hs.append(stmp);
}
return hs.toString().toUpperCase();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment