Commit 494b7825 authored by qinxunjia's avatar qinxunjia

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

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