Commit 53c312a4 authored by fuwanli's avatar fuwanli

"单条部分"

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