| 
					
				 | 
			
			
				@@ -53,11 +53,18 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //检验该手机号码是否注册 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String key = "smsValidTime:" + phone; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        getUser(phone,key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int user = getUser(phone, key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(user==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage(ResultStatus.PHONE_NUMBER_NOT_FOUND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(user==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage(ResultStatus.UNABLE_SEND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verifyCode(phone,key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return countVerify(phone); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/v2/send") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -69,17 +76,24 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String validKey = "smsValidTime:" + mobile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        getUser(mobile,validKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int user = getUser(mobile, validKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(user==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             return  new AjaxMessage(ResultStatus.PHONE_NUMBER_NOT_FOUND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(user==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage(ResultStatus.UNABLE_SEND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String key = "validateCode:" + random; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         byte[] redisValidateCodeByte = redisUtil.get(key.getBytes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (redisValidateCodeByte == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new ServiceException(ResultStatus.VALIDATE_CODE_EXPIRED_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage(ResultStatus.VALIDATE_CODE_EXPIRED_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ValidateCode validateCode = (ValidateCode) ByteArrayUtils.bytesToObject(redisValidateCodeByte).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (validateCode.isExpried() || !StringUtils.equals(validateCode.getCode(), code)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                throw new ServiceException(ResultStatus.VALIDATE_CODE_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return  new AjaxMessage(ResultStatus.VALIDATE_CODE_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verifyCode(mobile,validKey); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -87,6 +101,12 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.del(key.getBytes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("test") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value = "发送短信") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void test(String phone){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        countVerify(phone); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private AjaxMessage countVerify(String phone){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDate now = LocalDate.now(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AjaxMessage ajaxMessage=new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -99,6 +119,8 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else if(count==maxSendCodeNum){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ajaxMessage=new AjaxMessage(ResultStatus.SMS_CODE_LIMIT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redisUtil.set(key,"0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.incr(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.setExpire(key,60*60*24); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -114,9 +136,9 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         VerifyCodeUtil.sendVerificationCodeSms(mobile, verifyCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.setExpire(validKey.getBytes(), "".getBytes(), 60);//60秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private AjaxMessage getUser(String phone,String key){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private int getUser(String phone,String key){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.equals(phone, "18800000000") || StringUtils.equals(phone, "18800000001")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //检验该手机号码是否注册 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -124,15 +146,16 @@ public class SmsController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         userQuery.setPhone(phone); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         User user =  userService.findUser(userQuery); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (user == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new ServiceException(ResultStatus.PHONE_NUMBER_NOT_FOUND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         byte[] redisValidateCodeByte = redisUtil.get(key.getBytes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (redisValidateCodeByte != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new ServiceException(ResultStatus.UNABLE_SEND_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |