Commit e0b542d9 by 李小龙

fix: 语音短信模板

parent ab289d3e
......@@ -19,7 +19,6 @@ import java.net.URLEncoder;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -49,25 +48,31 @@ public class SmsMsgSender implements IMsgSender{
Date now = new Date();
String time = String.valueOf(now.getTime());
Collection<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送短信失败:"+jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
}else {
log.info("发送短信成功");
for (String receiver : receiverList) {
try {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiver);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送短信失败:" + jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
} else {
log.info("发送短信成功");
}
}catch (Exception e){
log.error("发送短信异常:",msgDTO,e);
}
}
}catch (Exception e){
log.error("发送短信异常:",msgDTO,e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment