Commit e0b542d9 by 李小龙

fix: 语音短信模板

parent ab289d3e
...@@ -19,7 +19,6 @@ import java.net.URLEncoder; ...@@ -19,7 +19,6 @@ import java.net.URLEncoder;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
...@@ -49,25 +48,31 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -49,25 +48,31 @@ public class SmsMsgSender implements IMsgSender{
Date now = new Date(); Date now = new Date();
String time = String.valueOf(now.getTime()); String time = String.valueOf(now.getTime());
Collection<String> receiverList = msgDTO.getReceiverList(); Collection<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(",")); for (String receiver : receiverList) {
HashMap<String, String> paramMap = new HashMap<>(); try {
paramMap.put("uid", smsConfig.getUid()); HashMap<String, String> paramMap = new HashMap<>();
//md5-32位( md5-16位(登录密码)+ time ) paramMap.put("uid", smsConfig.getUid());
String md16 = CryptoUtil.md5_16(smsConfig.getPwd()); //md5-32位( md5-16位(登录密码)+ time )
String md32 = CryptoUtil.md5(md16 + time); String md16 = CryptoUtil.md5_16(smsConfig.getPwd());
paramMap.put("pwd", md32); String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("time", time); paramMap.put("pwd", md32);
paramMap.put("mobile", receiverJoin); paramMap.put("time", time);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8")); paramMap.put("mobile", receiver);
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class); paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
JSONObject jsonObject = JSON.parseObject(resStr); String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
String status = String.valueOf(jsonObject.get("status")); JSONObject jsonObject = JSON.parseObject(resStr);
if (!StringUtils.equals(status, "0")) { String status = String.valueOf(jsonObject.get("status"));
log.error("发送短信失败:"+jsonObject.get("status_code")); if (!StringUtils.equals(status, "0")) {
throw new BusinessException((String) jsonObject.get("status_code")); log.error("发送短信失败:" + jsonObject.get("status_code"));
}else { throw new BusinessException((String) jsonObject.get("status_code"));
log.info("发送短信成功"); } else {
log.info("发送短信成功");
}
}catch (Exception e){
log.error("发送短信异常:",msgDTO,e);
}
} }
}catch (Exception e){ }catch (Exception e){
log.error("发送短信异常:",msgDTO,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