瀏覽代碼

小程序支付

李天标 2 年之前
父節點
當前提交
8648838c9a
共有 2 個文件被更改,包括 524 次插入18 次删除
  1. 523 18
      src/main/java/com/szwl/controller/TOrderController.java
  2. 1 0
      src/main/java/com/szwl/model/entity/TOrder.java

+ 523 - 18
src/main/java/com/szwl/controller/TOrderController.java

@@ -254,7 +254,7 @@ public class TOrderController {
 
         switch (type) {
 
-            case 2:
+            case 0:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
                 if (agencyMch == null ) {
                     return JsonMessage.error("设备商家未注册提现账户");
@@ -270,7 +270,7 @@ public class TOrderController {
                 agencyJson.put("isGuar", "12");
                 altInfo.add(agencyJson);
                 break;
-            case 3:
+            case 1:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
 //                agencyMch = mchService.getUniqueness(admin.getAgencyId());
@@ -310,7 +310,7 @@ public class TOrderController {
                 altInfo.add(merchantJson);
 
                 break;
-            case 4:
+            case 2:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
                 merchantMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getMerchantId())));
@@ -659,7 +659,7 @@ public class TOrderController {
 
         switch (type) {
 
-            case 2:
+            case 0:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
 
                 if (agencyMch == null ) {
@@ -676,7 +676,7 @@ public class TOrderController {
                 agencyJson.put("isGuar", "12");
                 altInfo.add(agencyJson);
                 break;
-            case 3:
+            case 1:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
 //                agencyMch = mchService.getUniqueness(admin.getAgencyId());
@@ -716,7 +716,7 @@ public class TOrderController {
                 altInfo.add(merchantJson);
 
                 break;
-            case 4:
+            case 2:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
                 merchantMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getMerchantId())));
@@ -1057,7 +1057,7 @@ public class TOrderController {
 
         switch (type) {
 
-            case 2:
+            case 0:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
 
                 if (agencyMch == null ) {
@@ -1074,7 +1074,7 @@ public class TOrderController {
                 agencyJson.put("isGuar", "12");
                 altInfo.add(agencyJson);
                 break;
-            case 3:
+            case 1:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
 //                agencyMch = mchService.getUniqueness(admin.getAgencyId());
@@ -1114,7 +1114,7 @@ public class TOrderController {
                 altInfo.add(merchantJson);
 
                 break;
-            case 4:
+            case 2:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
                 merchantMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getMerchantId())));
@@ -1591,7 +1591,7 @@ public class TOrderController {
 
         switch (type) {
 
-            case 2:
+            case 0:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
 
                 if (agencyMch == null ) {
@@ -1608,7 +1608,7 @@ public class TOrderController {
                 agencyJson.put("isGuar", "12");
                 altInfo.add(agencyJson);
                 break;
-            case 3:
+            case 1:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
 //                agencyMch = mchService.getUniqueness(admin.getAgencyId());
@@ -1648,7 +1648,7 @@ public class TOrderController {
                 altInfo.add(merchantJson);
 
                 break;
-            case 4:
+            case 2:
                 agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
 
                 merchantMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getMerchantId())));
@@ -1896,6 +1896,511 @@ public class TOrderController {
         }
 
     }
+    @ApiOperation(value = "购物车 微信支付")
+    @PostMapping("/carsPayXCX")
+    public Object carsPayXCX(String clientId,String id, @RequestBody Map<String,String> productNameMap) {
+//        IPage<?> iPage = R.getDataIfSuccess(szwlFeign.testPay("1"));
+//        productName = "玫瑰精灵";
+        if(productNameMap==null){
+            return  JsonMessage.error("数据出错");
+        }
+        StringBuffer productName1 = new StringBuffer();
+        StringBuffer note = new StringBuffer();
+        StringBuffer productName = new StringBuffer();
+        TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
+        if(equipment==null||equipment.getId()==null){
+            return JsonMessage.error("找不到设备");
+        }
+        BigDecimal price = new BigDecimal("0.00");
+//        JSONObject mapList = JSON.parseObject(productNameMap);
+        TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
+        if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
+            //1,type=0,原始设定,没有第二件半价
+            for (String key : productNameMap.keySet()) {
+//                System.out.println("key= "+ key + " and value= " + productNameMap.get(key));
+                String entryValue = String.valueOf(productNameMap.get(key));
+//                String key = String.valueOf(entry.getKey());
+//                String entryValue = String.valueOf(entry.getValue());
+                List<String> value = JSON.parseArray(entryValue, String.class);
+                List<TPromoCode> promoCodeList = new ArrayList<>();
+                //1,校验优惠码
+                if(value.size()>0){
+                    for(String code:value){
+                        if(!code.equals("0")){
+                            TPromoCode promoCode = new TPromoCode();
+                            TPromoCode tPromoCode = R.getDataIfSuccess(szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString()));
+                            promoCode = tPromoCode;
+                            if (tPromoCode == null||tPromoCode.getId()==null) {
+                                //不存在
+                                return JsonMessage.success("1");
+                            }
+//                            IPage<TPromoCode> pagePromoCode = R.getDataIfSuccess(szwlFeign.getTPromoCode(code));
+//                            List<TPromoCode> codeList = pagePromoCode.getRecords();
+//
+//                            if (codeList.size() == 0) {
+//                                //不存在
+//                                return JsonMessage.success("1");
+//                            }
+//                            for (TPromoCode cod : codeList) {
+//                                if(!cod.getAdminId().equals("1")){
+//                                    String adminId = cod.getAdminId();
+//                                    String adminId1 = String.valueOf(equipment.getAdminId());
+//                                    if (adminId.equals(adminId1)) {
+//                                        promoCode = cod;
+//                                    }
+//                                }else{
+//                                    promoCode = cod;
+//                                }
+//                            }
+                            Date lastUseDate = null;
+                            if (promoCode != null) {
+                                lastUseDate = promoCode.getLastUseDate();
+                            }
+
+                            if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
+                                promoCode.setIsUse("2");
+                                szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
+                                //过期
+                                return JsonMessage.success("4");
+                            }
+                            if (promoCode.getId() == null) {
+                                //不存在
+                                return JsonMessage.success("1");
+                            }
+                            if (promoCode.getIsUse().equals("1")) {
+                                //被使用
+                                return JsonMessage.success("2");
+                            }
+                            if(!promoCode.getAdminId().equals("1")){
+                                if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
+
+                                } else {
+                                    //不是本机
+                                    return JsonMessage.success("3");
+                                }
+                            }
+                            if (promoCode.getDiscount() == null) {
+                                //旧优惠码
+                                return JsonMessage.success("0");
+                            }
+                            if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
+                                //0折
+                                return JsonMessage.success("0");
+                            }
+                            promoCodeList.add(promoCode);
+                        }
+                    }
+                }
+                String[] productNum = key.split("-");
+                String productNamea = productNum[0];
+                String num = productNum[1];
+                productName.append(productNamea).append(num);
+                note.append(productNamea).append(num).append(":");
+                productName1.append(productNamea).append(num);
+                //确定价格,然后叠加R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
+                TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productName.toString()));
+                if (product == null) {
+                    return JsonMessage.error("找不到商品");
+                }
+                BigDecimal productPrice = product.getRmbPrice();
+                if(promoCodeList.size()>0){
+                    //有优惠码
+                    BigDecimal onePrice = new BigDecimal("0.00");
+                    int i;
+                    for( i = 0;i<promoCodeList.size();i++){
+                        BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
+                        BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
+                        price = price.add(price1);
+                        onePrice = onePrice.add(price1);
+                    }
+                    if(i<Integer.valueOf(num)){
+                        int a = Integer.valueOf(num)-i;
+                        BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
+                        price =price.add(price2);
+                        onePrice = onePrice.add(price2);
+                    }
+                    note.append(onePrice).append(",");
+                }else {
+                    //1,type=0,原始设定,没有第二件半价
+                    int a = Integer.valueOf(num);
+                    BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
+                    price =price.add(price2);
+                    note.append(price2).append(",");
+                }
+            }
+        }else {
+            //2,type=1,第二件半价
+            //2.1 判定是否有第二件,有多少个第二件半价
+            for (String key : productNameMap.keySet()) {
+//                System.out.println("key= "+ key + " and value= " + productNameMap.get(key));
+                String entryValue = String.valueOf(productNameMap.get(key));
+                List<String> value = JSON.parseArray(entryValue, String.class);
+                String[] productNum = key.split("-");
+                String productNamea = productNum[0];
+                String num = productNum[1];
+                TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productName.toString()));
+                BigDecimal productPrice = product.getRmbPrice();
+                productName.append(productNamea).append(num);
+                productName1.append(productNamea).append(num);
+                note.append(productNamea).append(num).append(":");
+                switch (num) {
+                    case "1":
+                        //1个  0个半价
+                        price =price.add(productPrice);
+                        note.append(price).append(",");
+                        break;
+                    case "2":
+                        //2个  1个半价
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        note.append(price).append(",");
+                        break;
+                    case "3":
+                        //3个 1个半价
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        price =price.add(productPrice);
+                        note.append(price).append(",");
+                        break;
+                    case "4":
+                        //4个 2个半价
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        note.append(price).append(",");
+                        break;
+                    case "5":
+                        //5个 2个半价
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        price =price.add(productPrice);
+                        price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
+                        price =price.add(productPrice);
+                        note.append(price).append(",");
+                        break;
+                }
+            }
+        }
+
+        if (equipment == null) {
+            return JsonMessage.error("找不到设备");
+        }
+
+        Long equipmentId = equipment.getId();
+        //查找商品
+        TProduct product =  R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName.toString()));
+        if (product == null) {
+            return JsonMessage.error("找不到商品");
+        }
+
+        if (BigDecimal.ZERO.compareTo(price) >= 0) {
+            return JsonMessage.error("商品价格异常");
+        }
+        String sn1 = orderService.initSn(equipmentId);
+//        String sn2 = orderService.initSn(equipmentId);
+        //获取分销  关联设备
+        TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(equipmentId)));
+
+        if (proportion == null&&proportion.getId()==null) {
+            return JsonMessage.error("设备商家未完成分销设置");
+        }
+        TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
+        if (admin == null) {
+            return JsonMessage.error("找不到设备商家");
+        }
+
+        Integer type = proportion.getType();
+        JSONArray altInfo = new JSONArray();
+        JSONArray altNewInfo = new JSONArray();
+
+        BigDecimal adminProportion = null, agencyProportion = null, merchantProportion = null, personageProportion = null, selfProportion = null;
+        Long agencyId = proportion.getAgencyId();
+        Long merchantId = proportion.getMerchantId();
+        Long personageId = proportion.getPersonageId();
+
+        String orderType = null;
+
+        if (type == null) {
+            return JsonMessage.error("设备商家未完成分销设置");
+        }
+
+        BigDecimal agencyAmount = null;
+        BigDecimal merchantAmount = null;
+        BigDecimal personageAmount = null;
+        BigDecimal selfAmount = null;
+
+        TJoinpayMch agencyMch = null;
+        TJoinpayMch merchantMch = null;
+        TJoinpayMch personageMch = null;
+        TJoinpayMch selfMch = null;
+
+        JSONObject agencyJson = null;
+        JSONObject merchantJson = null;
+        JSONObject personageJson = null;
+        JSONObject selfJson = null;
+
+        // 砍掉千6手续费
+//        BigDecimal cutPrice = price.multiply(new BigDecimal(99.4)).divide(new BigDecimal(100));
+        //取消平台扣手续费
+        BigDecimal cutPrice = price.multiply(new BigDecimal(100)).divide(new BigDecimal(100));
+
+        switch (type) {
+
+            case 0:
+                agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
+
+                if (agencyMch == null ) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+                agencyProportion = proportion.getProportion();
+                adminProportion = proportion.getAdminProportion();
+                orderType = "1";
+                // 代理分销获得利润
+                agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                agencyJson = new JSONObject();
+                agencyJson.put("altMchNo", agencyMch.getAltMchNo());
+                agencyJson.put("altAmount", agencyAmount.toString());
+                agencyJson.put("isGuar", "12");
+                altInfo.add(agencyJson);
+                break;
+            case 1:
+                agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
+
+//                agencyMch = mchService.getUniqueness(admin.getAgencyId());
+                selfMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
+
+                if (agencyMch == null ) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+                if (selfMch == null ) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+                agencyProportion = proportion.getAgencyProportion();
+                adminProportion = proportion.getAdminProportion();
+                selfProportion = proportion.getProportion();
+                orderType = "2";
+//            if(totalMoney.compareTo(refuseAmount) == 0){
+////                System.out.println("a等于b");
+//            }
+                BigDecimal refuseAmount = new BigDecimal(0.00);
+                if(agencyProportion.compareTo(refuseAmount) == 0||agencyProportion==null){
+//                System.out.println("a等于b");
+                }else {
+                    // 一级分销获得利润
+                    agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                    agencyJson = new JSONObject();
+                    agencyJson.put("altMchNo", agencyMch.getAltMchNo());
+                    agencyJson.put("altAmount", agencyAmount.toString());
+                    agencyJson.put("isGuar", "12");
+                    altInfo.add(agencyJson);
+                }
+                // 商家自己分销获得利润
+                selfAmount = cutPrice.multiply(selfProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                merchantJson = new JSONObject();
+                merchantJson.put("altMchNo", selfMch.getAltMchNo());
+                merchantJson.put("altAmount", selfAmount.toString());
+                merchantJson.put("isGuar", "12");
+                altInfo.add(merchantJson);
+
+                break;
+            case 2:
+                agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAgencyId())));
+
+                merchantMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getMerchantId())));
+
+                selfMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
+
+                if (agencyMch == null ) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                if (merchantMch == null ) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                if (personageMch == null) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                agencyProportion = proportion.getAgencyProportion();
+                adminProportion = proportion.getAdminProportion();
+                merchantProportion = proportion.getMerchantProportion();
+                personageProportion = proportion.getPersonageProportion();
+
+                orderType = "3";
+                BigDecimal refuseAmount1 = new BigDecimal(0.00);
+                if(agencyProportion.compareTo(refuseAmount1) == 0||agencyProportion==null){
+//                System.out.println("a等于b");
+                }else {
+                    // 代理分销获得利润
+                    agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                    agencyJson = new JSONObject();
+                    agencyJson.put("altMchNo", agencyMch.getAltMchNo());
+                    agencyJson.put("altAmount", agencyAmount.toString());
+                    agencyJson.put("isGuar", "12");
+                    altInfo.add(agencyJson);
+
+                }
+                if(merchantProportion.compareTo(refuseAmount1) == 0||merchantProportion==null){
+//                System.out.println("a等于b");
+                }else {
+                    // 经销商分销获得利润
+                    merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                    merchantJson = new JSONObject();
+                    merchantJson.put("altMchNo", merchantMch.getAltMchNo());
+                    merchantJson.put("altAmount", merchantAmount.toString());
+                    merchantJson.put("isGuar", "12");
+                    altInfo.add(merchantJson);
+                }
+                // 自己分销获得利润
+//                personageAmount = cutPrice.multiply(personageProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+//                personageJson = new JSONObject();
+//                personageJson.put("altMchNo", personageMch.getAltMchNo());
+//                personageJson.put("altAmount", personageAmount.toString());
+//                personageJson.put("isGuar", "12");
+//                altInfo.add(personageJson);
+                // 商家自己分销获得利润
+                selfAmount = cutPrice.multiply(selfProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+                merchantJson = new JSONObject();
+                merchantJson.put("altMchNo", selfMch.getAltMchNo());
+                merchantJson.put("altAmount", selfAmount.toString());
+                merchantJson.put("isGuar", "12");
+                altInfo.add(merchantJson);
+                break;
+
+
+        }
+
+
+        String orderNo1 = sn1;
+//        String orderNo2 = sn2;
+        BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
+        String productDesc = "";
+        String commonParameter = "";
+        String returnUrl = null;
+        String notifyUrl = JoinpayConstant.Notify_Url;
+        String isShowPic = "1";
+        String openId = null;
+        String authCode = null;
+        String appid = null;
+        String transactionModel = null;
+        String tradeMerchantNo = admin.getTradeMerchantNo();
+        String buyerId = null;
+        String isAlt = "1";
+        String altType = "11";
+        String altUrl = null;
+        BigDecimal marketingAmount = null;
+        String frpCode1 = "WEIXIN_XCX";
+//        String frpCode2 = "ALIPAY_NATIVE";
+
+        TOrder order = new TOrder();
+        order.setCreateDate(new Date());
+        order.setModifyDate(new Date());
+        order.setAdminId(admin.getId());
+        order.setSn(sn1);
+        order.setProductId(product.getId());
+        order.setProductNo(product.getNo());
+        order.setProductName(productName.toString());
+        order.setPrice(price);
+        order.setClientId(equipment.getClientId());
+        order.setEquipmentId(equipmentId);
+        order.setFrpCode(frpCode1);
+        order.setAltInfo(altInfo.toString());
+        order.setStatus(0);
+        order.setType(type);
+        if(type==0){
+            order.setAdminProportion(adminProportion);
+            order.setAgencyProportion(agencyProportion);
+            order.setAgencyId(admin.getId());
+        }
+        if(type==1){
+            order.setAdminProportion(adminProportion);
+            order.setAgencyProportion(agencyProportion);
+            order.setAgencyId(agencyId);
+            order.setMerchantProportion(merchantProportion);
+            order.setMerchantId(admin.getId());
+        }
+        if(type==2){
+            order.setAdminProportion(adminProportion);
+            order.setAgencyProportion(agencyProportion);
+            order.setAgencyId(agencyId);
+            order.setMerchantProportion(merchantProportion);
+            order.setMerchantId(merchantId);
+            order.setPersonageProportion(personageProportion);
+            order.setPersonageId(admin.getId());
+        }
+        String payPlatform = admin.getPayPlatform();
+        order.setPayPlatform(payPlatform);
+        if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
+            order.setIsSettlement("0");
+        }
+        order.setNote(note.toString());
+        if(StringUtils.isNotEmpty(id)){
+            order.setWxId(Long.valueOf(id));
+        }
+        orderService.save(order);
+        Iterator<Object> iterator = altInfo.iterator();
+        while (iterator.hasNext()) {
+            JSONObject jsonObject = (JSONObject) iterator.next();
+            String altAmount = jsonObject.getString("altAmount");
+            if (altAmount.equals("0.00")) {
+                iterator.remove();
+            }
+        }
+
+        String result = null;
+        if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
+            try {
+                result = shandeMchService.uniPay(
+                        orderNo1, amount, productName1.toString(), productDesc,
+                        commonParameter, returnUrl, notifyUrl, null,
+                        isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
+                        buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
+                );
+            } catch (Exception e) {
+                e.printStackTrace();
+                return JsonMessage.error("申请支付失败");
+            }
+            JSONObject resultJson = JSONObject.parseObject(result);
+            // 返回支付二维码图片
+            String rd_Pic = resultJson.getString("qr_code");
+            String qrcode = toQrcode(rd_Pic);
+            if (resultJson == null || StringUtils.isBlank(rd_Pic)) {
+                return JsonMessage.error("找不到支付图片");
+            }
+            JSONObject kindData = new JSONObject();
+            kindData.put("sn", sn1);
+            kindData.put("rd_Pic", qrcode);
+            return JsonMessage.success(kindData.toString());
+        }else{
+            try {
+                result = joinpayMchService.uniPay(
+                        orderNo1, amount, productName.toString(), productDesc,
+                        commonParameter, returnUrl, notifyUrl, frpCode1,
+                        isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
+                        buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
+                );
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+                return JsonMessage.error("申请支付失败");
+            }
+            JSONObject resultJson = JSONObject.parseObject(result);
+            // 汇聚支付支付申请返回支付二维码图片
+            String rc_Result = resultJson.getString("rc_Result");
+            if (resultJson == null || StringUtils.isBlank(rc_Result)) {
+                return JsonMessage.error("申请支付失败");
+            }
+//            JSONObject kindData = new JSONObject();
+//            kindData.put("sn", sn1);
+//            kindData.put("rc_Result", rc_Result);
+            Map<String,String> map = new HashMap<>();
+            map.put("sn", sn1);
+            map.put("rc_Result", rc_Result);
+            return JsonMessage.success(map);
+        }
+
+    }
     /**
      * 支付成功回调  汇聚
      *
@@ -2037,7 +2542,7 @@ public class TOrderController {
             TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(byClientId.getId())));
             Integer type = proportion.getType();
             switch (type) {
-                case 2:
+                case 0:
 
                     BigDecimal agencyProportion = proportion.getProportion();
                     // 代理分销获得利润
@@ -2049,7 +2554,7 @@ public class TOrderController {
                     shandeMch.setTodayBalance(todayBalance);
                     szwlFeign.updateShandeMch(shandeMch);
                     break;
-                case 3:
+                case 1:
                     BigDecimal agencyProportion1 =  proportion.getAgencyProportion();
                     BigDecimal merchantProportion1 = proportion.getProportion();
 
@@ -2075,7 +2580,7 @@ public class TOrderController {
                     shandeMch3.setTodayBalance(todayBalance3);
                     szwlFeign.updateShandeMch(shandeMch3);
                     break;
-                case 4:
+                case 2:
 
                     BigDecimal agencyProportion2 = proportion.getAgencyProportion();
                     BigDecimal merchantProportion2 = proportion.getMerchantProportion();
@@ -2541,13 +3046,13 @@ public class TOrderController {
         Integer type = proportion.getType();
         switch (type) {
 
-            case 2:
+            case 0:
                 orderType = "1";
                 break;
-            case 3:
+            case 1:
                 orderType = "2";
                 break;
-            case 4:
+            case 2:
                 orderType = "3";
                 break;
         }

+ 1 - 0
src/main/java/com/szwl/model/entity/TOrder.java

@@ -87,5 +87,6 @@ public class TOrder implements Serializable {
 
     private String proportionDesc;
 
+    private Long wxId;
 
 }