| | |
| | | private RedisManager redisManager; |
| | | |
| | | @Override |
| | | public void sendBindVCode(Long uid, String phone, int codeLength) throws SMSException { |
| | | public void sendBindVCode(String uid, String phone, int codeLength) throws SMSException { |
| | | String limitKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLIMIT, uid + ""); |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0); |
| | | if (StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey))) |
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey))) |
| | | throw new SMSException(1001, "请过60秒再试"); |
| | | |
| | | |
| | | String msgCode = StringUtil.getVerifyCode(codeLength); |
| | | String msgCode = StringUtil.getNumberVerifyCode(codeLength); |
| | | |
| | | TencentSMSConfig tencentSMSConfig = Constant.tencentSMSConfig; |
| | | |
| | |
| | | throw new SMSException(result.result, "短信发送失败"); |
| | | } |
| | | //保存验证码 |
| | | redisManager.cacheCommonString(key, msgCode, 60 * 2); |
| | | redisManager.cacheCommonString(key, msgCode, 60 * 5); |
| | | //60s后再发送 |
| | | redisManager.cacheCommonString(limitKey, "1", 60); |
| | | } |
| | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0); |
| | | String cacheCode = redisManager.getCommonString(key); |
| | | if (cacheCode != null && cacheCode.equalsIgnoreCase(code)) { |
| | | redisManager.removeCommonString(key); |
| | | return true; |
| | | } |
| | | return false; |