| 
					
				 | 
			
			
				@@ -7,6 +7,10 @@ import com.platform.yijia.param.request.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.pojo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.utils.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.utils.redis.RedisCacheUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.utils.weixinapp.WeiXinUserUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.utils.weixinapp.WxPushUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,6 +41,12 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private CustomerPointsService customerPointsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IntegralRuleService integralRuleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private CustomerPointsRecordService customerPointsRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisCacheUtil redisCacheUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private WxPushUtil wxPushUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /*** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 微信子商户支付接口 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -650,11 +660,22 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 logger.info("不存在客户 新增时参数: " + customerManage.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 payOrderService.insertCustomer(customerManage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//==========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/*/==========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             //客户积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            /*CustomerPoints customerPoints = new CustomerPoints(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            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());   //存入手机号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            customerPointsRecord.setCustomerName(infoMap.get("consumer").toString());       //客户名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            customerPointsRecord.setRecordType("+");            // "+"表示增加积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            customerPointsRecord.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            customerPointsRecord.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if(infoMap.containsKey("userType") && infoMap.get("userType") !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 switch (infoMap.get("userType").toString()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     case "1": 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -673,38 +694,113 @@ public class PayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if(rule !=null && rule.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 //获取该用户积分信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(customerPointsInfo !=null){      //已存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    String ruleType = rule.get(0).getRuleType();   //获取积分规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if(customerPointsInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String ruleType = rule.get(0).getRuleType();   //获取积分规则类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String[] datePicker={};     //积分比例时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(rule.get(0).getDatePicker() != null && rule.get(0).getDatePicker() !=""){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        datePicker = rule.get(0).getDatePicker().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    List<IntegralRuleDetail> integralRuleDetailList = rule.get(0).getIntegralRuleDetailList();  //积分规则详细计算信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     switch (ruleType){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         case "1":   //以订单实付累计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             //已存在:现有余额积分 + 本次消费所获得的积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            BigDecimal amt1 = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            if(amt1.compareTo(rule.get(0).getRuleAmt()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                BigDecimal integral = amt1.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            BigDecimal realAmt = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                if(realAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    BigDecimal integral = realAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //设置积分多倍时间时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    if(datePicker !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                        for(String str: datePicker){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                                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())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         case "2":   //以订单应付累计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             //已存在:现有余额积分 + 本次消费所获得的积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());  //本次消费实收金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            if(receivableAmt.compareTo(rule.get(0).getRuleAmt()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                BigDecimal integral = receivableAmt.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                customerPoints.setPoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                customerPoints.setAccumulatePoints(customerPointsInfo.getPoints() + Integer.valueOf(integral.toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                if(receivableAmt.compareTo(integralRuleDetail.getRuleTerms()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    BigDecimal integral = receivableAmt.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //设置积分多倍时间时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    if(datePicker !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                        for(String str: datePicker){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                                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())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         case "3":   //以加油升数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            BigDecimal orderLiters = new BigDecimal(infoMap.get("orderLiters").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            for(IntegralRuleDetail integralRuleDetail : integralRuleDetailList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                if(orderLiters.compareTo(integralRuleDetail.getRuleTerms()) ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //计算积分并取整 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    BigDecimal integral = orderLiters.divide(integralRuleDetail.getSaleAmt(), 0).multiply(integralRuleDetail.getIntegral()).setScale(0, BigDecimal.ROUND_DOWN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    //设置积分多倍时间时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    if(datePicker !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                        for(String str: datePicker){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                            if (str.contains(currentTime) && rule.get(0).getIntegralProportion() !=null ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                                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())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     //更新客户余额积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     customerPointsService.updateCustomerPointsInfo(customerPoints); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    //插入客户积分记录表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    customerPointsRecordService.insertCustomerPointsInfo(customerPointsRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    //客户公众号积分增加通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String gzhAppId =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String gzhAppSecret =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String stationName = "";        //油站名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    Map<String, String> m = stationService.getStationAppIdAndAppSecret(Integer.valueOf(infoMap.get("stationId").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    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","尊敬的"+infoMap.get("consumer").toString()+",您好:\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", customerPointsRecord.getIntegral().toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    wxMpTemplate.add(new WxMpTemplateData("From", stationName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    wxMpTemplate.add(new WxMpTemplateData("remark", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            "截止至" + new SimpleDateFormat(" yyyy年MM月dd日HH时mm分").format(new Date())+",您在"+stationName+"的可用积分为 "+customerPoints.getPoints().toString()+" 分")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String templateId = "G9tN--a3tGM5BN3otqZr73b4ErQCYWISSgyshbTqLYc";  //积分兑换成功通知模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, customerPoints.getBlogOpenId(), wxMpTemplate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+*///========================================================================================================================================================// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             //打印机打印小票 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String content1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String content2; 
			 |