Commit 52e36a29 authored by qinxunjia's avatar qinxunjia

短信插件适配短链接的模板

parent 767e04f9
...@@ -35,6 +35,7 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -35,6 +35,7 @@ public class BgySmsServiceImpl implements BgySmsService {
private static final Logger log = LoggerFactory.getLogger(BgySmsServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(BgySmsServiceImpl.class);
private static final String SUCCESS = "success"; private static final String SUCCESS = "success";
private static final String Fail = "Fail"; private static final String Fail = "Fail";
private static final String OK = "Fail";
private static final String sendSuccessCode = "0"; // 发送响应成功字段 private static final String sendSuccessCode = "0"; // 发送响应成功字段
private static final String createTemplateStatus = "status"; // 响应状态字段 private static final String createTemplateStatus = "status"; // 响应状态字段
private static final String retMsg = "msg"; // 响应描述 private static final String retMsg = "msg"; // 响应描述
...@@ -117,13 +118,10 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -117,13 +118,10 @@ public class BgySmsServiceImpl implements BgySmsService {
} }
JSONObject retJson = JSONObject.parseObject(retStr); JSONObject retJson = JSONObject.parseObject(retStr);
String err = retJson.getString("err"); String err = retJson.getString("err");
String retPack = retJson.getString("package");
String status = retJson.getString("Status");
String retCode = retJson.getString("ret"); String retCode = retJson.getString("ret");
if (StringUtils.isBlank(status) || Fail.equals(status)) { String retPack = retJson.getString("package");
if (!sendSuccessCode.equals(retCode)) {
return new CLBizResponse(ResponseCode.UPSTREAM_FAIL.getCode(), err); return new CLBizResponse(ResponseCode.UPSTREAM_FAIL.getCode(), err);
} else if (sendSuccessCode.equals(retCode)) {
return new CLBizResponse(ResponseCode.SUCCESS);
} else { } else {
return new CLBizResponse(ResponseCode.UPSTREAM_FAIL.getCode(), err); return new CLBizResponse(ResponseCode.UPSTREAM_FAIL.getCode(), err);
} }
...@@ -160,7 +158,7 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -160,7 +158,7 @@ public class BgySmsServiceImpl implements BgySmsService {
updateInfo.setUpRejectMsg(auditReason); updateInfo.setUpRejectMsg(auditReason);
updateInfo.setLastUpdated(new Date()); updateInfo.setLastUpdated(new Date());
smsTemplateService.updateById(updateInfo); smsTemplateService.updateById(updateInfo);
xiaoShuService.updateDmhubSmsTempStatus(dmhubStatue,smsTemplateInfo.getDmTemplateId(),auditReason); xiaoShuService.updateDmhubSmsTempStatus(dmhubStatue, smsTemplateInfo.getDmTemplateId(), auditReason);
return new BGYResponse(); return new BGYResponse();
} }
......
...@@ -16,6 +16,8 @@ public class DmHubConfig { ...@@ -16,6 +16,8 @@ public class DmHubConfig {
public static String appId; public static String appId;
public static String appSecret; public static String appSecret;
public static String shortUrl;
@Value("${system.config.dmHub.applicationId}") @Value("${system.config.dmHub.applicationId}")
public void setApplicationId(String applicationId) { public void setApplicationId(String applicationId) {
DmHubConfig.applicationId = applicationId; DmHubConfig.applicationId = applicationId;
...@@ -46,5 +48,10 @@ public class DmHubConfig { ...@@ -46,5 +48,10 @@ public class DmHubConfig {
DmHubConfig.appSecret = appSecret; DmHubConfig.appSecret = appSecret;
} }
@Value("${system.config.dmHub.shortUrl}")
public void setShortUrl(String shortUrl) {
DmHubConfig.shortUrl = shortUrl;
}
} }
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.bgy.sms.channel.bgy.config.BgySMSConfig; 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.channel.dmHub.config.DmHubConfig;
import com.bgy.sms.channel.dto.*; import com.bgy.sms.channel.dto.*;
import com.bgy.sms.config.ResponseCode; import com.bgy.sms.config.ResponseCode;
import com.bgy.sms.repository.domain.*; import com.bgy.sms.repository.domain.*;
...@@ -72,6 +73,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -72,6 +73,7 @@ public class MessageServiceImpl implements MessageService {
// 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式 // 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式
TemplateChangeBean bean = dmHub2BgyTemplateSend(templateContent); TemplateChangeBean bean = dmHub2BgyTemplateSend(templateContent);
String bgySendStr = bean.getUpSendStr(); String bgySendStr = bean.getUpSendStr();
String upCreateStr = bean.getUpCreateStr();
String params = bean.getParams().toString(); String params = bean.getParams().toString();
SmsTemplateInfo dbInfo = smsTemplateService.selectOne(new EntityWrapper<SmsTemplateInfo>().eq("dm_template_id", templateId)); SmsTemplateInfo dbInfo = smsTemplateService.selectOne(new EntityWrapper<SmsTemplateInfo>().eq("dm_template_id", templateId));
if (dbInfo != null) { if (dbInfo != null) {
...@@ -111,7 +113,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -111,7 +113,7 @@ public class MessageServiceImpl implements MessageService {
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "未找到当前登录用户的售楼系统ID"); xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "未找到当前登录用户的售楼系统ID");
return new DmHubResponse(ResponseCode.NO_USER_ID); return new DmHubResponse(ResponseCode.NO_USER_ID);
} }
response = bgySmsService.createTemplate(bgySendStr, account, TEMPLATETYPE, pkID); response = bgySmsService.createTemplate(upCreateStr, account, TEMPLATETYPE, pkID);
String code = response.getCode(); String code = response.getCode();
String msg = response.getMsg(); String msg = response.getMsg();
if (code.equals(ResponseCode.SUCCESS.getCode())) { if (code.equals(ResponseCode.SUCCESS.getCode())) {
...@@ -166,21 +168,25 @@ public class MessageServiceImpl implements MessageService { ...@@ -166,21 +168,25 @@ public class MessageServiceImpl implements MessageService {
upSendStr = upSendStr.replaceAll(g, "\\$\\$"); upSendStr = upSendStr.replaceAll(g, "\\$\\$");
if (t.contains("${surl!")) { if (t.contains("${surl!")) {
// 短链没传长度,固定长度20 // 短链没传长度,固定长度20
upCreateStr = upCreateStr.replaceAll(g, "\\{s20\\}"); String str = DmHubConfig.shortUrl + "\\$$";
} else { str = java.util.regex.Matcher.quoteReplacement(str);
int i = t.indexOf("@"); upCreateStr = upCreateStr.replaceAll(g, str);
int i1 = t.indexOf("!");
String str = t.substring(i + 1, i1);
if (isNumeric(str)) {
Integer integer = Integer.valueOf(str);
if (integer == 0) {
upCreateStr = upCreateStr.replaceAll(g, "\\{s20\\}");
} else {
upCreateStr = upCreateStr.replaceAll(g, "\\{s" + integer + "\\}");
}
} else { } else {
upCreateStr = upCreateStr.replaceAll(g, "\\{s20\\}"); upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
} // int i = t.indexOf("@");
// int i1 = t.indexOf("!");
// String str = t.substring(i + 1, i1);
// if (isNumeric(str)) {
// Integer integer = Integer.valueOf(str);
// if (integer == 0) {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// } else {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// }
// } else {
// upCreateStr = upCreateStr.replaceAll(g, "\\$\\$");
// }
} }
} }
arr.addAll(groups); arr.addAll(groups);
......
...@@ -53,6 +53,7 @@ system: ...@@ -53,6 +53,7 @@ system:
report: ${${system.config.dmHub.baseApiURL}}/v1/sms/report report: ${${system.config.dmHub.baseApiURL}}/v1/sms/report
appId: 1smsdemo appId: 1smsdemo
appSecret: ac031765c3a8c9acc4747808e4fe5918 appSecret: ac031765c3a8c9acc4747808e4fe5918
shortUrl: urlshort-xsma-sit.bgy.com.cn
logging: logging:
level: debug level: debug
......
...@@ -53,6 +53,7 @@ system: ...@@ -53,6 +53,7 @@ system:
report: ${system.config.dmHub.baseApiURL}/v1/sms/report report: ${system.config.dmHub.baseApiURL}/v1/sms/report
appId: ${smsAppId} appId: ${smsAppId}
appSecret: ${smsSecret} appSecret: ${smsSecret}
shortUrl: ${shortUrl}
logging: logging:
level: ${logLevel} level: ${logLevel}
......
...@@ -46,6 +46,7 @@ system: ...@@ -46,6 +46,7 @@ system:
report: https://api.convertlab.com/v1/sms/report report: https://api.convertlab.com/v1/sms/report
appId: 1smsdemo appId: 1smsdemo
appSecret: ac031765c3a8c9acc4747808e4fe5918 appSecret: ac031765c3a8c9acc4747808e4fe5918
shortUrl: urlshort-xsma-sit.bgy.com.cn
logging: logging:
level: debug level: debug
......
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