| 
					
				 | 
			
			
				@@ -2253,25 +2253,289 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             map.put("stationId", payOrderRequest.getStationId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //获取油站油品价格 优惠方案 是否开启电子卡 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Map<String, Object> resultOilPrice = stationService.selectStationOilPriceAndDiscountSetting(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String oilPrice = resultOilPrice.get("oilPrice").toString();                //油站油品价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            payOrder.setOilPirce(oilPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal divide = new BigDecimal(payOrderRequest.getReceivableAmt()).divide(new BigDecimal(oilPrice), 4, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            payOrder.setOrderLiters(divide.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal oilPrice = new BigDecimal(resultOilPrice.get("oilPrice").toString());                //油站油品价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            payOrder.setOilPirce(resultOilPrice.get("oilPrice").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal orderLiters = new BigDecimal(payOrderRequest.getReceivableAmt()).divide(oilPrice, 4, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            payOrder.setOrderLiters(orderLiters.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(stationInfos.getIsLngFlagGroup() !=null && stationInfos.getIsLngFlagGroup().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //如果是加气站 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 payOrder.setSellAmt(Double.valueOf(payOrderRequest.getReceivableAmt())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 payOrder.setSellDiscountAmt(Double.valueOf("0.00")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                payOrder.setSellOilPrice(Double.valueOf(oilPrice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setSellOilPrice(Double.valueOf(resultOilPrice.get("oilPrice").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 payOrder.setDriverDiscountAmt(Double.valueOf("0.00")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                payOrder.setDriverOilPrice(Double.valueOf(oilPrice)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setDriverOilPrice(Double.valueOf(resultOilPrice.get("oilPrice").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resultMap.put("driverDiscountAmt", "0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resultMap.put("sellDiscountAmt", "0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("discountAmt", "0.00");                                          //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("amt", payOrderRequest.getReceivableAmt());                   //实收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("receivableAmt", payOrderRequest.getReceivableAmt());         //应收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resultMap.put("oilLiters", divide.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultMap.put("oilLiters", orderLiters.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("discountPrice", oilPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal discountPrice = oilPrice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal amt = new BigDecimal(payOrderRequest.getReceivableAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal discountAmt = new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal receivableAmt = new BigDecimal(payOrderRequest.getReceivableAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //表示支付宝支付只走满减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationInfos.getDiscountSetting() !=null && stationInfos.getDiscountSetting().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String ,Object> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("discountPlanType", "1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("stationId", payOrderRequest.getStationId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("oilName", oilName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("discountAmt").toString());                //条件金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("gasoilDiscountAmt").toString());    //享受的优惠 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (receivableAmt.compareTo(discountAmt_b) == 1 || receivableAmt.compareTo(discountAmt_b) == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(gasoilDiscountAmt_b);  //优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //会员活动是否开启:1是;0否' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (customerMarkertPlanList.get(0).containsKey("discountSettingFlag") && customerMarkertPlanList.get(0).get("discountSettingFlag").toString() != "") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            String discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (discountSettingFlag != null && discountSettingFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountType = customerMarkertPlanList.get(0).get("discountType").toString();    //会员日周期类型设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString();    //按固定日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString();  //会员日优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //当前时间是否是会员日 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    boolean b = isActivityDay(discountType, discountDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if (b) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(discountActivityAmt));  //优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt = receivableAmt.subtract(discountAmt);  //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt = amt.toString().equals("0.00") ? new BigDecimal("0.01") : amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt = amt.signum() == -1 ? new BigDecimal("0.01") : amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountPrice = orderLiters.equals(new BigDecimal("0.0000")) ? discountPrice : amt.divide(orderLiters, 2, BigDecimal.ROUND_HALF_UP);  //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountPrice = discountPrice.compareTo(oilPrice) == 1 ? oilPrice : discountPrice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setAmt(Double.valueOf(amt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setDiscountAmt(Double.valueOf(discountAmt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountAmt", discountAmt.toString());    //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("amt", amt.toString());                   //实收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountPrice", discountPrice.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //表示支付宝支付只走立减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationInfos.getDiscountSetting() !=null && stationInfos.getDiscountSetting().equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String ,Object> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("discountPlanType", "2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("stationId", payOrderRequest.getStationId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("oilName", oilName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("discountAmt").toString());                //条件金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("gasoilDiscountAmt").toString());    //享受的优惠 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(receivableAmt.compareTo(discountAmt_b) == 1 || receivableAmt.compareTo(discountAmt_b) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(gasoilDiscountAmt_b);  //优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //会员活动是否开启:1是;0否' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(customerMarkertPlanList.get(0).containsKey("discountSettingFlag") && customerMarkertPlanList.get(0).get("discountSettingFlag").toString() !=""){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            String discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(discountSettingFlag !=null && discountSettingFlag.equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountType = customerMarkertPlanList.get(0).get("discountType").toString();    //会员日周期类型设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString();    //按固定日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString();  //会员日优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //当前时间是否是会员日 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    boolean b = isActivityDay(discountType, discountDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(b){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(discountActivityAmt));  //优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt = receivableAmt.subtract(discountAmt);  //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt = amt.toString().equals("0.00") ? new BigDecimal("0.01") : amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        amt =amt.signum() == -1 ? new BigDecimal("0.01"): amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountPrice = orderLiters.equals(new BigDecimal("0.0000")) ? discountPrice : amt.divide(orderLiters, 2, BigDecimal.ROUND_HALF_UP);  //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        discountPrice =discountPrice.compareTo(oilPrice) == 1 ? oilPrice : discountPrice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setAmt(Double.valueOf(amt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setDiscountAmt(Double.valueOf(discountAmt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountAmt", discountAmt.toString());    //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("amt", amt.toString());                   //实收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountPrice", discountPrice.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //表示支付宝支付只走直降 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationInfos.getDiscountSetting() !=null && stationInfos.getDiscountSetting().equals("3")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //只有直降 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String ,Object> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("discountPlanType", "3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("stationId", payOrderRequest.getStationId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("oilName", oilName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("discountAmt").toString());   //条件金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("gasoilDiscountAmt").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String discountTerm = customerMarkertPlanList.get(0).get("discountTerm").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String discountSettingFlag; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    switch (discountTerm){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        case "1":   //按照加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(orderLiters.compareTo(discountAmt_b) == 1 || orderLiters.compareTo(discountAmt_b) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountPrice = oilPrice.subtract(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(discountPrice.compareTo(oilPrice) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = new BigDecimal(payOrderRequest.getReceivableAmt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //会员活动是否开启:1是;0否' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(customerMarkertPlanList.get(0).containsKey("discountSettingFlag") && customerMarkertPlanList.get(0).get("discountSettingFlag").toString() !="") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if (discountSettingFlag != null && discountSettingFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountType = customerMarkertPlanList.get(0).get("discountType").toString();    //会员日周期类型设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString();    //按固定日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString();  //会员日优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if (StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            //当前时间是否是活动会员日 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            boolean b = isActivityDay(discountType, discountDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            if (b) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                discountPrice = oilPrice.subtract(new BigDecimal(discountActivityAmt)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                if(discountPrice.compareTo(oilPrice) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    amt = amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = discountAmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //discountAmt = oilLiters.multiply(new BigDecimal(discountActivityAmt)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        case "2":   //按照加油金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(receivableAmt.compareTo(discountAmt_b) ==1 || receivableAmt.compareTo(discountAmt_b) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountPrice = oilPrice.subtract(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(discountPrice.compareTo(oilPrice) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = receivableAmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //会员活动是否开启:1是;0否' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(customerMarkertPlanList.get(0).containsKey("discountSettingFlag") && customerMarkertPlanList.get(0).get("discountSettingFlag").toString() !="") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if (discountSettingFlag != null && discountSettingFlag.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountType = customerMarkertPlanList.get(0).get("discountType").toString();    //会员日周期类型设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString();    //按固定日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString();  //会员日优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if (StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            //当前时间是否是活动会员日 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            boolean b = isActivityDay(discountType, discountDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            if (b) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                discountPrice = oilPrice.subtract(new BigDecimal(discountActivityAmt)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                if(discountPrice.compareTo(oilPrice) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    amt = amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = discountAmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //discountAmt = oilLiters.multiply(new BigDecimal(discountActivityAmt)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                amt = amt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(amt.toString().equals("0.00")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    amt = new BigDecimal("0.01"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                amt =amt.signum() == -1 ? new BigDecimal("0.01"): amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setAmt(Double.valueOf(amt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setDiscountAmt(Double.valueOf(discountAmt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountAmt", discountAmt.toString());    //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("amt", amt.toString());                   //实收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountPrice", discountPrice.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //表示支付宝支付只走阶梯 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationInfos.getDiscountSetting() !=null && stationInfos.getDiscountSetting().equals("4")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String ,Object> params = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("discountPlanType", "4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("stationId", payOrderRequest.getStationId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                params.put("oilName", oilName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for(Map m : customerMarkertPlanList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal discountAmt_b = new BigDecimal(m.get("discountAmt").toString());   //条件金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal gasoilDiscountAmt_b = new BigDecimal(m.get("gasoilDiscountAmt").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String discountTerm = m.get("discountTerm").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(discountTerm.equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(orderLiters.compareTo(discountAmt_b) ==1 || orderLiters.compareTo(discountAmt_b) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountPrice = oilPrice.subtract(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(discountPrice.compareTo(oilPrice) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = receivableAmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    //discountAmt = oilLiters.multiply(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }else if(discountTerm.equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(receivableAmt.compareTo(discountAmt_b) ==1 || receivableAmt.compareTo(discountAmt_b) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountPrice = oilPrice.subtract(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(discountPrice.compareTo(oilPrice) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = receivableAmt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    amt = discountPrice.multiply(orderLiters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = receivableAmt.subtract(amt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    //discountAmt = oilLiters.multiply(gasoilDiscountAmt_b); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //amt = receivableAmt.subtract(discountAmt);  //应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                amt = amt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(amt.toString().equals("0.00")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    amt = new BigDecimal("0.01"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                amt =amt.signum() == -1 ? new BigDecimal("0.01"): amt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setAmt(Double.valueOf(amt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                payOrder.setDiscountAmt(Double.valueOf(discountAmt.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountAmt", discountAmt.toString());    //优惠价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("amt", amt.toString());                   //实收价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("discountPrice", discountPrice.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //返回订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("ordNo", ordNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //表示为一人一码:一个加油员一个码 
			 |