jk-GitHub-coder há 4 anos atrás
pai
commit
f50dfe16e5

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

@@ -10,7 +10,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * 客户优惠
+ * 客户优惠和营销
  */
 @Controller
 @RequestMapping("/api")
@@ -26,5 +26,14 @@ public class CustomerGradeController {
         return customerGradeServices.getCustomerGradeList();
     }
 
+    // 营销:立减方案
+    @RequestMapping("/getmarkertPlanList")
+    @ResponseBody
+    public List<Map> getmarkertPlanList(){
+        return customerGradeServices.getMarkertPlanListByDiscountPlanType();
+    }
+
+
+
 
 }

+ 18 - 6
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -8,6 +8,7 @@ import com.platform.yijia.pojo.AppUserInfo;
 import com.platform.yijia.pojo.PayOrder;
 import com.platform.yijia.service.AppUserInfoService;
 import com.platform.yijia.service.PayOrderService;
+import com.platform.yijia.service.StationOilGunService;
 import com.platform.yijia.utils.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -26,6 +27,8 @@ public class PayController {
     private PayOrderService payOrderService;
     @Resource
     private AppUserInfoService appUserInfoService;
+    @Resource
+    private StationOilGunService stationOilGunService;
 
     /***
      * 微信子商户支付接口
@@ -461,7 +464,6 @@ public class PayController {
                 //状态为未支付 0  修改状态为1已支付
                 if (status.equals("0")) {
                     PayOrder payOrder = new PayOrder();
-                    //payOrder.setOrderId(ordId);
                     payOrder.setOrderNo(ordNo);
                     payOrder.setStatus("1");
                     payOrder.setPayDate(new Date());    //支付时间
@@ -474,7 +476,6 @@ public class PayController {
                         logger.info(req.toString());
                         //开始打印
                         List<PayOrder> listUp = payOrderService.getPayOrderList(ordNo);
-                        String sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
                         String content1;
                         String content2;
                         String orderNoP = "";
@@ -486,8 +487,10 @@ public class PayController {
                         String receivableAmtP = "";
                         String discountAmtP = "";
                         String amtP = "";
+                        String sn;  //打印机编号
                         if(listUp != null && listUp.size() == 1){
-                            logger.info("要打印小票的订单信息:"+ listUp);
+                            logger.info("要打印小票的订单信息: "+ listUp);
+
                             if(StringUtils.isNotBlank(listUp.get(0).getOrderNo())){
                                 orderNoP =listUp.get(0).getOrderNo();
                             }
@@ -544,11 +547,20 @@ public class PayController {
                             content2 += "优惠: "+discountAmtP+" 元<BR>";
                             content2 += "支付: "+amtP+" 元<BR>";
                             content2 += "<BR>";
-                            FeiEPrinterUtil.printReceipt(sn, content1 +content2);
+                            //获取打印机编号
+                            //sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
+                            Map params  =new HashMap();
+                            params.put("stationId", listUp.get(0).getStationId());
+                            params.put("oilGunNo", listUp.get(0).getOilGun());
+                            Map m = stationOilGunService.getPrinterSnByStationIdAndOilGunNo(params);
+                            if(m.containsKey("") && m.get("printerSn").toString()!= null && m.get("printerSn").toString()!=""){
+                                sn = m.get("printerSn").toString();
+                                FeiEPrinterUtil.printReceipt(sn, content1 + content2);
+                            }else {
+                                logger.info("请正确配置打印机");
+                            }
                         }
-
                     }
-
                 }
             }
         }else {

+ 2 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/CustomerGradeMapper.java

@@ -8,4 +8,6 @@ public interface CustomerGradeMapper {
     //查询直降
     List<Map> getCustomerGradeList();
 
+    //营销 立减
+    List<Map> getMarkertPlanListByDiscountPlanType();
 }

+ 7 - 1
YijiaRestful/src/main/java/com/platform/yijia/dao/StationOilGunMapper.java

@@ -3,9 +3,15 @@ package com.platform.yijia.dao;
 import com.platform.yijia.pojo.StationOilGun;
 import com.platform.yijia.pojo.StationOilGunExample;
 import java.util.List;
+import java.util.Map;
+
 import org.apache.ibatis.annotations.Param;
 
 public interface StationOilGunMapper {
+
+    //根据油站Id油枪号获取打印机编号
+    Map<String, Object> getPrinterSnByStationIdAndOilGunNo(Map<String, Object> params);
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table station_oil_gun
@@ -93,4 +99,4 @@ public interface StationOilGunMapper {
      * @mbg.generated
      */
     int updateByPrimaryKey(StationOilGun record);
-}
+}

