admin
2020-06-30 e40d1c22c7202aac843c66f9ee9cc000744f9e10
fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java
@@ -94,6 +94,31 @@
   }
   @Override
   public void sendRemoveVCode(String phone, int codeLength) throws SMSException {
      boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_REMVOE);
      if (limit)
         throw new SMSException(1001, "请过60秒再试");
      String msgCode = StringUtil.getVerifyCode(codeLength);
      // 验证码模板
      String msg = Constant.smsConfig.getSmsBind().replace("[签名]", Constant.smsConfig.getSmsSign()).replace("[验证码]",
            msgCode);
      // 发送短信
      TencentSMSUtil.sendSingleMsg(phone, msg);
      // 缓存
      redisManager.sendSms(phone, SMSHistory.TYPE_REMVOE);
      redisManager.saveSMSVCode(phone, SMSHistory.TYPE_REMVOE, msgCode);
      SMSHistory smsHistory = new SMSHistory();
      smsHistory.setContent(msg);
      smsHistory.setCreateTime(new Date());
      smsHistory.setPhone(phone);
      smsHistory.setType(SMSHistory.TYPE_REMVOE);
      smsHistoryMapper.insertSelective(smsHistory);
   }
   @Override
   public void sendExtractVCode(String phone) throws SMSException {
      boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_EXTRACT);
      if (limit)