Sfoglia il codice sorgente

优惠券,打印设备选择

jk-GitHub-coder 3 anni fa
parent
commit
c3ff4fd509

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

@@ -2,6 +2,9 @@ package com.platform.yijia.controller;
 
 import com.google.gson.Gson;
 import com.platform.yijia.config.YiJiaRequest;
+import com.platform.yijia.pojo.Coupon;
+import com.platform.yijia.pojo.UserCoupon;
+import com.platform.yijia.service.CouponService;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
 import io.swagger.annotations.Api;
@@ -12,6 +15,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
+import java.util.List;
+
 /*
  * <Title> CouponController </Title>
  * <Description> 优惠券 </Description>
@@ -25,6 +31,29 @@ import org.springframework.web.bind.annotation.*;
 public class CouponController {
     private static Logger logger =(Logger) LoggerFactory.getLogger(CouponController.class);
 
+    @Resource
+    private CouponService couponService;
+
+    //获取优惠券信息
+    @RequestMapping(value = "/selectCouponInfo", method = RequestMethod.GET)
+    @ResponseBody
+    @ApiOperation(value = "获取优惠券信息", httpMethod = "GET", notes = "获取优惠券信息")
+    public String selectCouponInfo(@ApiParam(value = "优惠券ID", required = true) @RequestParam Integer id){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        try {
+            Coupon coupon = new Coupon();
+            coupon.setId(id);
+            Coupon couponInfo = couponService.selectCouponInfo(coupon);
+            resultData = ResultData.success(couponInfo);
+        }catch (Exception e){
+            logger.error("获取优惠券错误信息:" + e.getMessage());
+            resultData = ResultData.error(CodeMsg.SEARCH_FAIL);
+        }
+        return  gson.toJson(resultData);
+    }
+
     //获取客户所拥有的优惠券
     @RequestMapping(value = "/selectUserCoupons", method = RequestMethod.GET)
     @ResponseBody
@@ -35,7 +64,11 @@ public class CouponController {
         //返回结果集
         ResultData resultData = null;
         try {
-            resultData = ResultData.success("查询成功!");
+            UserCoupon userCoupon = new UserCoupon();
+            userCoupon.setStationId(stationId);
+            userCoupon.setUnionId(unionId);
+            List<UserCoupon> userCoupons = couponService.selectUserCoupons(userCoupon);
+            resultData = ResultData.success(userCoupons);
         }catch (Exception e){
             logger.error("获取客户所拥有的优惠券错误信息:" + e.getMessage());
             resultData = ResultData.error(CodeMsg.SEARCH_FAIL);

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

@@ -440,7 +440,7 @@ public class ElectronicMembershipCardController {
                         customerManage.setLiters(customerManageInfo.getLiters().add(new BigDecimal(oilLiters)));
                         logger.info("存在客户 更新时手机号参数: " + customerManage.getPhoneNumber());
                         List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeListOrderByDesc(params_1);  //直降
-                        logger.info("该站直降等级信息:"+ customerGradeInfo);
+                        //logger.info("该站直降等级信息:"+ customerGradeInfo);
                         for (Map m: customerGradeInfo){
                             if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString())){
                                 customerManage.setGrade(m.get("id").toString());     //存入等级ID
@@ -459,7 +459,7 @@ public class ElectronicMembershipCardController {
                         customerManage.setUnionId(unionId);
                         customerManage.setRegtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(registeDate));
                         List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(params_1);  //直降
-                        logger.info("该站直降等级信息:"+ customerGradeInfo);
+                        //logger.info("该站直降等级信息:"+ customerGradeInfo);
                         if(customerGradeInfo !=null && customerGradeInfo.size() >0){
                             customerManage.setGrade(customerGradeInfo.get(0).get("id").toString());     //存入等级ID
                         }
@@ -491,14 +491,6 @@ public class ElectronicMembershipCardController {
                             stationName = m.get("stationName");
                             gzhAppId = m.get("gzhAppId");
                             gzhAppSecret = m.get("gzhAppSecret");
-//                            Oil oil_1 = new Oil();
-//                            oil.setOilsType(customerCardUseRecordInfo.getCardOilsType());
-//                            if(customerCardUseRecordInfo.getCardOilsType().equals("1") || customerCardUseRecordInfo.getCardOilsType().equals("2")){
-//                                oil.setDictType("oil");
-//                            }else {
-//                                oil.setDictType("oil_name");
-//                            }
-//                            String cardName =sysDictDataService.selectOilType(oil).getOilName();
                             //推送模板
                             List<WxMpTemplateData> wxMpTemplate = new ArrayList<>();
                             wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+consumer+",您好:\n" + "您在"+stationName+"的最新消费交易信息如下"));
@@ -519,9 +511,6 @@ public class ElectronicMembershipCardController {
                     }
                     int integral =0;
                     //是否启用积分功能
-//                    StationInfo stationInfo = new StationInfo();
-//                    stationInfo.setStationId(Integer.valueOf(stationId));
-//                    StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
                     CalculateIntegral calculateIntegral = new CalculateIntegral();
                     calculateIntegral.setGroupId(stationInfos.getGroupId());
                     calculateIntegral.setNickName(consumer);
@@ -542,7 +531,6 @@ public class ElectronicMembershipCardController {
                     CalculateIntegral calculateIntegralInfos;
                     if(stationInfos.getIntegralRuleFlagGroup().equals("1")){    //表示积分共享
                         if(stationInfos.getIntegralFlagGroup().equals("1")){    //集团开启积分功能
-                            //calculateIntegral.setGroupId(stationInfos.getGroupId());
                             calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
                             //插入客户所得积分
                             customerPoints = this.insertUserIntegral(calculateIntegralInfos);
@@ -552,7 +540,6 @@ public class ElectronicMembershipCardController {
                         }
                     }else {
                         if(stationInfos.getIntegralFlag().equals("1")){
-                            //calculateIntegral.setStationId(stationInfos.getStationId());
                             calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
                             integral =calculateIntegralInfos.getIntegral();
                             //插入客户所得积分
@@ -563,22 +550,59 @@ public class ElectronicMembershipCardController {
                     }
                     resultData = ResultData.success(CodeMsg.SUCCESS);
 
-                    //油站小票打印方式
-                    if(stationInfos !=null && stationInfos.getPrintDeviceType() !=null){
-                        logger.info("小票打印方式:" + stationInfo.getPrintDeviceType());
-                        switch (stationInfos.getPrintDeviceType()){
-                            case "1":   //小票机打印
-                                logger.info("小票机打印");
-                                this.printReceipt(payOrder);
-                                break;
-                            case "2":   //POS机打印
-                                logger.info("POS打印");
-                                payOrder.setIntegral(String.valueOf(integral));
-                                payOrder.setPrintSetting(stationInfos.getPrintSetting());
-                                this.posPrintReceipt(payOrder);
-                                break;
+                    //获取油枪绑定的POS机信息
+                    StationDeviceManager stationDeviceManager = new StationDeviceManager();
+                    stationDeviceManager.setGunNo(resultMap.get("oilGun").toString());
+                    stationDeviceManager.setStationId(Integer.valueOf(stationId));
+                    List<StationDeviceManager> stationDeviceManagerList = stationService.getStationDeviceManagerList(stationDeviceManager);
+                    if(stationDeviceManagerList !=null && stationDeviceManagerList.size() >0){
+                        String deviceType = stationDeviceManagerList.get(0).getDeviceType();
+                        if(deviceType !=null && deviceType !=""){
+                            switch (deviceType){
+                                case "1":
+                                    logger.info("小票机打印方式");
+                                    if(stationDeviceManagerList.get(0).getDeviceNo() !=null){
+                                        payOrder.setDeviceNo(stationDeviceManagerList.get(0).getDeviceNo());
+                                        payOrder.setPrintSetting(stationInfos.getPrintSetting());
+                                        this.printReceipt(payOrder);
+                                    }else {
+                                        logger.info("小票机配置错误,请正确配置打印机");
+                                    }
+                                    break;
+                                case "2":
+                                    logger.info("POS机打印方式");
+                                    payOrder.setIntegral(String.valueOf(integral));
+                                    payOrder.setPrintSetting(stationInfos.getPrintSetting());
+                                    if(stationDeviceManagerList.get(0).getDeviceNo()!=null && stationDeviceManagerList.get(0).getPosFanoutExchange() !=null && stationDeviceManagerList.get(0).getPosQueue() !=null){
+                                        payOrder.setPosFanoutExchange(stationDeviceManagerList.get(0).getPosFanoutExchange());
+                                        payOrder.setPosQueue(stationDeviceManagerList.get(0).getPosFanoutExchange());
+                                        payOrder.setDeviceNo(stationDeviceManagerList.get(0).getDeviceNo());
+                                        this.posPrintReceipt(payOrder);
+                                    }else {
+                                        logger.info("POS机配置错误,请正确配置打印机");
+                                    }
+                                    break;
+                            }
                         }
                     }
+
+
+                    //油站小票打印方式
+//                    if(stationInfos !=null && stationInfos.getPrintDeviceType() !=null){
+//                        logger.info("小票打印方式:" + stationInfo.getPrintDeviceType());
+//                        switch (stationInfos.getPrintDeviceType()){
+//                            case "1":   //小票机打印
+//                                logger.info("小票机打印");
+//                                this.printReceipt(payOrder);
+//                                break;
+//                            case "2":   //POS机打印
+//                                logger.info("POS打印");
+//                                payOrder.setIntegral(String.valueOf(integral));
+//                                payOrder.setPrintSetting(stationInfos.getPrintSetting());
+//                                this.posPrintReceipt(payOrder);
+//                                break;
+//                        }
+//                    }
                 }else {
                     resultData=ResultData.error(CodeMsg.BALANCE_NOT_EENOUGH);
                 }
@@ -674,15 +698,15 @@ public class ElectronicMembershipCardController {
         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());
+//        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", payOrder.getPosFanoutExchange());
+            params.put("posQueue", payOrder.getPosQueue());
+            params.put("tusn", payOrder.getDeviceNo());
             params.put("printSetting", payOrder.getPrintSetting()); //小票打印方式
             List<Map<String, Object>> list = new ArrayList<>();
             list.add(m);
@@ -699,7 +723,7 @@ public class ElectronicMembershipCardController {
                 p.setOrderNo(infoMap.get("orderNo").toString());
                 payOrderService.getUpdatePayOrder(p);
             }
-        }
+        //}
 
     }
 
@@ -837,39 +861,28 @@ public class ElectronicMembershipCardController {
         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());
-        params.put("deviceType", "1");
-        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);
+        //开始打印
+        sn = payOrder.getDeviceNo();
+        String printInfo="";    //打印信息
+            switch (payOrder.getPrintSetting()){
+                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;
             }
-        }else {
-            logger.info("请正确配置打印机");
+        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);
         }
     }
 

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

@@ -282,33 +282,46 @@ public class IntegralShoppingMallController {
                                 wxPushUtil.push(gzhAppId, gzhAppSecret, gzhNewsTemplateInfo.getTemplateId(), request.getOpenId(), wxMpTemplate);
                             }
                             resultData=ResultData.success(CodeMsg.SUCCESS);
+
+
+                            //===============================================================打印积分订单小票==============================================================================//
                             StationInfo stationInfo = new StationInfo();
                             stationInfo.setStationId(request.getStationId());
                             //获取油站功能信息
                             StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
                             if(stationInfos.getIntegralPrintFlag().equals("1")){
-                                if(stationInfos.getPrintDeviceType().equals("2")){
-                                    //POS机打印小票
-                                    Map<String, Object> map = new HashMap<>();
-                                    map.put("orderNo", integralOrderNo);
-                                    map.put("createdDate", new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss").format(integralOrder.getExchangeTime()));
-                                    map.put("payDate", new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss").format(integralOrder.getExchangeTime()));
-                                    map.put("stationName", stationName);
-                                    map.put("waresName", integralOrder.getWaresName());
-                                    map.put("exchangeNum", integralOrder.getExchangeNum());
-                                    map.put("orderSumIntegral", orderSumIntegral);
-                                    map.put("surplusPoints", surplusPoints);
-                                    map.put("customerName", integralOrder.getCustomerName());
-                                    map.put("orderType", "integral");
-                                    map.put("stationId", request.getStationId().toString());
-                                    //map.put("printSetting", stationInfos.getPrintSetting());
-                                    this.posPrintReceipt(map, stationInfos.getPrintSetting());
-                                }else {
-                                    //打印机打印小票
-                                    List<Map<String, Object>> stationPrinterList = stationService.getStationPrinterList(request.getStationId());
-                                    if(stationPrinterList != null && stationPrinterList.get(0).get("integralPrintFlag").toString().equals("1")){
-                                        if(stationPrinterList.get(0).get("printerSn") !=null){
-                                            String sn=stationPrinterList.get(0).get("printerSn").toString();
+                                StationDeviceManager stationDeviceManager = new StationDeviceManager();
+                                stationDeviceManager.setStationId(request.getStationId());
+                                //获取该油站的打印设备信息
+                                List<StationDeviceManager> stationDeviceManagerList = stationService.getStationDeviceManagerList(stationDeviceManager);
+                                if(stationDeviceManagerList !=null && stationDeviceManagerList.size() >0){
+                                    if(stationDeviceManagerList.get(0).getDeviceType().equals("2")){ //POS机打印小票
+                                        Map<String, Object> map = new HashMap<>();
+                                        map.put("orderNo", integralOrderNo);
+                                        map.put("createdDate", new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss").format(integralOrder.getExchangeTime()));
+                                        map.put("payDate", new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss").format(integralOrder.getExchangeTime()));
+                                        map.put("stationName", stationName);
+                                        map.put("waresName", integralOrder.getWaresName());
+                                        map.put("exchangeNum", integralOrder.getExchangeNum());
+                                        map.put("orderSumIntegral", orderSumIntegral);
+                                        map.put("surplusPoints", surplusPoints);
+                                        map.put("customerName", integralOrder.getCustomerName());
+                                        map.put("orderType", "integral");
+                                        map.put("stationId", request.getStationId().toString());
+                                        //map.put("printSetting", stationInfos.getPrintSetting());
+                                        if(stationDeviceManagerList.get(0).getDeviceNo() !=null){
+                                            PayOrder order = new PayOrder();
+                                            order.setDeviceNo(stationDeviceManagerList.get(0).getDeviceNo());
+                                            order.setPosQueue(stationDeviceManagerList.get(0).getPosQueue());
+                                            order.setPosFanoutExchange(stationDeviceManagerList.get(0).getPosFanoutExchange());
+                                            order.setPrintSetting(stationInfos.getPrintSetting());
+                                            this.posPrintReceipt(map, order);
+                                        }else {
+                                            logger.info("请正确配置POS机!");
+                                        }
+                                    }else { //打印机打印小票
+                                        if(stationDeviceManagerList.get(0).getDeviceNo() !=null){
+                                            String sn=stationDeviceManagerList.get(0).getDeviceNo();
                                             String content1;
                                             content1 = "<CB>客户联-积分小票</CB><BR>";
                                             content1 += "订单号:"+integralOrderNo+"  <BR>";
@@ -318,7 +331,6 @@ public class IntegralShoppingMallController {
                                             content1 += "商品数量:x "+integralOrder.getExchangeNum()+"  <BR>";
                                             content1 += "消耗积分: "+orderSumIntegral+" 分<BR>";
                                             content1 += "剩余积分: "+surplusPoints+" 分<BR>";
-                                            //content1 += "<BOLD><B>消耗积分: "+orderSumIntegral+" 分</B></BOLD><BR>";
                                             content1 += "客户昵称: "+integralOrder.getCustomerName()+"  <BR>";
                                             content1 += "<BR>";
 
@@ -331,7 +343,6 @@ public class IntegralShoppingMallController {
                                             content2 += "商品数量:x "+integralOrder.getExchangeNum()+"  <BR>";
                                             content2 += "消耗积分: "+orderSumIntegral+" 分<BR>";
                                             content2 += "剩余积分: "+surplusPoints+" 分<BR>";
-                                            //content1 += "<BOLD><B>消耗积分: "+orderSumIntegral+" 分</B></BOLD><BR>";
                                             content2 += "客户昵称: "+integralOrder.getCustomerName()+"  <BR>";
                                             content2 += "<BR>";
 
@@ -348,10 +359,11 @@ public class IntegralShoppingMallController {
                                                 integralOrder.setPrinterStatus("1");
                                                 integralOrderService.updateIntegralOrder(integralOrder);
                                             }
+                                        }else {
+                                            logger.info("请正确配置小票机!");
                                         }
                                     }
                                 }
-
                             }
                         }else {
                             resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
@@ -370,46 +382,31 @@ public class IntegralShoppingMallController {
     }
 
     //POS机打印小票
-    public void posPrintReceipt(Map map, String printSetting){
+    public void posPrintReceipt(Map map, PayOrder order){
         logger.info("要推送的订单的信息:" +map.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(map.get("stationId").toString()));
-//        stationDeviceManager.setGunNo("1");
-//        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", printSetting);
-//        }
-        List<StationDeviceManager> stationDeviceManagerList = stationService.getStationDeviceManagerList(stationDeviceManager);
-        if(stationDeviceManagerList != null && stationDeviceManagerList.size()>0){
-            params.put("posFanoutExchange", stationDeviceManagerList.get(0).getPosFanoutExchange());
-            params.put("posQueue", stationDeviceManagerList.get(0).getPosQueue());
-            params.put("tusn", stationDeviceManagerList.get(0).getDeviceNo());
-            params.put("printSetting", printSetting);
-            List<Map<String, Object>> list = new ArrayList<>();
-            list.add(map);
-            Map<String, Object> mm = new HashMap<>();
-            mm.put("contentData", list);
-            params.put("messageContent", mm);
-            //开始推送消息
-            logger.info("开始推送消息:" +JSONObject.toJSONString(params));
-            String resultString = PosPrinterUtil.sendPosPrintDirectMessage(params);
-            JSONObject jsonObject_pos = JSONObject.parseObject(resultString);
-            if(jsonObject_pos.containsKey("code") && jsonObject_pos.get("code").toString().equals("200")){
-                //如果打印成功 添加小票数量
-                IntegralOrder integralOrder = new IntegralOrder();
-                integralOrder.setIntegralOrderNo(map.get("orderNo").toString());
-                integralOrder.setPrinterStatus("1");
-                integralOrderService.updateIntegralOrder(integralOrder);
-            }
+        params.put("posFanoutExchange", order.getPosFanoutExchange());
+        params.put("posQueue", order.getPosQueue());
+        params.put("tusn", order.getDeviceNo());
+        params.put("printSetting", order.getPrintSetting());
+        List<Map<String, Object>> list = new ArrayList<>();
+        list.add(map);
+        Map<String, Object> mm = new HashMap<>();
+        mm.put("contentData", list);
+        params.put("messageContent", mm);
+        //开始推送消息
+        logger.info("开始推送消息:" +JSONObject.toJSONString(params));
+        String resultString = PosPrinterUtil.sendPosPrintDirectMessage(params);
+        JSONObject jsonObject_pos = JSONObject.parseObject(resultString);
+        if(jsonObject_pos.containsKey("code") && jsonObject_pos.get("code").toString().equals("200")){
+            //如果打印成功 添加小票数量
+            IntegralOrder integralOrder = new IntegralOrder();
+            integralOrder.setIntegralOrderNo(map.get("orderNo").toString());
+            integralOrder.setPrinterStatus("1");
+            integralOrderService.updateIntegralOrder(integralOrder);
         }
     }
 

+ 79 - 49
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -420,8 +420,8 @@ public class PayController {
     public void getCallback(@RequestBody JSONObject request) throws ParseException {
         logger.info("-------------------------------回调开始----------------------------------------------");
         logger.info("回调返回过来的参数"+request);
-        logger.info("ordNo信息:" + request.get("ordNo").toString());
-        logger.info("sign信息:" + request.get("sign").toString());
+//        logger.info("ordNo信息:" + request.get("ordNo").toString());
+//        logger.info("sign信息:" + request.get("sign").toString());
         Gson gson =new Gson();
 
 
@@ -564,7 +564,7 @@ public class PayController {
             logger.info("返回随行付参数信息:"+req.toString());
             //验签成功,修改订单状态
             List<PayOrder> list = payOrderService.getPayOrderList(ordNo);
-            logger.info("根据订单号,查询订单"+gson.toJson(list));
+            //logger.info("根据订单号,查询订单"+gson.toJson(list));
             if (list != null && list.size() == 1) {
                 String status = list.get(0).getStatus();
                 //状态为未支付 0  修改状态为1已支付
@@ -644,29 +644,59 @@ public class PayController {
                                 }
                             }
 
-
-                            //logger.info("小票打印方式:" + stationInfo.getPrintDeviceType());
-                            if(stationInfos !=null && stationInfos.getPrintDeviceType() !=null){
-                                switch (stationInfos.getPrintDeviceType()){
-                                    case "1":   //小票机打印
-                                        logger.info("小票机打印");
-                                        Map map = new HashMap();
-                                        map.put("stationId", infoMap.get("stationId").toString());
-                                        map.put("oilGunNo", infoMap.get("oilGun").toString());
-                                        map.put("deviceType", stationInfos.getPrintDeviceType());
-                                        List<Map> listDevices = stationOilGunService.getPrinterSnByStationIdAndOilGunNoList(map);
-                                        infoMap.put("sn", listDevices.get(0).get("printerSn").toString());
-                                        infoMap.put("printSetting", stationInfos.getPrintSetting());
-                                        this.printReceipt(infoMap);
-                                        break;
-                                    case "2":   //POS机打印
-                                        logger.info("POS机打印");
-                                        payOrder.setIntegral(String.valueOf(integral));
-                                        payOrder.setPrintSetting(stationInfos.getPrintSetting());
-                                        this.posPrintReceipt(payOrder);
-                                        break;
+                            //获取油枪绑定的POS机信息
+                            StationDeviceManager stationDeviceManager = new StationDeviceManager();
+                            stationDeviceManager.setGunNo(infoMap.get("oilGun").toString());
+                            stationDeviceManager.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
+                            List<StationDeviceManager> stationDeviceManagerList = stationService.getStationDeviceManagerList(stationDeviceManager);
+                            if(stationDeviceManagerList !=null && stationDeviceManagerList.size() >0){
+                                String deviceType = stationDeviceManagerList.get(0).getDeviceType();
+                                if(deviceType !=null && deviceType !=""){
+                                    switch (deviceType){
+                                        case "1":
+                                            logger.info("小票机打印方式");
+                                            infoMap.put("sn", stationDeviceManagerList.get(0).getDeviceNo());
+                                            infoMap.put("printSetting", stationInfos.getPrintSetting());
+                                            this.printReceipt(infoMap);
+                                            break;
+                                        case "2":
+                                            logger.info("POS机打印方式");
+                                            payOrder.setIntegral(String.valueOf(integral));
+                                            payOrder.setPrintSetting(stationInfos.getPrintSetting());
+                                            if(stationDeviceManagerList.get(0).getPosFanoutExchange() !=null && stationDeviceManagerList.get(0).getPosQueue() !=null){
+                                                payOrder.setPosFanoutExchange(stationDeviceManagerList.get(0).getPosFanoutExchange());
+                                                payOrder.setPosQueue(stationDeviceManagerList.get(0).getPosFanoutExchange());
+                                                payOrder.setDeviceNo(stationDeviceManagerList.get(0).getDeviceNo());
+                                                this.posPrintReceipt(payOrder);
+                                            }
+                                            break;
+                                    }
                                 }
                             }
+
+
+                            //logger.info("小票打印方式:" + stationInfo.getPrintDeviceType());
+//                            if(stationInfos !=null && stationInfos.getPrintDeviceType() !=null){
+//                                switch (stationInfos.getPrintDeviceType()){
+//                                    case "1":   //小票机打印
+//                                        logger.info("小票机打印");
+//                                        Map map = new HashMap();
+//                                        map.put("stationId", infoMap.get("stationId").toString());
+//                                        map.put("oilGunNo", infoMap.get("oilGun").toString());
+//                                        map.put("deviceType", stationInfos.getPrintDeviceType());
+//                                        List<Map> listDevices = stationOilGunService.getPrinterSnByStationIdAndOilGunNoList(map);
+//                                        infoMap.put("sn", listDevices.get(0).get("printerSn").toString());
+//                                        infoMap.put("printSetting", stationInfos.getPrintSetting());
+//                                        this.printReceipt(infoMap);
+//                                        break;
+//                                    case "2":   //POS机打印
+//                                        logger.info("POS机打印");
+//                                        payOrder.setIntegral(String.valueOf(integral));
+//                                        payOrder.setPrintSetting(stationInfos.getPrintSetting());
+//                                        this.posPrintReceipt(payOrder);
+//                                        break;
+//                                }
+//                            }
                         }else{
                             logger.info("该用户无手机号!");
                         }
@@ -846,32 +876,32 @@ public class PayController {
         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);
-            }
+//        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", payOrder.getPosFanoutExchange());
+        params.put("posQueue", payOrder.getPosQueue());
+        params.put("tusn", payOrder.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);
         }
+        //}
 
     }
 

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/CouponMapper.java

@@ -2,9 +2,15 @@ package com.platform.yijia.dao;
 
 
 import com.platform.yijia.pojo.Coupon;
+import com.platform.yijia.pojo.UserCoupon;
+
+import java.util.List;
 
 public interface CouponMapper {
 
     //获取加油券信息
     Coupon selectCouponInfo(Coupon coupon);
+
+    //获取用户优惠券
+    List<UserCoupon> selectUserCoupons(UserCoupon userCoupon);
 }

+ 5 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/PayOrder.java

@@ -82,4 +82,9 @@ public class PayOrder implements Serializable {
     private String transactionId;
     private String integral;
 
+    //打印小票所需的设备的参数
+    private String posFanoutExchange;
+    private String posQueue;
+    private String deviceNo;
+
 }

+ 31 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/UserCoupon.java

@@ -0,0 +1,31 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 用户优惠券实体类
+ */
+@Data
+public class UserCoupon {
+    private Integer couponId;               //优惠券ID;
+    private String unionId;                 //用户union_id;
+    private Integer stationId;              //油站ID
+    private String couponOrigin;            //优惠券来源
+    private String isUsed;                  //优惠券是否被使用
+
+    //优惠券属性
+    private BigDecimal couponThresholdAmt;  //优惠券使用门槛金额;
+    private String oilType;                 //1 柴油,2 汽油;
+    private String couponAmt;               //优惠券优惠金额;
+    private String effectiveTimeType;       //有效时间类型: 1,固定时间;2,领取后x天内有效;
+    private Date effectiveTimeStart;        //固定时间-有效开始时间;
+    private Date effectiveTimeEnd;          //固定时间-有效结束时间;
+    private Integer effectiveDayNum;        //有效天数;
+    private String openPlatform;            //'发放平台,1.微信 2支付宝';
+    private String grantStatus;             //发放状态:0,未发放;1,已发放;
+    private String status;                  //有效状态:0,未生效; 1,生效;2,失效;
+
+}

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/CouponService.java

