Переглянути джерело

feat:“区分七云商户支付功能”

soobin 1 рік тому
батько
коміт
7f5920f6fc

+ 24 - 102
src/main/java/com/szwl/constant/HuifuConstant.java

@@ -45,17 +45,32 @@ public class HuifuConstant {
     /**
      * 申泽商户公众账号ID
      */
-    public static final String WX_SUB_APP_ID = "wxcd5b1b2636c9f611";
+    public static final String SZ_WX_SUB_APP_ID = "wxcd5b1b2636c9f611";
 
     /**
-     * 申泽商户公众账号ID
+     * 七云商户公众账号ID
+     */
+    public static final String SC_WX_SUB_APP_ID = "wxd9c7c138a055ee66";
+
+    /**
+     * 申泽商户公众账号密钥
+     */
+    public static final String SZ_WX_APP_SECRET = "e2854aa99f8279f33b4f065b2ffb75b1";
+
+    /**
+     * 七云商户公众账号密钥
+     */
+    public static final String SC_WX_APP_SECRET = "f131c85c06a80e466bd7e366cd477b93";
+
+    /**
+     * 申泽分账商户号
      */
-    public static final String WX_APP_SECRET = "e2854aa99f8279f33b4f065b2ffb75b1";
+    public static final String SZ_DIV_HUIFU_ID = "6666000136120737";
 
     /**
-     * 分账商户号
+     * 七云分账商户号
      */
-    public static final String DIV_HUIFU_ID = "6666000136120737";
+    public static final String SC_DIV_HUIFU_ID = "6666000139220493";
 
     /**
      * >>>>>>>>>>>>> 币种 >>>>>>>>>>>>>
@@ -69,8 +84,10 @@ public class HuifuConstant {
     /**
      * 跳转链接
      */
-    public final static String JUMP_URL = "http://szwlh.sunzee.com.cn/shenze";
-//    public final static String JUMP_URL = "http://szwltest.sunzee.com.cn/shenze";
+    public final static String SZ_JUMP_URL = "http://szwlh.sunzee.com.cn/shenze";
+    public final static String SC_JUMP_URL = "http://sevencloud.com.cn/sc";
+//    public final static String SC_JUMP_URL = "http://szwltest.sunzee.com.cn/sc";
+//    public final static String SZ_JUMP_URL = "http://szwltest.sunzee.com.cn/shenze";
 
 
     /**
@@ -101,22 +118,6 @@ public class HuifuConstant {
     public final static String TRANS_STAT_P = "P";
     public final static String RESP_CODE_0 = "00000000";
 
-    /**
-     * >>>>>>>>>>>>> 签名类型 >>>>>>>>>>>>>
-     * 1=MD5,2=RSA
-     */
-    public final static String sign_type_MD5 = "1";
-    public final static String sign_type_RSA = "2";
-
-
-
-    /**
-     * >>>>>>>>>>>>> 账户类型 >>>>>>>>>>>>>
-     * 1 借记卡,4 对公账户
-     */
-    public final static Integer bank_account_type1 = 1;
-    public final static Integer bank_account_type4 = 4;
-
 
     /**
      *
@@ -196,85 +197,6 @@ public class HuifuConstant {
 
 
     /**
-     * >>>>>>>>>>>>> 支付交易类型 >>>>>>>>>>>>>
-     */
-    public static final Map<String, String> frp_code = new HashMap<>();
-    public static final String frp_code_ALIPAY_NATIVE = "ALIPAY_NATIVE";
-    public static final String frp_code_ALIPAY_CARD = "ALIPAY_CARD";
-    public static final String frp_code_ALIPAY_APP = "ALIPAY_APP";
-    public static final String frp_code_ALIPAY_H5 = "ALIPAY_H5";
-    public static final String frp_code_ALIPAY_FWC = "ALIPAY_FWC";
-    public static final String frp_code_ALIPAY_SYT = "ALIPAY_SYT";
-    public static final String frp_code_WEIXIN_NATIVE = "WEIXIN_NATIVE";
-    public static final String frp_code_WEIXIN_CARD = "WEIXIN_CARD";
-    public static final String frp_code_WEIXIN_APP = "WEIXIN_APP";
-    public static final String frp_code_WEIXIN_APP2 = "WEIXIN_APP2";
-    public static final String frp_code_WEIXIN_H5 = "WEIXIN_H5";
-    public static final String frp_code_WEIXIN_GZH = "WEIXIN_GZH";
-    public static final String frp_code_WEIXIN_XCX = "WEIXIN_XCX";
-    public static final String frp_code_JD_NATIVE = "JD_NATIVE";
-    public static final String frp_code_JD_CARD = "JD_CARD";
-    public static final String frp_code_JD_APP = "JD_APP";
-    public static final String frp_code_JD_H5 = "JD_H5";
-    public static final String frp_code_QQ_NATIVE = "QQ_NATIVE";
-    public static final String frp_code_QQ_CARD = "QQ_CARD";
-    public static final String frp_code_QQ_APP = "QQ_APP";
-    public static final String frp_code_QQ_H5 = "QQ_H5";
-    public static final String frp_code_QQ_GZH = "QQ_GZH";
-    public static final String frp_code_UNIONPAY_NATIVE = "UNIONPAY_NATIVE";
-    public static final String frp_code_UNIONPAY_CARD = "UNIONPAY_CARD";
-    public static final String frp_code_UNIONPAY_APP = "UNIONPAY_APP";
-    public static final String frp_code_UNIONPAY_H5 = "UNIONPAY_H5";
-    public static final String frp_code_BAIDU_NATIVE = "BAIDU_NATIVE";
-    public static final String frp_code_SUNING_NATIVE = "SUNING_NATIVE";
-
-
-    static {
-        biz_code.put(frp_code_ALIPAY_NATIVE, "支付宝扫码(主扫)");
-        biz_code.put(frp_code_ALIPAY_CARD, "支付宝刷卡(被扫)");
-        biz_code.put(frp_code_ALIPAY_APP, "支付宝APP 支付");
-        biz_code.put(frp_code_ALIPAY_H5, "支付宝H5");
-        biz_code.put(frp_code_ALIPAY_FWC, "支付宝服务窗");
-        biz_code.put(frp_code_ALIPAY_SYT, "支付宝收银台");
-        biz_code.put(frp_code_WEIXIN_NATIVE, "微信扫码(主扫)");
-        biz_code.put(frp_code_WEIXIN_CARD, "微信刷卡(被扫)");
-        biz_code.put(frp_code_WEIXIN_APP, "微信APP 支付");
-        biz_code.put(frp_code_WEIXIN_APP2, "微信APP2 支付");
-        biz_code.put(frp_code_WEIXIN_H5, "微信H5 支付");
-        biz_code.put(frp_code_WEIXIN_GZH, "微信公众号支付");
-        biz_code.put(frp_code_WEIXIN_XCX, "微信小程序支付");
-        biz_code.put(frp_code_JD_NATIVE, "京东扫码(主扫)");
-        biz_code.put(frp_code_JD_CARD, "京东刷卡(被扫)");
-        biz_code.put(frp_code_JD_APP, "京东APP 支付");
-        biz_code.put(frp_code_JD_H5, "京东H5 支付");
-        biz_code.put(frp_code_QQ_NATIVE, "QQ 扫码(主扫)");
-        biz_code.put(frp_code_QQ_CARD, "QQ 刷卡(被扫)");
-        biz_code.put(frp_code_QQ_APP, "QQ APP 支付");
-        biz_code.put(frp_code_QQ_H5, "QQH5 支付");
-        biz_code.put(frp_code_QQ_GZH, "QQ 公众号支付");
-        biz_code.put(frp_code_UNIONPAY_NATIVE, "银联扫码(主扫)");
-        biz_code.put(frp_code_UNIONPAY_CARD, "银联刷卡(被扫)");
-        biz_code.put(frp_code_UNIONPAY_APP, "银联APP 支付");
-        biz_code.put(frp_code_UNIONPAY_H5, "银联H5");
-        biz_code.put(frp_code_BAIDU_NATIVE, "百度扫码(主扫)");
-        biz_code.put(frp_code_SUNING_NATIVE, "苏宁扫码(主扫)");
-    }
-
-
-    /**
-     *
-     *
-     *  >>>>>>>>>>>>> 汇聚支付接口 >>>>>>>>>>>>>
-     *
-     *
-     */
-
-    /**
-     * 版本
-     */
-    public static final String pay_version = "2.1";
-
-    /**
      * 文件类型
      */
     public enum fileType {

+ 163 - 80
src/main/java/com/szwl/controller/TOrderController.java

@@ -230,12 +230,13 @@ public class TOrderController {
 
         // 支付方式:0或null为汇聚,1为汇付支付
         String payPlatform = admin.getPayPlatform();
+        String companyType = admin.getCompanyType();
         // 汇聚分账参数
         JSONArray altInfo = new JSONArray();
         // 汇付分账明细参数
         JSONObject acctSplitBunch = new JSONObject();
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
-            acctSplitBunch = getAcctSplitBunch(proportion, price);
+            acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
         } else {
             altInfo = getAltInfo(proportion, price);
         }
@@ -282,14 +283,14 @@ public class TOrderController {
         if(admin.getType()==0){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
             order.setAgencyId(proportion.getAgencyId());
             order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
             order.setAdminProportion(proportion.getAdminProportion());
@@ -298,7 +299,7 @@ public class TOrderController {
             order.setMerchantProportion(proportion.getMerchantProportion());
             order.setMerchantId(proportion.getMerchantId());
             order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order.setPersonageId(proportion.getPersonageId());
         }
 
         order.setPayPlatform(payPlatform);
@@ -315,7 +316,7 @@ public class TOrderController {
         orderDetails.setProductNumber(productNumber);
         orderDetails.setAmount(price);
         orderDetails.setRefundStatus("0");
-        orderDetails.setCompanyType(admin.getCompanyType());
+        orderDetails.setCompanyType(companyType);
         orderDetails.setMachineType(equipment.getMachineType());
 
         String client6 = clientId.substring(clientId.length() - 6);
@@ -332,8 +333,12 @@ public class TOrderController {
                 tHuifuTempOrder.setId(id);
                 BeanUtil.copyProperties(order,tHuifuTempOrder,ignoreProperties);
                 huifuTempOrderService.save(tHuifuTempOrder);
-                result =  HuifuConstant.JUMP_URL+ "/#/weChatPay?id=" + id;
-                System.out.println(result);
+                if (StrUtil.isNotEmpty(companyType)&&companyType.equals("1")) {
+                    result =  HuifuConstant.SC_JUMP_URL+ "/#/weChatPay?id=" + id;
+                } else {
+                    result =  HuifuConstant.SZ_JUMP_URL+ "/#/weChatPay?id=" + id;
+                }
+                log.info("返回链接:{}", result);
                 String qrcode = toQrcode(result);
                 JSONObject kindData = new JSONObject();
                 kindData.put("sn", sn);
@@ -344,7 +349,7 @@ public class TOrderController {
             try {
                 result = huifuMchService.uniPay(
                         orderNo, amount, productName1, productDesc,
-                        notifyUrl, frpCode, openId, appid, acctSplitBunch
+                        notifyUrl, frpCode, openId, appid, acctSplitBunch, companyType
                 );
             } catch (Exception e) {
                 e.printStackTrace();
@@ -490,12 +495,13 @@ public class TOrderController {
 
         // 支付方式:0或null为汇聚,1为汇付支付
         String payPlatform = admin.getPayPlatform();
+        String companyType = admin.getCompanyType();
         // 汇聚分账参数
         JSONArray altInfo = new JSONArray();
         // 汇付分账明细参数
         JSONObject acctSplitBunch = new JSONObject();
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
-            acctSplitBunch = getAcctSplitBunch(proportion, price);
+      acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
         } else {
             altInfo = getAltInfo(proportion, price);
         }
@@ -543,14 +549,14 @@ public class TOrderController {
         if(admin.getType()==0){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
             order.setAgencyId(proportion.getAgencyId());
             order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
             order.setAdminProportion(proportion.getAdminProportion());
@@ -559,7 +565,7 @@ public class TOrderController {
             order.setMerchantProportion(proportion.getMerchantProportion());
             order.setMerchantId(proportion.getMerchantId());
             order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order.setPersonageId(proportion.getPersonageId());
         }
         order.setPayPlatform(payPlatform);
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
@@ -579,7 +585,7 @@ public class TOrderController {
         orderDetails.setProductNumber(productNumber);
         orderDetails.setAmount(price);
         orderDetails.setRefundStatus("0");
-        orderDetails.setCompanyType(admin.getCompanyType());
+        orderDetails.setCompanyType(companyType);
         orderDetails.setMachineType(equipment.getMachineType());
 
         String client6 = clientId.substring(clientId.length() - 6);
@@ -589,7 +595,7 @@ public class TOrderController {
             order.setAcctSplitBunch(acctSplitBunch.toString());
             try {
                 result = huifuMchService.cardPay(
-                        orderNo, amount, productName1, notifyUrl, authCode,  acctSplitBunch
+                        orderNo, amount, productName1, notifyUrl, authCode,  acctSplitBunch, companyType
                 );
             } catch (Exception e) {
                 e.printStackTrace();
@@ -727,12 +733,13 @@ public class TOrderController {
 
         // 支付方式:0或null为汇聚,1为汇付支付
         String payPlatform = admin.getPayPlatform();
+        String companyType = admin.getCompanyType();
         // 汇聚分账参数
         JSONArray altInfo = new JSONArray();
         // 汇付分账明细参数
         JSONObject acctSplitBunch = new JSONObject();
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
-            acctSplitBunch = getAcctSplitBunch(proportion, price);
+            acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
         } else {
             altInfo = getAltInfo(proportion, price);
         }
@@ -776,19 +783,19 @@ public class TOrderController {
         order.setAltInfo(altInfo.toString());
         order.setStatus(0);
         order.setType(admin.getType());
-        order.setCompanyType(admin.getCompanyType());
+        order.setCompanyType(companyType);
         order.setMachineType(equipment.getMachineType());
         if(admin.getType()==0){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
             order.setAgencyId(proportion.getAgencyId());
             order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
             order.setAdminProportion(proportion.getAdminProportion());
@@ -797,7 +804,7 @@ public class TOrderController {
             order.setMerchantProportion(proportion.getMerchantProportion());
             order.setMerchantId(proportion.getMerchantId());
             order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order.setPersonageId(proportion.getPersonageId());
         }
         order.setPayPlatform(payPlatform);
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
@@ -818,9 +825,31 @@ public class TOrderController {
         order2.setFrpCode(frpCode2);
         order2.setAltInfo(altInfo.toString());
         order2.setStatus(0);
+        order2.setType(admin.getType());
         order2.setPayPlatform(payPlatform);
-        order2.setCompanyType(admin.getCompanyType());
+        order2.setCompanyType(companyType);
         order2.setMachineType(equipment.getMachineType());
+        if(admin.getType()==0){
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
+        }
+        if(admin.getType()==1){
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
+            order2.setMerchantProportion(proportion.getMerchantProportion());
+            order2.setMerchantId(proportion.getMerchantId());
+        }
+        if(admin.getType()==2){
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
+            order2.setMerchantProportion(proportion.getMerchantProportion());
+            order2.setMerchantId(proportion.getMerchantId());
+            order2.setPersonageProportion(proportion.getPersonageProportion());
+            order2.setPersonageId(proportion.getPersonageId());
+        }
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
             order2.setIsSettlement("0");
         }
@@ -834,7 +863,7 @@ public class TOrderController {
         orderDetails.setProductNo(product.getNo());
         orderDetails.setProductNumber(productNumber);
         orderDetails.setAmount(price);
-        orderDetails.setCompanyType(admin.getCompanyType());
+        orderDetails.setCompanyType(companyType);
         orderDetails.setRefundStatus("0");
         orderDetails.setMachineType(equipment.getMachineType());
 
@@ -852,12 +881,17 @@ public class TOrderController {
             tHuifuTempOrder.setId(id);
             BeanUtil.copyProperties(order,tHuifuTempOrder,ignoreProperties);
             huifuTempOrderService.save(tHuifuTempOrder);
-            String result1 =  HuifuConstant.JUMP_URL+ "/#/weChatPay?id=" + id;
+            String result1 = "";
+            if (StrUtil.isNotEmpty(companyType)&&companyType.equals("1")) {
+                result1 =  HuifuConstant.SC_JUMP_URL+ "/#/weChatPay?id=" + id;
+            } else {
+                result1 =  HuifuConstant.SZ_JUMP_URL+ "/#/weChatPay?id=" + id;
+            }
             // 支付宝
             try {
                 result = huifuMchService.uniPay(
                         sn2, amount, productName1, productDesc,
-                        notifyUrl, frpCode2, openId, appid, acctSplitBunch
+                        notifyUrl, frpCode2, openId, appid, acctSplitBunch,companyType
                 );
             } catch (Exception e) {
                 e.printStackTrace();
@@ -1117,12 +1151,13 @@ public class TOrderController {
 
         // 支付方式:0或null为汇聚,1为汇付支付
         String payPlatform = admin.getPayPlatform();
+        String companyType = admin.getCompanyType();
         // 汇聚分账参数
         JSONArray altInfo = new JSONArray();
         // 汇付分账明细参数
         JSONObject acctSplitBunch = new JSONObject();
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
-            acctSplitBunch = getAcctSplitBunch(proportion, price);
+            acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
         } else {
             altInfo = getAltInfo(proportion, price);
         }
@@ -1170,19 +1205,19 @@ public class TOrderController {
         order.setProductNumber(productNumber);
         order.setStatus(0);
         order.setType(admin.getType());
-        order.setCompanyType(admin.getCompanyType());
+        order.setCompanyType(companyType);
         order.setMachineType(equipment.getMachineType());
         if(admin.getType()==0){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
             order.setAgencyId(proportion.getAgencyId());
             order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
             order.setAdminProportion(proportion.getAdminProportion());
@@ -1191,7 +1226,7 @@ public class TOrderController {
             order.setMerchantProportion(proportion.getMerchantProportion());
             order.setMerchantId(proportion.getMerchantId());
             order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order.setPersonageId(proportion.getPersonageId());
         }
         order.setPayPlatform(payPlatform);
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
@@ -1212,29 +1247,29 @@ public class TOrderController {
         order2.setAltInfo(altInfo.toString());
         order2.setStatus(0);
         order2.setProductNumber(productNumber);
-        order.setType(admin.getType());
-        order.setCompanyType(admin.getCompanyType());
+        order2.setType(admin.getType());
+        order2.setCompanyType(companyType);
         order2.setMachineType(equipment.getMachineType());
         if(admin.getType()==0){
-            order.setAdminProportion(proportion.getAdminProportion());
-            order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
-            order.setAdminProportion(proportion.getAdminProportion());
-            order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(proportion.getAgencyId());
-            order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
+            order2.setMerchantProportion(proportion.getMerchantProportion());
+            order2.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
-            order.setAdminProportion(proportion.getAdminProportion());
-            order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(proportion.getAgencyId());
-            order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(proportion.getMerchantId());
-            order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order2.setAdminProportion(proportion.getAdminProportion());
+            order2.setAgencyProportion(proportion.getAgencyProportion());
+            order2.setAgencyId(proportion.getAgencyId());
+            order2.setMerchantProportion(proportion.getMerchantProportion());
+            order2.setMerchantId(proportion.getMerchantId());
+            order2.setPersonageProportion(proportion.getPersonageProportion());
+            order2.setPersonageId(proportion.getPersonageId());
         }
         order2.setPayPlatform(payPlatform);
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
@@ -1246,7 +1281,7 @@ public class TOrderController {
         orderDetails.setAdminId(admin.getId());
         orderDetails.setEquipmentId(equipmentId);
         orderDetails.setCreateDate(new Date());
-        orderDetails.setCompanyType(admin.getCompanyType());
+        orderDetails.setCompanyType(companyType);
         orderDetails.setRefundStatus("0");
         orderDetails.setMachineType(equipment.getMachineType());
 
@@ -1273,12 +1308,17 @@ public class TOrderController {
             tHuifuTempOrder.setId(id);
             BeanUtil.copyProperties(order,tHuifuTempOrder,ignoreProperties);
             huifuTempOrderService.save(tHuifuTempOrder);
-            String result1 =  HuifuConstant.JUMP_URL+"/#/weChatPay?id=" + id;
+            String result1 = "";
+            if (StrUtil.isNotEmpty(companyType)&&companyType.equals("1")) {
+                result1 =  HuifuConstant.SC_JUMP_URL+ "/#/weChatPay?id=" + id;
+            } else {
+                result1 =  HuifuConstant.SZ_JUMP_URL+ "/#/weChatPay?id=" + id;
+            }
             // 支付宝
             try {
                 result = huifuMchService.uniPay(
                         sn2, amount, productName1, productDesc,
-                        notifyUrl, frpCode2, openId, appid, acctSplitBunch
+                        notifyUrl, frpCode2, openId, appid, acctSplitBunch, companyType
                 );
             } catch (Exception e) {
                 e.printStackTrace();
@@ -1578,12 +1618,13 @@ public class TOrderController {
 
         // 支付方式:0或null为汇聚,1为汇付支付
         String payPlatform = admin.getPayPlatform();
+        String companyType = admin.getCompanyType();
         // 汇聚分账参数
         JSONArray altInfo = new JSONArray();
         // 汇付分账明细参数
         JSONObject acctSplitBunch = new JSONObject();
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
-            acctSplitBunch = getAcctSplitBunch(proportion, price);
+            acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
         } else {
             altInfo = getAltInfo(proportion, price);
         }
@@ -1673,7 +1714,7 @@ public class TOrderController {
         order.setType(admin.getType());
         order.setMarketingAmount(marketingAmount);
         order.setProductNumber(productNumber);
-        order.setCompanyType(admin.getCompanyType());
+        order.setCompanyType(companyType);
         order.setMachineType(equipment.getMachineType());
         if(couponList.size()>0){
             order.setCoupons(couponList.toString());
@@ -1681,14 +1722,14 @@ public class TOrderController {
         if(admin.getType()==0){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
-            order.setAgencyId(admin.getId());
+            order.setAgencyId(proportion.getAgencyId());
         }
         if(admin.getType()==1){
             order.setAdminProportion(proportion.getAdminProportion());
             order.setAgencyProportion(proportion.getAgencyProportion());
             order.setAgencyId(proportion.getAgencyId());
             order.setMerchantProportion(proportion.getMerchantProportion());
-            order.setMerchantId(admin.getId());
+            order.setMerchantId(proportion.getMerchantId());
         }
         if(admin.getType()==2){
             order.setAdminProportion(proportion.getAdminProportion());
@@ -1697,7 +1738,7 @@ public class TOrderController {
             order.setMerchantProportion(proportion.getMerchantProportion());
             order.setMerchantId(proportion.getMerchantId());
             order.setPersonageProportion(proportion.getPersonageProportion());
-            order.setPersonageId(admin.getId());
+            order.setPersonageId(proportion.getPersonageId());
         }
         order.setPayPlatform(payPlatform);
         if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
@@ -1726,7 +1767,7 @@ public class TOrderController {
         orderDetails.setAdminId(admin.getId());
         orderDetails.setEquipmentId(equipmentId);
         orderDetails.setCreateDate(new Date());
-        orderDetails.setCompanyType(admin.getCompanyType());
+        orderDetails.setCompanyType(companyType);
         orderDetails.setRefundStatus("0");
         orderDetails.setMachineType(equipment.getMachineType());
 
@@ -1747,7 +1788,7 @@ public class TOrderController {
             try {
                 result = huifuMchService.uniPay(
                         orderNo1, amount, productName1, productDesc,
-                        notifyUrl, frpCode1, openId, appid, acctSplitBunch
+                        notifyUrl, frpCode1, openId, appid, acctSplitBunch, companyType
                 );
             } catch (Exception e) {
                 e.printStackTrace();
@@ -1819,27 +1860,54 @@ public class TOrderController {
         // 获取code
         String code = request.getParameter("code");
         String id = request.getParameter("state");
-        // 获取openid
-        String openUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
-                "appid=" + HuifuConstant.WX_SUB_APP_ID +
-                "&secret=" + HuifuConstant.WX_APP_SECRET +
-                "&code=" + code +
-                "&grant_type=authorization_code";
-        org.json.JSONObject jsonObject = HttpClientUtils.get(openUrl);
-        String openid = jsonObject.getString("openid");
-        // 从临时表中获取订单信息
         LambdaQueryWrapper<THuifuTempOrder> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(THuifuTempOrder::getId,id);
         THuifuTempOrder huifuTempOrder = huifuTempOrderService.getOne(wrapper);
+        // 从临时表中获取订单信息
         String result = null;
-        if(huifuTempOrder.getStatus() == 1) {
-//            result = "http://szwltest.sunzee.com.cn/shenze/#/popPayment?status=1";
-            result = HuifuConstant.JUMP_URL+"/#/popPayment?status=1";
-        } else {
-            try {
-                result = huifuMchService.wetchatPay(huifuTempOrder,openid);
-            } catch (Exception e) {
-                e.printStackTrace();
+        if(huifuTempOrder != null) {
+            String companyType = huifuTempOrder.getCompanyType();
+            if(huifuTempOrder.getStatus() == 1) {
+                if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+                    result = HuifuConstant.SC_JUMP_URL+"/#/popPayment?status=1";
+                } else {
+                    result = HuifuConstant.SZ_JUMP_URL+"/#/popPayment?status=1";
+                }
+            } else {
+                String openid;
+                if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+                    // 获取openid
+                    try {
+                        String openUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
+                                "appid=" + HuifuConstant.SC_WX_SUB_APP_ID +
+                                "&secret=" + HuifuConstant.SC_WX_APP_SECRET +
+                                "&code=" + code +
+                                "&grant_type=authorization_code";
+                        log.info("获取openID:{}", openUrl);
+                        org.json.JSONObject jsonObject = HttpClientUtils.get(openUrl);
+                        log.info("获取openID结果:{}", jsonObject);
+                        openid = jsonObject.getString("openid");
+                        result = huifuMchService.wetchatPay(huifuTempOrder,openid);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                } else {
+                    // 获取openid
+                    try {
+                        String openUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
+                                "appid=" + HuifuConstant.SZ_WX_SUB_APP_ID +
+                                "&secret=" + HuifuConstant.SZ_WX_APP_SECRET +
+                                "&code=" + code +
+                                "&grant_type=authorization_code";
+                        log.info("获取openID:{}", openUrl);
+                        org.json.JSONObject jsonObject = HttpClientUtils.get(openUrl);
+                        log.info("获取openID结果:{}", jsonObject);
+                        openid = jsonObject.getString("openid");
+                        result = huifuMchService.wetchatPay(huifuTempOrder,openid);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
             }
         }
         log.info("支付链接:{}",result);
@@ -2570,10 +2638,10 @@ public class TOrderController {
                 order.setRefundAmount(newRefundAmount);
                 // 如果小于订单金额
                 if(newRefundAmount.compareTo(order.getPrice()) < 0) {
-                    acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice().subtract(newRefundAmount)).toString();
+                    acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice().subtract(newRefundAmount), order.getCompanyType()).toString();
                     order.setAcctSplitBunch(acctSplitBunch);
                 } else {
-                    acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice()).toString();
+                    acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice(), order.getCompanyType()).toString();
                     order.setAcctSplitBunch(acctSplitBunch);
                 }
             } else {
@@ -2581,7 +2649,7 @@ public class TOrderController {
                 if(new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP).compareTo(order.getPrice()) < 0) {
                     // 重新设置分销
                     acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice()
-                            .subtract(new BigDecimal(ordAmt).setScale(2,RoundingMode.HALF_UP))).toString();
+                            .subtract(new BigDecimal(ordAmt).setScale(2,RoundingMode.HALF_UP)), order.getCompanyType()).toString();
                     order.setAcctSplitBunch(acctSplitBunch);
                 }
             }
@@ -3185,7 +3253,7 @@ public class TOrderController {
      * @param price
      * @return
      */
-    public JSONObject getAcctSplitBunch(TProportion proportion, BigDecimal price) {
+    public JSONObject getAcctSplitBunch(TProportion proportion, BigDecimal price, String companyType) {
 
         // 获取分账有几方:0:分账方2个,1:分账方3个,2:分账方4个,3:分账方超4个
         Integer type = proportion.getType();
@@ -3232,7 +3300,12 @@ public class TOrderController {
                 // 公司平台分销
                 adminJson = new JSONObject();
                 adminJson.put("div_amt", adminAmount.toString());
-                adminJson.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+                // 判断为申泽还是七云
+                if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+                    adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+                } else {
+                    adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+                }
                 acctInfos.add(adminJson);
                 // 商家分销获得利润
                 selfJson = new JSONObject();
@@ -3258,7 +3331,12 @@ public class TOrderController {
                 // 公司平台分销
                 adminJson = new JSONObject();
                 adminJson.put("div_amt", adminAmount.toString());
-                adminJson.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+                // 判断为申泽还是七云
+                if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+                    adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+                } else {
+                    adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+                }
                 acctInfos.add(adminJson);
                 // 商家分销获得利润
                 selfJson = new JSONObject();
@@ -3294,7 +3372,12 @@ public class TOrderController {
                 // 公司平台分销
                 adminJson = new JSONObject();
                 adminJson.put("div_amt", adminAmount.toString());
-                adminJson.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+                // 判断为申泽还是七云
+                if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+                    adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+                } else {
+                    adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+                }
                 acctInfos.add(adminJson);
                 // 商家分销获得利润
                 selfJson = new JSONObject();
@@ -3332,7 +3415,7 @@ public class TOrderController {
             for (int i = 0; i < acctInfos.size(); i++) {
                 JSONObject jsonObject = acctInfos.getJSONObject(i);
                 String huifuId = jsonObject.getString("huifu_id");
-                if (huifuId.equals(HuifuConstant.DIV_HUIFU_ID)) {
+                if (huifuId.equals(HuifuConstant.SZ_DIV_HUIFU_ID) || huifuId.equals(HuifuConstant.SC_DIV_HUIFU_ID)) {
                     BigDecimal currentDivAmt = new BigDecimal(jsonObject.getString("div_amt"));
                     BigDecimal adjustedDivAmt = currentDivAmt.subtract(diffAmount).max(BigDecimal.ZERO);
                     jsonObject.put("div_amt", adjustedDivAmt.toString());

+ 9 - 2
src/main/java/com/szwl/service/THuifuMchService.java

@@ -28,9 +28,14 @@ public interface THuifuMchService extends IService<THuifuMch> {
      * @param openId 微信openId
      * @param appid 微信appId
      * @param acctSplitBunch 分账明细
+     * @param companyType 公司平台
      * @return
+     * @throws Exception
      */
-    String uniPay(String orderNo, BigDecimal amount, String productName, String productDesc, String notifyUrl, String frpCode, String openId, String appid, JSONObject acctSplitBunch) throws Exception;
+    String uniPay(String orderNo, BigDecimal amount, String productName,
+                  String productDesc, String notifyUrl, String frpCode,
+                  String openId, String appid, JSONObject acctSplitBunch,
+                  String companyType) throws Exception;
 
     /**
      * 汇付微信聚合正扫
@@ -49,5 +54,7 @@ public interface THuifuMchService extends IService<THuifuMch> {
      * @param acctSplitBunch
      * @return
      */
-    String cardPay(String orderNo, BigDecimal amount, String productName, String notifyUrl, String authCode, JSONObject acctSplitBunch) throws Exception;
+    String cardPay(String orderNo, BigDecimal amount, String productName,
+                   String notifyUrl, String authCode, JSONObject acctSplitBunch,
+                   String companyType) throws Exception;
 }

+ 45 - 14
src/main/java/com/szwl/service/impl/THuifuMchServiceImpl.java

@@ -1,6 +1,7 @@
 package com.szwl.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.huifu.bspay.sdk.opps.core.utils.DateTools;
@@ -57,13 +58,20 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
     SzwlFeign szwlFeign;
 
     @Override
-    public String uniPay(String orderNo, BigDecimal amount, String productName, String productDesc, String notifyUrl, String frpCode, String openId, String appid, JSONObject acctSplitBunch) throws Exception {
+    public String uniPay(String orderNo, BigDecimal amount, String productName,
+                         String productDesc, String notifyUrl, String frpCode,
+                         String openId, String appid, JSONObject acctSplitBunch,
+                         String companyType) throws Exception {
         String url = "https://api.huifu.com/v2/trade/payment/jspay";
         HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
         JSONObject request = new JSONObject();
         request.put("req_seq_id", orderNo);
         request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
-        request.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+        if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+            request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+        } else {
+            request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+        }
         if(frpCode.equals("ALIPAY_NATIVE")) {
             request.put("trade_type", "A_NATIVE");
         }
@@ -112,7 +120,12 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         String sn = HuifuUtils.initReqSeqId();
         request.put("req_seq_id", sn);
         request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
-        request.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+        String companyType = huifuTempOrder.getCompanyType();
+        if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+            request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+        } else {
+            request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+        }
         request.put("trade_type", "T_JSAPI");
         request.put("trans_amt", huifuTempOrder.getPrice());
         String clientId = huifuTempOrder.getClientId();
@@ -130,14 +143,17 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
             productName1 = productName + "-" + equipment.getName() + "-" + client6;
         }
         request.put("goods_desc", productName1);
-//        request.put("goods_desc", huifuTempOrder.getProductName());
         request.put("notify_url", HuifuConstant.Notify_Url);
         request.put("remark", huifuTempOrder.getId());
         // 分账明细
         request.put("acct_split_bunch", huifuTempOrder.getAcctSplitBunch());
         // 微信支付配置
         JSONObject wxData = new JSONObject();
-        wxData.put("sub_appid",HuifuConstant.WX_SUB_APP_ID);
+        if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+            wxData.put("sub_appid",HuifuConstant.SC_WX_SUB_APP_ID);
+        } else {
+            wxData.put("sub_appid",HuifuConstant.SZ_WX_SUB_APP_ID);
+        }
         wxData.put("open_id",openid);
         request.put("wx_data", wxData);
         // 签名:sign
@@ -167,12 +183,22 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         // 获取paySign的值
         String paySign = payInfoJson.getString("paySign");
         // 测试链接:http://szwltest.sunzee.com.cn/shenze
-        String resultUrl = HuifuConstant.JUMP_URL+"/#/popPayment?" +
-                "sn=" + sn +
-                "&timeStamp=" + timeStamp +
-                "&nonceStr=" + nonceStr +
-                "&package=" + packageValue +
-                "&paySign=" + paySign;
+        String resultUrl = "";
+        if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+            resultUrl = HuifuConstant.SC_JUMP_URL+"/#/popPayment?" +
+                    "sn=" + sn +
+                    "&timeStamp=" + timeStamp +
+                    "&nonceStr=" + nonceStr +
+                    "&package=" + packageValue +
+                    "&paySign=" + paySign;
+        } else {
+            resultUrl = HuifuConstant.SZ_JUMP_URL+"/#/popPayment?" +
+                    "sn=" + sn +
+                    "&timeStamp=" + timeStamp +
+                    "&nonceStr=" + nonceStr +
+                    "&package=" + packageValue +
+                    "&paySign=" + paySign;
+        }
         log.info("微信支付链接:{}", resultUrl);
         // 保存订单到数据库
         TOrder tOrder = new TOrder();
@@ -232,14 +258,19 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
     }
 
     @Override
-    public String cardPay(String orderNo, BigDecimal amount, String productName, String notifyUrl, String authCode, JSONObject acctSplitBunch) throws Exception {
+    public String cardPay(String orderNo, BigDecimal amount, String productName,
+                          String notifyUrl, String authCode, JSONObject acctSplitBunch,
+                          String companyType) throws Exception {
         String url = "https://api.huifu.com/v2/trade/payment/micropay";
         HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
         JSONObject request = new JSONObject();
-//        String sn = HuifuUtils.initReqSeqId();
         request.put("req_seq_id", orderNo);
         request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
-        request.put("huifu_id", HuifuConstant.DIV_HUIFU_ID);
+        if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
+            request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
+        } else {
+            request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
+        }
         request.put("auth_code", authCode);
         request.put("trans_amt", amount);
         request.put("goods_desc", productName);