Commit 22c51a83 by 朱淼
parents f38cf4c1 e0b542d9
...@@ -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,7 +48,8 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -49,7 +48,8 @@ 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) {
try {
HashMap<String, String> paramMap = new HashMap<>(); HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsConfig.getUid()); paramMap.put("uid", smsConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time ) //md5-32位( md5-16位(登录密码)+ time )
...@@ -57,15 +57,15 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -57,15 +57,15 @@ public class SmsMsgSender implements IMsgSender{
String md32 = CryptoUtil.md5(md16 + time); String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32); paramMap.put("pwd", md32);
paramMap.put("time", time); paramMap.put("time", time);
paramMap.put("mobile", receiverJoin); paramMap.put("mobile", receiver);
paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8")); paramMap.put("content", URLEncoder.encode(msgDTO.getOriContent(), "UTF-8"));
String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class); String resStr = HttpClient.sendJSONPostRequest(smsConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr); JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status")); String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) { if (!StringUtils.equals(status, "0")) {
log.error("发送短信失败:"+jsonObject.get("status_code")); log.error("发送短信失败:" + jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code")); throw new BusinessException((String) jsonObject.get("status_code"));
}else { } else {
log.info("发送短信成功"); log.info("发送短信成功");
} }
}catch (Exception e){ }catch (Exception e){
...@@ -73,4 +73,9 @@ public class SmsMsgSender implements IMsgSender{ ...@@ -73,4 +73,9 @@ public class SmsMsgSender implements IMsgSender{
} }
} }
}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