@@ -2,10 +2,16 @@ package com.platform.yijia.service;
 
 
 import com.platform.yijia.pojo.Coupon;
+import com.platform.yijia.pojo.UserCoupon;
+
+import java.util.List;
 
 public interface CouponService {
 
     //获取加油券信息
     Coupon selectCouponInfo(Coupon coupon);
 
+    //获取用户优惠券
+    List<UserCoupon> selectUserCoupons(UserCoupon userCoupon);
+
 }

+ 8 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/CouponServiceImpl.java

@@ -2,10 +2,12 @@ package com.platform.yijia.service.impl;
 
 import com.platform.yijia.dao.CouponMapper;
 import com.platform.yijia.pojo.Coupon;
+import com.platform.yijia.pojo.UserCoupon;
 import com.platform.yijia.service.CouponService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @Service("couponService")
 public class CouponServiceImpl implements CouponService {
@@ -17,4 +19,10 @@ public class CouponServiceImpl implements CouponService {
     public Coupon selectCouponInfo(Coupon coupon) {
         return couponMapper.selectCouponInfo(coupon);
     }
+
+    //获取用户优惠券
+    @Override
+    public List<UserCoupon> selectUserCoupons(UserCoupon userCoupon) {
+        return couponMapper.selectUserCoupons(userCoupon);
+    }
 }

+ 1 - 1
YijiaRestful/src/main/java/com/platform/yijia/utils/CodeMsg.java

@@ -18,7 +18,7 @@ public class CodeMsg {
     public static CodeMsg NO_FollowGzh = new CodeMsg(-4,"未关注公众号");
     public static CodeMsg USERGZHINFO_EXSIST = new CodeMsg(-5,"系统暂无此用户公众号信息");
     public static CodeMsg CHECK_DATA_ERROR = new CodeMsg(-6,"数据不一致");
-    public static CodeMsg SEARCH_FAIL = new CodeMsg(001,"查询失败");
+    public static CodeMsg SEARCH_FAIL = new CodeMsg(-1,"查询失败");
     public static CodeMsg INSERT_FAIL = new CodeMsg(001,"添加失败");
     public static CodeMsg SEARCH_APPID_FAIL = new CodeMsg(-1,"油站公众号配置不完善");
     public static CodeMsg DELETE_FAIL = new CodeMsg(003,"删除失败");

+ 51 - 0
YijiaRestful/src/main/resources/mapper/CouponMapper.xml

@@ -19,6 +19,30 @@
     <result column="status"                   jdbcType="VARCHAR"   property="status" />
   </resultMap>
 
+  <resultMap id="UserCouponsBaseResultMap" type="com.platform.yijia.pojo.UserCoupon">
+    <result column="coupon_id"               jdbcType="INTEGER"   property="couponId" />
+    <result column="union_id"                jdbcType="VARCHAR"   property="unionId" />
+    <result column="station_id"              jdbcType="INTEGER"   property="stationId" />
+    <result column="coupon_origin"           jdbcType="VARCHAR"   property="couponOrigin" />
+    <result column="is_used"                 jdbcType="VARCHAR"   property="isUsed" />
+
+    <result column="coupon_name"              jdbcType="VARCHAR"   property="couponName" />
+    <result column="coupon_type"              jdbcType="VARCHAR"   property="couponType" />
+    <result column="coupon_threshold_amt"     jdbcType="DECIMAL"   property="couponThresholdAmt" />
+    <result column="oil_type"                 jdbcType="VARCHAR"   property="oilType" />
+    <result column="coupon_amt"               jdbcType="VARCHAR"   property="couponAmt" />
+    <result column="coupon_num"               jdbcType="INTEGER"   property="couponNum" />
+    <result column="effective_time_type"      jdbcType="VARCHAR"   property="effectiveTimeType" />
+    <result column="effective_time_start"     jdbcType="TIMESTAMP" property="effectiveTimeStart" />
+    <result column="effective_time_end"       jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
+    <result column="effective_day_num"        jdbcType="INTEGER"   property="effectiveDayNum" />
+    <result column="coupon_receive_num"       jdbcType="INTEGER"   property="couponReceiveNum" />
+    <result column="open_platform"            jdbcType="VARCHAR"   property="openPlatform" />
+    <result column="grant_status"             jdbcType="VARCHAR"   property="grantStatus" />
+    <result column="status"                   jdbcType="VARCHAR"   property="status" />
+  </resultMap>
+
+
   <sql id="Base_Column_List">
     id, coupon_name, coupon_type, coupon_threshold_amt, oil_type, coupon_amt, coupon_num, effective_time_type,
     effective_time_start, effective_time_end, effective_day_num, coupon_receive_num, open_platform, grant_status, status
@@ -27,6 +51,8 @@
   <select id="selectCouponInfo" parameterType="com.platform.yijia.pojo.Coupon" resultMap="BaseResultMap">
         SELECT
             <include refid="Base_Column_List"/>
+        FROM
+            coupon_info
         <where>
           <if test="id !=null">
             id = #{id}
@@ -34,4 +60,29 @@
         </where>
   </select>
 
+  <!--获取用户所拥有的加油券-->
+  <select id="selectUserCoupons" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
+    SELECT
+        T1.union_id,
+        T1.coupon_id,
+        T2.oil_type,
+        T2.coupon_name,
+        T2.coupon_threshold_amt,
+        T2.coupon_amt,
+        T2.effective_time_type,
+        T2.effective_time_start,
+        T2.effective_time_end,
+        T2.effective_day_num,
+        T2.status
+    FROM
+        coupon_user     AS  T1 LEFT JOIN coupon_info T2 ON T1.coupon_id = T2.id
+    <where>
+      <if test="stationId !=null and stationId !=''">
+        T1.station_id = #{stationId}
+      </if>
+      <if test="unionId !=null and unionId !=''">
+       AND T1.union_id = #{unionId}
+      </if>
+    </where>
+  </select>
 </mapper>

+ 1 - 1
YijiaRestful/src/main/resources/mapper/StationInfoMapper.xml

@@ -648,7 +648,7 @@
         AND FIND_IN_SET(#{gunNo}, gun_no)
       </if>
     </where>
-    ORDER BY device_no
+    ORDER BY device_id
   </select>
 
   <!--获取油站的打印设备信息-->