浏览代码

积分修改

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

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

@@ -198,7 +198,7 @@ public class IntegralShoppingMallController {
                         BigDecimal consumptionPoints = new BigDecimal(customerPointsInfo.getConsumptionPoints()).add(multiply);
                         customerPoints.setConsumptionPoints(Integer.valueOf(consumptionPoints.toString()));
                         customerPoints.setRecentConsumptionDate(new Date());
-                        logger.info("用户积分: "+ consumptionPoints.toString());
+                        logger.info("用户已使用积分累计: "+ consumptionPoints.toString());
                         customerPointsService.updateCustomerPointsInfo(customerPoints);
 
                         integralWares.setWaresOutCount(integralWaresInfoList.get(0).getWaresOutCount()+1);

+ 262 - 264
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -552,123 +552,8 @@ public class PayController {
                         logger.info("根据订单查询用户手机号等信息infoMap"+ infoMap.toString());
                         //手机号必须有
                         if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
-
-                            //存放客户信息
-                            CustomerManage customerManage = new CustomerManage();
-                            //存放查询用户信息
-                            AppUserInfo appUserInfo = new AppUserInfo();
-                            appUserInfo.setMobilePhone(infoMap.get("mobilePhone").toString());
-                            //从客户信息表查询数据用于插入客户表 使用List原因:app_user_info存在小程序和公众号两种信息
-                            List<AppUserInfo> appUserInfoList = payOrderService.getUserInfoByOpenId(appUserInfo);
-                            Date blogRegTime = null;    //公众号注册时间
-                            Date minaRegTime = null;    //小程序注册时间
-                            if(appUserInfoList != null && appUserInfoList.size() >0){
-                                for(AppUserInfo u : appUserInfoList){
-                                    //向客户表插入小程序和公众号的openId 用户表ID 用户手机号 注册时间
-                                    if(u.getUnionId() !=null && u.getUnionId() !=""){
-                                        customerManage.setUnionId(u.getUnionId());
-                                    }
-                                    switch (u.getUserType()){
-                                        case "1":
-                                            customerManage.setBlogOpenid(u.getBlogOpenid());
-                                            customerManage.setBlogUserId(u.getUserId());
-                                            customerManage.setPhoneNumber(u.getMobilePhone());
-                                            customerManage.setCustomerName(u.getBlogNickName());
-                                            blogRegTime =u.getRegisteDate();
-                                            break;
-                                        case "2":
-                                            customerManage.setMinaOpenid(u.getMinaOpenid());
-                                            customerManage.setMinaUserId(u.getUserId());
-                                            customerManage.setPhoneNumber(u.getMobilePhone());
-                                            customerManage.setCustomerName(u.getBlogNickName());
-                                            minaRegTime = u.getRegisteDate();
-                                            break;
-                                    }
-                                }
-                                //判断公众号和小程序时间取最早的时间
-                                if(blogRegTime !=null && minaRegTime != null){
-                                    if(blogRegTime.compareTo(minaRegTime) >0){
-                                        customerManage.setRegtime(minaRegTime);
-                                    }else if(blogRegTime.compareTo(minaRegTime) <0){
-                                        customerManage.setRegtime(blogRegTime);
-                                    }else if(blogRegTime.compareTo(minaRegTime) ==0){
-                                        //相等时随便取一个
-                                        customerManage.setRegtime(minaRegTime);
-                                    }
-                                }else if(blogRegTime == null){
-                                    customerManage.setRegtime(minaRegTime);
-                                }else if(minaRegTime == null){
-                                    customerManage.setRegtime(blogRegTime);
-                                }
-                            }
-
-                            customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));    //油站ID
-                            customerManage.setOilName(infoMap.get("oilName").toString());    //油品名称
-                            customerManage.setStationName(infoMap.get("stationName").toString());   //存入油站名称
-                            //已存在用户信息 existCustomer
-                            CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
-                            logger.info("查询出客户是否存在数据 null 表示没有" + existCustomer);
-
-                            //获取该油站的优惠方式
-                            String discountPlanType = stationService.getStationDiscountWay(infoMap.get("stationId").toString());
-                            logger.info("油站优惠方式:"+discountPlanType);
-
-                            //判断该用户是否已存在
-                            if(existCustomer != null){  //存在该用户时更新
-                                //此处if放null处理
-                                if(existCustomer.getAmt() !=null){
-                                    //存入金额 累加原来金额
-                                    customerManage.setAmt(existCustomer.getAmt().add(BigDecimal.valueOf((Double) infoMap.get("amt"))));
-                                }else {
-                                    customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));
-                                }
-                                if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")) {
-                                    if (existCustomer.getLiters() != null) {
-                                        //存入升数 累加原来升数
-                                        customerManage.setLiters(existCustomer.getLiters().add(BigDecimal.valueOf((Double) infoMap.get("orderLiters"))));
-                                    } else {
-                                        customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));
-                                    }
-                                }
-                                logger.info("存在客户 更新时手机号参数: " + customerManage.getPhoneNumber());
-
-                                if(discountPlanType !=null && discountPlanType.equals("1")){
-                                    //直降时存入等级名称和等级ID
-                                    List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
-                                    logger.info("该站直降等级信息:"+ customerGradeInfo);
-                                    for (Map m: customerGradeInfo){
-                                        if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString()) && Double.valueOf(customerManage.getAmt().toString()) < Double.valueOf(m.get("memberConditEnd").toString())){
-                                            customerManage.setGrade(m.get("grade").toString());     //存入等级名称
-                                            customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
-                                            break;
-                                        }
-                                    }
-                                    logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
-                                }
-                                //存在 更新
-                                payOrderService.updateCustomer(customerManage);
-                            }else{
-                                //该客户不存在时插入
-                                if(discountPlanType !=null && discountPlanType.equals("1")){
-                                    //直降时存入等级名称和等级ID
-                                    List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
-                                    logger.info("该站直降等级信息:"+ customerGradeInfo);
-                                    if(customerGradeInfo !=null && customerGradeInfo.size() >0){
-                                        customerManage.setGrade(customerGradeInfo.get(0).get("grade").toString());     //存入等级名称
-                                        customerManage.setMemberGrade(customerGradeInfo.get(0).get("id").toString());     //存入等级ID
-                                    }
-                                    logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
-                                }
-                                customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
-                                if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")){
-                                    customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
-                                }
-
-                                //不存在 新增
-                                logger.info("不存在客户 新增时参数: " + customerManage.toString());
-                                payOrderService.insertCustomer(customerManage);
-                            }
-//==========================================================================================================================================================//
+                            //插入客户积分返回要插入客户的信息
+                            CustomerManage customerManage = insertCustomerManage(infoMap);
                             //计算积分并推送
                             CalculateIntegral calculateIntegral = new CalculateIntegral();
                             calculateIntegral.setOpenId(infoMap.get("minaOpenid").toString());
