| 
					
				 | 
			
			
				@@ -7,6 +7,7 @@ import com.platform.yijia.pojo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.service.CouponService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.service.StationService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.utils.CodeMsg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.platform.yijia.utils.CryptUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.platform.yijia.utils.ResultData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sun.corba.se.spi.ior.ObjectKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sun.org.apache.bcel.internal.classfile.Code; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -60,87 +61,91 @@ public class CouponController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Gson gson =new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //返回前端结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            StationInfo stationInfo = new StationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            stationInfo.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            StationInfo stationInfos = stationService.selectStationInfo(stationInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                CouponIssue couponIssue = new CouponIssue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                couponIssue.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                couponIssue.setCouponIssueId(couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //获取该领取方式的状态是否启用 1启用 0未启用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<CouponIssue> couponIssuesList = couponService.selectCouponIssueList(couponIssue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(couponIssuesList !=null && couponIssuesList.size() >0 && couponIssuesList.get(0).getStatus().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    resultMap.put("giveLimit", couponIssuesList.get(0).getGiveLimit()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    CouponUserGiveCount couponUserGiveCount = new CouponUserGiveCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    couponUserGiveCount.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    couponUserGiveCount.setUnionId(unionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    couponUserGiveCount.setCouponIssueId(couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //用户能进入领取界面的次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    CouponUserGiveCount cgcInfo = couponService.selectCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(cgcInfo !=null && cgcInfo.getIssueGiveCount() >=  cgcInfo.getGiveCount()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        resultData = ResultData.error(CodeMsg.COUPON_GIVE_COUNT_MAX); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(cgcInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            //更新次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            Integer issueGiveCount = cgcInfo.getIssueGiveCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            int i = issueGiveCount + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponUserGiveCount.setIssueGiveCount(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponUserGiveCount.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponService.updateCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(unionId !=null && stationId !=null && couponIssueId !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //返回前端结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationInfo stationInfo = new StationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationInfo.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationInfo stationInfos = stationService.selectStationInfo(stationInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    CouponIssue couponIssue = new CouponIssue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    couponIssue.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    couponIssue.setCouponIssueId(couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //获取该领取方式的状态是否启用 1启用 0未启用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<CouponIssue> couponIssuesList = couponService.selectCouponIssueList(couponIssue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(couponIssuesList !=null && couponIssuesList.size() >0 && couponIssuesList.get(0).getStatus().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resultMap.put("giveLimit", couponIssuesList.get(0).getGiveLimit()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CouponUserGiveCount couponUserGiveCount = new CouponUserGiveCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        couponUserGiveCount.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        couponUserGiveCount.setUnionId(unionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        couponUserGiveCount.setCouponIssueId(couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //用户能进入领取界面的次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CouponUserGiveCount cgcInfo = couponService.selectCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(cgcInfo !=null && cgcInfo.getIssueGiveCount() >=  cgcInfo.getGiveCount()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            resultData = ResultData.error(CodeMsg.COUPON_GIVE_COUNT_MAX); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            //新增次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponUserGiveCount.setIssueGiveCount(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponUserGiveCount.setCreteTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            couponService.addCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        //该领取方式能领取优惠券的时间类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        String availableControl = couponIssuesList.get(0).getAvailableControl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        switch (availableControl){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "0": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                List<Coupon> couponsList = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                resultMap.put("couponsList", couponsList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "1": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                String cycleDays_1 = couponIssuesList.get(0).getCycleDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(!this.isActivityDay(availableControl, cycleDays_1)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    List<Coupon> couponsList_1 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultMap.put("couponsList", couponsList_1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "2": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                //String cycleDays_2 = couponIssuesList.get(0).getCycleDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(!this.isActivityDay(availableControl, couponIssuesList.get(0).getCycleDays())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    List<Coupon> couponsList_2 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultMap.put("couponsList", couponsList_2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case "3": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                String appointedDays_3 = couponIssuesList.get(0).getAppointedDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if(!this.isActivityDay(availableControl, appointedDays_3)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    List<Coupon> couponsList_3 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resultMap.put("couponsList", couponsList_3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(cgcInfo !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //更新次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Integer issueGiveCount = cgcInfo.getIssueGiveCount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                int i = issueGiveCount + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponUserGiveCount.setIssueGiveCount(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponUserGiveCount.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponService.updateCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //新增次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponUserGiveCount.setIssueGiveCount(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponUserGiveCount.setCreteTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                couponService.addCouponUserGiveCount(couponUserGiveCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //该领取方式能领取优惠券的时间类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            String availableControl = couponIssuesList.get(0).getAvailableControl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            switch (availableControl){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                case "0": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    List<Coupon> couponsList = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    resultMap.put("couponsList", couponsList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                case "1": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String cycleDays_1 = couponIssuesList.get(0).getCycleDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(!this.isActivityDay(availableControl, cycleDays_1)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        List<Coupon> couponsList_1 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultMap.put("couponsList", couponsList_1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                case "2": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    //String cycleDays_2 = couponIssuesList.get(0).getCycleDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(!this.isActivityDay(availableControl, couponIssuesList.get(0).getCycleDays())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        List<Coupon> couponsList_2 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultMap.put("couponsList", couponsList_2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                case "3": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    String appointedDays_3 = couponIssuesList.get(0).getAppointedDays(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if(!this.isActivityDay(availableControl, appointedDays_3)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.error(CodeMsg.NOT_GIVE_COUPON_TIME); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        List<Coupon> couponsList_3 = this.selectCouponIssue(stationId, couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultMap.put("couponsList", couponsList_3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        resultData = ResultData.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // -7 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resultData = ResultData.error(CodeMsg.ISSUE_CLOSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // -7 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    resultData = ResultData.error(CodeMsg.ISSUE_CLOSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultData = ResultData.error(CodeMsg.PARAMS_NUll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -188,24 +193,27 @@ public class CouponController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation(value = "获取客户所拥有的优惠券", httpMethod = "GET", notes = "获取客户所拥有的优惠券") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String selectUserCoupons(@ApiParam(value = "油站ID", required = true) @RequestParam Integer stationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     @ApiParam(value = "用户unionId", required = true) @RequestParam String unionId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Gson gson =new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            StationInfo stationInfo = new StationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            stationInfo.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            StationInfo stationInfos = stationService.selectStationInfo(stationInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                UserCoupon userCoupon = new UserCoupon(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                userCoupon.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(stationInfos.getCouponFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    userCoupon.setStationId(stationInfos.getGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(stationId !=null && StringUtils.isNotBlank(unionId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationInfo stationInfo = new StationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stationInfo.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StationInfo stationInfos = stationService.selectStationInfo(stationInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    UserCoupon userCoupon = new UserCoupon(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userCoupon.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(stationInfos.getCouponFlag() !=null && stationInfos.getCouponFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        userCoupon.setStationId(stationInfos.getGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userCoupon.setUnionId(unionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<UserCoupon> userCoupons = couponService.selectUserCoupons(userCoupon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resultData = ResultData.success(userCoupons); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                userCoupon.setUnionId(unionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<UserCoupon> userCoupons = couponService.selectUserCoupons(userCoupon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                resultData = ResultData.success(userCoupons); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultData = ResultData.error(CodeMsg.PARAMS_NUll); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -216,21 +224,23 @@ public class CouponController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //用户领取优惠券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @RequestMapping(value = "/addUserCoupon", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @RequestMapping(value = "/addUserCoupon", consumes = "application/json", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //@ApiOperation(value = "用户领取优惠券", httpMethod = "POST", notes = "用户领取优惠券") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public String addUserCoupon(@ApiParam(value = "用户unionId", required = true) @RequestParam String unionId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                @ApiParam(value = "优惠券IDS", required = true) @RequestParam String couponIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                @ApiParam(value = "领取方式ID", required = true) @RequestParam String couponIssueId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                @ApiParam(value = "油站ID", required = true) @RequestParam Integer stationId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String addUserCoupon(@RequestBody CouponUserRequest couponUserRequest){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Gson gson = new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String unionId =  couponUserRequest.getUnionId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String couponIds = couponUserRequest.getCouponIds(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String couponIssueId =  couponUserRequest.getCouponIssueId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer stationId = couponUserRequest.getStationId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             logger.info("用户领取优惠券所需参数: unionId: "+ unionId+ "; 油站ID:" +stationId + "; 优惠券IDS:" + couponIds + "; 领取方式ID: " + couponIssueId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             StationInfo stationInfo = new StationInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             stationInfo.setStationId(stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             StationInfo stationInfos = stationService.selectStationInfo(stationInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //油站是否开启优惠券功能 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if(StringUtils.isNotBlank(couponIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     String str[] = couponIds.split(","); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -281,7 +291,8 @@ public class CouponController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 userCouponParam.setCouponIsUsed("0");           //是否使用:0、未使用;1、已使用; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 long currentTimeMillis = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 String s = stationId + Long.toString(currentTimeMillis) + Math.round((Math.random() + 1) * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                userCouponParam.setCouponNo(s);                //优惠券编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                String s1 = CryptUtil.useMD5(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                userCouponParam.setCouponNo(s1);                //优惠券编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 userCouponParam.setUnionId(unionId);            //用户unionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 userCouponParam.setIssueId(couponIssueId);      //领取方式ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 userCouponParam.setCouponId(coupon.getId());    //优惠券ID 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -366,7 +377,7 @@ public class CouponController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //logger.error("用户领取优惠券错误信息:" + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resultData = ResultData.error(CodeMsg.INSERT_FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //resultData = ResultData.error(CodeMsg.INSERT_FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |