jk-GitHub-coder hace 4 años
padre
commit
a714640884

+ 11 - 11
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -73,7 +73,7 @@ public class AppUserInfoController {
         ResultData resultData=null;
         try{
             AppUserInfo appUserInfo =new AppUserInfo();
-            CustomerManage customerManage = new CustomerManage();
+            //CustomerManage customerManage = new CustomerManage();
             String openId = "";     //此参数用于查询该用户是否已注册过
             //String token ="";       //用户token
             if(request.getUserType()!=null){
@@ -84,7 +84,7 @@ public class AppUserInfoController {
                     appUserInfo.setBlogToken(request.getBlogToken());
                     openId = request.getBlogOpenid();
                     appUserInfo.setBlogOpenid(openId);
-                    customerManage.setBlogOpenid(openId);
+                    //customerManage.setBlogOpenid(openId);
                  //2-微信小程序
                 }else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getMinaOpenid())){
                     appUserInfo.setUserType(request.getUserType());
@@ -92,16 +92,16 @@ public class AppUserInfoController {
                     appUserInfo.setMinaToken(request.getMinaToken());
                     openId = request.getMinaOpenid();
                     appUserInfo.setMinaOpenid(openId);
-                    customerManage.setMinaOpenid(openId);
+                    //customerManage.setMinaOpenid(openId);
                 }
             }
             if(StringUtils.isNotBlank(request.getBlogNickName())){
                 appUserInfo.setBlogNickName(request.getBlogNickName());
-                customerManage.setCustomerName(request.getBlogNickName());
+                //customerManage.setCustomerName(request.getBlogNickName());
             }
             if(StringUtils.isNotBlank(request.getMobilePhone())){
                 appUserInfo.setMobilePhone(request.getMobilePhone());
-                customerManage.setPhoneNumber(request.getMobilePhone());
+                //customerManage.setPhoneNumber(request.getMobilePhone());
             }
             if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
                 appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
@@ -115,8 +115,8 @@ public class AppUserInfoController {
                 appUserInfo.setSexFlag(request.getSexFlag());
             }
 
-            customerManage.setLiters(new BigDecimal(0));
-            customerManage.setAmt(new BigDecimal(0));
+//            customerManage.setLiters(new BigDecimal(0));
+//            customerManage.setAmt(new BigDecimal(0));
             Map<String, Object> params = new HashMap<>();
             params.put("openId", openId);                   //注册用户openId
             //params.put("token", token);                     //用户登录凭证
@@ -128,10 +128,10 @@ public class AppUserInfoController {
             }else {
                 appUserInfoService.AddAppUserInfo(appUserInfo);
                 //向客户表中插入数据 判断该客户是否存在
-                CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
-                if(existCustomer ==null){
-                    payOrderService.insertCustomer(customerManage);
-                }
+//                CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
+//                if(existCustomer ==null){
+//                    payOrderService.insertCustomer(customerManage);
+//                }
                 resultData = ResultData.success(CodeMsg.SUCCESS);
             }
         }catch (Exception e){

+ 54 - 8
YijiaRestful/src/main/java/com/platform/yijia/controller/CustomerGradeController.java

@@ -2,7 +2,9 @@ package com.platform.yijia.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
+import com.platform.yijia.pojo.CustomerManage;
 import com.platform.yijia.service.CustomerGradeServices;
+import com.platform.yijia.service.PayOrderService;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
 import org.apache.commons.lang3.StringUtils;
@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,6 +28,9 @@ public class CustomerGradeController {
     @Resource
     private CustomerGradeServices customerGradeServices;
 
+    @Resource
+    private PayOrderService payOrderService;
+
     /*
      * 查询直降客户等级条件和优惠
      * @param stationId
@@ -61,7 +67,8 @@ public class CustomerGradeController {
         params.put("mobilePhone", jsonObject.get("mobilePhone"));
         params.put("stationId", jsonObject.get("stationId"));
         params.put("userType", jsonObject.get("userType"));
-        //params.put("grade", jsonObject.get("grade"));
+        params.put("discountPlanType", jsonObject.get("discountPlanType"));
+        //用户类型
         switch (jsonObject.get("userType").toString()){
             case "1":
                 params.put("blogOpenid", jsonObject.get("openId").toString());
@@ -71,13 +78,52 @@ public class CustomerGradeController {
                 break;
         }
         logger.info("查询客户等级所传参数:"+params.toString());
-        if(jsonObject.get("discountPlanType").toString().equals("直降")){
-            //直降
-            resultData = ResultData.success(customerGradeServices.getCustomerGradeInfo(params));
-        }else {
-            //营销优惠立减 满减
-            params.put("discountPlanType", jsonObject.get("discountPlanType").toString());
-            resultData = ResultData.success(customerGradeServices.getCustomerGradeInfoByYouHui(params));
+
+        CustomerManage customerManage = new CustomerManage();
+        customerManage.setPhoneNumber(params.get("mobilePhone").toString());
+        customerManage.setPhoneNumber(params.get("oilName").toString());
+        customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));
+        CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
+        //如果为空则是此油品第一次下单
+        if(existCustomer ==null){
+            if(jsonObject.get("discountPlanType").toString().equals("直降")){
+                //如果该油站使用是直降
+                List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
+                //只存在一种等级的时候
+                if(customerGradeInfoList !=null && customerGradeInfoList.size() ==1){
+                    resultData = ResultData.success(customerGradeInfoList);
+                }else if(customerGradeInfoList !=null && customerGradeInfoList.size() >1){
+                    //存在多个等级时 查询出结果升序排列取第一个即可
+                    resultData = ResultData.success(customerGradeInfoList.get(0));
+                }
+            }else {
+                //如果该油站使用优惠或者立减
+                List<Map<String, Object>> customerGradeInfoByYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
+                //只存在一个等级时
+                if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() ==1){
+                    resultData = ResultData.success(customerGradeInfoByYouHuiList);
+                }else if(customerGradeInfoByYouHuiList !=null && customerGradeInfoByYouHuiList.size() > 1){
+                    //存在多个等级时 查询出结果升序排列取第一个即可
+                    resultData = ResultData.success(customerGradeInfoByYouHuiList.get(0));
+                }else {
+                    resultData = ResultData.success("该站暂无优惠");
+                }
+            }
+        }else{
+            //否则该客户此油品已下过订单 存在等级
+            String memberGrade = existCustomer.getMemberGrade();
+            if(memberGrade != null && memberGrade !=""){
+                params.put("grade", memberGrade);
+            }
+            if(jsonObject.get("discountPlanType").toString().equals("直降")){
+                //如果该油站使用是直降
+                List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
+                resultData = ResultData.success(customerGradeInfoList);
+            }else {
+                //如果该油站使用优惠或者立减
+                List<Map<String, Object>> customerGradeInfoYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
+                resultData = ResultData.success(customerGradeInfoYouHuiList);
+            }
         }
         return gson.toJson(resultData);
     }

+ 79 - 77
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.CustomerManage;
 import com.platform.yijia.pojo.PayOrder;
 import com.platform.yijia.service.AppUserInfoService;
+import com.platform.yijia.service.CustomerGradeServices;
 import com.platform.yijia.service.PayOrderService;
 import com.platform.yijia.service.StationOilGunService;
 import com.platform.yijia.utils.*;
@@ -32,6 +33,8 @@ public class PayController {
     private AppUserInfoService appUserInfoService;
     @Resource
     private StationOilGunService stationOilGunService;
+    @Resource
+    private CustomerGradeServices customerGradeServices;
 
     /***
      * 微信子商户支付接口
@@ -478,7 +481,7 @@ public class PayController {
                         req.put("msg","修改订单状态成功");
                         logger.info(req.toString());
 
-                        //将用户消费的信息插入顾客表 以手机号 油品名称 油站id为条件插入且存入 加油升数、实收金额、油站名称  根据订单号查询用户手机号
+                        //将用户消费的信息插入顾客表 以手机号 油品名称 油站id为条件插入且存入 加油升数、实收金额、油站名称  根据订单号查询用户手机号
                         Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);   //获取该订单手机号、加油升数、实收金额、油站名称
                         //手机号必须有
                         if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
@@ -527,87 +530,86 @@ public class PayController {
                                     customerManage.setRegtime(blogRegTime);
                                 }
                             }
-                            //第一次判断用户是否存在原因:用户新登录时在向客户表中插入数据时没有油品名称 油站ID 只有手机号
-                            CustomerManage existCustomerNoOilName = payOrderService.isExistCustomer(customerManage);
-                            if(existCustomerNoOilName !=null && existCustomerNoOilName.getOilName() == null){
-                                customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));    //油站ID
-                                customerManage.setOilName(infoMap.get("oilName").toString());    //油品名称
-                                customerManage.setStationName(infoMap.get("stationName").toString());   //存入油站名称
-                                customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
-                                customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
-                                //不存在 新增
-                                //logger.info("不存在客户 新增时参数: " + customerManage.toString());
-                                //只根据手机号更新
-                                payOrderService.updateCustomerByPhoneNumber(customerManage);
-                            }else{
-                                customerManage.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));    //油站ID
-                                customerManage.setOilName(infoMap.get("oilName").toString());    //油品名称
-                                customerManage.setStationName(infoMap.get("stationName").toString());   //存入油站名称
-                                //第二次判断用户是否存在原因:已存在客户信息 此时用户已下过订单 存在油品名称 油站ID
-                                CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
-                                logger.info("查询出客户是否存在数据 null 表示没有" + existCustomer);
-                                //判断该用户是否已存在
-                                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(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());
-                                    //存在 更新
-                                    payOrderService.updateCustomer(customerManage);
-                                }else{
-                                    customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
-                                    customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
-                                    //不存在 新增
-                                    logger.info("不存在客户 新增时参数: " + customerManage.toString());
-                                    payOrderService.insertCustomer(customerManage);
+                            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);
+                            //判断该用户是否已存在
+                            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(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());
 
+                                //用户等级设置 说明:每个油站只存在一种优惠方案。 立减满减在另一张表故作次条件判断,如果该油站没有设置优惠方案则不去存会员等级
+                                List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                                if(customerGradeInfo != null && customerGradeInfo.size() >0){
+                                    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.setMemberId(m.get("id").toString());     //存入等级ID
+                                        }
+                                        break;
+                                    }
+                                }else {
+                                    //立减满减
+                                    List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(infoMap);
+                                    if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){
+                                        for(Map m: customerMarkertPlanList){
+                                            if(Double.valueOf(customerManage.getAmt().toString()) >= Double.valueOf(m.get("discountAmt").toString())){
+                                                customerManage.setGrade(m.get("grade").toString());     //存入等级名称
+                                                customerManage.setMemberId(m.get("id").toString());     //存入等级ID
+                                            }
+                                            break;
+                                        }
+                                    }
+                                }
+                                //存在 更新
+                                payOrderService.updateCustomer(customerManage);
+                            }else{          //该客户不存在时插入
+                                //用户等级设置 说明:每个油站只存在一种优惠方案。立减满减在另一张表故作此条件判断,如果该油站没有设置优惠方案则不去存会员等级
+                                List<Map> customerGradeInfo = customerGradeServices.getCustomerGradeList(infoMap);  //直降
+                                if(customerGradeInfo != null && customerGradeInfo.size() >0){
+                                    for (Map m: customerGradeInfo){
+                                        if(Double.valueOf(infoMap.get("amt").toString()) >= Double.valueOf(m.get("memberConditStart").toString()) && Double.valueOf(infoMap.get("amt").toString()) < Double.valueOf(m.get("memberConditEnd").toString())){
+                                            customerManage.setGrade(m.get("grade").toString());     //存入等级名称
+                                            customerManage.setMemberId(m.get("id").toString());     //存入等级ID
+                                        }
+                                        break;
+                                    }
+                                }else {
+                                    //立减满减
+                                    List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(infoMap);
+                                    if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){
+                                        for(Map m: customerMarkertPlanList){
+                                            if(Double.valueOf(infoMap.get("amt").toString()) >= Double.valueOf(m.get("discountAmt").toString())){
+                                                customerManage.setGrade(m.get("grade").toString());     //存入等级名称
+                                                customerManage.setMemberId(m.get("id").toString());     //存入等级ID
+                                            }
+                                            break;
+                                        }
+                                    }
+                                }
+                                customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
+                                customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
+                                //不存在 新增
+                                logger.info("不存在客户 新增时参数: " + customerManage.toString());
+                                payOrderService.insertCustomer(customerManage);
                             }
 
-//                            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);
-//                            //判断该用户是否已存在
-//                            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(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());
-//                                //存在 更新
-//                                payOrderService.updateCustomer(customerManage);
-//                            }else{
-//                                customerManage.setAmt(BigDecimal.valueOf((Double) infoMap.get("amt")));    //存入金额
-//                                customerManage.setLiters(BigDecimal.valueOf((Double) infoMap.get("orderLiters")));    //存入升数
-//                                //不存在 新增
-//                                logger.info("不存在客户 新增时参数: " + customerManage.toString());
-//                                payOrderService.insertCustomer(customerManage);
-//                            }
-
                             //打印机打印小票
                             String content1;
                             String content2;

+ 2 - 42
YijiaRestful/src/main/java/com/platform/yijia/controller/StationController.java

@@ -34,47 +34,6 @@ public class StationController {
     private AppUserInfoService appUserInfoService;
 
 
-//    /*
-//     * 新增打印机
-//     * @param jsonObject
-//     * @return
-//     */
-//    @RequestMapping(value = "/addprinter", consumes = "application/json", method = RequestMethod.POST)
-//    @ResponseBody
-//    public String addprinter(@RequestBody JSONObject jsonObject){
-//        //提示:打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。
-//        // snlist = "sn1#key1#remark1#carnum1\nsn2#key2#remark2#carnum2";
-//        String snlist = jsonObject.getString("sn")+"#"+jsonObject.getString("key");
-//        return FeiEPrinterUtil.addprinter(snlist);
-//    }
-//
-//    /*
-//     * 班结打印
-//     * @return
-//     */
-//    @RequestMapping(value = "/printClassesSummary")
-//    @ResponseBody
-//    public String printClassesSummary(){
-//        //打印机编号
-//        String sn="921611605";  //测试打印机 sn:921611605 key:72338zma
-//        //打印内容
-//        String content;
-//        content = "<CB>班结小票</CB><BR>";
-//        content += "--------------------------------<BR>";
-//        content += "油品   升数   金额  单数  优惠<BR>";
-//        content += "--------------------------------<BR>";
-//        content += "92#    1.0    1   1.0   20<BR>";
-//        content += "95#  10.0   10  10.0   30<BR>";
-//        content += "--------------------------------<BR>";
-//        content += "合计: 55    350  23     36<BR>";
-//        content += "小票张数:23 张<BR>";
-//        content += "班结金额:350 元<BR>";
-//        content += "优惠总额:36 元<BR>";
-//        content += "实际支付:314 元<BR>";
-//        content += "班结人:莉雅丝<BR>";
-//        return FeiEPrinterUtil.printReceipt(sn, content);
-//    }
-
     /**
      * 根据坐标获取油站列表
      */
@@ -107,9 +66,10 @@ public class StationController {
      */
     @RequestMapping(value = "/getStationList", method = RequestMethod.GET)
     @ResponseBody
-    public String getStationList(@RequestParam StationRequest request){
+    public String getStationList(@RequestParam("appId") String appId){
         Gson gson =new Gson();
         StationInfo stationInfo =new StationInfo();
+        stationInfo.setAppId(appId);
         List<StationInfo> stationInfoList = stationService.getStationList(stationInfo);
         return gson.toJson(stationInfoList);
     }

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

@@ -1,5 +1,7 @@
 package com.platform.yijia.dao;
 
+import com.platform.yijia.pojo.CustomerManage;
+
 import java.util.List;
 import java.util.Map;
 
@@ -8,11 +10,17 @@ public interface CustomerGradeMapper {
     //查询直降
     List<Map> getCustomerGradeList(Map map);
 
+    //查询立减满减
+    List<Map> getCustomerMarkertPlanList(Map map);
+
     //获取客户等级信息
-    Map<String, Object> getCustomerGradeInfo(Map map);
+    List<Map<String, Object>> getCustomerGradeInfo(Map map);
 
     //获取客户优惠等级信息
-    Map<String, Object> getCustomerGradeInfoByYouHui(Map map);
+    List<Map<String, Object>> getCustomerGradeInfoByYouHui(Map map);
+
+    //根据手机号和油站ID判断该用户是否已在客户表
+    List<CustomerManage> isExistCustomerByStationIdAndPhoneNumber(CustomerManage customerManage);
 
     //营销 立减
     List<Map> getMarkertPlanListByDiscountPlanType();

+ 9 - 0
YijiaRestful/src/main/java/com/platform/yijia/param/request/StationRequest.java

@@ -16,6 +16,15 @@ public class StationRequest {
     private Integer pageNum;//当前页
     private String userType;
     private String token;
+    private String appId;       //小程序APPID
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
 
     public String getToken() {
         return token;

+ 11 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/StationInfo.java

@@ -117,6 +117,17 @@ public class StationInfo {
      *
      * @mbg.generated
      */
+
+    private String appId;       //小程序APPID
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
     public Integer getStationId() {
         return stationId;
     }

+ 6 - 1
YijiaRestful/src/main/java/com/platform/yijia/pojo/StationInfoExample.java

@@ -923,6 +923,11 @@ public class StationInfoExample {
             addCriterion("mno not between", value1, value2, "mno");
             return (Criteria) this;
         }
+
+        public Criteria andAppIdEqualTo(String value) {
+            addCriterion("app_id =", value, "appId");
+            return (Criteria) this;
+        }
     }
 
     /**
@@ -1029,4 +1034,4 @@ public class StationInfoExample {
             this(condition, value, secondValue, null);
         }
     }
-}
+}

+ 10 - 2
YijiaRestful/src/main/java/com/platform/yijia/service/CustomerGradeServices.java

@@ -1,6 +1,8 @@
 package com.platform.yijia.service;
 
 
+import com.platform.yijia.pojo.CustomerManage;
+
 import java.util.List;
 import java.util.Map;
 
@@ -10,11 +12,17 @@ public interface CustomerGradeServices {
     //查询直降方式
     List<Map> getCustomerGradeList(Map map);
 
+    //查询立减满减
+    List<Map> getCustomerMarkertPlanList(Map<String, Object> map);
+
     //获取客户等级信息
-    Map<String, Object> getCustomerGradeInfo(Map map);
+    List<Map<String, Object>> getCustomerGradeInfo(Map map);
 
     //获取客户优惠等级信息
-    Map<String, Object> getCustomerGradeInfoByYouHui(Map map);
+    List<Map<String, Object>> getCustomerGradeInfoByYouHui(Map map);
+
+    //根据手机号和油站ID判断该用户是否已在客户表
+    List<CustomerManage> isExistCustomerByStationIdAndPhoneNumber(CustomerManage customerManage);
 
     //立减
     List<Map> getMarkertPlanListByDiscountPlanType();

+ 15 - 2
YijiaRestful/src/main/java/com/platform/yijia/service/impl/CustomerGradeServiceImpl.java

@@ -1,6 +1,7 @@
 package com.platform.yijia.service.impl;
 
 import com.platform.yijia.dao.CustomerGradeMapper;
+import com.platform.yijia.pojo.CustomerManage;
 import com.platform.yijia.service.CustomerGradeServices;
 import org.springframework.stereotype.Service;
 
@@ -21,18 +22,30 @@ public class CustomerGradeServiceImpl implements CustomerGradeServices {
         return customerGradeMapper.getCustomerGradeList(map);
     }
 
+    //查询立减满减
+    @Override
+    public List<Map> getCustomerMarkertPlanList(Map map) {
+        return customerGradeMapper.getCustomerMarkertPlanList(map);
+    }
+
     //查询客户等级信息
     @Override
-    public Map<String, Object> getCustomerGradeInfo(Map map) {
+    public List<Map<String, Object>> getCustomerGradeInfo(Map map) {
         return customerGradeMapper.getCustomerGradeInfo(map);
     }
 
     //获取客户优惠等级信息
     @Override
-    public Map<String, Object> getCustomerGradeInfoByYouHui(Map map) {
+    public List<Map<String, Object>> getCustomerGradeInfoByYouHui(Map map) {
         return customerGradeMapper.getCustomerGradeInfoByYouHui(map);
     }
 
+    //根据手机号和油站ID判断该用户是否已在客户表
+    @Override
+    public List<CustomerManage> isExistCustomerByStationIdAndPhoneNumber(CustomerManage customerManage) {
+        return customerGradeMapper.isExistCustomerByStationIdAndPhoneNumber(customerManage);
+    }
+
     //营销立减
     @Override
     public List<Map> getMarkertPlanListByDiscountPlanType() {

+ 2 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/StationServiceImpl.java

@@ -124,6 +124,8 @@ public class StationServiceImpl implements StationService {
     @Override
     public List<StationInfo> getStationList(StationInfo stationInfo) {
         StationInfoExample example = new StationInfoExample();
+        //example.or().andOrderNoEqualTo(orderNo);
+        example.or().andAppIdEqualTo(stationInfo.getAppId());
         List<StationInfo> stationInfolist = stationInfoMapper.selectByExample(example);
         return stationInfolist;
     }

+ 80 - 2
YijiaRestful/src/main/resources/mapper/CustomerGradeMapper.xml

@@ -2,6 +2,46 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.platform.yijia.dao.CustomerGradeMapper">
 
+    <!--根据油站ID查询该油站会员成长规则-->
+    <select id="customerGrouthRuleByStationId" parameterType="String" resultType="map">
+        SELECT
+            grouth_value_name       AS grouthValueName,
+            grouth_value_consume    AS grouthValueConsume,
+            grouth_value            AS grouthValue
+        FROM
+            customer_grouth_rule
+        <where>
+            <if test="stationId != null and stationId != ''">
+                station_id = #{stationId}
+            </if>
+        </where>
+    </select>
+
+    <!-- 查询立减满减优惠方案 -->
+    <select id="getCustomerMarkertPlanList"  resultType="map" parameterType="map">
+        SELECT
+            id                          AS id,
+            grade                       AS grade,
+            discount_term               AS discountTerm,
+            discount_amt                AS discountAmt,
+            member_condit               AS memberCondit,
+            station_id                  AS stationId,
+            discount_plan_type          AS discountPlanType,
+            station_name                AS stationName,
+            oil_name                    AS oilName
+        FROM customer_grade_setting
+        <where>
+            <if test="stationId != null and stationId != ''">
+                station_id = #{stationId}
+            </if>
+            <if test="oilName != null and oilName != ''">
+                AND oil_name = #{oilName}
+            </if>
+        </where>
+    </select>
+
+
+
   <!-- 查询直降优惠方案 -->
   <select id="getCustomerGradeList"  resultType="map" parameterType="map">
     SELECT
@@ -12,6 +52,8 @@
         gasoil_discount_litre       AS dieseloilDiscountLitre,
         member_condit               AS memberCondit,
         station_id                  AS stationId,
+        member_condit_start         AS memberConditStart,
+        member_condit_end           AS memberConditEnd,
         station_name                AS stationName,
         oil_name                    AS oilName
     FROM customer_grade_setting
@@ -41,7 +83,7 @@
             app_user_info 					AS T1
         LEFT JOIN customer_manage 			AS T2   ON T1.mobile_phone = T2.phone_number
         LEFT JOIN customer_grade_setting 	AS T3   ON T2.station_id = T3.station_id AND T2.oil_name = T3.oil_name
-<!--            <if test="grade !=null and grade != ''"> AND T3.grade = T2.member_grade </if>-->
+            <if test="grade !=null and grade != ''"> AND T3.id = T2.member_grade </if>
         <where>
             <if test="mobilePhone != null and mobilePhone !=''">
                 T1.mobile_phone = #{mobilePhone}
@@ -61,7 +103,11 @@
             <if test="minaOpenid != null and minaOpenid != ''">
                 AND T1.mina_openid = #{minaOpenid}
             </if>
+            <if test="grade != null and grade != ''">
+                AND T3.grade = #{grade}
+            </if>
         </where>
+        ORDER BY T3.gasoil_discount_litre ASC
     </select>
 
 
@@ -82,7 +128,7 @@
             app_user_info 				AS T1
         LEFT JOIN customer_manage 		AS T2   ON T1.mobile_phone = T2.phone_number
         LEFT JOIN markert_plan 	        AS T3   ON T3.station_id = T2.station_id AND T3.oil_name = T2.oil_name
-<!--            <if test="grade !=null and grade != ''"> AND T3.grade = T2.member_grade </if>-->
+            <if test="grade !=null and grade != ''"> AND T3.id = T2.member_grade </if>
         <where>
             <if test="mobilePhone != null and mobilePhone !=''">
                 T1.mobile_phone = #{mobilePhone}
@@ -105,6 +151,38 @@
             <if test="minaOpenid != null and minaOpenid != ''">
                 AND T1.mina_openid = #{minaOpenid}
             </if>
+            <if test="grade != null and grade != ''">
+                AND T3.grade = #{grade}
+            </if>
+        </where>
+        ORDER BY T3.discount_amt ASC
+    </select>
+
+
+    <!-- 判断客户表是否已存在-->
+    <select id="isExistCustomerByStationIdAndPhoneNumber" parameterType="com.platform.yijia.pojo.CustomerManage" resultType="com.platform.yijia.pojo.CustomerManage">
+        SELECT
+            id              AS id,
+            member_id       AS memberId,
+            member_grade    AS memberGrade,
+            phone_number    AS phoneNumber,
+            regtime         AS regtime,
+            station_name    AS stationName,
+            oil_name        AS oilName,
+            liters          AS liters,
+            amt             AS amt
+        FROM
+            customer_manage
+        <where>
+            <if test="phoneNumber !=null and phoneNumber !='' ">
+                phone_number = #{phoneNumber}
+            </if>
+            <if test="stationId !=null and stationId !='' ">
+                AND station_id = #{stationId}
+            </if>
+            <if test="oilName !=null and oilName !='' ">
+                AND oil_name = #{oilName}
+            </if>
         </where>
     </select>
 

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

@@ -18,6 +18,7 @@
     <result column="station_latitude" jdbcType="VARCHAR" property="stationLatitude" />
     <result column="station_pic" jdbcType="VARCHAR" property="stationPic" />
     <result column="mno" jdbcType="INTEGER" property="mno" />
+    <result column="app_id" jdbcType="VARCHAR" property="appId" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.platform.yijia.pojo.StationInfo">
     <!--