jk-GitHub-coder 4 년 전
부모
커밋
416c6b6699

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

@@ -337,7 +337,7 @@ public class ElectronicMembershipCardController {
                     balance = cardInfo.getAmt();
                 }
                 //判断订单金额是否小于电子会员卡的余额
-                if(balance !=null && customerCardUseRecord.getAmt().compareTo(balance) == -1){
+                if(balance !=null && customerCardUseRecord.getAmt().compareTo(balance) == -1 || customerCardUseRecord.getAmt().compareTo(balance) ==0){
                     electronicMembershipCardService.insetCardUseRecordConsumption(customerCardUseRecord);
                     //更新电子会员卡余额
                     CustomerElectronicCard c = new CustomerElectronicCard();
@@ -1269,6 +1269,7 @@ public class ElectronicMembershipCardController {
                 //用户已累积积分
                 BigDecimal add = new BigDecimal(customerPointsInfo.getAccumulatePoints()).add(new BigDecimal(integral));
                 customerPoints.setAccumulatePoints(add.intValue());
+                customerPoints.setRecentConsumptionDate(new Date());
                 //更新客户积分
                 customerPointsService.updateCustomerPointsInfo(customerPoints);
                 logger.info("更新客户积分信息成功!");
@@ -1315,6 +1316,7 @@ public class ElectronicMembershipCardController {
                 customerPoints.setStationName(stationName);
                 customerPoints.setAccumulatePoints(integral);
                 customerPoints.setInvalidPoints(0);
+                customerPoints.setRecentConsumptionDate(new Date());
                 customerPoints.setCreateTime(new Date());
                 //新增客户积分
                 customerPointsService.insertCustomerPointsInfo(customerPoints);

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

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

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

@@ -1147,6 +1147,7 @@ public class PayController {
                 //用户已累积积分
                 BigDecimal add = new BigDecimal(customerPointsInfo.getAccumulatePoints()).add(new BigDecimal(integral));
                 customerPoints.setAccumulatePoints(add.intValue());
+                customerPoints.setRecentConsumptionDate(new Date());
                 //更新客户积分
                 customerPointsService.updateCustomerPointsInfo(customerPoints);
                 logger.info("更新客户积分信息成功!");
@@ -1193,6 +1194,7 @@ public class PayController {
                 customerPoints.setStationName(stationName);
                 customerPoints.setAccumulatePoints(integral);
                 customerPoints.setInvalidPoints(0);
+                customerPoints.setRecentConsumptionDate(new Date());
                 customerPoints.setCreateTime(new Date());
                 //新增客户积分
                 customerPointsService.insertCustomerPointsInfo(customerPoints);

+ 176 - 59
YijiaRestful/src/main/java/com/platform/yijia/controller/PayOrderController.java

@@ -271,13 +271,13 @@ public class PayOrderController {
         CustomerElectronicCard electronicCardInfo = electronicMembershipCardService.getElectronicCardInfoByUnionId(customerElectronicCard);
         BigDecimal balance = null;
         String cardOilsType1 ="";
+        Map<String, String> result = new HashMap<>();
         if(electronicCardInfo !=null){
             balance = electronicCardInfo.getAmt();
             cardOilsType1 = electronicCardInfo.getCardOilsType();
+            result.put("balance",balance.toString());
+            result.put("cardOilsType",cardOilsType1);
         }
-        Map<String, String> result = new HashMap<>();
-        result.put("balance",balance.toString());
-        result.put("cardOilsType",cardOilsType1);
         return result;
     }
 
@@ -521,6 +521,7 @@ public class PayOrderController {
         if(payOrderRequest.getReceivableAmt() !=null){  //应收金额
             Double receivableAmt = payOrderRequest.getReceivableAmt();  //应收金额 用户输入的金额
             Integer stationId = payOrderRequest.getStationId();         //油站ID
+
             //String oilGun = payOrderRequest.getOilGun();                //油枪号
             String oilName = payOrderRequest.getOilName();          //油品名称
             String openId = payOrderRequest.getOpenId();        //用户的openId
@@ -540,6 +541,21 @@ public class PayOrderController {
             //resultMap.put("stationName", stationNanme);
             resultMap.put("oilPrice", oilPrice);        //油品价格
             resultMap.put("receivableAmt", receivableAmt);        //应收价格
+//            String isGradeSetting ="";  //电子卡是否开启等级
+//            String isMarket ="";        //
+//            StationPayManage stationPayManage = new StationPayManage();
+//            stationPayManage.setStationId(stationId);
+//            StationPayManage stationPayManageInfo = stationService.selectStationPayManage(stationPayManage);    //换取油站配置信息
+//            //是否开起电子卡功能
+//            if(stationPayManageInfo !=null && stationPayManageInfo.getCardEnabledFlag().equals("1")){
+//                CustomerCardSetting customerCardSetting = new CustomerCardSetting();
+//                customerCardSetting.setStationId(stationId);
+//                List<CustomerCardSetting> cardRechargeSettingList = electronicMembershipCardService.getCardRechargeSettingList(customerCardSetting);
+//                if(cardRechargeSettingList !=null && cardRechargeSettingList.size() >0){
+//                    isGradeSetting = cardRechargeSettingList.get(0).getIsGradeSetting();
+//                    isMarket = cardRechargeSettingList.get(0).getIsMarket();
+//                }
+//            }
             //该油站的优惠方式
             String stationDiscountWay = stationService.getStationDiscountWay(stationId.toString());
             Map<String ,Object> params = new HashMap<String, Object>();
@@ -566,7 +582,6 @@ public class PayOrderController {
                         }
                         amt = receivableAmt_b.subtract(discountAmt);
                         discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                        //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
                         resultMap.put("discountAmt", discountAmt.doubleValue());
                         resultMap.put("amt", amt.doubleValue());
                         resultMap.put("oilLiters", oilLiters.doubleValue());
@@ -585,11 +600,8 @@ public class PayOrderController {
                             }else {
                                 discountAmt =new BigDecimal("0.00");
                             }
-//                            discountAmt = oilLiters.multiply(new BigDecimal(customerGradeList.get(0).get("gasoilDiscountLitre").toString()));
-//                            discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
                             amt = receivableAmt_b.subtract(discountAmt);
                             discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                            //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
                             resultMap.put("discountAmt", discountAmt.doubleValue());
                             resultMap.put("amt", amt.doubleValue());
                             resultMap.put("oilLiters", oilLiters.doubleValue());
@@ -673,9 +685,9 @@ public class PayOrderController {
                     params.put("discountPlanType", "2");
                     //营销方案
                     List<Map> customerMarkertPlanList_2 = customerGradeServices.getCustomerMarkertPlanList(params);
-                    //是否共享会员优惠叠加: 1 代表是; 2 代表否;
-                    String vipDiscountyPlus = customerMarkertPlanList_2.get(0).get("vipDiscountyPlus").toString();
                     if(customerMarkertPlanList_2 !=null && customerMarkertPlanList_2.size() >0){
+                        //是否共享会员优惠叠加: 1 代表是; 2 代表否;
+                        String vipDiscountyPlus = customerMarkertPlanList_2.get(0).get("vipDiscountyPlus").toString();
                         //如果当前应收金额大于条件金额
                         BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_2.get(0).get("discountAmt").toString());   //条件金额
                         if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
@@ -684,7 +696,6 @@ public class PayOrderController {
                             amt = receivableAmt_b.subtract(gasoilDiscountAmt_b);   //实收金额
                             oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP);   //加油升数
                             discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                            //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);        //优惠价格
                             switch (vipDiscountyPlus){
                                 case "1":
                                     Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
@@ -741,71 +752,98 @@ public class PayOrderController {
                     //营销方案
                     List<Map> customerMarkertPlanList_3 = customerGradeServices.getCustomerMarkertPlanList(params);
                     if(customerMarkertPlanList_3 !=null && customerMarkertPlanList_3.size() >0){
-                        boolean flag= true;
-                        //独立直降时会存在多条
-                        for(Map m : customerMarkertPlanList_3){
-                            BigDecimal discountAmt_b = new BigDecimal(m.get("discountAmt").toString());   //条件金额
-                            BigDecimal gasoilDiscountAmt_b = new BigDecimal(m.get("gasoilDiscountAmt").toString());
-                            oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP);   //加油升数
-                            if(m.get("discountTerm").toString().equals("1")){   //按升数优惠
-                                if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
-                                    //计算
-                                    discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
-                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
+                        //是否共享会员优惠叠加: 1 代表是; 2 代表否;
+                        String vipDiscountyPlus_4 = customerMarkertPlanList_3.get(0).get("vipDiscountyPlus").toString();
+                        BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_3.get(0).get("discountAmt").toString());   //条件金额
+                        BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList_3.get(0).get("gasoilDiscountAmt").toString());
+                        oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice), 2, BigDecimal.ROUND_HALF_UP);   //加油升数
+                        if(customerMarkertPlanList_3.get(0).get("discountTerm").toString().equals("1")){   //按升数优惠
+                            if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
+                                //计算
+                                discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
+                                discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
+                                amt = receivableAmt_b.subtract(discountAmt);
+                                discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                                //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);        //优惠价格
+
+                                if(vipDiscountyPlus_4.equals("1")){
+                                    Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
+                                    discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
                                     amt = receivableAmt_b.subtract(discountAmt);
                                     discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                                    //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);        //优惠价格
-                                    //是否共享会员优惠叠加
-                                    String vipDiscountyPlus_3 = m.get("vipDiscountyPlus").toString();
-                                    if(vipDiscountyPlus_3.equals("1")){
+                                    //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                                }
+                                resultMap.put("discountAmt", discountAmt.doubleValue());
+                                resultMap.put("amt", amt.doubleValue());
+                                resultMap.put("oilLiters", oilLiters.doubleValue());
+                                resultMap.put("discountPrice", discountPrice.doubleValue());
+                                break;
+                            }else {
+                                //不满足优惠条件
+                                switch (vipDiscountyPlus_4) {
+                                    case "1":
                                         Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
                                         discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
                                         amt = receivableAmt_b.subtract(discountAmt);
                                         discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                                        //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                                    }
-                                    resultMap.put("discountAmt", discountAmt.doubleValue());
-                                    resultMap.put("amt", amt.doubleValue());
-                                    resultMap.put("oilLiters", oilLiters.doubleValue());
-                                    resultMap.put("discountPrice", discountPrice.doubleValue());
-                                    flag =false;
-                                    break;
+                                        resultMap.put("discountAmt", discountAmt.doubleValue());
+                                        resultMap.put("amt", amt.doubleValue());
+                                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                                        resultMap.put("discountPrice", discountPrice.doubleValue());
+                                        break;
+                                    case "2":
+                                        resultMap.put("discountAmt", 0);
+                                        resultMap.put("amt", receivableAmt.doubleValue());
+                                        oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP);   //加油升数
+                                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                                        resultMap.put("discountPrice", oilPrice);
+                                        break;
                                 }
-                            }else if(m.get("discountTerm").toString().equals("2")){     //按金额优惠
-                                if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
-                                    discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
-                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
+                            }
+                        }else if(customerMarkertPlanList_3.get(0).get("discountTerm").toString().equals("2")){     //按金额优惠
+                            if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
+                                discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
+                                discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
+                                amt = receivableAmt_b.subtract(discountAmt);
+                                discountPrice = oilLiters !=new BigDecimal("0.00") ? amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP) : new BigDecimal(oilPrice);
+                                //是否共享会员优惠叠加
+                                if(vipDiscountyPlus_4.equals("1")){
+                                    Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
+                                    discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
                                     amt = receivableAmt_b.subtract(discountAmt);
-                                    discountPrice = oilLiters !=new BigDecimal("0.00") ? amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP) : new BigDecimal(oilPrice);
-                                    //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);        //优惠价格
-                                    //是否共享会员优惠叠加
-                                    String vipDiscountyPlus_3 = m.get("vipDiscountyPlus").toString();
-                                    if(vipDiscountyPlus_3.equals("1")){
+                                    discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                                    //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                                }
+                                resultMap.put("discountAmt", discountAmt.doubleValue());
+                                resultMap.put("amt", amt.doubleValue());
+                                resultMap.put("oilLiters", oilLiters.doubleValue());
+                                resultMap.put("discountPrice", discountPrice.doubleValue());
+                                break;
+                            }else {
+                                //不满足优惠条件
+                                switch (vipDiscountyPlus_4) {
+                                    case "1":
                                         Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
                                         discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
                                         amt = receivableAmt_b.subtract(discountAmt);
                                         discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                                        //discountPrice = amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
-                                    }
-                                    resultMap.put("discountAmt", discountAmt.doubleValue());
-                                    resultMap.put("amt", amt.doubleValue());
-                                    resultMap.put("oilLiters", oilLiters.doubleValue());
-                                    resultMap.put("discountPrice", discountPrice.doubleValue());
-                                    flag =false;
-                                    break;
+                                        resultMap.put("discountAmt", discountAmt.doubleValue());
+                                        resultMap.put("amt", amt.doubleValue());
+                                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                                        resultMap.put("discountPrice", discountPrice.doubleValue());
+                                        break;
+                                    case "2":
+                                        resultMap.put("discountAmt", 0);
+                                        resultMap.put("amt", receivableAmt.doubleValue());
+                                        oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP);   //加油升数
+                                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                                        resultMap.put("discountPrice", oilPrice);
+                                        break;
                                 }
                             }
                         }
-                        //如果用户加油金额都不符合优惠门槛则计算等级的优惠
-                        if(flag){
-                            Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
-                            resultMap.put("discountAmt", map.get("discountAmt").toString());
-                            resultMap.put("amt", map.get("amt").toString());
-                            resultMap.put("oilLiters", map.get("oilLiters").toString());
-                            resultMap.put("discountPrice", map.get("discountPrice").toString());
-                        }
                     }else {
-                        //用户没有设置优惠规则
+                        //没有设置优惠条件时
                         Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
                         resultMap.put("discountAmt", map.get("discountAmt").toString());
                         resultMap.put("amt", map.get("amt").toString());
@@ -818,6 +856,9 @@ public class PayOrderController {
         return resultMap;
     }
 
+    //计算
+
+
     //计算等级直降
     public  Map<String, Object> calcuteDengJiZhiJiang(Map params){
         Double receivableAmt = Double.valueOf(params.get("receivableAmt").toString());
@@ -877,6 +918,82 @@ public class PayOrderController {
         return resultMap;
     }
 
+    //计算满减
+    public Map<String, Object> calcuteManjian(Map params){
+        Map<String, Object> resultMap = new HashMap<>();
+        Double receivableAmt = Double.valueOf(params.get("receivableAmt").toString());
+        BigDecimal oilLiters = null;
+        BigDecimal discountAmt =null;
+        BigDecimal discountPrice = null;
+        BigDecimal amt = null;
+        BigDecimal receivableAmt_b = new BigDecimal(receivableAmt); //传入的应收金额
+        String oilPrice = params.get("oilPrice").toString();
+        params.put("discountPlanType", "1");
+        //营销方案
+        List<Map> customerMarkertPlanList_1 = customerGradeServices.getCustomerMarkertPlanList(params);
+        //有优惠规则
+        if(customerMarkertPlanList_1 !=null && customerMarkertPlanList_1.size() >0){
+            //是否共享会员优惠叠加: 1 代表是; 2 代表否;
+            String vipDiscountyPlus = customerMarkertPlanList_1.get(0).get("vipDiscountyPlus").toString();
+            //如果当前应收金额大于条件金额
+            BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList_1.get(0).get("discountAmt").toString());   //条件金额
+            if(receivableAmt_b.compareTo(discountAmt_b) ==1 || receivableAmt_b.compareTo(discountAmt_b) ==0){
+                BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList_1.get(0).get("gasoilDiscountAmt").toString());   //每满多少优惠多少的金额
+                discountAmt = receivableAmt_b.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(gasoilDiscountAmt_b);  //优惠金额
+                discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
+                amt = receivableAmt_b.subtract(discountAmt);   //实收金额
+                oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP);   //加油升数
+                discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                switch (vipDiscountyPlus){
+                    case "1":
+                        Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
+                        discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
+                        amt = receivableAmt_b.subtract(discountAmt);
+                        discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                        resultMap.put("discountAmt", discountAmt.doubleValue());
+                        resultMap.put("amt", amt.doubleValue());
+                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                        resultMap.put("discountPrice", discountPrice.doubleValue());
+                        break;
+                    case "2":
+                        resultMap.put("discountAmt", discountAmt.doubleValue());
+                        resultMap.put("amt", amt.doubleValue());
+                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                        resultMap.put("discountPrice", discountPrice.doubleValue());
+                        break;
+                }
+            }else{
+                switch (vipDiscountyPlus){
+                    case "1":
+                        Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
+                        discountAmt = discountAmt.add(new BigDecimal(map.get("discountAmt").toString()));
+                        amt = receivableAmt_b.subtract(discountAmt);
+                        discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+                        resultMap.put("discountAmt", discountAmt.doubleValue());
+                        resultMap.put("amt", amt.doubleValue());
+                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                        resultMap.put("discountPrice", discountPrice.doubleValue());
+                        break;
+                    case "2":
+                        resultMap.put("discountAmt", 0);
+                        resultMap.put("amt", receivableAmt.doubleValue());
+                        oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_HALF_UP);   //加油升数
+                        resultMap.put("oilLiters", oilLiters.doubleValue());
+                        resultMap.put("discountPrice", oilPrice);
+                        break;
+                }
+            }
+        }else {
+            //用户没有设置优惠规则时
+            Map<String, Object> map = this.calcuteDengJiZhiJiang(params);
+            resultMap.put("discountAmt", map.get("discountAmt").toString());
+            resultMap.put("amt", map.get("amt").toString());
+            resultMap.put("oilLiters", map.get("oilLiters").toString());
+            resultMap.put("discountPrice", map.get("discountPrice").toString());
+        }
+
+        return  resultMap;
+    };
 
     /**
      * 根据订单号获取订单信息

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

@@ -122,8 +122,7 @@
         FROM
             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>-->
+        LEFT JOIN customer_grade_setting 	AS T3   ON T2.station_id = T3.station_id AND T2.oil_name = T3.oil_name AND T3.id = T2.member_grade
         <where>
             <if test="mobilePhone != null and mobilePhone !=''">
                 T1.mobile_phone = #{mobilePhone}