+ 4 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/CustomerGradeServices.java

@@ -10,4 +10,8 @@ public interface CustomerGradeServices {
 
     //查询直降方式
     List<Map> getCustomerGradeList();
+
+    //立减
+    List<Map> getMarkertPlanListByDiscountPlanType();
+
 }

+ 5 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/StationOilGunService.java

@@ -3,8 +3,13 @@ package com.platform.yijia.service;
 import com.platform.yijia.pojo.StationOilGun;
 
 import java.util.List;
+import java.util.Map;
 
 public interface StationOilGunService {
     //油枪管理
     List<StationOilGun> stationOilGunList(StationOilGun stationOilGun);
+
+    //根据油站Id油枪号获取打印机编号
+    Map<String, Object> getPrinterSnByStationIdAndOilGunNo(Map<String, Object> params);
+
 }

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

@@ -19,4 +19,10 @@ public class CustomerGradeServiceImpl implements CustomerGradeServices {
     public List<Map> getCustomerGradeList() {
         return customerGradeMapper.getCustomerGradeList();
     }
+
+    //营销立减
+    @Override
+    public List<Map> getMarkertPlanListByDiscountPlanType() {
+        return customerGradeMapper.getMarkertPlanListByDiscountPlanType();
+    }
 }

+ 11 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/StationOilGunServiceImpl.java

@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 @Service("stationOilGunService")
 public class StationOilGunServiceImpl implements StationOilGunService {
@@ -21,4 +22,14 @@ public class StationOilGunServiceImpl implements StationOilGunService {
         return stationInfolist;
 
     }
+
+    /*
+     * 根据油站Id油枪号获取打印机编号
+     * @param params
+     * @return
+     */
+    @Override
+    public Map<String, Object> getPrinterSnByStationIdAndOilGunNo(Map<String, Object> params) {
+        return stationOilGunMapper.getPrinterSnByStationIdAndOilGunNo(params);
+    }
 }

+ 9 - 5
YijiaRestful/src/main/java/com/platform/yijia/utils/FeiEPrinterUtil.java

@@ -28,6 +28,10 @@ public class FeiEPrinterUtil {
 
     private static Logger logger =(Logger) LoggerFactory.getLogger(FeiEPrinterUtil.class);
 
+    /*飞鹅后台管理登录账号
+        账号:79800875@qq.com
+        密码:jk18654585051
+     */
     public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改
     public static final String USER = "79800875@qq.com";//*必填*:账号名
     public static final String UKEY = "ScyIqKvntVSJkWhz";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
@@ -104,7 +108,7 @@ public class FeiEPrinterUtil {
                 if (httpentity != null){
                     //服务器返回的JSON字符串,建议要当做日志记录起来
                     result = EntityUtils.toString(httpentity);
-                    logger.info(result);
+                    logger.info("小票打印功能返回结果信息:" +result);
                 }
             }
         }
@@ -175,7 +179,7 @@ public class FeiEPrinterUtil {
                 if (httpentity != null){
                     //服务器返回
                     result = EntityUtils.toString(httpentity);
-                    logger.info(result);
+                    logger.info("查询某订单是否打印成功信息:" + result);
                 }
             }
         }
@@ -247,7 +251,7 @@ public class FeiEPrinterUtil {
                 if (httpentity != null){
                     //服务器返回
                     result = EntityUtils.toString(httpentity);
-                    logger.info(result);
+                    logger.info("查询指定打印机某天的订单详情: "+result);
                 }
             }
         }
