Commit 494b7825 authored by qinxunjia's avatar qinxunjia

短信插件优化,区分不同类型用不同账号

parent c9d1d951
...@@ -14,8 +14,10 @@ public class BgySMSConfig { ...@@ -14,8 +14,10 @@ public class BgySMSConfig {
public static String securityCode; public static String securityCode;
// 请求地址 // 请求地址
public static String url; public static String url;
// 项目楼盘id // 通知类项目楼盘ID
public static String areaId; public static String notifyAreaId;
// 营销类项目楼盘ID
public static String marketAreaId;
// api // api
public static String api; public static String api;
...@@ -35,9 +37,14 @@ public class BgySMSConfig { ...@@ -35,9 +37,14 @@ public class BgySMSConfig {
BgySMSConfig.url = url; BgySMSConfig.url = url;
} }
@Value("${system.config.bgy.areaId}") @Value("${system.config.bgy.notifyAreaId}")
public void setAreaId(String areaId) { public void setNotifyAreaId(String notifyAreaId) {
BgySMSConfig.areaId = areaId; BgySMSConfig.notifyAreaId = notifyAreaId;
}
@Value("${system.config.bgy.marketAreaId}")
public void setMarketAreaId(String marketAreaId) {
BgySMSConfig.marketAreaId = marketAreaId;
} }
@Value("${system.config.bgy.api}") @Value("${system.config.bgy.api}")
......
...@@ -6,7 +6,7 @@ public interface BgySmsService { ...@@ -6,7 +6,7 @@ public interface BgySmsService {
CLBizResponse sendSms(String mobile, String content) throws Exception; CLBizResponse sendSms(String mobile, String content,String areaId) throws Exception;
} }
...@@ -39,11 +39,10 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -39,11 +39,10 @@ public class BgySmsServiceImpl implements BgySmsService {
private DmHubService dmHubService; private DmHubService dmHubService;
@Override @Override
public CLBizResponse sendSms(String mobile, String content) throws Exception { public CLBizResponse sendSms(String mobile, String content, String areaId) throws Exception {
String appId = BgySMSConfig.appId; String appId = BgySMSConfig.appId;
String securityCode = BgySMSConfig.securityCode; String securityCode = BgySMSConfig.securityCode;
String url = BgySMSConfig.url; String url = BgySMSConfig.url;
String areaId = BgySMSConfig.areaId;
String api = BgySMSConfig.api; String api = BgySMSConfig.api;
Map<String, String> requestParams = new HashMap<>(); Map<String, String> requestParams = new HashMap<>();
requestParams.put("api", api); requestParams.put("api", api);
......
...@@ -3,6 +3,7 @@ package com.bgy.sms.service.impl; ...@@ -3,6 +3,7 @@ package com.bgy.sms.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.bgy.sms.channel.bgy.config.BgySMSConfig;
import com.bgy.sms.channel.bgy.dto.CLBizResponse; import com.bgy.sms.channel.bgy.dto.CLBizResponse;
import com.bgy.sms.channel.bgy.service.BgySmsService; import com.bgy.sms.channel.bgy.service.BgySmsService;
import com.bgy.sms.config.ResponseCode; import com.bgy.sms.config.ResponseCode;
...@@ -191,7 +192,15 @@ public class MessageServiceImpl implements MessageService { ...@@ -191,7 +192,15 @@ public class MessageServiceImpl implements MessageService {
// 模板参数占位符 // 模板参数占位符
String params = templateInfo.getParams(); String params = templateInfo.getParams();
JSONArray paramsArr = JSONArray.parseArray(params); JSONArray paramsArr = JSONArray.parseArray(params);
String smsType = templateInfo.getType();
String areaId;
if ("notification".equals(smsType)) {
areaId = BgySMSConfig.notifyAreaId;
} else if ("marketing".equals(smsType)) {
areaId = BgySMSConfig.marketAreaId;
} else {
return new DmHubSendResponse("999", "未获取到短信类型");
}
// 封装参数 // 封装参数
List<String> paramList = new ArrayList<>(); List<String> paramList = new ArrayList<>();
Set<String> keys = data.keySet(); Set<String> keys = data.keySet();
...@@ -242,7 +251,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -242,7 +251,7 @@ public class MessageServiceImpl implements MessageService {
String upContent = templateInfo.getUpContent(); String upContent = templateInfo.getUpContent();
content = getMsg(upContent, paramList); content = getMsg(upContent, paramList);
} }
response = bgySmsService.sendSms(mobile, content); response = bgySmsService.sendSms(mobile, content, areaId);
String code = response.getCode(); String code = response.getCode();
String msg = response.getMsg(); String msg = response.getMsg();
// TODO 根据DM hub需要的返回数据封装 // TODO 根据DM hub需要的返回数据封装
...@@ -392,6 +401,15 @@ public class MessageServiceImpl implements MessageService { ...@@ -392,6 +401,15 @@ public class MessageServiceImpl implements MessageService {
if (null == templateInfo) { if (null == templateInfo) {
return new DmHubSendResponse("999", "短信插件未获取到模板信息"); return new DmHubSendResponse("999", "短信插件未获取到模板信息");
} }
String smsType = templateInfo.getType();
String areaId;
if ("notification".equals(smsType)) {
areaId = BgySMSConfig.notifyAreaId;
} else if ("marketing".equals(smsType)) {
areaId = BgySMSConfig.marketAreaId;
} else {
return new DmHubSendResponse("999", "未获取到短信类型");
}
// 模板参数占位符 // 模板参数占位符
String params = templateInfo.getParams(); String params = templateInfo.getParams();
JSONArray paramsArr = JSONArray.parseArray(params); JSONArray paramsArr = JSONArray.parseArray(params);
...@@ -434,6 +452,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -434,6 +452,7 @@ public class MessageServiceImpl implements MessageService {
} }
} }
DmBatchInfo dmInfo = new DmBatchInfo(); DmBatchInfo dmInfo = new DmBatchInfo();
dmInfo.setDmBatchId(batchId); dmInfo.setDmBatchId(batchId);
dmInfo.setDmTemplateId(templateId); dmInfo.setDmTemplateId(templateId);
...@@ -460,7 +479,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -460,7 +479,7 @@ public class MessageServiceImpl implements MessageService {
try { try {
for (String mobile : mobileList) { for (String mobile : mobileList) {
try { try {
response = bgySmsService.sendSms(mobile, templateInfo.getUpContent()); response = bgySmsService.sendSms(mobile, templateInfo.getUpContent(), areaId);
} catch (Exception e) { } catch (Exception e) {
log.error("除0"); log.error("除0");
} }
...@@ -479,7 +498,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -479,7 +498,7 @@ public class MessageServiceImpl implements MessageService {
String mobile = entry.getKey().toString(); String mobile = entry.getKey().toString();
List<String> paramsList = entry.getValue(); List<String> paramsList = entry.getValue();
String sendMsg = getMsg(templateInfo.getUpContent(), paramsList); String sendMsg = getMsg(templateInfo.getUpContent(), paramsList);
response = bgySmsService.sendSms(mobile, sendMsg); response = bgySmsService.sendSms(mobile, sendMsg, areaId);
String code = response.getCode(); String code = response.getCode();
String msg = response.getMsg(); String msg = response.getMsg();
} catch (Exception e) { } catch (Exception e) {
...@@ -491,7 +510,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -491,7 +510,7 @@ public class MessageServiceImpl implements MessageService {
return new DmHubSendResponse(ResponseCode.SUCCESS); return new DmHubSendResponse(ResponseCode.SUCCESS);
} catch (Exception e) { } catch (Exception e) {
log.error("调用创蓝逻辑错误:", e); log.error("调用创蓝逻辑错误:", e);
return new DmHubSendResponse(ResponseCode.SYSTEM_ERROR); return new DmHubSendResponse("999", "插件服务系统异常");
} }
} }
return new DmHubSendResponse(ResponseCode.SUCCESS); return new DmHubSendResponse(ResponseCode.SUCCESS);
......
...@@ -33,7 +33,8 @@ system: ...@@ -33,7 +33,8 @@ system:
appId: 2021 # 系统id appId: 2021 # 系统id
securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码 securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码
url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId: XXJSB notifyAreaId: XXJSB
marketAreaId: XXJSB
api: SendSms api: SendSms
dmHub: dmHub:
applicationId: cl0300171a6012c21 applicationId: cl0300171a6012c21
......
...@@ -34,7 +34,8 @@ system: ...@@ -34,7 +34,8 @@ system:
appId: 2021 # 系统id appId: 2021 # 系统id
securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码 securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码
url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId: XXJSB notifyAreaId: XXJSB
marketAreaId: XXJSB
api: SendSms api: SendSms
dmHub: dmHub:
applicationId: cl0300171a6012c21 applicationId: cl0300171a6012c21
......
...@@ -34,6 +34,8 @@ system: ...@@ -34,6 +34,8 @@ system:
securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码 securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码
url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId: XXJSB areaId: XXJSB
notifyAreaId: XXJSB
marketAreaId: XXJSB
api: SendSms api: SendSms
dmHub: dmHub:
applicationId: cl0300171a6012c21 applicationId: cl0300171a6012c21
......
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