jk-GitHub-coder 4 年 前
コミット
00919653fa

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

@@ -5,6 +5,7 @@ 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.service.StationService;
 import com.platform.yijia.utils.CodeMsg;
 import com.platform.yijia.utils.ResultData;
 import org.apache.commons.lang3.StringUtils;
@@ -31,6 +32,9 @@ public class CustomerGradeController {
     @Resource
     private PayOrderService payOrderService;
 
+    @Resource
+    private StationService stationService;
+
     /*
      * 查询直降客户等级条件和优惠
      * @param stationId
@@ -44,7 +48,17 @@ public class CustomerGradeController {
         if(StringUtils.isNotBlank(stationId)){
             Map params = new HashMap();
             params.put("stationId", stationId);
-            resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params));
+            String discountPlanType = stationService.getStationDiscountWay(stationId);
+            if(discountPlanType.equals("1")){
+                //直降表查询
+                List<Map> customerGradeList = customerGradeServices.getCustomerGradeList(params);
+                resultData = ResultData.success(customerGradeList);
+            }else {
+                //立减满减表查询
+                List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params);
+                resultData = ResultData.success(customerMarkertPlanList);
+            }
+//            resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params));
         }else {
             resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
         }
@@ -67,66 +81,68 @@ public class CustomerGradeController {
         params.put("mobilePhone", jsonObject.get("mobilePhone"));
         params.put("stationId", jsonObject.get("stationId"));
         params.put("userType", jsonObject.get("userType"));
-        params.put("discountPlanType", jsonObject.get("discountPlanType"));
-        //用户类型
-        switch (jsonObject.get("userType").toString()){
-            case "1":
-                params.put("blogOpenid", jsonObject.get("openId").toString());
-                break;
-            case "2":
-                params.put("minaOpenid", jsonObject.get("openId").toString());
-                break;
-        }
+//        //用户类型
+//        switch (jsonObject.get("userType").toString()){
+//            case "1":
+//                params.put("blogOpenid", jsonObject.get("openId").toString());
+//                break;
+//            case "2":
+//                params.put("minaOpenid", jsonObject.get("openId").toString());
+//                break;
+//        }
         logger.info("查询客户等级所传参数:"+params.toString());
-
-        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));
+        //优惠方案类型
+        String discountPlanType = stationService.getStationDiscountWay(params.get("stationId").toString());
+        if(discountPlanType != null && discountPlanType !=""){
+            params.put("discountPlanType", discountPlanType);
+            CustomerManage customerManage = new CustomerManage();
+            customerManage.setPhoneNumber(params.get("mobilePhone").toString());
+            customerManage.setOilName(params.get("oilName").toString());
+            customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));
+            CustomerManage existCustomer = payOrderService.isExistCustomer(customerManage);
+            //如果为空则是此油品第一次下单
+            if(existCustomer ==null){
+                if(discountPlanType.equals("1")){
+                    //如果该油站使用是直降
+                    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 {
-                //如果该油站使用优惠或者立减
-                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{
+                //否则该客户此油品已下过订单 存在等级
+                String memberGrade = existCustomer.getMemberGrade();
+                if(memberGrade != null && memberGrade !=""){
+                    params.put("grade", memberGrade);
+                }
+                if(discountPlanType.equals("1")){
+                    //如果该油站使用是直降
+                    List<Map<String, Object>> customerGradeInfoList = customerGradeServices.getCustomerGradeInfo(params);
+                    resultData = ResultData.success(customerGradeInfoList);
                 }else {
-                    resultData = ResultData.success("该站暂无优惠");
+                    //如果该油站使用优惠或者立减
+                    List<Map<String, Object>> customerGradeInfoYouHuiList = customerGradeServices.getCustomerGradeInfoByYouHui(params);
+                    resultData = ResultData.success(customerGradeInfoYouHuiList);
                 }
             }
-        }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);
-            }
+        }else {
+            resultData = ResultData.success("该油站暂无设置优惠方案");
         }
         return gson.toJson(resultData);
     }
 
-
 }

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

@@ -576,6 +576,7 @@ public class PayController {
                                             break;
                                         }
                                     }
+
                                 }
                                 //存在 更新
                                 payOrderService.updateCustomer(customerManage);

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

@@ -39,7 +39,7 @@ public class StationController {
      */
     @RequestMapping(value = "/getStationInfoList", method = RequestMethod.GET)
     @ResponseBody
-     public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize){
+     public String getStationInfoList(@RequestParam String stationLongitude,String stationLatitude,Integer pageNum,Integer pageSize, String appId){
         Gson gson =new Gson();
         //返回结果集
         ResultData resultData=null;
@@ -50,6 +50,7 @@ public class StationController {
                 stationRequest.setStationLongitude(stationLongitude);
                 stationRequest.setPageNum(pageNum);
                 stationRequest.setPageSize(pageSize);
+                stationRequest.setAppId(appId);
                 //调用接口 根据坐标筛选距离最近的加油站
                 StationInfoVo stationInfoVo = stationService.stationInfoList(stationRequest);
                  resultData=ResultData.success(stationInfoVo);
@@ -66,10 +67,9 @@ public class StationController {
      */
     @RequestMapping(value = "/getStationList", method = RequestMethod.GET)
     @ResponseBody
-    public String getStationList(@RequestParam("appId") String appId){
+    public String getStationList(@RequestParam StationRequest request){
         Gson gson =new Gson();
         StationInfo stationInfo =new StationInfo();
-        stationInfo.setAppId(appId);
         List<StationInfo> stationInfoList = stationService.getStationList(stationInfo);
         return gson.toJson(stationInfoList);
     }

+ 5 - 1
YijiaRestful/src/main/java/com/platform/yijia/dao/StationInfoMapper.java

@@ -6,6 +6,10 @@ import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
 public interface StationInfoMapper {
+
+    //获取该油站的优惠方式
+    String getStationDiscountWay(String stationId);
+
     /**
      * This method was generated by MyBatis Generator.
      * This method corresponds to the database table station_info
@@ -117,4 +121,4 @@ public interface StationInfoMapper {
      * @mbg.generated
      */
     int updateByPrimaryKey(StationInfo record);
-}
+}

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/StationService.java

@@ -19,4 +19,7 @@ public interface StationService {
     void updateStationInfo(StationInfo stationInfo);
     //删除油站信息
     void deleteStationInfo(StationInfo stationInfo);
+
+    //获取该油站的优惠方式
+    String getStationDiscountWay(String stationId);
 }

+ 23 - 19
YijiaRestful/src/main/java/com/platform/yijia/service/impl/PayOrderServiceImpl.java

@@ -106,24 +106,28 @@ public class PayOrderServiceImpl implements PayOrderService {
             payOrder.setOrderLiters(String.valueOf(oilLitersCheck));
 
             //获取该油站的某个油品的优惠方案用作校验前台传来数据 要校验字段:实收金额 优惠金额
-            params.put("oilName", payOrderRequest.getOilName());
-            List<Map> gradeList = customerGradeMapper.getCustomerGradeList(params);
-            Double amtCheck =null;      //后台实收金额
-            Double discountAmtCheck = null;     //后台优惠金额
-            if(gradeList !=null && gradeList.size()== 1){
-                //如果优惠方式是直降
-                if(gradeList.get(0).get("discountWay").toString().equals("直降")){
-                    if(gradeList.get(0).containsKey("gasoilDiscountLitre") && gradeList.get(0).get("gasoilDiscountLitre") !=null){
-                        //优惠金额 = 每升优惠价格 x 油升数
-                        discountAmtCheck = new BigDecimal(Double.valueOf(gradeList.get(0).get("gasoilDiscountLitre").toString())).multiply(new BigDecimal(oilLitersCheck)).doubleValue();
-                        // 实收金额 = 应收金额 - 优惠金额
-                        amtCheck = receivableAmt - discountAmtCheck;
-                    }
-                }
-            }
+//            params.put("oilName", payOrderRequest.getOilName());
+//            List<Map> gradeList = customerGradeMapper.getCustomerGradeList(params);
+//            Double amtCheck =null;      //后台实收金额
+//            Double discountAmtCheck = null;     //后台优惠金额
+//            if(gradeList !=null && gradeList.size()== 1){
+//                //如果优惠方式是直降
+//                if(gradeList.get(0).get("discountWay").toString().equals("直降")){
+//                    if(gradeList.get(0).containsKey("gasoilDiscountLitre") && gradeList.get(0).get("gasoilDiscountLitre") !=null){
+//                        //优惠金额 = 每升优惠价格 x 油升数
+//                        BigDecimal b = new BigDecimal(Double.valueOf(gradeList.get(0).get("gasoilDiscountLitre").toString())).multiply(new BigDecimal(oilLitersCheck)).setScale(2, BigDecimal.ROUND_HALF_UP);
+//                        discountAmtCheck = b.doubleValue();
+//                        // 实收金额 = 应收金额 - 优惠金额
+//                        BigDecimal bigDecimal = new BigDecimal(receivableAmt).subtract(new BigDecimal(discountAmtCheck)).setScale(2, BigDecimal.ROUND_HALF_UP);
+//                        //保留俩位小数
+//                        amtCheck = bigDecimal.doubleValue();
+//
+//                    }
+//                }
+//            }
 
             //实收金额 优惠金额
-            if (amtCheck.equals(Double.valueOf(payOrderRequest.getAmt()))  && discountAmtCheck.equals(Double.valueOf(payOrderRequest.getDiscountAmt()))){
+            //if (amtCheck.equals(Double.valueOf(payOrderRequest.getAmt()))  && discountAmtCheck.equals(Double.valueOf(payOrderRequest.getDiscountAmt()))){
                 payOrder.setAmt(Double.valueOf(payOrderRequest.getAmt()));
                 payOrder.setDiscountAmt(payOrderRequest.getDiscountAmt());
                 String oilName = payOrderRequest.getOilName();
@@ -159,9 +163,9 @@ public class PayOrderServiceImpl implements PayOrderService {
                 //返回订单号
                 ordNo= payOrderList.get(0).getOrderNo();
                 return ordNo;
-            }else {
-                return "0";
-            }
+//            }else {
+//                return "0";
+//            }
         }else {
             return "1";
         }

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

@@ -27,6 +27,10 @@ public class StationServiceImpl implements StationService {
          StationInfoExample example=new StationInfoExample();
         if(StringUtils.isNotBlank(stationRequest.getStationName())){
             example.or().andStationNameLike(stationRequest.getStationName());
+
+        }
+        if(StringUtils.isNotBlank(stationRequest.getAppId())){
+            example.or().andAppIdEqualTo(stationRequest.getAppId());
         }
         // 数据库查询门店数据
         List<StationInfo> stationInfolist = stationInfoMapper.selectByExample(example);
@@ -124,8 +128,6 @@ 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;
     }
@@ -159,4 +161,10 @@ public class StationServiceImpl implements StationService {
         stationInfoMapper.deleteByExample(example);
     }
 
+    //获取该油站的优惠方式
+    @Override
+    public String getStationDiscountWay(String stationId) {
+        return stationInfoMapper.getStationDiscountWay(stationId);
+    }
+
 }

+ 4 - 4
YijiaRestful/src/main/resources/mapper/CustomerGradeMapper.xml

@@ -83,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.id = 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}
@@ -104,7 +104,7 @@
                 AND T1.mina_openid = #{minaOpenid}
             </if>
             <if test="grade != null and grade != ''">
-                AND T3.grade = #{grade}
+                AND T3.id = #{grade}
             </if>
         </where>
         ORDER BY T3.gasoil_discount_litre ASC
@@ -128,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.id = 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}
@@ -152,7 +152,7 @@
                 AND T1.mina_openid = #{minaOpenid}
             </if>
             <if test="grade != null and grade != ''">
-                AND T3.grade = #{grade}
+                AND T3.id = #{grade}
             </if>
         </where>
         ORDER BY T3.discount_amt ASC

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

@@ -458,4 +458,18 @@
       mno = #{mno,jdbcType=INTEGER}
     where station_id = #{stationId,jdbcType=INTEGER}
   </update>
+
+  <!--查询油站的优惠方式-->
+  <select id="getStationDiscountWay" parameterType="String" resultType="String">
+    SELECT
+        discount_setting AS discountSetting
+    FROM
+        station_pay
+    <where>
+      <if test="stationId !='' and stationId != null" >
+        station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
 </mapper>