Commit 53c312a4 authored by fuwanli's avatar fuwanli

"单条部分"

parent f0999109
...@@ -101,6 +101,9 @@ public class DmHubApi { ...@@ -101,6 +101,9 @@ public class DmHubApi {
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "接口请求签名校验不通过"); return new DmHubResponse("555", "接口请求签名校验不通过");
} }
response = messageService.batchSendOneByOne(request); response = messageService.batchSendOneByOne(request);
response.setCode(response.getError().getString("errorCode")); response.setCode(response.getError().getString("errorCode"));
} catch (Exception e) { } catch (Exception e) {
...@@ -137,7 +140,6 @@ public class DmHubApi { ...@@ -137,7 +140,6 @@ public class DmHubApi {
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过"); return new DmHubResponse("555", "签名校验不通过");
} }
response = messageService.send(request); response = messageService.send(request);
response.setCode(response.getError().getString("errorCode")); response.setCode(response.getError().getString("errorCode"));
} catch (Exception e) { } catch (Exception e) {
......
...@@ -9,10 +9,9 @@ public interface BgySmsService { ...@@ -9,10 +9,9 @@ public interface BgySmsService {
CLBizResponse sendSms(String mobile, String content, String areaId,String api) throws Exception; CLBizResponse sendSms(String mobile, String content, String areaId,String api) throws Exception;
CLBizResponse sendbatchSms(String mobile, String areaId,String api) throws Exception; CLBizResponse sendbatchSms(String data, String areaId,String api,String templateId) throws Exception;
CLBizResponse createTemplate(String content,String account,String templateType,String pkID) throws Exception; CLBizResponse createTemplate(String content,String account,String templateType,String pkID) throws Exception;
void asyncNotify(TemplateNotify templateNotify); void asyncNotify(TemplateNotify templateNotify);
} }
...@@ -84,7 +84,7 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -84,7 +84,7 @@ public class BgySmsServiceImpl implements BgySmsService {
} }
@Override @Override
public CLBizResponse sendbatchSms(String data, String areaId,String api) throws Exception { public CLBizResponse sendbatchSms(String data, String areaId,String api,String templateId) throws Exception {
log.info("进入碧桂园短信发送接口"); log.info("进入碧桂园短信发送接口");
String appId = BgySMSConfig.appId; String appId = BgySMSConfig.appId;
// String areaId = BgySMSConfig.areaId; // String areaId = BgySMSConfig.areaId;
...@@ -96,8 +96,9 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -96,8 +96,9 @@ public class BgySmsServiceImpl implements BgySmsService {
requestParams.put("appId", appId); requestParams.put("appId", appId);
requestParams.put("security", Md5Util.encrypt(appId + securityCode.toUpperCase())); requestParams.put("security", Md5Util.encrypt(appId + securityCode.toUpperCase()));
requestParams.put("areaId", areaId); requestParams.put("areaId", areaId);
requestParams.put("templateId", templateId);
requestParams.put("data", data); requestParams.put("data", data);
log.info("碧桂园短信接口参数:{}", requestParams); log.info("碧桂园短信接口参数:{}", requestParams);//TODO
String retStr = SendSmsUtil.sendSmsByPost(url, JSONObject.toJSONString(requestParams)); String retStr = SendSmsUtil.sendSmsByPost(url, JSONObject.toJSONString(requestParams));
log.info("碧桂园短信接口返回信息:{}", retStr); log.info("碧桂园短信接口返回信息:{}", retStr);
if (retStr == null) { if (retStr == null) {
......
...@@ -383,13 +383,18 @@ public class MessageServiceImpl implements MessageService { ...@@ -383,13 +383,18 @@ public class MessageServiceImpl implements MessageService {
return new DmHubResponse("999", "短信插件未获取到模板信息"); return new DmHubResponse("999", "短信插件未获取到模板信息");
} }
if (templateInfo.getTemplateRecordId() == null){
return new DmHubResponse("1001", "当前模板暂未审核,请重新选择");
}
String api = ""; String api = "";
if ("marketing".equals(templateInfo.getType())) { if ("marketing".equals(templateInfo.getType())) {
api = "SendYXSMS"; api = "SendYXSMS";
} else { } else {
api = "SendNotifySMS"; api = "SendNotifySMS";
} }
//模板流水号
String templateRecordId = templateInfo.getTemplateRecordId();
String smsType = templateInfo.getType(); String smsType = templateInfo.getType();
String templateName = templateInfo.getTemplateName(); String templateName = templateInfo.getTemplateName();
String[] split = templateName.split("_"); String[] split = templateName.split("_");
...@@ -474,11 +479,13 @@ public class MessageServiceImpl implements MessageService { ...@@ -474,11 +479,13 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo.setAreaId(channelAccount); sysRecordInfo.setAreaId(channelAccount);
if (paramsArr == null || paramsArr.isEmpty()) { if (paramsArr == null || paramsArr.isEmpty()) {
List<JSONObject> list = new ArrayList<>(); // List<JSONObject> list = new ArrayList<>();
List<Map<String,String>> list = new ArrayList<>();
StringBuilder mobiles = new StringBuilder(); StringBuilder mobiles = new StringBuilder();
String content = templateInfo.getUpContent(); String content = templateInfo.getUpContent();
for (String mobile : mobileList) { for (String mobile : mobileList) {
JSONObject jsonObject = new JSONObject(); //JSONObject jsonObject = new JSONObject();
Map<String,String> jsonObject = new HashMap<>();
mobiles.append(mobile + ","); mobiles.append(mobile + ",");
jsonObject.put("mobile", mobile); jsonObject.put("mobile", mobile);
jsonObject.put("content", content); jsonObject.put("content", content);
...@@ -486,7 +493,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -486,7 +493,7 @@ public class MessageServiceImpl implements MessageService {
} }
try { try {
if (!list.isEmpty()) { if (!list.isEmpty()) {
response = bgySmsService.sendbatchSms(list.toString(), areaId,api); response = bgySmsService.sendbatchSms(list.toString(), areaId,api,templateRecordId);
String code = response.getCode(); String code = response.getCode();
if (code.equals(ResponseCode.SUCCESS.getCode())) { if (code.equals(ResponseCode.SUCCESS.getCode())) {
sysRecordInfo.setChargeNum(list.size()); sysRecordInfo.setChargeNum(list.size());
...@@ -519,7 +526,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -519,7 +526,8 @@ public class MessageServiceImpl implements MessageService {
} else { } else {
// 变量短信 // 变量短信
Set<Map.Entry<String, List<String>>> entries = paramsMap.entrySet(); Set<Map.Entry<String, List<String>>> entries = paramsMap.entrySet();
List<JSONObject> list = new ArrayList<>(); // List<JSONObject> list = new ArrayList<>();
List<Map<String,String>> list = new ArrayList<>();
StringBuilder mobiles = new StringBuilder(); StringBuilder mobiles = new StringBuilder();
String content = templateInfo.getUpContent(); String content = templateInfo.getUpContent();
for (Map.Entry<String, List<String>> entry : entries) { for (Map.Entry<String, List<String>> entry : entries) {
...@@ -527,15 +535,16 @@ public class MessageServiceImpl implements MessageService { ...@@ -527,15 +535,16 @@ public class MessageServiceImpl implements MessageService {
List<String> paramsList = entry.getValue(); List<String> paramsList = entry.getValue();
String sendMsg = getMsg(templateInfo.getUpContent(), paramsList); String sendMsg = getMsg(templateInfo.getUpContent(), paramsList);
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
Map<String,String> jsonObject = new HashMap<>();
mobiles.append(mobile + ","); mobiles.append(mobile + ",");
jsonObject.put("mobile", mobile); jsonObject.put("Mobile", mobile);
jsonObject.put("content", sendMsg); jsonObject.put("Content", sendMsg);
list.add(jsonObject); list.add(jsonObject);
} }
try { try {
response = bgySmsService.sendbatchSms(list.toString(), areaId,api); response = bgySmsService.sendbatchSms(list.toString(), areaId,api,templateRecordId);
String code = response.getCode(); String code = response.getCode();
if (code.equals(ResponseCode.SUCCESS.getCode())) { if (code.equals(ResponseCode.SUCCESS.getCode())) {
sysRecordInfo.setChargeNum(list.size()); sysRecordInfo.setChargeNum(list.size());
......
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 to comment