jk-GitHub-coder 4 年之前
父节点
当前提交
036c4db1a5

+ 1 - 1
YijiaRestful/src/main/java/com/platform/yijia/controller/ElectronicMembershipCardController.java

@@ -529,7 +529,7 @@ public class ElectronicMembershipCardController {
                             integral =calculateIntegralInfos.getIntegral();
                         }
                     }else {
-                        if(stationInfos.getIntegralRuleFlag().equals("1")){
+                        if(stationInfos.getIntegralFlag().equals("1")){
                             //calculateIntegral.setStationId(stationInfos.getStationId());
                             calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
                             //插入客户所得积分

+ 122 - 3
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -609,7 +609,7 @@ public class PayController {
                                     integral =calculateIntegralInfos.getIntegral();
                                 }
                             }else {
-                                if(stationInfos.getIntegralRuleFlag().equals("1")){
+                                if(stationInfos.getIntegralFlag().equals("1")){
                                     //calculateIntegral.setStationId(stationInfos.getStationId());
                                     calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
                                     //插入客户所得积分
@@ -732,6 +732,7 @@ public class PayController {
         return customerManage;
     }
 
+
     //POS机打印小票
     public void posPrintReceipt(PayOrder payOrder){
         Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);
@@ -833,8 +834,7 @@ public class PayController {
             map.put("contentData", list);
             params.put("messageContent", map);
             logger.info("开始推送消息:" +JSONObject.toJSONString(params));
-
-            String resultString = PosPrinterUtil.sendPosPrintDirectMessage(m);
+            String resultString = PosPrinterUtil.sendPosPrintDirectMessage(params);
             JSONObject jsonObject = JSONObject.parseObject(resultString);
             if(jsonObject.containsKey("code") && jsonObject.get("code").toString().equals("200")){
                 //如果打印成功 添加小票数量
@@ -1372,4 +1372,123 @@ public class PayController {
         }
     }
 
+
+    @RequestMapping(value = "/posPrintReceiptCeshi", consumes = "application/json", method = RequestMethod.POST)
+    @ResponseBody
+    public String posPrintReceiptCeshi(@RequestBody PayOrder payOrder){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);
+        Map<String, Object> m = new HashMap<>();
+
+        if(payOrder.getTransactionId() !=null){
+            m.put("transactionId", payOrder.getTransactionId());
+        }
+        if(payOrder.getIntegral() !=null){
+            m.put("integral", payOrder.getIntegral());
+        }
+        if(infoMap !=null && infoMap.containsKey("orderNo") && infoMap.get("orderNo") !=null){
+            m.put("orderNo", infoMap.get("orderNo").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("amt") && infoMap.get("amt") !=null){
+            m.put("amt", infoMap.get("amt").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("receivableAmt") && infoMap.get("receivableAmt") !=null){
+            m.put("receivableAmt", infoMap.get("receivableAmt").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("discountAmt") && infoMap.get("discountAmt") !=null){
+            m.put("discountAmt", infoMap.get("discountAmt").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("oilName") && infoMap.get("oilName") !=null){
+            m.put("oilName", infoMap.get("oilName").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("oilGun") && infoMap.get("oilGun") !=null){
+            m.put("oilGun", infoMap.get("oilGun").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("createdDate") && infoMap.get("createdDate") !=null){
+            //格式化日期
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String createdDate = sdf.format(infoMap.get("createdDate"));
+            m.put("createdDate", createdDate);
+        }
+        if(infoMap !=null && infoMap.containsKey("payDate") && infoMap.get("payDate") !=null){
+            //格式化日期
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String payDate = sdf.format(infoMap.get("payDate"));
+            m.put("payDate", payDate);
+        }
+        if(infoMap !=null && infoMap.containsKey("payType") && infoMap.get("payType") !=null){
+            String payType = "";
+            if(infoMap.get("payType").equals("wx")){
+                payType ="微信";
+            }
+            if(infoMap.get("payType").equals("dzk")){
+                payType ="电子卡";
+            }
+            m.put("payType", payType);
+        }
+        if(infoMap !=null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null){
+            String phone =infoMap.get("mobilePhone")+"";
+            //手机号中间四位****代替
+            phone = phone.substring(0, 3) + "****" + phone.substring(7, phone.length());
+            m.put("mobilePhone", phone);
+        }
+        if(infoMap !=null && infoMap.containsKey("orderLiters") && infoMap.get("orderLiters") !=null){
+            m.put("orderLiters", infoMap.get("orderLiters").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("stationName") && infoMap.get("stationName") !=null){
+            m.put("stationName", infoMap.get("stationName").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("oilPirce") && infoMap.get("oilPirce") !=null){
+            m.put("oilPirce", infoMap.get("oilPirce").toString());
+        }
+        if(infoMap !=null && infoMap.containsKey("stationId") && infoMap.get("stationId") !=null){
+            m.put("stationId", infoMap.get("stationId").toString());
+        }
+//        if(infoMap !=null && infoMap.containsKey("orderType") && infoMap.get("orderType") !=null){
+//            m.put("orderType", infoMap.get("orderType").toString());
+//        }
+        if(infoMap !=null && infoMap.containsKey("oilType") && infoMap.get("oilType") !=null){
+            if(infoMap.get("oilType").equals("3")){
+                m.put("orderType", "noOil");
+            }else {
+                m.put("orderType", "oil");
+            }
+        }
+        logger.info("要推送的订单的信息:" +m.toString());
+        //定义推送格式
+        Map<String, Object> params = new HashMap<>();
+        params.put("messageTitle", "pos");
+        params.put("messageType", "sys");
+        //获取油枪绑定的POS机信息
+        StationDeviceManager stationDeviceManager = new StationDeviceManager();
+        stationDeviceManager.setDeviceType("2");
+        stationDeviceManager.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
+        stationDeviceManager.setGunNo(infoMap.get("oilGun").toString());
+        StationDeviceManager stationDeviceManagerInfo = stationService.getStationDeviceManager(stationDeviceManager);
+        if(stationDeviceManagerInfo !=null && stationDeviceManagerInfo.getPosFanoutExchange() !=null && stationDeviceManagerInfo.getPosQueue() !=null){
+            params.put("posFanoutExchange", stationDeviceManagerInfo.getPosFanoutExchange());
+            params.put("posQueue", stationDeviceManagerInfo.getPosQueue());
+            params.put("tusn", stationDeviceManagerInfo.getDeviceNo());
+            params.put("printSetting", payOrder.getPrintSetting()); //小票打印方式
+            List<Map<String, Object>> list = new ArrayList<>();
+            list.add(m);
+            Map<String, Object> map = new HashMap<>();
+            map.put("contentData", list);
+            params.put("messageContent", map);
+            logger.info("开始推送消息:" +JSONObject.toJSONString(params));
+            String resultString = PosPrinterUtil.sendPosPrintDirectMessage(params);
+            JSONObject jsonObject = JSONObject.parseObject(resultString);
+            if(jsonObject.containsKey("code") && jsonObject.get("code").toString().equals("200")){
+                //如果打印成功 添加小票数量
+                PayOrder p = new PayOrder();
+                p.setPrintCount(1);
+                p.setOrderNo(infoMap.get("orderNo").toString());
+                payOrderService.getUpdatePayOrder(p);
+            }
+        }
+        return  gson.toJson(resultData);
+    }
+
 }