|
@@ -17,6 +17,8 @@ import com.zhongzheng.modules.alisms.service.IAliSmsService;
|
|
|
import com.zhongzheng.modules.alisms.vo.ResultBean;
|
|
|
import com.zhongzheng.modules.base.bo.SmsAddBo;
|
|
|
import com.zhongzheng.modules.base.service.ISmsService;
|
|
|
+import com.zhongzheng.modules.distribution.domain.DistributionSeller;
|
|
|
+import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import org.slf4j.Logger;
|
|
@@ -60,6 +62,9 @@ public class AliSmsServiceImpl implements IAliSmsService {
|
|
|
@Autowired
|
|
|
private ISmsService iSmsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDistributionSellerService iDistributionSellerService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public ResultBean sendSms(String tel, String param) {
|
|
@@ -239,4 +244,101 @@ public class AliSmsServiceImpl implements IAliSmsService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean sendSellerRegisterSms(String tel) {
|
|
|
+ if(tel==null){
|
|
|
+ throw new CustomException("手机号码不能为空");
|
|
|
+ }
|
|
|
+ DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(tel)).last("limit 1"));
|
|
|
+ if(Validator.isNotNull(seller)){
|
|
|
+ throw new CustomException("该手机号已注册");
|
|
|
+ }
|
|
|
+ String code = ToolsUtils.getSmsCode();
|
|
|
+ String key = Constants.REGISTER_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,REGISTERTEMPLATECODE, JSON.toJSONString(param),ACCESSKEYID,ACCESSKEYSECRET);
|
|
|
+ System.out.println(response.getBody().getMessage());
|
|
|
+ if(response.getBody().getMessage().equals("OK")){
|
|
|
+ SmsAddBo smsAddBo = new SmsAddBo();
|
|
|
+ smsAddBo.setCode(code);
|
|
|
+ smsAddBo.setTel(tel);
|
|
|
+ smsAddBo.setType(6L);
|
|
|
+ smsAddBo.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ iSmsService.insertByAddBo(smsAddBo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException(e.getMessage());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean sendSellerForgetSms(String tel) {
|
|
|
+ if(tel==null){
|
|
|
+ throw new CustomException("手机号码不能为空");
|
|
|
+ }
|
|
|
+ DistributionSeller user = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(tel)).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("该手机号未注册");
|
|
|
+ }
|
|
|
+ String code = ToolsUtils.getSmsCode();
|
|
|
+ String key = Constants.FORGET_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,FORGETTEMPLATECODE, JSON.toJSONString(param),ACCESSKEYID,ACCESSKEYSECRET);
|
|
|
+ if(response.getBody().getMessage().equals("OK")){
|
|
|
+ SmsAddBo smsAddBo = new SmsAddBo();
|
|
|
+ smsAddBo.setCode(code);
|
|
|
+ smsAddBo.setTel(tel);
|
|
|
+ smsAddBo.setType(7L);
|
|
|
+ smsAddBo.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ iSmsService.insertByAddBo(smsAddBo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException(e.getMessage());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean sendSellerLoginSms(String tel) {
|
|
|
+ if(tel==null){
|
|
|
+ throw new CustomException("手机号码不能为空");
|
|
|
+ }
|
|
|
+ DistributionSeller user = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
|
|
|
+ .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(tel)).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(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,LOGINTEMPLATECODE, JSON.toJSONString(param),ACCESSKEYID,ACCESSKEYSECRET);
|
|
|
+ if(response.getBody().getMessage().equals("OK")){
|
|
|
+ SmsAddBo smsAddBo = new SmsAddBo();
|
|
|
+ smsAddBo.setCode(code);
|
|
|
+ smsAddBo.setTel(tel);
|
|
|
+ smsAddBo.setType(8L);
|
|
|
+ smsAddBo.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ iSmsService.insertByAddBo(smsAddBo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException(e.getMessage());
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|