@@ -317,7 +321,7 @@ public class FeiEPrinterUtil {
                 if (httpentity != null){
                     //服务器返回
                     result = EntityUtils.toString(httpentity);
-                    logger.info(result);
+                    logger.info("查询打印机的状态: "+result);
                 }
             }
         }
@@ -392,7 +396,7 @@ public class FeiEPrinterUtil {
                 HttpEntity httpentity = response.getEntity();
                 if (httpentity != null){
                     result = EntityUtils.toString(httpentity);
-                    logger.info(result);
+                    logger.info("添加打印机接口: " + result);
                 }
             }
         }

+ 20 - 1
YijiaRestful/src/main/resources/mapper/CustomerGradeMapper.xml

@@ -11,10 +11,29 @@
         gasoil_discount_litre       AS gasoilDiscountLitre,
         gasoil_discount_litre       AS dieseloilDiscountLitre,
         member_condit               AS memberCondit
-    FROM customer_grade_setting
+      FROM customer_grade_setting
     <where>
       discount_way = "直降"
     </where>
   </select>
 
+    <!-- 营销立减-->
+    <select id="getMarkertPlanListByDiscountPlanType"  resultType="map">
+        SELECT
+            id                          AS id,
+            grade                       AS grade,
+            discount_term               AS discountWay,
+            discount_amt                AS discountAmt,
+            gasoil_discount_amt         AS gasoilDiscountAmt,
+            dieseloil_discount_amt      AS dieseloilDiscountAmt,
+            vip_discounty_plus          AS vipDiscountyPlus,
+            coupon_plus                 AS couponPlus,
+            discount_plan_type          AS discountPlanType
+        FROM
+            markert_plan
+        <where>
+            discount_plan_type = "2"
+        </where>
+    </select>
+
 </mapper>

+ 23 - 4
YijiaRestful/src/main/resources/mapper/StationOilGunMapper.xml

@@ -109,7 +109,7 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from station_oil_gun
     where oil_gun_id = #{oilGunId,jdbcType=INTEGER}
