Commit a57bd496 authored by qinxunjia's avatar qinxunjia

优化逻辑

parent c5086574
//package com.bgy.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.StringRedisTemplate;
//
//import javax.annotation.PreDestroy;
//import javax.annotation.Resource;
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//import java.util.Date;
//import java.util.Timer;
//import java.util.TimerTask;
//import java.util.concurrent.TimeUnit;
//
//@Configuration
//@Slf4j
//public class MachineIdConfig {
// @Resource
// private StringRedisTemplate redisTemplate;
//
// @Value("${snowFlake.dataCenter}")
// private Integer dataCenterId;
//
// @Value("${snowFlake.appName}")
// private String APP_NAME;
//
// /**
// * 机器id
// */
// public static Integer machineId;
// /**
// * 本地ip地址
// */
// private static String localIp;
//
// /**
// * 获取ip地址
// *
// * @return
// * @throws UnknownHostException
// */
// private String getIPAddress() throws UnknownHostException {
// InetAddress address = InetAddress.getLocalHost();
// return address.getHostAddress();
// }
//
// /**
// * hash机器IP初始化一个机器ID
// */
// @Bean
// public SnowFlake initMachineId() throws Exception {
// localIp = getIPAddress(); // 192.168.0.233
//
// Long ip_ = Long.parseLong(localIp.replaceAll("\\.", ""));// 1921680233
// //
// machineId = ip_.hashCode() % 32;// 0-31
// // 创建一个机器ID
// createMachineId();
//
// log.info("初始化 machine_id :{}", machineId);
// return new SnowFlake(machineId, dataCenterId);
// }
//
// /**
// * 容器销毁前清除注册记录
// */
// @PreDestroy
// public void destroyMachineId() {
// redisTemplate.delete(APP_NAME + dataCenterId + machineId);
// }
//
//
// /**
// * 主方法:首先获取机器 IP 并 % 32 得到 0-31
// * 使用 业务名 + 组名 + IP 作为 Redis 的 key,机器IP作为 value,存储到Redis中
// *
// * @return
// */
// public Integer createMachineId() {
// try {
// // 向redis注册,并设置超时时间
// log.info("注册一个机器ID到Redis " + machineId + " IP:" + localIp);
// Boolean flag = registerMachine(machineId, localIp);
// // 注册成功
// if (flag) {
// // 启动一个线程更新超时时间
// updateExpTimeThread();
// // 返回机器Id
// log.info("Redis中端口没有冲突 " + machineId + " IP:" + localIp);
// return machineId;
// }
// // 注册失败,可能原因 Hash%32 的结果冲突
// if (!checkIfCanRegister()) {
// // 如果 0-31 已经用完,使用 32-64之间随机的ID
// getRandomMachineId();
// createMachineId();
// } else {
// // 如果存在剩余的ID
// log.warn("Redis中端口冲突了,使用 0-31 之间未占用的Id " + machineId + " IP:" + localIp);
// createMachineId();
// }
// } catch (Exception e) {
// // 获取 32 - 63 之间的随机Id
// // 返回机器Id
// log.error("Redis连接异常,不能正确注册雪花机器号 " + machineId + " IP:" + localIp, e);
// log.warn("使用临时方案,获取 32 - 63 之间的随机数作为机器号,请及时检查Redis连接");
// getRandomMachineId();
// return machineId;
// }
// return machineId;
// }
//
// /**
// * 检查是否被注册满了
// *
// * @return
// */
// private Boolean checkIfCanRegister() {
// // 判断0~31这个区间段的机器IP是否被占满
//
// Boolean flag = true;
// for (int i = 0; i < 32; i++) {
// flag = redisTemplate.hasKey(APP_NAME + dataCenterId + i);
// // 如果不存在。设置机器Id为这个不存在的数字
// if (!flag) {
// machineId = i;
// break;
// }
// }
// return !flag;
//
// }
//
// /**
// * 1.更新超時時間
// * 注意,更新前检查是否存在机器ip占用情况
// */
// private void updateExpTimeThread() {
// // 开启一个线程执行定时任务:
// // 每23小时更新一次超时时间
// new Timer(localIp).schedule(new TimerTask() {
// @Override
// public void run() {
// // 检查缓存中的ip与本机ip是否一致, 一致则更新时间,不一致则重新获取一个机器id
// Boolean b = checkIsLocalIp(String.valueOf(machineId));
// if (b) {
// log.info("IP一致,更新超时时间 ip:{},machineId:{}, time:{}", localIp, machineId, new Date());
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// } else {
// // IP冲突
// log.info("重新生成机器ID ip:{},machineId:{}, time:{}", localIp, machineId, new Date());
// // 重新生成机器ID,并且更改雪花中的机器ID
// getRandomMachineId();
// // 重新生成并注册机器id
// createMachineId();
// // 更改雪花中的机器ID
// SnowFlake.setWorkerId(machineId);
// // 结束当前任务
// log.info("Timer->thread->name:{}", Thread.currentThread().getName());
// this.cancel();
// }
// }
// }, 10 * 1000, 1000 * 60 * 60 * 23);
// }
//
// /**
// * 获取32-63随机数
// */
// public void getRandomMachineId() {
// machineId = (int) (Math.random() * 31) + 31;
// }
//
//
// /**
// * 检查Redis中对应Key的Value是否是本机IP
// *
// * @param mechineId
// * @return
// */
// private Boolean checkIsLocalIp(String mechineId) {
// String ip = redisTemplate.opsForValue().get(APP_NAME + dataCenterId + mechineId);
// log.info("checkIsLocalIp->ip:{}", ip);
// return localIp.equals(ip);
// }
//
// /**
// * 1.注册机器
// * 2.设置超时时间
// *
// * @param machineId 取值为0~31
// * @return
// */
// private Boolean registerMachine(Integer machineId, String localIp) throws Exception {
// // try with resources 写法,出异常会释放括号内的资源 Java7特性
//
// // key 业务号 + 数据中心ID + 机器ID value 机器IP
// Long result = jedis.setnx(APP_NAME + dataCenterId + machineId, localIp);
// if (result == 1) {
// // 过期时间 1 天
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// return true;
// } else {
// // 如果Key存在,判断Value和当前IP是否一致,一致则返回True
// String value = redisTemplate.opsForValue().get(APP_NAME + dataCenterId + machineId);
// if (localIp.equals(value)) {
// // IP一致,注册机器ID成功
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// return true;
// }
// return false;
// }
//
// }
//}
//package com.bgy.config;
//
//import org.springframework.context.annotation.Configuration;
//
///**
// * 功能:分布式ID生成工具类
// *
// */
//@Configuration
//public class SnowFlake {
// /**
// * 开始时间截 (2019-09-08) 服务一旦运行过之后不能修改。会导致ID生成重复
// */
// private final long twepoch = 1567872000000L;
//
// /**
// * 机器Id所占的位数 0 - 64
// */
// private final long workerIdBits = 6L;
//
// /**
// * 工作组Id所占的位数 0 - 16
// */
// private final long dataCenterIdBits = 4L;
//
// /**
// * 支持的最大机器id,结果是63 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
// */
// private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
//
// /**
// * 支持的最大数据标识id,结果是15
// */
// private final long maxDatacenterId = -1L ^ (-1L << dataCenterIdBits);
//
// /**
// * 序列在id中占的位数
// */
// private final long sequenceBits = 12L;
//
// /**
// * 机器ID向左移12位
// */
// private final long workerIdShift = sequenceBits;
//
// /**
// * 数据标识id向左移17位(12+5)
// */
// private final long datacenterIdShift = sequenceBits + workerIdBits;
//
// /**
// * 时间截向左移22位(5+5+12)
// */
// private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
//
// /**
// * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
// */
// private final long sequenceMask = -1L ^ (-1L << sequenceBits);
//
// /**
// * 工作机器ID(0~63)
// */
// private static long workerId;
//
// /**
// * 数据中心ID(0~16)
// */
// private long datacenterId;
//
// /**
// * 毫秒内序列(0~4095)
// */
// private long sequence = 0L;
//
// /**
// * 上次生成ID的时间截
// */
// private long lastTimestamp = -1L;
//
// //==============================Constructors=====================================
//
// /**
// * 构造函数
// *
// * @param workerId 工作ID (0~63)
// * @param datacenterId 数据中心ID (0~15)
// */
// public SnowFlake(long workerId, long datacenterId) {
// if (workerId > maxWorkerId || workerId < 0) {
// throw new IllegalArgumentException(String.format("机器ID必须小于 %d 且大于 0", maxWorkerId));
// }
// if (datacenterId > maxDatacenterId || datacenterId < 0) {
// throw new IllegalArgumentException(String.format("工作组ID必须小于 %d 且大于 0", maxDatacenterId));
// }
// this.workerId = workerId;
// this.datacenterId = datacenterId;
// }
//
// /**
// * 构造函数
// *
// */
// public SnowFlake() {
// this.workerId = 0;
// this.datacenterId = 0;
// }
//
// /**
// * 获得下一个ID (该方法是线程安全的)
// *
// * @return SnowFlakeId
// */
// public synchronized long nextId() {
// long timestamp = timeGen();
//
// //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
// if (timestamp < lastTimestamp) {
// throw new RuntimeException(
// String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
// }
//
// // 如果是同一时间生成的,则进行毫秒内序列
// if (lastTimestamp == timestamp) {
// sequence = (sequence + 1) & sequenceMask;
// // 毫秒内序列溢出
// if (sequence == 0) {
// // 阻塞到下一个毫秒,获得新的时间戳
// timestamp = tilNextMillis(lastTimestamp);
// }
// }
// //时间戳改变,毫秒内序列重置
// else {
// sequence = 0L;
// }
//
// // 上次生成ID的时间截
// lastTimestamp = timestamp;
//
// // 移位并通过或运算拼到一起组成64位的ID
// return ((timestamp - twepoch) << timestampLeftShift) //
// | (datacenterId << datacenterIdShift) //
// | (workerId << workerIdShift) //
// | sequence;
// }
//
// /**
// * 阻塞到下一个毫秒,直到获得新的时间戳
// *
// * @param lastTimestamp 上次生成ID的时间截
// * @return 当前时间戳
// */
// protected long tilNextMillis(long lastTimestamp) {
// long timestamp = timeGen();
// while (timestamp <= lastTimestamp) {
// timestamp = timeGen();
// }
// return timestamp;
// }
//
// /**
// * 返回以毫秒为单位的当前时间
// *
// * @return 当前时间(毫秒)
// */
// protected long timeGen() {
// return System.currentTimeMillis();
// }
//
// public long getWorkerId() {
// return workerId;
// }
//
// public static void setWorkerId(long workerId) {
// SnowFlake.workerId = workerId;
// }
//
// public long getDatacenterId() {
// return datacenterId;
// }
//
// public void setDatacenterId(long datacenterId) {
// this.datacenterId = datacenterId;
// }
//}
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.bgy.sms.channel.bgy.dto.TemplateNotify; import com.bgy.sms.channel.bgy.dto.TemplateNotify;
import com.bgy.sms.channel.bgy.dto.ReportDto; import com.bgy.sms.channel.bgy.dto.ReportDto;
import com.bgy.sms.channel.bgy.service.BgySmsService; import com.bgy.sms.channel.bgy.service.BgySmsService;
import com.bgy.sms.channel.dto.BGYResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,32 +21,17 @@ public class BgyApi { ...@@ -20,32 +21,17 @@ public class BgyApi {
private BgySmsService bgySmsService; private BgySmsService bgySmsService;
@PostMapping("/templateNotify") @PostMapping("/templateNotify")
public String notify(@RequestBody TemplateNotify templateNotify) { public BGYResponse notify(@RequestBody TemplateNotify templateNotify) {
log.info("碧桂园异步通知接口入参:{}", JSONObject.toJSONString(templateNotify)); log.info("碧桂园异步通知接口入参:{}", JSONObject.toJSONString(templateNotify));
String response = "success"; BGYResponse response = null;
try { try {
bgySmsService.asyncNotify(templateNotify); response = bgySmsService.asyncNotify(templateNotify);
} catch (Exception e) { } catch (Exception e) {
log.error("处理创建模板异步通知异常:", e); log.error("处理创建模板异步通知异常:", e);
response = "fail"; response = new BGYResponse(500, "系统异常");
} }
log.info("碧桂园异步通知接口出参:{}", response); log.info("碧桂园异步通知接口出参:{}", JSONObject.toJSONString(response));
return response; return response;
} }
// @GetMapping("/report")
// public String report(ReportDto report) {
// log.info("回送报告接口入参:{}", JSONObject.toJSONString(report));
// String response = "success";
// try {
//// CLBizResponse responses = chuangLanSmsService.report(report);
// } catch (Exception e) {
// log.error("处理回执逻辑异常:", e);
// response = "fail";
// }
// log.info("碧桂园异步通知接口出参:{}", response);
// return response;
// }
//
} }
...@@ -40,15 +40,16 @@ public class DmHubApi { ...@@ -40,15 +40,16 @@ public class DmHubApi {
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "接口请求签名校验不通过"); response = new DmHubResponse("555", "接口请求签名校验不通过");
log.info("**********创建模板接口出参*******:{}", JSONObject.toJSONString(response));
return response;
} }
response = messageService.createTemplate(params); messageService.createTemplate(params);
} catch (Exception e) { } catch (Exception e) {
log.error("创建模板短信异常", e); log.error("创建模板短信异常", e);
response = new DmHubResponse("999", "创建模板短信异常"); new DmHubResponse("999", "创建模板短信异常");
} }
log.info("**********创建模板接口出参*******:{}", JSONObject.toJSONString(response)); return null;
return response;
} }
/** /**
......
...@@ -3,6 +3,7 @@ package com.bgy.sms.channel.bgy.service; ...@@ -3,6 +3,7 @@ package com.bgy.sms.channel.bgy.service;
import com.alibaba.fastjson.JSONObject; 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 com.bgy.sms.channel.dto.BGYResponse;
import java.util.List; import java.util.List;
...@@ -15,5 +16,5 @@ public interface BgySmsService { ...@@ -15,5 +16,5 @@ public interface BgySmsService {
CLBizResponse createTemplate(String content,String account,String templateType,String pkID) throws Exception; CLBizResponse createTemplate(String content,String account,String templateType,String pkID) throws Exception;
void asyncNotify(TemplateNotify templateNotify); BGYResponse asyncNotify(TemplateNotify templateNotify);
} }
...@@ -9,9 +9,11 @@ import com.bgy.sms.channel.bgy.dto.TemplateNotify; ...@@ -9,9 +9,11 @@ import com.bgy.sms.channel.bgy.dto.TemplateNotify;
import com.bgy.sms.channel.bgy.service.BgySmsService; import com.bgy.sms.channel.bgy.service.BgySmsService;
import com.bgy.sms.channel.bgy.utils.SendSmsUtil; import com.bgy.sms.channel.bgy.utils.SendSmsUtil;
import com.bgy.sms.channel.dmHub.service.DmHubService; import com.bgy.sms.channel.dmHub.service.DmHubService;
import com.bgy.sms.channel.dto.BGYResponse;
import com.bgy.sms.config.ResponseCode; import com.bgy.sms.config.ResponseCode;
import com.bgy.sms.repository.domain.SmsTemplateInfo; import com.bgy.sms.repository.domain.SmsTemplateInfo;
import com.bgy.sms.service.SmsTemplateService; import com.bgy.sms.service.SmsTemplateService;
import com.bgy.sms.service.XiaoShuService;
import com.bgy.util.HttpUtil; import com.bgy.util.HttpUtil;
import com.bgy.util.Md5Util; import com.bgy.util.Md5Util;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -38,6 +40,9 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -38,6 +40,9 @@ public class BgySmsServiceImpl implements BgySmsService {
private static final String retMsg = "msg"; // 响应描述 private static final String retMsg = "msg"; // 响应描述
private static final String createTemplateData = "data"; // 创建模板响应数据 private static final String createTemplateData = "data"; // 创建模板响应数据
private static final String REJECTED = "rejected"; // 创建模板响应数据
private static final String APPROVED = "approved"; // 创建模板响应数据
private static final String notificationId = "49"; // 碧桂园通知类短信ID private static final String notificationId = "49"; // 碧桂园通知类短信ID
private static final String marketingId = "52"; // 碧桂园营销类短信ID private static final String marketingId = "52"; // 碧桂园营销类短信ID
...@@ -49,6 +54,9 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -49,6 +54,9 @@ public class BgySmsServiceImpl implements BgySmsService {
@Autowired @Autowired
private SmsTemplateService smsTemplateService; private SmsTemplateService smsTemplateService;
@Autowired
private XiaoShuService xiaoShuService;
@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("进入碧桂园短信发送接口");
...@@ -62,7 +70,8 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -62,7 +70,8 @@ public class BgySmsServiceImpl implements BgySmsService {
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()));
requestParams.put("areaId", areaId); requestParams.put("areaId", BgySMSConfig.areaId);
requestParams.put("subModule", areaId);
requestParams.put("content", content); requestParams.put("content", content);
requestParams.put("mobile", mobile); requestParams.put("mobile", mobile);
log.info("碧桂园短信接口参数:{}", requestParams); log.info("碧桂园短信接口参数:{}", requestParams);
...@@ -95,7 +104,8 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -95,7 +104,8 @@ public class BgySmsServiceImpl implements BgySmsService {
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()));
requestParams.put("areaId", areaId); requestParams.put("areaId", BgySMSConfig.areaId);
requestParams.put("subModule", areaId);
requestParams.put("templateId", templateId); requestParams.put("templateId", templateId);
requestParams.put("data", data); requestParams.put("data", data);
log.info("碧桂园短信接口参数:{}", requestParams); log.info("碧桂园短信接口参数:{}", requestParams);
...@@ -123,9 +133,10 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -123,9 +133,10 @@ public class BgySmsServiceImpl implements BgySmsService {
* 处理短信模板的通知 * 处理短信模板的通知
* *
* @param templateNotify * @param templateNotify
* @return
*/ */
@Override @Override
public void asyncNotify(TemplateNotify templateNotify) { public BGYResponse asyncNotify(TemplateNotify templateNotify) {
log.info("碧桂园短信模板审核通知接口入参:{}", templateNotify); log.info("碧桂园短信模板审核通知接口入参:{}", templateNotify);
//模板流水号 //模板流水号
String templateRecordId = templateNotify.getData(); String templateRecordId = templateNotify.getData();
...@@ -133,18 +144,24 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -133,18 +144,24 @@ public class BgySmsServiceImpl implements BgySmsService {
String auditReason = templateNotify.getAuditReason(); String auditReason = templateNotify.getAuditReason();
SmsTemplateInfo smsTemplateInfo = smsTemplateService.selectOne(new EntityWrapper<SmsTemplateInfo>().eq("template_record_id", templateRecordId)); SmsTemplateInfo smsTemplateInfo = smsTemplateService.selectOne(new EntityWrapper<SmsTemplateInfo>().eq("template_record_id", templateRecordId));
if (smsTemplateInfo == null) { if (smsTemplateInfo == null) {
throw new RuntimeException(ResponseCode.NO_TEMPLATE.getMsg()); return new BGYResponse(2, "未找到短信模板");
} }
SmsTemplateInfo updateInfo = new SmsTemplateInfo();
updateInfo.setId(smsTemplateInfo.getId());
String dmhubStatue = null;
if ("1".equals(status)) { if ("1".equals(status)) {
smsTemplateInfo.setStatus("normal"); updateInfo.setStatus("normal");
smsTemplateInfo.setLastUpdated(new Date()); dmhubStatue = APPROVED;
updateInfo.setLastUpdated(new Date());
} else { } else {
smsTemplateInfo.setStatus("abnormal"); dmhubStatue = REJECTED;
updateInfo.setStatus("abnormal");
} }
smsTemplateInfo.setUpRejectMsg(auditReason); updateInfo.setUpRejectMsg(auditReason);
smsTemplateInfo.setLastUpdated(new Date()); updateInfo.setLastUpdated(new Date());
smsTemplateService.updateById(smsTemplateInfo); smsTemplateService.updateById(updateInfo);
xiaoShuService.updateDmhubSmsTempStatus(dmhubStatue,smsTemplateInfo.getDmTemplateId());
return new BGYResponse();
} }
......
package com.bgy.sms.channel.dto;
import java.io.Serializable;
public class BGYResponse implements Serializable {
private static final long serialVersionUID = 1L;
private int ret;
private String err;
public BGYResponse(int ret, String err) {
this.ret = ret;
this.err = err;
}
public BGYResponse() {
this.ret = 0;
this.err = "成功";
}
public int getRet() {
return ret;
}
public void setRet(int ret) {
this.ret = ret;
}
public String getErr() {
return err;
}
public void setErr(String err) {
this.err = err;
}
}
...@@ -5,5 +5,5 @@ import org.apache.ibatis.annotations.Param; ...@@ -5,5 +5,5 @@ import org.apache.ibatis.annotations.Param;
public interface XiaoShuMapper { public interface XiaoShuMapper {
String getLoginNameByTempId(@Param("tempId") String templateId); String getLoginNameByTempId(@Param("tempId") String templateId);
void updateSmsTemplateStatus(@Param("tempId") String templateId); void updateDmhubTemp(@Param("status")String status, @Param("tempId")String tempId);
} }
...@@ -3,6 +3,5 @@ package com.bgy.sms.service; ...@@ -3,6 +3,5 @@ package com.bgy.sms.service;
public interface XiaoShuService { public interface XiaoShuService {
String selectUserIdByTemplate(String templateId); String selectUserIdByTemplate(String templateId);
void updateSmsTemplateStatus(String templateId); void updateDmhubSmsTempStatus(String dmhubStatue, String dmTemplateId);
} }
...@@ -105,7 +105,6 @@ public class MessageServiceImpl implements MessageService { ...@@ -105,7 +105,6 @@ public class MessageServiceImpl implements MessageService {
if (StringUtils.isBlank(account)) { if (StringUtils.isBlank(account)) {
return new DmHubResponse(ResponseCode.NO_USER_ID); return new DmHubResponse(ResponseCode.NO_USER_ID);
} }
xiaoShuService.updateSmsTemplateStatus(templateId);
response = bgySmsService.createTemplate(bgySendStr, account, TEMPLATETYPE, pkID); response = bgySmsService.createTemplate(bgySendStr, account, TEMPLATETYPE, pkID);
String code = response.getCode(); String code = response.getCode();
String msg = response.getMsg(); String msg = response.getMsg();
...@@ -303,7 +302,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -303,7 +302,7 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo.setStatus(ResponseCode.SUCCESS.getCode()); sysRecordInfo.setStatus(ResponseCode.SUCCESS.getCode());
sysRecordInfo.setStatusDesc(response.getMsg()); sysRecordInfo.setStatusDesc(response.getMsg());
sysRecordService.insert(sysRecordInfo); sysRecordService.insert(sysRecordInfo);
return new DmHubResponse(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg()); return new DmHubResponse(ResponseCode.SUCCESS);
} else { } else {
sysRecordInfo.setStatus(ResponseCode.UPSTREAM_FAIL.getCode()); sysRecordInfo.setStatus(ResponseCode.UPSTREAM_FAIL.getCode());
sysRecordInfo.setStatusDesc(response.getMsg()); sysRecordInfo.setStatusDesc(response.getMsg());
...@@ -495,7 +494,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -495,7 +494,8 @@ public class MessageServiceImpl implements MessageService {
return new DmHubResponse("999", "插件服务系统异常"); return new DmHubResponse("999", "插件服务系统异常");
} }
} else { }
else {
// 变量短信 // 变量短信
Set<Map.Entry<String, List<String>>> entries = paramsMap.entrySet(); Set<Map.Entry<String, List<String>>> entries = paramsMap.entrySet();
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
...@@ -521,7 +521,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -521,7 +521,7 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo.setStatus(ResponseCode.SUCCESS.getCode()); sysRecordInfo.setStatus(ResponseCode.SUCCESS.getCode());
sysRecordInfo.setStatusDesc(response.getMsg()); sysRecordInfo.setStatusDesc(response.getMsg());
sysRecordService.insert(sysRecordInfo); sysRecordService.insert(sysRecordInfo);
return new DmHubResponse(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg()); return new DmHubResponse(ResponseCode.SUCCESS);
} else { } else {
sysRecordInfo.setChargeNum(list.size()); sysRecordInfo.setChargeNum(list.size());
sysRecordInfo.setMobile(mobiles.deleteCharAt(mobiles.length() - 1).toString()); sysRecordInfo.setMobile(mobiles.deleteCharAt(mobiles.length() - 1).toString());
......
...@@ -21,9 +21,11 @@ public class XiaoShuServiceImpl implements XiaoShuService { ...@@ -21,9 +21,11 @@ public class XiaoShuServiceImpl implements XiaoShuService {
return loginName; return loginName;
} }
@Override @Override
@DB(value = DataSourceType.DB2) @DB(value = DataSourceType.DB2)
public void updateSmsTemplateStatus(String templateId) { public void updateDmhubSmsTempStatus(String dmhubStatue, String dmTemplateId) {
xiaoShuMapper.updateSmsTemplateStatus(templateId); xiaoShuMapper.updateDmhubTemp( dmhubStatue, dmTemplateId);
} }
} }
...@@ -8,7 +8,7 @@ info: ...@@ -8,7 +8,7 @@ info:
spring: spring:
profiles: profiles:
active: dev active: test
mybatis-plus: mybatis-plus:
mapper-locations: classpath:mapper/*.xml mapper-locations: classpath:mapper/*.xml
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
where B.id = #{tempId} where B.id = #{tempId}
</select> </select>
<update id="updateSmsTemplateStatus" parameterType="string"> <update id="updateDmhubTemp" parameterType="string">
update sms_template set status = 'applying' where id = #{tempId} update sms_template set status = #{status} where id = #{tempId}
</update> </update>
</mapper> </mapper>
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