| 
					
				 | 
			
			
				@@ -667,141 +667,157 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 payOrderService.insertCustomer(customerManage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //==========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            //客户积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            IntegralRule integralRule  =new IntegralRule(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            integralRule.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //计算积分并推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            CalculateIntegral calculateIntegral = new CalculateIntegral(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            calculateIntegral.setOpenId(infoMap.get("minaOpenid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            calculateIntegral.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            calculateIntegral.setAmt(new BigDecimal(infoMap.get("amt").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                integralRule.setOilName(infoMap.get("oilName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                integralRule.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                calculateIntegral.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                calculateIntegral.setOilName(infoMap.get("oilName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                calculateIntegral.setOilLiters(new BigDecimal(infoMap.get("orderLiters").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             }else if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                integralRule.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                calculateIntegral.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //计算积分并推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            this.calculateIntegralAndPushIntegral(calculateIntegral); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            //获取该油站的积分规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            integralRule.setEmptyDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            List<IntegralRule> rule = integralRuleService.getIntegralRule(integralRule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            logger.info("当前油站油品的积分规则:" + rule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if(rule !=null && rule.size() > 0 && rule.get(0).getEmptyDate().compareTo(new Date()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                CustomerPoints customerPoints = new CustomerPoints();       //客户积分实体表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();     //客户积分记录实体表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(infoMap.containsKey("unionId")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    customerPoints.setUnionId(infoMap.get("unionId").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    customerPointsRecord.setUnionId(infoMap.get("unionId").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPoints.setCustomerName(infoMap.get("consumer").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPoints.setMobilePhone(infoMap.get("mobilePhone").toString());   //存入手机号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPoints.setStationName(infoMap.get("stationName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPoints.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPointsRecord.setCustomerName(infoMap.get("consumer").toString());       //客户名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPointsRecord.setRecordType("+");            // "+"表示增加积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPointsRecord.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPointsRecord.setStationName(infoMap.get("stationName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                customerPointsRecord.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                //获取该用户积分信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(customerPointsInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //String ruleType = rule.get(0).getRuleType();   //获取积分规则类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    String[] datePicker={};     //积分比例时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    if(rule.get(0).getDatePicker() != null && rule.get(0).getDatePicker() !=""){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        if(rule.get(0).getDatePicker().contains(",")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            datePicker = rule.get(0).getDatePicker().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            datePicker= new String[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            datePicker[0] = rule.get(0).getDatePicker(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    List<IntegralRuleDetail> integralRuleDetailList = rule.get(0).getIntegralRuleDetailList();  //积分规则详细计算信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    if(integralRuleDetailList !=null && integralRuleDetailList.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        BigDecimal orderLiters = null;  //本次加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            orderLiters = new BigDecimal(infoMap.get("orderLiters").toString());    //本次加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        //循环规则明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            if(integralRuleDetail.getOilType().equals("1")){    //油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                //规则类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                logger.info("当前生成积分类型:油品"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                String ruleType = integralRuleDetail.getRuleType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                logger.info("当前油品规则类型ruleType: " + ruleType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                if(ruleType !=null && ruleType.equals("1") && realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1 || realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    //以实收金额为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    logger.info("以实收金额为准时"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                }else if(ruleType !=null && ruleType.equals("2") && receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1 || receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    //应收金额为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    logger.info("应收金额为准"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (receivableAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (receivableAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                }else if(ruleType !=null && ruleType.equals("3") && orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1 || orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    //加油升数为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    logger.info("加油升数为准"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (orderLiters, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        countIntegral (orderLiters, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    customerPoints.setPoints(customerPointsInfo.getPoints()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    customerPoints.setAccumulatePoints(customerPointsInfo.getPoints()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                    customerPointsRecord.setIntegral(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            }else if(integralRuleDetail.getOilType().equals("2")){ //非油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                logger.info("当前生成积分类型:非油品"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    logger.info("客户积分customerPoints:"+ customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    logger.info("客户积分记录customerPointsRecord:"+ customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //更新客户余额积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    customerPointsService.updateCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //插入客户积分记录表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //客户公众号积分增加通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //customerPoints.getBlogOpenId() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    //weiXinPushIntegralInfo(infoMap.get("stationId").toString(), infoMap.get("consumer").toString(), customerPointsRecord.getIntegral().toString(), customerPoints.getPoints().toString(), customerPoints.getBlogOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                   CustomerPoints m = new CustomerPoints(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                   m.setUnionId(customerPoints.getUnionId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                   CustomerPoints cus = customerPointsService.getCustomerPointsInfo(m); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                   if(cus.getBlogOpenId() !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                       //公众号积分消息推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                     this.weiXinPushIntegralInfo(cus.getStationId().toString(), cus.getCustomerName(), customerPointsRecord.getIntegral().toString(), cus.getPoints().toString(), cus.getBlogOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //客户积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            IntegralRule integralRule  =new IntegralRule(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            integralRule.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                integralRule.setOilName(infoMap.get("oilName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                integralRule.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            }else if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                integralRule.setOilType(infoMap.get("orderType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            //获取该油站的积分规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            integralRule.setEmptyDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            List<IntegralRule> rule = integralRuleService.getIntegralRule(integralRule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            logger.info("当前油站油品的积分规则:" + rule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            if(rule !=null && rule.size() > 0 && rule.get(0).getEmptyDate().compareTo(new Date()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                CustomerPoints customerPoints = new CustomerPoints();       //客户积分实体表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();     //客户积分记录实体表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                if(infoMap.containsKey("unionId")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    customerPoints.setUnionId(infoMap.get("unionId").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    customerPointsRecord.setUnionId(infoMap.get("unionId").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPoints.setCustomerName(infoMap.get("consumer").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPoints.setMobilePhone(infoMap.get("mobilePhone").toString());   //存入手机号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPoints.setStationName(infoMap.get("stationName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPoints.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPointsRecord.setCustomerName(infoMap.get("consumer").toString());       //客户名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPointsRecord.setRecordType("+");            // "+"表示增加积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPointsRecord.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPointsRecord.setStationName(infoMap.get("stationName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                customerPointsRecord.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                //获取该用户积分信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                if(customerPointsInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //String ruleType = rule.get(0).getRuleType();   //获取积分规则类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    String[] datePicker={};     //积分比例时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    if(rule.get(0).getDatePicker() != null && rule.get(0).getDatePicker() !=""){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        if(rule.get(0).getDatePicker().contains(",")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            datePicker = rule.get(0).getDatePicker().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            datePicker= new String[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            datePicker[0] = rule.get(0).getDatePicker(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    List<IntegralRuleDetail> integralRuleDetailList = rule.get(0).getIntegralRuleDetailList();  //积分规则详细计算信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    if(integralRuleDetailList !=null && integralRuleDetailList.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        BigDecimal orderLiters = null;  //本次加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        if(infoMap.containsKey("orderType") && infoMap.get("orderType").toString().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            orderLiters = new BigDecimal(infoMap.get("orderLiters").toString());    //本次加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        //循环规则明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            if(integralRuleDetail.getOilType().equals("1")){    //油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                //规则类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                logger.info("当前生成积分类型:油品"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                String ruleType = integralRuleDetail.getRuleType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                logger.info("当前油品规则类型ruleType: " + ruleType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                if(ruleType !=null && ruleType.equals("1") && realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1 || realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    //以实收金额为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    logger.info("以实收金额为准时"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                }else if(ruleType !=null && ruleType.equals("2") && receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1 || receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    //应收金额为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    logger.info("应收金额为准"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (receivableAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (receivableAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                }else if(ruleType !=null && ruleType.equals("3") && orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1 || orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    //加油升数为准时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    logger.info("加油升数为准"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    if(discountPlanType == "1" && integralRuleDetail.getGread() !=null && customerManage.getGrade().equals(integralRuleDetail.getGread())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (orderLiters, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        logger.info("油站没有使用等级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        countIntegral (orderLiters, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    customerPoints.setPoints(customerPointsInfo.getPoints()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    customerPoints.setAccumulatePoints(customerPointsInfo.getPoints()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                    customerPointsRecord.setIntegral(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            }else if(integralRuleDetail.getOilType().equals("2")){ //非油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                logger.info("当前生成积分类型:非油品"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                countIntegral (realAmt, integralRuleDetail, datePicker, currentTime,  rule, customerPoints, customerPointsRecord, customerPointsInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    logger.info("客户积分customerPoints:"+ customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    logger.info("客户积分记录customerPointsRecord:"+ customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //更新客户余额积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    customerPointsService.updateCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //插入客户积分记录表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //客户公众号积分增加通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //customerPoints.getBlogOpenId() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                    //weiXinPushIntegralInfo(infoMap.get("stationId").toString(), infoMap.get("consumer").toString(), customerPointsRecord.getIntegral().toString(), customerPoints.getPoints().toString(), customerPoints.getBlogOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                   CustomerPoints m = new CustomerPoints(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                   m.setUnionId(customerPoints.getUnionId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                   CustomerPoints cus = customerPointsService.getCustomerPointsInfo(m); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                   if(cus.getBlogOpenId() !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                       //公众号积分消息推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                     this.weiXinPushIntegralInfo(cus.getStationId().toString(), cus.getCustomerName(), customerPointsRecord.getIntegral().toString(), cus.getPoints().toString(), cus.getBlogOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ///========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             //打印机打印小票 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -964,25 +980,25 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //计算积分并赋值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void  countIntegral (BigDecimal b1, IntegralRuleDetail integralRuleDetail, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                String[] datePicker, String currentTime, List<IntegralRule> rule, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                CustomerPoints customerPoints, CustomerPointsRecord customerPointsRecord, CustomerPoints customerPointsInfo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        BigDecimal integral = b1.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        logger.info("该用户本次消费获取积分值:"+integral.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置积分多倍时间时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        logger.info("积分双倍时间:" +datePicker); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(datePicker !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for(String str: datePicker){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        customerPointsRecord.setIntegral(Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    public void  countIntegral (BigDecimal b1, IntegralRuleDetail integralRuleDetail, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                String[] datePicker, String currentTime, List<IntegralRule> rule, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                                CustomerPoints customerPoints, CustomerPointsRecord customerPointsRecord, CustomerPoints customerPointsInfo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        BigDecimal integral = b1.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        logger.info("该用户本次消费获取积分值:"+integral.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        //设置积分多倍时间时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        logger.info("积分双倍时间:" +datePicker); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        if(datePicker !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            for(String str: datePicker){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    integral=integral.multiply(new BigDecimal(rule.get(0).getIntegralProportion())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        customerPointsRecord.setIntegral(Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 微信公众号消息推送 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -991,29 +1007,187 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param customerPointsRecordIntegral  用户积分记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param customerPointsIntegral        用户当前还剩余的积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void weiXinPushIntegralInfo (String stationId, String consumer, String customerPointsRecordIntegral, String customerPointsIntegral, String openId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //客户公众号积分增加通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    public void weiXinPushIntegralInfo (String stationId, String consumer, String customerPointsRecordIntegral, String customerPointsIntegral, String openId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        //客户公众号积分增加通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        String gzhAppId =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        String gzhAppSecret =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        String stationName = "";        //油站名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        Map<String, String> m = stationService.getStationAppIdAndAppSecret(Integer.valueOf(stationId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            stationName = m.get("stationName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            gzhAppId = m.get("gzhAppId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            gzhAppSecret = m.get("gzhAppSecret"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        List<WxMpTemplateData> wxMpTemplate = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+consumer+",您好:\n" + "您在"+stationName+"的积分最新交易信息如下")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("time", new SimpleDateFormat("yyyy年MM月dd日HH时mm分").format(new Date()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("type", "增加")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("Point", customerPointsRecordIntegral)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("From", stationName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxMpTemplate.add(new WxMpTemplateData("remark", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+customerPointsIntegral+" 分")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        //wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, customerPoints.getBlogOpenId(), wxMpTemplate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, openId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 计算消费生成积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void calculateIntegralAndPushIntegral(CalculateIntegral calculateIntegral){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int integral =0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        IntegralRule integralRule = new IntegralRule(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        integralRule.setStationId(calculateIntegral.getStationId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        integralRule.setEmptyDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        integralRule.setOilName(calculateIntegral.getOilName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        integralRule.setOilType(calculateIntegral.getOilType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取该油站的积分规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<IntegralRule> integralRuleList = integralRuleService.getIntegralRule(integralRule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(integralRuleList !=null && integralRuleList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<IntegralRuleDetail> integralRuleDetailList = integralRuleList.get(0).getIntegralRuleDetailList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String datePicker=null;         //活动时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String[] datePickerArray ={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String integralActivity = integralRuleList.get(0).getIntegralActivity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String integralProportion =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(integralActivity.equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                datePicker = integralRuleList.get(0).getDatePicker(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                integralProportion = integralRuleList.get(0).getIntegralProportion(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(datePicker.contains(",")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    datePickerArray = datePicker.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    datePickerArray= new String[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    datePickerArray[0] = datePicker; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(integralRuleDetailList !=null && integralRuleDetailList.size() >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(integralRuleDetail.getOilType().equals("1")){    //油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (integralRuleDetail.getRuleType().equals("1")){  //按照实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 1 || calculateIntegral.getAmt().compareTo(integralRuleDetail.getRuleTerms()) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal divide = calculateIntegral.getAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal multiply = divide.multiply(integralRuleDetail.getIntegral()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(integralActivity.equals("1") && datePickerArray !=null && integralProportion !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    for (String s : datePickerArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(s.contains(currentTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            multiply = multiply.multiply(new BigDecimal(integralProportion)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                integral =multiply.intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }else if (integralRuleDetail.getRuleType().equals("2")){    //按应收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal multiply = divide.multiply(integralRuleDetail.getIntegral()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(integralActivity.equals("1") && datePickerArray !=null && integralProportion !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    for (String s : datePickerArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(s.contains(currentTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            multiply = multiply.multiply(new BigDecimal(integralProportion)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                integral = multiply.intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }else if (integralRuleDetail.getRuleType().equals("3")){    //按照加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(calculateIntegral.getOilLiters().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getOilLiters().compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal divide = calculateIntegral.getOilLiters().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                BigDecimal multiply = divide.multiply(integralRuleDetail.getIntegral()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(integralActivity.equals("1") && datePickerArray !=null && integralProportion !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    for (String s : datePickerArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(s.contains(currentTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            multiply = multiply.multiply(new BigDecimal(integralProportion)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                integral =multiply.intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else if (integralRuleDetail.getOilType().equals("2")){     //非油品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==1 || calculateIntegral.getReceivableAmt().compareTo(integralRuleDetail.getRuleTerms()) ==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            BigDecimal divide = calculateIntegral.getReceivableAmt().divide(integralRuleDetail.getSaleAmt(), 0, BigDecimal.ROUND_HALF_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            BigDecimal multiply = divide.multiply(integralRuleDetail.getIntegral()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(integralActivity.equals("1") && datePickerArray !=null && integralProportion !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                for (String s : datePickerArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(s.contains(currentTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        multiply = multiply.multiply(new BigDecimal(integralProportion)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            integral = multiply.intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.pushIntegral(calculateIntegral.getStationId(), integral, calculateIntegral.getOpenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 公众号推送积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param stationId 油站ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param integral  本次所得积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param openId    小程序用户openID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void pushIntegral(Integer stationId, int integral, String openId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String gzhAppId =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String gzhAppSecret =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String stationName = "";        //油站名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> m = stationService.getStationAppIdAndAppSecret(Integer.valueOf(stationId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            stationName = m.get("stationName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            gzhAppId = m.get("gzhAppId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            gzhAppSecret = m.get("gzhAppSecret"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal surplusIntegral=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String customerName =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(StringUtils.isNotBlank(openId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> m = stationService.getStationAppIdAndAppSecret(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(m !=null && m.containsKey("stationName") && m.containsKey("gzhAppId") && m.containsKey("gzhAppSecret")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationName = m.get("stationName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gzhAppId = m.get("gzhAppId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gzhAppSecret = m.get("gzhAppSecret"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CustomerPoints customerPoints = new CustomerPoints(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            customerPoints.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            customerPoints.setMinaOpenId(openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfoByMinaOpenId(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(customerPointsInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerName =customerPointsInfo.getCustomerName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                surplusIntegral =new BigDecimal(customerPointsInfo.getPoints()).add(new BigDecimal(integral)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setCustomerName(customerName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setStationName(stationName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setRecordType("+"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setUnionId(customerPointsInfo.getUnionId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecord.setIntegral(integral); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsRecordService.insertCustomerPointsRecordInfo(customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPoints.setUnionId(customerPointsInfo.getUnionId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPoints.setPoints(surplusIntegral.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //更新客户积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                customerPointsService.updateCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String blogOpenId = customerPointsInfo.getBlogOpenId();     //公众号openId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(blogOpenId !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //推送模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<WxMpTemplateData> wxMpTemplate = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+customerName+",您好:\n" + "您在"+stationName+"的积分最新交易信息如下")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("time", new SimpleDateFormat("yyyy年MM月dd日HH时mm分").format(new Date()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("type", "增加")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("Point", String.valueOf(integral))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("From", stationName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxMpTemplate.add(new WxMpTemplateData("remark", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+surplusIntegral.toString()+" 分")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, blogOpenId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<WxMpTemplateData> wxMpTemplate = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("first","尊敬的"+consumer+",您好:\n" + "您在"+stationName+"的积分最新交易信息如下")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("time", new SimpleDateFormat("yyyy年MM月dd日HH时mm分").format(new Date()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("type", "增加")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("Point", customerPointsRecordIntegral)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("From", stationName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxMpTemplate.add(new WxMpTemplateData("remark", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+customerPointsIntegral+" 分")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, customerPoints.getBlogOpenId(), wxMpTemplate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, openId, wxMpTemplate);  //oJR5R6r4EJhaORFcPap70r_mtFZo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |