|  |  | @ -53,6 +53,8 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     UserDAO userDAO; | 
			
		
	
		
			
				
					|  |  |  | //    @Autowired
 | 
			
		
	
		
			
				
					|  |  |  | //    VoteRecord voteRecord;
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | //     private boolean isInIpRestrictAddress(VoteRecord voteRecord,String ipAddress,long time){
 | 
			
		
	
		
			
				
					|  |  |  | //         Map<String,Object> aidMap = (Map<String, Object>) redisUtils.get(ipAddress);
 | 
			
		
	
	
		
			
				
					|  |  | @ -72,7 +74,7 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  | //     }
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private int isInIpRestrictAddress(String aid, String ipAddress){ | 
			
		
	
		
			
				
					|  |  |  |         Map<String,Object> aidMap = (Map<String,Object>) redisUtils.get(ipAddress); | 
			
		
	
		
			
				
					|  |  |  |         Map<String,Integer> aidMap = (Map<String,Integer>) redisUtils.get(ipAddress); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | //        Map<String,Object> ipMap = (Map<String, Object>) redisUtils.get(ipAddress);
 | 
			
		
	
		
			
				
					|  |  |  |         if (aidMap == null){ | 
			
		
	
	
		
			
				
					|  |  | @ -85,7 +87,7 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private void setCurrentIpuserTotalVotes(String aid, String ipAddress, int userTotalVotes,long time){ | 
			
		
	
		
			
				
					|  |  |  |         Map<String,Object> aidMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         Map<String,Integer> aidMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         aidMap.put(aid,userTotalVotes); | 
			
		
	
		
			
				
					|  |  |  |         redisUtils.set(ipAddress,aidMap,time); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
	
		
			
				
					|  |  | @ -184,7 +186,7 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  |                             voteRecord.getAid(), | 
			
		
	
		
			
				
					|  |  |  |                             request.getRemoteAddr()); | 
			
		
	
		
			
				
					|  |  |  |                 if(0 != result){ | 
			
		
	
		
			
				
					|  |  |  |                     // userTotalVotes = result;
 | 
			
		
	
		
			
				
					|  |  |  | //                     userTotalVotes = result;
 | 
			
		
	
		
			
				
					|  |  |  |                     if(result >= totalVotes){ | 
			
		
	
		
			
				
					|  |  |  |                         return ResultFactory.buildFailResult("你已投过票或该IP投票次数已达上限"); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
	
		
			
				
					|  |  | @ -221,6 +223,15 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 多选 | 
			
		
	
		
			
				
					|  |  |  |      * @param captcha | 
			
		
	
		
			
				
					|  |  |  |      * @param captchaKey | 
			
		
	
		
			
				
					|  |  |  |      * @param voteData | 
			
		
	
		
			
				
					|  |  |  |      * @param request | 
			
		
	
		
			
				
					|  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Result multipleVote(String captcha,String captchaKey,JSONObject voteData ,HttpServletRequest request) { | 
			
		
	
		
			
				
					|  |  |  |         log.info("voteData ==== > ",voteData); | 
			
		
	
	
		
			
				
					|  |  | @ -264,12 +275,13 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  | //        }
 | 
			
		
	
		
			
				
					|  |  |  |         //判断是否是周期性投票
 | 
			
		
	
		
			
				
					|  |  |  |         //1.非周期性投票
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if(typeMap.get("cycleType").equals("false")){ | 
			
		
	
		
			
				
					|  |  |  |             int userTotalVotes = voteRecordDAO.countByAidAndUid(activity.getId(),uid); | 
			
		
	
		
			
				
					|  |  |  |             // ip验证
 | 
			
		
	
		
			
				
					|  |  |  |             if(activity.isIpRestrict()){ | 
			
		
	
		
			
				
					|  |  |  |                 int result = isInIpRestrictAddress( | 
			
		
	
		
			
				
					|  |  |  |                             voteRecord.getAid(), | 
			
		
	
		
			
				
					|  |  |  |                             aid, | 
			
		
	
		
			
				
					|  |  |  |                             request.getRemoteAddr()); | 
			
		
	
		
			
				
					|  |  |  |                 if(0 != result){ | 
			
		
	
		
			
				
					|  |  |  |                     userTotalVotes = result; | 
			
		
	
	
		
			
				
					|  |  | @ -314,11 +326,12 @@ public class VoteRecordServiceImpl implements IVoteRecordService { | 
			
		
	
		
			
				
					|  |  |  |             // ip验证
 | 
			
		
	
		
			
				
					|  |  |  |             if(activity.isIpRestrict()){ | 
			
		
	
		
			
				
					|  |  |  |                 int result = isInIpRestrictAddress( | 
			
		
	
		
			
				
					|  |  |  |                             voteRecord.getAid(), | 
			
		
	
		
			
				
					|  |  |  |                             aid, | 
			
		
	
		
			
				
					|  |  |  |                             request.getRemoteAddr()); | 
			
		
	
		
			
				
					|  |  |  |                 if(0 != result){ | 
			
		
	
		
			
				
					|  |  |  |                     // userTotalVotes = result;
 | 
			
		
	
		
			
				
					|  |  |  |                     if(result >= totalVotes){ | 
			
		
	
		
			
				
					|  |  |  | //                    if(result >= totalVotes){
 | 
			
		
	
		
			
				
					|  |  |  |                         if(result >= 0){ | 
			
		
	
		
			
				
					|  |  |  |                         return ResultFactory.buildFailResult("你已投过票或该IP投票次数已达上限"); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
	
		
			
				
					|  |  | 
 |