@@ -684,153 +569,8 @@ public class PayController {
                             calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString()));
                             //计算积分并推送
                             this.calculateIntegralAndPushIntegral(calculateIntegral, customerManage);
-///========================================================================================================================================================//
-                            //打印机打印小票
-                            String content1;
-                            String content2;
-                            String orderNoP = "";
-                            String createdDateP ="";
-                            String stationNameP ="";
-                            String oilNameP ="";
-                            String orderLitersP ="";
-                            String oilPirceP ="";
-                            String receivableAmtP = "";
-                            String discountAmtP = "";
-                            String amtP = "";
-                            String mobilePhoneP = "";
-                            String payWayP = "";
-                            String sn;  //打印机编号
-
-                            if(StringUtils.isNotBlank(infoMap.get("orderNo").toString())){
-                                orderNoP =infoMap.get("orderNo").toString();
-                            }
-                            if(infoMap.containsKey("createdDate") && infoMap.get("createdDate") !=null ){
-                                //格式化日期
-                                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                                createdDateP =sdf.format(infoMap.get("createdDate"));
-                            }
-                            if(infoMap.containsKey("stationName") && infoMap.get("stationName") !=null ){
-                                stationNameP =infoMap.get("stationName").toString();
-                            }
-                            if(infoMap.containsKey("oilName") && infoMap.get("oilName") !=null ){
-                                oilNameP =infoMap.get("oilName").toString();
-                            }
-                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")) {
-                                //加油升数
-                                if (infoMap.containsKey("orderLiters") && infoMap.get("orderLiters") != null) {
-                                    orderLitersP = infoMap.get("orderLiters") + "";
-                                }
-                                //油价
-                                if (infoMap.containsKey("oilPirce") && infoMap.get("oilPirce") != null) {
-                                    oilPirceP = infoMap.get("oilPirce") + "";
-                                }
-                                if(infoMap.containsKey("discountAmt") && infoMap.get("discountAmt") !=null ){
-                                    discountAmtP =infoMap.get("discountAmt")+"";
-                                }
-                            }else if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("2")) {
-                                orderLitersP ="0.00";
-                                oilPirceP = "0.00";
-                                discountAmtP ="0.00";
-                                receivableAmtP=infoMap.get("amt")+"";
-                            }
-                            if(infoMap.containsKey("receivableAmt") && infoMap.get("receivableAmt") !=null ){
-                                receivableAmtP =infoMap.get("receivableAmt")+"";
-                            }
-
-                            if(infoMap.containsKey("amt") && infoMap.get("amt") !=null ){
-                                amtP =infoMap.get("amt")+"";
-                            }
-                            if(infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
-                                String phone =infoMap.get("mobilePhone")+"";
-                                //手机号中间四位****代替
-                                mobilePhoneP = phone.substring(0, 3) + "****" + phone.substring(7, phone.length());
-                            }
-                            if(infoMap.containsKey("payWay") && infoMap.get("payWay") !=null ){
-                                if(infoMap.get("payWay").equals("02") || infoMap.get("payWay").equals("03")){
-                                    payWayP ="微信";
-                                }
-                            }
-
-                            content1 = "<CB>支付小票--顾客联</CB><BR>";
-                            content1 += "订单号:"+orderNoP+"  <BR>";
-                            content1 += "时间:"+createdDateP+" <BR>";
-                            content1 += "油站:"+stationNameP+"  <BR>";
-                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
-                                content1 += "油品: "+oilNameP+"  <BR>";
-                                content1 += "油量: "+orderLitersP+"  升<BR>";
-                                content1 += "单价: "+oilPirceP+" L/元<BR>";
-                            }
-                            content1 += "<BOLD><B>原价: "+receivableAmtP+" 元</B></BOLD><BR>";
-                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
-                                content1 += "优惠: "+discountAmtP+" 元<BR>";
-                            }
-                            content1 += "支付: "+amtP+" 元<BR>";
-                            content1 += "支付方式: "+payWayP+" <BR>";
-                            content1 += "<BR>";
-                            //content1 += "--------------------------------<BR>";
-                            content1 += "<BR>";
-
-                            content2 = "<CB>支付小票--商户联</CB><BR>";
-                            content2 += "订单号:"+orderNoP+" <BR>";
-                            content2 += "时间:"+createdDateP+"<BR>";
-                            content2 += "油站:"+stationNameP+" <BR>";
-                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
-                                content2 += "油品: "+oilNameP+" <BR>";
-                                content2 += "油量: "+orderLitersP+" 升<BR>";
-                                content2 += "单价: "+oilPirceP+" L/元<BR>";
-                            }
-                            content2 += "<BOLD><B>原价: "+receivableAmtP+" 元</B></BOLD><BR>";
-                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
-                                content2 += "优惠: "+discountAmtP+" 元<BR>";
-                            }
-                            content2 += "支付: "+amtP+" 元<BR>";
-                            content2 += "手机号: "+mobilePhoneP+" <BR>";
-                            content2 += "支付方式: "+payWayP+" <BR>";
-                            content2 += "<BR>";
-                            //获取打印机编号
-                            //sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
-                            Map params  =new HashMap();
-                            params.put("stationId", infoMap.get("stationId").toString());
-                            params.put("oilGunNo", infoMap.get("oilGun").toString());
-                            Map m = stationOilGunService.getPrinterSnByStationIdAndOilGunNo(params);
-                            if(m !=null && m.containsKey("printerSn") && m.get("printerSn").toString()!= null && m.get("printerSn").toString()!=""){
-                                sn = m.get("printerSn").toString();
-//                                //查询打印机的状态
-//                                JSONObject jsonPrintStatus = JSONObject.parseObject(FeiEPrinterUtil.queryPrinterStatus(sn));
-//                                if(jsonPrintStatus.getString("data").equals("\\u5728\u7ebf\\uff0c\\u5de5\\u4f5c\\u72b6\u6001\\u6b63\\u5e38\\u3002")){
-//                                    logger.info("打印机在线,工作状态正常:" + jsonPrintStatus.toString());
-                                //开始打印
-                                String printInfo="";    //打印信息
-                                if(m.containsKey("printSetting") && m.get("printSetting").toString()!= null && m.get("printSetting").toString()!=""){
-                                    switch (m.get("printSetting").toString()){
-                                        case "1":   //1 客户联
-                                            printInfo = FeiEPrinterUtil.printReceipt(sn, content1);
-                                            break;
-                                        case "2":   //2 商户联
-                                            printInfo = FeiEPrinterUtil.printReceipt(sn, content2);
-                                            break;
-                                        case "3":   //3商户联和客户联
-                                            printInfo = FeiEPrinterUtil.printReceipt(sn, content1 + content2);
-                                            break;
-                                    }
-                                }
-                                JSONObject jsonObject = JSONObject.parseObject(printInfo);
-                                if(jsonObject != null && jsonObject.getString("msg").equals("ok")){
-                                    logger.info("打印成功:" + jsonObject.toString());
-                                    //如果打印成功 添加小票数量
-                                    PayOrder p = new PayOrder();
-                                    p.setPrintCount(1);
-                                    p.setOrderNo(ordNo);
-                                    payOrderService.getUpdatePayOrder(p);
-                                }
-//                                }else if(jsonPrintStatus.getString("data").equals("\\u79bb\\u7ebf\\u3002")){
-//                                    logger.info("打印机离线:" + jsonPrintStatus.toString());
-//                                }else if(jsonPrintStatus.getString("data").equals("\\u5728\\u7ebf\\uff0c\\u5de5\\u4f5c\\u72b6\\u6001\\u4e0d\\u6b63\\u5e38\\u3002")){
-//                                    logger.info("打印机在线,纸异常: "+jsonPrintStatus.toString());
-//                                }
-                            }else {
-                                logger.info("请正确配置打印机");
-                            }
+                            //打印小票
+                            this.printReceipt(infoMap);
                         }else{
                             logger.info("该用户无手机号!");
                         }
