优化短信提醒

pull/371/head
wuyibo 2 years ago
parent 88b7816220
commit 09d6f76198

@ -75,8 +75,6 @@ public class CompetitionServiceImpl implements ICompetitionService
@Resource
private IMessageService messageService;
@Resource
private ISysConfigService configService;
@Resource
private RedisService redisService;
@Resource
private SmsService smsService;
@ -681,16 +679,13 @@ public class CompetitionServiceImpl implements ICompetitionService
msg.append(teamName);
msg.append("]申请出战,请尽快审批处理!");
sms.setMs(msg.toString());
String adminTelephone = configService.selectConfigByKey("sys.admin.telephone");
sms.setMobile(adminTelephone);
sms.setMb(adminTelephone);
if(ObjectUtil.isNotNull(adminTelephone)) {
sms.setMobile(competition.getContactsTel());
sms.setMb(competition.getContactsTel());
SmsResponse smsResponse = smsService.sendSms(sms);
if (smsResponse.getStatus() == 0) {
//保存到缓存
// redisUtil.set(Constant.ESTABLISH_COMPETITION_SMS_CAPTCHA+sms.getMb(), randomNums,Constant.SMS_PAOPAO_EXPIRES);
}
}
return excleVo;
}
}

@ -1,15 +1,19 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.system.domain.Sms;
import com.ruoyi.system.domain.vo.SmsResponse;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.SmsService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@ -23,6 +27,10 @@ import java.util.Map;
public class SmsServiceImpl implements SmsService {
@Autowired
private RestTemplate restTemplate;
@Value("${spring.profiles.active}")
private String springProfilesActive;
@Resource
private ISysConfigService configService;
@Override
public SmsResponse sendSms(Sms sms) {
sms.setAccount(Constants.SMS_PAOPAO_ACCOUNT);
@ -40,7 +48,12 @@ public class SmsServiceImpl implements SmsService {
Map<String, Object> uriVariables = new HashMap<String, Object>();
uriVariables.put("account", sms.getAccount());
uriVariables.put("password",sms.getPassword());
if(StrUtil.isNotEmpty(springProfilesActive) && springProfilesActive.equals("prod")) {
uriVariables.put("mobile",sms.getMobile());
}else {
String adminTelephone = configService.selectConfigByKey("sys.admin.telephone");
uriVariables.put("mobile",adminTelephone);
}
uriVariables.put("content",sms.getContent());
uriVariables.put("extno",sms.getExtno());
String responseEntity = restTemplate.getForObject(url, String.class, uriVariables);

Loading…
Cancel
Save