| 
					
				 | 
			
			
				@@ -38,6 +38,8 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PayOrderMapper payOrderMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ElectronicMembershipCardService electronicMembershipCardService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private  CustomerManagerService customerManagerService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //小程序支付生成订单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @RequestMapping(value = "/AddPayOrderInfoNew", consumes = "application/json", method = RequestMethod.POST) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -533,29 +535,14 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             StationOilPrice oilPriceInfo = stationService.getStationOilPrice(stationOilPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String oilPrice = oilPriceInfo.getOilPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //String stationNanme = oilPriceInfo.getStationNanme(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal oilLiters = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal discountAmt =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal oilLiters = new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal discountAmt =new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             BigDecimal discountPrice = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             BigDecimal amt = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //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>(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -577,11 +564,31 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if(!oilLiters.toString().substring(oilLiters.toString().indexOf(".") + 1).equals("00")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(customerGradeInfo.get(0).get("gasoilDiscountLitre") !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            discountAmt = oilLiters.multiply(new BigDecimal(customerGradeInfo.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(customerGradeInfo.get(0).containsKey("gasoilDiscountLitre")){    //表示可以查到客户在当前油站的等级信息,油站等级体系没有删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(customerGradeInfo.get(0).get("gasoilDiscountLitre") !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountAmt = oilLiters.multiply(new BigDecimal(customerGradeInfo.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                discountAmt =new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            discountAmt =new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //如果存在客户等级,但油站修改等级体系,客户等级已超出等级体系时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            List<Map> cList = customerGradeServices.getCustomerGradeListOrderByDesc(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(cList !=null && cList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                CustomerManage customerManage = new CustomerManage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));    //油站ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                customerManage.setOilName(params.get("oilName").toString());                        //油品名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                customerManage.setPhoneNumber(params.get("mobilePhone").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                customerManage.setMinaOpenid(params.get("minaOpenid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                CustomerManage existCustomer = customerManagerService.getCustomerManageInfo(customerManage);         //已存在用户信息 existCustomer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                for(Map m : cList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(Double.valueOf(existCustomer.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = oilLiters.multiply(new BigDecimal(cList.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         amt = receivableAmt_b.subtract(discountAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -903,11 +910,32 @@ public class PayOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(!oilLiters.toString().substring(oilLiters.toString().indexOf(".") + 1).equals("00")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 oilLiters = receivableAmt_b.divide(new BigDecimal(oilPrice),2, BigDecimal.ROUND_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(customerGradeInfo.get(0).get("gasoilDiscountLitre") !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                discountAmt = oilLiters.multiply(new BigDecimal(customerGradeInfo.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(customerGradeInfo.get(0).containsKey("gasoilDiscountLitre")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(customerGradeInfo.get(0).get("gasoilDiscountLitre") !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    discountAmt = oilLiters.multiply(new BigDecimal(customerGradeInfo.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    discountAmt =new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                discountAmt =new BigDecimal("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //如果存在客户等级,但油站修改等级体系,客户等级已超出等级体系时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Map> cList = customerGradeServices.getCustomerGradeListOrderByDesc(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(cList !=null && cList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    CustomerManage customerManage = new CustomerManage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    customerManage.setStationId(Integer.valueOf(params.get("stationId").toString()));    //油站ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    customerManage.setOilName(params.get("oilName").toString());    //油品名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    customerManage.setPhoneNumber(params.get("mobilePhone").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    customerManage.setMinaOpenid(params.get("minaOpenid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    CustomerManage existCustomer = customerManagerService.getCustomerManageInfo(customerManage);         //已存在用户信息 existCustomer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for(Map m : cList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(Double.valueOf(existCustomer.getAmt().toString()) >= Double.valueOf(m.get("memberConditStart").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            discountAmt = oilLiters.multiply(new BigDecimal(cList.get(0).get("gasoilDiscountLitre").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             amt = receivableAmt_b.subtract(discountAmt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? new BigDecimal(oilPrice) : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); 
			 |