|
|
@@ -47,6 +47,8 @@ public class AliSmsServiceImpl implements IAliSmsService {
|
|
|
private String FORGETTEMPLATECODE;
|
|
|
@Value("${aliyun.sms.pwdTemplateCode}")
|
|
|
private String PWDTEMPLATECODE;
|
|
|
+ @Value("${aliyun.sms.bindNewTelCode}")
|
|
|
+ private String BINDNEWTELCODE;
|
|
|
|
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
|
@@ -202,4 +204,36 @@ public class AliSmsServiceImpl implements IAliSmsService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean sendBindNewTelSms(String tel) {
|
|
|
+ if(tel==null){
|
|
|
+ throw new CustomException("手机号码不能为空");
|
|
|
+ }
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getTelphone,tel).last("limit 1"));
|
|
|
+ if(Validator.isNotEmpty(user)){
|
|
|
+ throw new CustomException("该手机号已被使用");
|
|
|
+ }
|
|
|
+ String code = ToolsUtils.getSmsCode();
|
|
|
+ String key = Constants.LOGIN_SMS + tel;
|
|
|
+ redisCache.setCacheObject(key,code,5, TimeUnit.MINUTES);//5分钟
|
|
|
+ try{
|
|
|
+ Map<String,Object> param = new HashMap<>();
|
|
|
+ param.put("code",code);
|
|
|
+ SendSmsResponse response = SmsUtils.sendSms(tel,SIGNNAME,BINDNEWTELCODE, JSON.toJSONString(param),ACCESSKEYID,ACCESSKEYSECRET);
|
|
|
+ if(response.getBody().getMessage().equals("OK")){
|
|
|
+ SmsAddBo smsAddBo = new SmsAddBo();
|
|
|
+ smsAddBo.setCode(code);
|
|
|
+ smsAddBo.setTel(tel);
|
|
|
+ smsAddBo.setType(5L);
|
|
|
+ smsAddBo.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ iSmsService.insertByAddBo(smsAddBo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException(e.getMessage());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|