@@ -844,6 +584,264 @@ public class PayController {
         }
     }
 
+    /***
+     * 插入客户信息
+     * @param infoMap
+     * @return
+     */
+    public CustomerManage insertCustomerManage(Map infoMap){
+        CustomerManage customerManage = new CustomerManage();   //存放客户信息
+        AppUserInfo appUserInfo = new AppUserInfo();    //存放查询用户信息
+        appUserInfo.setMobilePhone(infoMap.get("mobilePhone").toString());
+        //从客户信息表查询数据用于插入客户表 使用List原因:app_user_info存在小程序和公众号两种信息
+        List<AppUserInfo> appUserInfoList = payOrderService.getUserInfoByOpenId(appUserInfo);
+        Date blogRegTime = null;    //公众号注册时间
+        Date minaRegTime = null;    //小程序注册时间
+        if(appUserInfoList != null && appUserInfoList.size() >0){
+            for(AppUserInfo u : appUserInfoList){
+                //向客户表插入小程序和公众号的openId 用户表ID 用户手机号 注册时间
+                if(u.getUnionId() !=null && u.getUnionId() !=""){
+                    customerManage.setUnionId(u.getUnionId());
+                }
+                switch (u.getUserType()){
+                    case "1":
+                        customerManage.setBlogOpenid(u.getBlogOpenid());
+                        customerManage.setBlogUserId(u.getUserId());
+                        customerManage.setPhoneNumber(u.getMobilePhone());
+                        customerManage.setCustomerName(u.getBlogNickName());
+                        blogRegTime =u.getRegisteDate();
+                        break;
+                    case "2":
+                        customerManage.setMinaOpenid(u.getMinaOpenid());
+                        customerManage.setMinaUserId(u.getUserId());
+                        customerManage.setPhoneNumber(u.getMobilePhone());
+                        customerManage.setCustomerName(u.getBlogNickName());
+                        minaRegTime = u.getRegisteDate();
+                        break;
+                }
+            }
+            //判断公众号和小程序时间取最早的时间
+            if(blogRegTime !=null && minaRegTime != null){
+                if(blogRegTime.compareTo(minaRegTime) >0){
+                    customerManage.setRegtime(minaRegTime);
+                }else if(blogRegTime.compareTo(minaRegTime) <0){
+                    customerManage.setRegtime(blogRegTime);
+                }else if(blogRegTime.compareTo(minaRegTime) ==0){
+                    //相等时随便取一个
+                    customerManage.setRegtime(minaRegTime);
+                }
+            }else if(blogRegTime == null){
+                customerManage.setRegtime(minaRegTime);
+            }else if(minaRegTime == null){
+                customerManage.setRegtime(blogRegTime);
+            }
+        }
+
+        customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));    //油站ID
+        customerManage.setOilName(infoMap.get("oilName").toString());    //油品名称
+        customerManage.setStationName(infoMap.get("stationName").toString());   //存入油站名称
+        //已存在用户信息 existCustomer
+        CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
+        logger.info("查询出客户是否存在数据 null表示没有" + existCustomer);
+
+        //获取该油站的优惠方式
+        String discountPlanType = stationService.getStationDiscountWay(infoMap.get("stationId").toString());
+        logger.info("油站优惠方式:"+discountPlanType);
+
+        //判断该用户是否已存在
+        if(existCustomer != null){  //存在该用户时更新
+            if(existCustomer.getAmt() !=null){
+                customerManage.setAmt(existCustomer.getAmt().add(BigDecimal.valueOf((Double) infoMap.get("amt"))));//存入金额 累加原来金额
+            }else {
+                customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));
+            }
+            if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")) {
+                if (existCustomer.getLiters() != null) {
+                    customerManage.setLiters(existCustomer.getLiters().add(BigDecimal.valueOf((Double) infoMap.get("orderLiters"))));//存入升数 累加原来升数
+                } else {
+                    customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));
+                }
+            }
+            logger.info("存在客户 更新时手机号参数: " + customerManage.getPhoneNumber());
+
+            if(discountPlanType !=null && discountPlanType.equals("1")){
+                //直降时存入等级名称和等级ID
+                List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                logger.info("该站直降等级信息:"+ customerGradeInfo);
+                for (Map m: customerGradeInfo){
+                    if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString()) && Double.valueOf(customerManage.getAmt().toString()) < Double.valueOf(m.get("memberConditEnd").toString())){
+                        customerManage.setGrade(m.get("grade").toString());     //存入等级名称
+                        customerManage.setMemberGrade(m.get("id").toString());     //存入等级ID
+                        break;
+                    }
+                }
+                logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
+            }
+            payOrderService.updateCustomer(customerManage); //存在 更新
+        }else{  //该客户不存在时插入
+            if(discountPlanType !=null && discountPlanType.equals("1")){
+                //直降时存入等级名称和等级ID
+                List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                logger.info("该站直降等级信息:"+ customerGradeInfo);
+                if(customerGradeInfo !=null && customerGradeInfo.size() >0){
+                    customerManage.setGrade(customerGradeInfo.get(0).get("grade").toString());     //存入等级名称
+                    customerManage.setMemberGrade(customerGradeInfo.get(0).get("id").toString());     //存入等级ID
+                }
+                logger.info("直降等级信息是否存入客户表:"+ "直降ID:"+ customerManage.getMemberGrade()+ "直降名称: "+customerManage.getGrade());
+            }
+            customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
+            if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")){
+                customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
+            }
+            logger.info("不存在客户 新增时参数: " + customerManage.toString());
+            payOrderService.insertCustomer(customerManage);//不存在 新增
+        }
+        return customerManage;
+    }
+
+    /**
+     * 打印小票
+     */
+    public void printReceipt(Map infoMap) {
+        //打印机打印小票
+        String content1;
+        String content2;
+        String orderNoP = "";
+        String createdDateP ="";
+        String stationNameP ="";
+        String oilNameP ="";
+        String orderLitersP ="";
+        String oilPirceP ="";
+        String receivableAmtP = "";
+        String discountAmtP = "";
+        String amtP = "";
+        String mobilePhoneP = "";
+        String payWayP = "";
+        String sn;  //打印机编号
+
+        if(StringUtils.isNotBlank(infoMap.get("orderNo").toString())){
+            orderNoP =infoMap.get("orderNo").toString();
+        }
+        if(infoMap.containsKey("createdDate") && infoMap.get("createdDate") !=null ){
+            //格式化日期
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            createdDateP =sdf.format(infoMap.get("createdDate"));
+        }
+        if(infoMap.containsKey("stationName") && infoMap.get("stationName") !=null ){
+            stationNameP =infoMap.get("stationName").toString();
+        }
+        if(infoMap.containsKey("oilName") && infoMap.get("oilName") !=null ){
+            oilNameP =infoMap.get("oilName").toString();
+        }
+        if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("1")) {
+            //加油升数
+            if (infoMap.containsKey("orderLiters") && infoMap.get("orderLiters") != null) {
+                orderLitersP = infoMap.get("orderLiters") + "";
+            }
+            //油价
+            if (infoMap.containsKey("oilPirce") && infoMap.get("oilPirce") != null) {
+                oilPirceP = infoMap.get("oilPirce") + "";
+            }
+            if(infoMap.containsKey("discountAmt") && infoMap.get("discountAmt") !=null ){
+                discountAmtP =infoMap.get("discountAmt")+"";
+            }
+        }else if(infoMap.containsKey("orderType") && infoMap.get("orderType").equals("2")) {
+            orderLitersP ="0.00";
+            oilPirceP = "0.00";
+            discountAmtP ="0.00";
+            receivableAmtP=infoMap.get("amt")+"";
+        }
+        if(infoMap.containsKey("receivableAmt") && infoMap.get("receivableAmt") !=null ){
+            receivableAmtP =infoMap.get("receivableAmt")+"";
+        }
+
+        if(infoMap.containsKey("amt") && infoMap.get("amt") !=null ){
+            amtP =infoMap.get("amt")+"";
+        }
+        if(infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
+            String phone =infoMap.get("mobilePhone")+"";
+            //手机号中间四位****代替
+            mobilePhoneP = phone.substring(0, 3) + "****" + phone.substring(7, phone.length());
+        }
+        if(infoMap.containsKey("payWay") && infoMap.get("payWay") !=null ){
+            if(infoMap.get("payWay").equals("02") || infoMap.get("payWay").equals("03")){
+                payWayP ="微信";
+            }
+        }
+
+        content1 = "<CB>支付小票--顾客联</CB><BR>";
+        content1 += "订单号:"+orderNoP+"  <BR>";
+        content1 += "时间:"+createdDateP+" <BR>";
+        content1 += "油站:"+stationNameP+"  <BR>";
+        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
+            content1 += "油品: "+oilNameP+"  <BR>";
+            content1 += "油量: "+orderLitersP+"  升<BR>";
+            content1 += "单价: "+oilPirceP+" L/元<BR>";
+        }
+        content1 += "<BOLD><B>原价: "+receivableAmtP+" 元</B></BOLD><BR>";
+        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
+            content1 += "优惠: "+discountAmtP+" 元<BR>";
+        }
+        content1 += "支付: "+amtP+" 元<BR>";
+        content1 += "支付方式: "+payWayP+" <BR>";
+        content1 += "<BR>";
+        //content1 += "--------------------------------<BR>";
+        content1 += "<BR>";
+
+        content2 = "<CB>支付小票--商户联</CB><BR>";
+        content2 += "订单号:"+orderNoP+" <BR>";
+        content2 += "时间:"+createdDateP+"<BR>";
+        content2 += "油站:"+stationNameP+" <BR>";
+        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
+            content2 += "油品: "+oilNameP+" <BR>";
+            content2 += "油量: "+orderLitersP+" 升<BR>";
+            content2 += "单价: "+oilPirceP+" L/元<BR>";
+        }
+        content2 += "<BOLD><B>原价: "+receivableAmtP+" 元</B></BOLD><BR>";
+        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){
+            content2 += "优惠: "+discountAmtP+" 元<BR>";
+        }
+        content2 += "支付: "+amtP+" 元<BR>";
+        content2 += "手机号: "+mobilePhoneP+" <BR>";
+        content2 += "支付方式: "+payWayP+" <BR>";
+        content2 += "<BR>";
+        //获取打印机编号
+        //sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
+        Map params  =new HashMap();
+        params.put("stationId", infoMap.get("stationId").toString());
+        params.put("oilGunNo", infoMap.get("oilGun").toString());
+        Map m = stationOilGunService.getPrinterSnByStationIdAndOilGunNo(params);
+        if(m !=null && m.containsKey("printerSn") && m.get("printerSn").toString()!= null && m.get("printerSn").toString()!=""){
+            sn = m.get("printerSn").toString();
+            //开始打印
+            String printInfo="";    //打印信息
+            if(m.containsKey("printSetting") && m.get("printSetting").toString()!= null && m.get("printSetting").toString()!=""){
+                switch (m.get("printSetting").toString()){
+                    case "1":   //1 客户联
+                        printInfo = FeiEPrinterUtil.printReceipt(sn, content1);
+                        break;
+                    case "2":   //2 商户联
+                        printInfo = FeiEPrinterUtil.printReceipt(sn, content2);
+                        break;
+                    case "3":   //3商户联和客户联
+                        printInfo = FeiEPrinterUtil.printReceipt(sn, content1 + content2);
+                        break;
+                }
+            }
+            JSONObject jsonObject = JSONObject.parseObject(printInfo);
+            if(jsonObject != null && jsonObject.getString("msg").equals("ok")){
+                logger.info("打印成功:" + jsonObject.toString());
+                //如果打印成功 添加小票数量
+                PayOrder p = new PayOrder();
+                p.setPrintCount(1);
+                p.setOrderNo(infoMap.get("orderNo").toString());
+                payOrderService.getUpdatePayOrder(p);
+            }
+        }else {
+            logger.info("请正确配置打印机");
+        }
+    }
+
     /**
      * 计算消费生成积分
      * 注释:  1.判断油站配置的优惠类型

+ 2 - 1
YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

@@ -798,7 +798,8 @@
         blog_openid      AS blogOpenid,
         registe_date     AS registeDate,
         mobile_phone     AS mobilePhone,
-        user_type 	     AS userType
+        user_type 	     AS userType,
+        union_id 	     AS unionId
     FROM
         app_user_info
     <where>