Commit a8064744 authored by fuwanli's avatar fuwanli

"修改状态取值"

parent 03962140
...@@ -102,8 +102,6 @@ public class DmHubApi { ...@@ -102,8 +102,6 @@ public class DmHubApi {
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) {
...@@ -140,6 +138,7 @@ public class DmHubApi { ...@@ -140,6 +138,7 @@ 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) {
......
...@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.bgy.sms.channel.bgy.dto.CLBizResponse; import com.bgy.sms.channel.bgy.dto.CLBizResponse;
import com.bgy.sms.channel.bgy.dto.TemplateNotify; import com.bgy.sms.channel.bgy.dto.TemplateNotify;
import java.util.List;
public interface BgySmsService { 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 data, String areaId,String api,String templateId) throws Exception; CLBizResponse sendBatchSms(List<JSONObject> 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;
......
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -47,13 +48,13 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -47,13 +48,13 @@ public class BgySmsServiceImpl implements BgySmsService {
private SmsTemplateService smsTemplateService; private SmsTemplateService smsTemplateService;
@Override @Override
public CLBizResponse sendSms(String mobile, String content, String areaId,String api) throws Exception { public CLBizResponse sendSms(String mobile, String content, String areaId, String api) throws Exception {
log.info("进入碧桂园短信发送接口"); log.info("进入碧桂园短信发送接口");
String appId = BgySMSConfig.appId; String appId = BgySMSConfig.appId;
// String areaId = BgySMSConfig.areaId; // String areaId = BgySMSConfig.areaId;
String securityCode = BgySMSConfig.securityCode; String securityCode = BgySMSConfig.securityCode;
String url = BgySMSConfig.url; String url = BgySMSConfig.url;
if (api==null) { if (api == null) {
api = BgySMSConfig.api; api = BgySMSConfig.api;
} }
Map<String, String> requestParams = new HashMap<>(); Map<String, String> requestParams = new HashMap<>();
...@@ -84,14 +85,14 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -84,14 +85,14 @@ public class BgySmsServiceImpl implements BgySmsService {
} }
@Override @Override
public CLBizResponse sendbatchSms(String data, String areaId,String api,String templateId) throws Exception { public CLBizResponse sendBatchSms(List<JSONObject> 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;
String securityCode = BgySMSConfig.securityCode; String securityCode = BgySMSConfig.securityCode;
String url = BgySMSConfig.url; String url = BgySMSConfig.url;
// String api = BgySMSConfig.api; // String api = BgySMSConfig.api;
Map<String, String> requestParams = new HashMap<>(); Map<String, Object> requestParams = new HashMap<>();
requestParams.put("api", api); requestParams.put("api", api);
requestParams.put("appId", appId); requestParams.put("appId", appId);
requestParams.put("security", Md5Util.encrypt(appId + securityCode.toUpperCase())); requestParams.put("security", Md5Util.encrypt(appId + securityCode.toUpperCase()));
...@@ -99,7 +100,8 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -99,7 +100,8 @@ public class BgySmsServiceImpl implements BgySmsService {
requestParams.put("templateId", templateId); requestParams.put("templateId", templateId);
requestParams.put("data", data); requestParams.put("data", data);
log.info("碧桂园短信接口参数:{}", requestParams);//TODO log.info("碧桂园短信接口参数:{}", requestParams);//TODO
String retStr = SendSmsUtil.sendSmsByPost(url, JSONObject.toJSONString(requestParams)); String reqStr = JSONObject.toJSONString(requestParams);
String retStr = SendSmsUtil.sendSmsByPost(url, reqStr);
log.info("碧桂园短信接口返回信息:{}", retStr); log.info("碧桂园短信接口返回信息:{}", retStr);
if (retStr == null) { if (retStr == null) {
return new CLBizResponse(ResponseCode.UPSTREAM_BLANK); return new CLBizResponse(ResponseCode.UPSTREAM_BLANK);
...@@ -190,7 +192,6 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -190,7 +192,6 @@ public class BgySmsServiceImpl implements BgySmsService {
} }
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -11,8 +11,6 @@ import com.bgy.sms.config.ResponseCode; ...@@ -11,8 +11,6 @@ import com.bgy.sms.config.ResponseCode;
import com.bgy.sms.repository.domain.*; import com.bgy.sms.repository.domain.*;
import com.bgy.sms.service.*; import com.bgy.sms.service.*;
import com.bgy.sms.service.bean.TemplateChangeBean; import com.bgy.sms.service.bean.TemplateChangeBean;
import com.bgy.util.HttpUtil;
import com.bgy.util.Md5Util;
import com.bgy.util.id.IdHandler; import com.bgy.util.id.IdHandler;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -223,13 +221,11 @@ public class MessageServiceImpl implements MessageService { ...@@ -223,13 +221,11 @@ public class MessageServiceImpl implements MessageService {
} }
// 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码 // 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码
// 模板参数占位符 // 模板参数占位符
if (templateInfo.getStatus() .equals("abnormal")) {
return new DmHubResponse("1001", "当前模板暂未审核通过,请重新选择");
String templateName = templateInfo.getTemplateName();
String[] split = templateName.split("_");
if (split == null || split.length <= 1) {
return new DmHubResponse("999", "短信模板名称命名不规范,请使用:项目ID_模板名称格式");
} }
String areaId = split[0];
String params = templateInfo.getParams(); String params = templateInfo.getParams();
JSONArray paramsArr = JSONArray.parseArray(params); JSONArray paramsArr = JSONArray.parseArray(params);
String smsType = templateInfo.getType(); String smsType = templateInfo.getType();
...@@ -291,7 +287,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -291,7 +287,7 @@ public class MessageServiceImpl implements MessageService {
api = "SendNotifySMS"; api = "SendNotifySMS";
} }
response = bgySmsService.sendSms(mobile, content, areaId, api); response = bgySmsService.sendSms(mobile, content, channelAccount, api);
//4.短信发送记录 //4.短信发送记录
SysRecordInfo sysRecordInfo = new SysRecordInfo(); SysRecordInfo sysRecordInfo = new SysRecordInfo();
...@@ -383,8 +379,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -383,8 +379,8 @@ public class MessageServiceImpl implements MessageService {
return new DmHubResponse("999", "短信插件未获取到模板信息"); return new DmHubResponse("999", "短信插件未获取到模板信息");
} }
if (templateInfo.getTemplateRecordId() == null) { if (templateInfo.getStatus() .equals("abnormal")) {
return new DmHubResponse("1001", "当前模板暂未审核,请重新选择"); return new DmHubResponse("1001", "当前模板暂未审核通过,请重新选择");
} }
String api = ""; String api = "";
...@@ -396,12 +392,6 @@ public class MessageServiceImpl implements MessageService { ...@@ -396,12 +392,6 @@ public class MessageServiceImpl implements MessageService {
//模板流水号 //模板流水号
String templateRecordId = templateInfo.getTemplateRecordId(); String templateRecordId = templateInfo.getTemplateRecordId();
String smsType = templateInfo.getType(); String smsType = templateInfo.getType();
String templateName = templateInfo.getTemplateName();
String[] split = templateName.split("_");
if (split == null || split.length <= 1) {
return new DmHubResponse("999", "短信模板名称命名不规范,请使用:项目ID_模板名称格式");
}
String areaId = split[0];
// 模板参数占位符 // 模板参数占位符
String params = templateInfo.getParams(); String params = templateInfo.getParams();
JSONArray paramsArr = JSONArray.parseArray(params); JSONArray paramsArr = JSONArray.parseArray(params);
...@@ -471,8 +461,6 @@ public class MessageServiceImpl implements MessageService { ...@@ -471,8 +461,6 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo.setId(IdHandler.nextId()); sysRecordInfo.setId(IdHandler.nextId());
long sysRecordInfoBatchId = IdHandler.nextId(); long sysRecordInfoBatchId = IdHandler.nextId();
sysRecordInfo.setSysBatchId(sysRecordInfoBatchId); sysRecordInfo.setSysBatchId(sysRecordInfoBatchId);
//sysRecordInfo.setMsgId();
//sysRecordInfo.setParams();
Date date = new Date(); Date date = new Date();
sysRecordInfo.setDateCreated(date); sysRecordInfo.setDateCreated(date);
sysRecordInfo.setLastUpdated(date); sysRecordInfo.setLastUpdated(date);
...@@ -491,7 +479,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -491,7 +479,7 @@ public class MessageServiceImpl implements MessageService {
} }
try { try {
if (!list.isEmpty()) { if (!list.isEmpty()) {
response = bgySmsService.sendbatchSms(JSONObject.toJSONString(list), areaId, api, templateRecordId); response = bgySmsService.sendBatchSms(list, channelAccount, 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());
...@@ -532,7 +520,6 @@ public class MessageServiceImpl implements MessageService { ...@@ -532,7 +520,6 @@ 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);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
mobiles.append(mobile + ","); mobiles.append(mobile + ",");
jsonObject.put("Mobile", mobile); jsonObject.put("Mobile", mobile);
...@@ -541,7 +528,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -541,7 +528,7 @@ public class MessageServiceImpl implements MessageService {
} }
try { try {
response = bgySmsService.sendbatchSms(JSONObject.toJSONString(list), areaId, api, templateRecordId); response = bgySmsService.sendBatchSms(list, channelAccount, 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