李天标 преди 5 години
родител
ревизия
456ca468d1

+ 285 - 0
app-api/src/main/java/com/hboxs/control/api/order/OrderController.java

@@ -755,6 +755,8 @@ public class OrderController extends BaseController {
         kindData.put("rd_Pic",rd_Pic);
         return JsonMessage.success(kindData.toString());
     }
+
+
     @RequestMapping(value = "/send", method = RequestMethod.GET)
     @ResponseBody
     public void send(String client,String sn,String productName){
@@ -853,6 +855,289 @@ public class OrderController extends BaseController {
     }
 
     /**
+     * 被扫支付
+     *
+     * @param clientId 设备client id
+     * @param productName 商品名称
+     * @param frpCode     支付方式 支付宝:ALIPAY_CARD , 微信:WEIXIN_CARD
+     * @return
+     */
+    @RequestMapping(value = "/CardPay", method = RequestMethod.GET)
+    @ResponseBody
+    public Object CardPay(String clientId, String productName, String frpCode,String authCode) {
+        //解决中文乱码
+//        try{
+//            if(productName!=null){
+//                productName = URLDecoder.decode(productName, "GB2312");
+////                productName = new String(productName.getBytes("ISO8859_1"), "UTF-8");productName = "玫瑰精灵"
+//            }
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }
+//        productName = "烈焰红唇";
+        Equipment equipment = equipmentService.findByClientId(clientId);
+        if (!frpCode.equals("ALIPAY_CARD") && !frpCode.equals("WEIXIN_CARD")) {
+            return JsonMessage.error("参数错误");
+        }
+        if(equipment==null){
+            return JsonMessage.error("找不到设备");
+        }
+
+        Long equipmentId = equipment.getId();
+
+        Product product = productService.getByProductName(equipmentId, productName);
+
+        if (product == null) {
+            return JsonMessage.error("找不到商品");
+        }
+
+
+        BigDecimal price = product.getRmbPrice();
+        if (BigDecimal.ZERO.compareTo(price) >= 0) {
+            return JsonMessage.error("商品价格异常");
+        }
+
+        String sn = orderService.initSn(equipmentId);
+
+        Proportion proportion = proportionService.getUniqueness(equipment.getAdminId());
+        if (proportion == null) {
+            return JsonMessage.error("设备商家未完成分销设置");
+        }
+
+        Admin admin = adminService.find(equipment.getAdminId());
+        if (admin == null) {
+            return JsonMessage.error("找不到设备商家");
+        }
+
+        Proportion.Type type = proportion.getType();
+        JSONArray altInfo = new JSONArray();
+        JSONArray altNewInfo = new JSONArray();
+
+        BigDecimal adminProportion = null, agencyProportion = null, merchantProportion = null, personageProportion = null;
+        Long agencyId = admin.getAgencyId();
+        Long merchantId = admin.getMerchantId();
+        Long personageId = admin.getPersonageId();
+        Order.Type orderType = null;
+
+        if (type == null) {
+            return JsonMessage.error("设备商家未完成分销设置");
+        }
+
+        BigDecimal agencyAmount = null;
+        BigDecimal merchantAmount = null;
+        BigDecimal personageAmount = null;
+
+        Mch agencyMch = null;
+        Mch merchantMch = null;
+        Mch personageMch = null;
+
+        JSONObject agencyJson = null;
+        JSONObject merchantJson = null;
+        JSONObject personageJson = 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 agency:
+
+                if (admin.getType() != Admin.Type.agency) {
+                    return JsonMessage.error("设备商家类型错误");
+                }
+
+                agencyMch = mchService.getUniqueness(admin.getAgencyId());
+                if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                agencyProportion = proportion.getAgencyProportion();
+                adminProportion = proportion.getAdminProportion();
+                orderType = Order.Type.agency;
+
+                // 代理分销获得利润
+                agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                agencyJson = new JSONObject();
+                agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
+                agencyJson.put("altAmount", agencyAmount.toString());
+                agencyJson.put("isGuar", "12");
+                altInfo.add(agencyJson);
+
+                break;
+
+            case merchant:
+
+                if (admin.getType() != Admin.Type.merchant) {
+                    return JsonMessage.error("设备商家类型错误");
+                }
+
+                agencyMch = mchService.getUniqueness(admin.getAgencyId());
+                merchantMch = mchService.getUniqueness(admin.getMerchantId());
+
+                if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                if (merchantMch == null || StringUtils.isBlank(merchantMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                agencyProportion = proportion.getAgencyProportion();
+                adminProportion = proportion.getAdminProportion();
+                merchantProportion = proportion.getMerchantProportion();
+                orderType = Order.Type.merchant;
+
+                // 代理分销获得利润
+                agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                // 经销商分销获得利润
+                merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                agencyJson = new JSONObject();
+                agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
+                agencyJson.put("altAmount", agencyAmount.toString());
+                agencyJson.put("isGuar", "12");
+                altInfo.add(agencyJson);
+
+                merchantJson = new JSONObject();
+                merchantJson.put("altMchNo", merchantMch.getAlt_mch_no());
+                merchantJson.put("altAmount", merchantAmount.toString());
+                merchantJson.put("isGuar", "12");
+                altInfo.add(merchantJson);
+
+                break;
+            case personage:
+
+                if (admin.getType() != Admin.Type.personage) {
+                    return JsonMessage.error("设备商家类型错误");
+                }
+
+
+                agencyMch = mchService.getUniqueness(admin.getAgencyId());
+                merchantMch = mchService.getUniqueness(admin.getMerchantId());
+                personageMch = mchService.getUniqueness(admin.getPersonageId());
+
+
+                if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                if (merchantMch == null || StringUtils.isBlank(merchantMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                if (personageMch == null || StringUtils.isBlank(personageMch.getOrder_status())) {
+                    return JsonMessage.error("设备商家未注册提现账户");
+                }
+
+                agencyProportion = proportion.getAgencyProportion();
+                adminProportion = proportion.getAdminProportion();
+                merchantProportion = proportion.getMerchantProportion();
+                personageProportion = proportion.getPersonageProportion();
+
+                orderType = Order.Type.personage;
+
+                // 代理分销获得利润
+                agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                // 经销商分销获得利润
+                merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                // 经销商分销获得利润
+                personageAmount = cutPrice.multiply(personageProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
+
+                agencyJson = new JSONObject();
+                agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
+                agencyJson.put("altAmount", agencyAmount.toString());
+                agencyJson.put("isGuar", "12");
+                altInfo.add(agencyJson);
+
+                merchantJson = new JSONObject();
+                merchantJson.put("altMchNo", merchantMch.getAlt_mch_no());
+                merchantJson.put("altAmount", merchantAmount.toString());
+                merchantJson.put("isGuar", "12");
+                altInfo.add(merchantJson);
+
+                personageJson = new JSONObject();
+                personageJson.put("altMchNo", personageMch.getAlt_mch_no());
+                personageJson.put("altAmount", personageAmount.toString());
+                personageJson.put("isGuar", "12");
+                altInfo.add(personageJson);
+                break;
+
+
+        }
+
+
+        String orderNo = sn;
+        BigDecimal amount = price;
+        String productDesc = "";
+        String commonParameter = "";
+        String returnUrl = null;
+        String notifyUrl = JoinpayConstant.Card_Notify_Url;
+        String isShowPic = "";
+        String openId = null;
+        String AuthCode = authCode;
+        String appid = null;
+        String transactionModel = null;
+        String tradeMerchantNo = null;
+        String buyerId = null;
+        String isAlt = "1";
+        String altType = "11";
+        String altUrl = null;
+        BigDecimal marketingAmount = null;
+
+        Order order = new Order(sn, product.getId(), productName, price, equipment.getClientId(), equipmentId,
+                orderType, admin.getId(), agencyId, merchantId, personageId,
+                frpCode, altInfo.toString(), adminProportion, agencyProportion, merchantProportion, personageProportion, Order.Status.unpay);
+
+        orderService.create(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 client6= clientId.substring(clientId.length()-6,clientId.length());
+        productName=productName+"-"+equipment.getName()+"-"+client6;
+        String result = null;
+        try {
+            result = tradeService.uniPay(
+
+                    orderNo, amount, productName, productDesc,
+                    commonParameter, returnUrl, notifyUrl, frpCode,
+                    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 rd_Pic = resultJson.getString("rd_Pic");
+//        Map<String,String> map2 = new HashMap<>();
+//        map2.put("sn",sn);
+//        map2.put("rd_Pic",rd_Pic);
+        if (resultJson == null || StringUtils.isBlank(rd_Pic)) {
+            return JsonMessage.error("找不到支付图片");
+        }
+//        send(clientId,sn,productName);
+//        return JsonMessage.success(rd_Pic);
+        JSONObject kindData = new JSONObject();
+        kindData.put("sn" , sn);
+        kindData.put("rd_Pic",rd_Pic);
+        return JsonMessage.success(kindData.toString());
+    }
+    /**
      * 清洗机器人支付成功回调
      *
      * @return

+ 3 - 45
app-backend-web/src/main/webapp/resources/index/js/angularIndex.js

@@ -14,7 +14,7 @@ function getConsumedResources(time){
             water.innerHTML = data.water;
             var electricity=window.document .getElementById ("electricity");
             electricity.innerHTML = data.electricity;
-            console.log("consumedResources:",number);
+            // console.log("consumedResources:",number);
         }
     });
 };
@@ -44,7 +44,7 @@ function getCleanLine(time){
                     '</li>';
                 ul.appendChild(li);
             }
-            console.log("cleanLine:",number);
+            // console.log("cleanLine:",number);
         }
     });
 };
@@ -62,7 +62,7 @@ function getAlarmRecordType(time){
         success: function(data){
             number = data.alarmRecordType;
             chart2(data.alarmRecordType);
-            console.log("alarmRecordType:",number);
+            // console.log("alarmRecordType:",number);
         }
     });
 };
@@ -113,45 +113,3 @@ function chart2(alarmRecordType) {
     };
     myChart2.setOption(option2);
 };
-// var equipmentLists = null;
-//机器的状态,温度,湿度,清洗剂的剩余用量
-// function getEquipmentShuxing(name){
-//     var equipmentList =null;
-//     $.ajax({
-//         url:"/asl-admin/index/equipmentStatus.htm",
-//         type:"get",
-//         contentType: "application/json;charset=utf-8",
-//         dataType: "json",
-//         success: function(data){
-//             number = data;
-//             equipmentList = data.equipmentList;
-//             equipmentLists = data.equipmentList;
-//             var odorConcentration=window.document .getElementById ("odorConcentration");
-//             var cabinetTm=window.document .getElementById ("cabinetTm");
-//             var cabinetHd=window.document .getElementById ("cabinetHd");
-//             for(var i = 0;i < equipmentList.length; i++){
-//                 if(name==equipmentList[i].name) {
-//                     odorConcentration.innerHTML = equipmentList[i].odorConcentration + "%";
-//                     cabinetTm.innerHTML = equipmentList[i].cabinetTm + "℃";
-//                     cabinetHd.innerHTML = equipmentList[i].cabinetHd + "%";
-//                 }
-//             }
-//
-//         }
-//     });
-// };
-// function getEquipmentName(){
-//     var equipmentList =null;
-//     $.ajax({
-//         url:"/asl-admin/index/equipmentStatus.htm",
-//         type:"get",
-//         contentType: "application/json;charset=utf-8",
-//         dataType: "json",
-//         success: function(data){
-//             number = data;
-//             equipmentLists = data.equipmentList;
-//             equipmentSelect(data.equipmentList);
-//             setInterval(changeA,equipmentLists.length*5000);
-//         }
-//     });
-// };

+ 6 - 6
app-backend-web/src/main/webapp/resources/index/js/scanboard.js

@@ -419,7 +419,7 @@ $(function(){
 							'</li>';
                     	ul.appendChild(li);
 					}
-                    console.log("list:",list);
+                    // console.log("list:",list);
             }
         });
 
@@ -440,7 +440,7 @@ $(function(){
                 open.innerHTML = equipmentNumber.openNum+"/";
                 var all=window.document .getElementById ("allMuchine");
                 all.innerHTML =  equipmentNumber.totalNum;
-                console.log("equipmentNumber:",equipmentNumber);
+                // console.log("equipmentNumber:",equipmentNumber);
             }
         });
 
@@ -460,7 +460,7 @@ $(function(){
                 var ele=window.document .getElementById ("peopleCouting");
                 ele.innerHTML = number;
                 // $("#peopleCouting").text(number);
-                console.log("number:",number);
+                // console.log("number:",number);
             }
         });
     };
@@ -481,7 +481,7 @@ $(function(){
                 regular.innerHTML = data.regular+"次";
                 var totalNum=window.document .getElementById ("totalNum");
                 totalNum.innerHTML = data.regular + data.random;
-                console.log("cleanNumber:",number);
+                // console.log("cleanNumber:",number);
             }
         });
     };
@@ -499,7 +499,7 @@ $(function(){
                 number = data;
                 equipmentLists = data.equipmentList;
 
-                console.log("equipmentList:",number);
+                // console.log("equipmentList:",number);
             }
         });
     };
@@ -517,7 +517,7 @@ $(function(){
                 equipmentSelect(data.equipmentList);
                 funA = setInterval(changeA,equipmentLists.length*5000);
                 funB = setInterval(changeB,equipmentLists.length*5000);
-                console.log("equipmentList:",number);
+                // console.log("equipmentList:",number);
             }
         });
     };

+ 2 - 0
app-common/src/main/java/com/hboxs/common/JoinpayConstant.java

@@ -42,6 +42,8 @@ public class JoinpayConstant {
      */
     public final static String Notify_Url = "http://clean.sunzee.com.cn/api/order/payCleanNotify.htm";
 
+    public final static String Card_Notify_Url = "http://clean.sunzee.com.cn/api/order/notify.htm";
+
     public final static String Notify_Url_PromoCode = "http://app.sunzee.com.cn/api/order/promoCodeNotify.htm";
 
     public final static Map<String,String> Result_status = new HashMap<>();