@@ -137,10 +137,10 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    insert into station_oil_gun (oil_gun_id, oil_gun_no, oil_name, 
+    insert into station_oil_gun (oil_gun_id, oil_gun_no, oil_name,
       station_id, station_name, date
       )
-    values (#{oilGunId,jdbcType=INTEGER}, #{oilGunNo,jdbcType=VARCHAR}, #{oilName,jdbcType=VARCHAR}, 
+    values (#{oilGunId,jdbcType=INTEGER}, #{oilGunNo,jdbcType=VARCHAR}, #{oilName,jdbcType=VARCHAR},
       #{stationId,jdbcType=INTEGER}, #{stationName,jdbcType=VARCHAR}, #{date,jdbcType=TIMESTAMP}
       )
   </insert>
@@ -285,4 +285,23 @@
       date = #{date,jdbcType=TIMESTAMP}
     where oil_gun_id = #{oilGunId,jdbcType=INTEGER}
   </update>
-</mapper>
+
+  <!--根据油站Id油枪号获取打印机编号 -->
+  <select id="getPrinterSnByStationIdAndOilGunNo" parameterType="map" resultType="map">
+    SELECT
+        gun_no       AS oilGunNo,
+        station_id   AS stationId,
+        device_no    AS printerSn
+    FROM  station_device_manage
+    <where>
+        <if test="oilGunNo != null oilGunNo !=''">
+          gun_no = #{oilGunNo}
+        </if>
+        <if test="stationId != null and stationId !=''">
+          AND station_id = #{stationId}
+        </if>
+    </where>
+
+  </select>
+
+</mapper>

+ 33 - 33
YijiaRestful/src/test/java/com/palatform/yijia/YijiaApplicationTests.java

@@ -12,40 +12,40 @@ import java.util.List;
 @SpringBootTest
 class YijiaApplicationTests {
 
-    @Resource
-    private PayOrderService payOrderService;
+//    @Resource
+//    private PayOrderService payOrderService;
     @Test
     public void contextLoads() {
-        String ordNo = "2546627325194192730676";
-        List<PayOrder> list = payOrderService.getPayOrderList(ordNo);
-        //logger.info("根据订单号,查询订单"+gson.toJson(list));
-        String sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
-        String content;
-        if (list != null && list.size() == 1) {
-            content = "<CB>支付小票--商户联</CB><BR>";
-            //content += "--------------------------------<BR>";
-            content += "订单号:" + list.get(0).getOrderNo() + " <BR>";
-            content += "时间:" + list.get(0).getCreatedDate().toString() + "<BR>";
-            content += "油站:" + list.get(0).getStationName() + " 元<BR>";
-            content += "油品: " + list.get(0).getOilName() + " 元<BR>";
-            content += "油量: " + list.get(0).getOrderLiters() + " 升<BR>";
-            content += "单价: " + list.get(0).getOilPirce() + " L/元<BR>";
-            content += "金额: " + list.get(0).getReceivableAmt().toString() + " 元<BR>";
-            content += "优惠: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
-            content += "支付: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
-            content += "--------------------------------<BR>";
-            content = "<CB>支付小票--顾客联</CB><BR>";
-            //content += "--------------------------------<BR>";
-            content += "订单号:" + list.get(0).getOrderNo() + " <BR>";
-            content += "时间:" + list.get(0).getCreatedDate().toString() + "<BR>";
-            content += "油站:" + list.get(0).getStationName() + " 元<BR>";
-            content += "油品: " + list.get(0).getOilName() + " 元<BR>";
-            content += "油量: " + list.get(0).getOrderLiters() + " 升<BR>";
-            content += "单价: " + list.get(0).getOilPirce() + " L/元<BR>";
-            content += "金额: " + list.get(0).getReceivableAmt().toString() + " 元<BR>";
-            content += "优惠: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
-            content += "支付: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
-            FeiEPrinterUtil.printReceipt(sn, content);
-        }
+//        String ordNo = "2546627325194192730676";
+//        List<PayOrder> list = payOrderService.getPayOrderList(ordNo);
+//        //logger.info("根据订单号,查询订单"+gson.toJson(list));
+//        String sn = "921611605";     //测试打印机 sn:921611605 key:72338zma
+//        String content;
+//        if (list != null && list.size() == 1) {
+//            content = "<CB>支付小票--商户联</CB><BR>";
+//            //content += "--------------------------------<BR>";
+//            content += "订单号:" + list.get(0).getOrderNo() + " <BR>";
+//            content += "时间:" + list.get(0).getCreatedDate().toString() + "<BR>";
+//            content += "油站:" + list.get(0).getStationName() + " 元<BR>";
+//            content += "油品: " + list.get(0).getOilName() + " 元<BR>";
+//            content += "油量: " + list.get(0).getOrderLiters() + " 升<BR>";
+//            content += "单价: " + list.get(0).getOilPirce() + " L/元<BR>";
+//            content += "金额: " + list.get(0).getReceivableAmt().toString() + " 元<BR>";
+//            content += "优惠: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
+//            content += "支付: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
+//            content += "--------------------------------<BR>";
+//            content = "<CB>支付小票--顾客联</CB><BR>";
+//            //content += "--------------------------------<BR>";
+//            content += "订单号:" + list.get(0).getOrderNo() + " <BR>";
+//            content += "时间:" + list.get(0).getCreatedDate().toString() + "<BR>";
+//            content += "油站:" + list.get(0).getStationName() + " 元<BR>";
+//            content += "油品: " + list.get(0).getOilName() + " 元<BR>";
+//            content += "油量: " + list.get(0).getOrderLiters() + " 升<BR>";
+//            content += "单价: " + list.get(0).getOilPirce() + " L/元<BR>";
+//            content += "金额: " + list.get(0).getReceivableAmt().toString() + " 元<BR>";
+//            content += "优惠: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
+//            content += "支付: " + list.get(0).getDiscountAmt().toString() + " 元<BR>";
+//            FeiEPrinterUtil.printReceipt(sn, content);
+ //       }
     }
 }