记得上下班打卡 | git大法好,push需谨慎

Commit 26cc581a authored by jiangxiulong's avatar jiangxiulong

发送订阅消息优化

parent 79d85aee
......@@ -39,7 +39,7 @@ public class SweetAppletSubMsgController {
return subMsgService.sendMsg(type, targetId);
}
@GetMapping("sendOfMid")
@PostMapping("sendOfMid")
@ApiOperation("发送模版消息OfMid")
public ResponseDto sendOfMid(
@RequestParam Integer type,
......
......@@ -66,35 +66,32 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[getPerformancesId=[{}]", targetId);
return ResponseDto.success();
return ResponseDto.success("无演出数据");
}
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
String sellTime = performanceVoData.getSellTime();
LocalDateTime sellTimeLocal = LocalDateTime.parse(sellTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime sellTimeLocalNew = sellTimeLocal.minusMinutes(5);
String sellTimeLocalNewStr = DateUtil.Formatter.yyyyMMddHHmmss.format(sellTimeLocalNew);
String stopSellTime = performanceVoData.getStopSellTime();
if (1 == DateUtil.compareStrDay(nowTimeStr, stopSellTime)) { // 超过售卖期 不推 删redis
log.info("超过售卖期:[nowTimeStr=[{}], [stopSellTime=[{}]",
nowTimeStr, stopSellTime);
return ResponseDto.success("超过售卖期");
}
if (-1 == DateUtil.compareStrDay(nowTimeStr, sellTimeLocalNewStr)) { // 还没到售卖期
log.info("还没到售卖期:[nowTimeStr=[{}], [sellTimeLocalNewStr=[{}]",
nowTimeStr, sellTimeLocalNewStr);
return ResponseDto.success("还没到售卖期");
}
KylinTicketTimesVo kylinTicketTimesVo = performanceVoData.getTicketTimeList().get(0);
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
String sellTime = performanceVoData.getSellTime();
LocalDateTime sellTimeLocal = LocalDateTime.parse(sellTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime sellTimeLocalNew = sellTimeLocal.minusMinutes(5);
String sellTimeLocalNewStr = DateUtil.Formatter.yyyyMMddHHmmss.format(sellTimeLocalNew);
String stopSellTime = performanceVoData.getStopSellTime();
if (1 == DateUtil.compareStrDay(nowTimeStr, stopSellTime)) { // 超过售卖期 不推 删redis
log.info("超过售卖期:[nowTimeStr=[{}], [stopSellTime=[{}]",
nowTimeStr, stopSellTime);
msgIdList.add(msgId);
continue;
}
if (-1 == DateUtil.compareStrDay(nowTimeStr, sellTimeLocalNewStr)) { // 还没到售卖期
log.info("还没到售卖期:[nowTimeStr=[{}], [sellTimeLocalNewStr=[{}]",
nowTimeStr, sellTimeLocalNewStr);
continue;
}
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, performanceVoData);
if (subMessage) {
......@@ -119,23 +116,6 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType) {
String[] templateIdArray = templateId.split(",");
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) {
sqlsDataA.add(new Object[]{
IDGenerator.nextSnowId(), openId, id, targetId, appletType, activityType
});
}
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
return ResponseDto.success();
}
@Override
public ResponseDto sendOfMid(Integer type, String midList, String targetId) {
String[] midListArray = midList.split(",");
......@@ -152,33 +132,30 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
log.info("无演出数据:[getPerformancesId=[{}]", targetId);
return ResponseDto.failure("无演出数据");
}
KylinTicketTimesVo kylinTicketTimesVo = performanceVoData.getTicketTimeList().get(0);
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
String sellTime = performanceVoData.getSellTime();
LocalDateTime sellTimeLocal = LocalDateTime.parse(sellTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime sellTimeLocalNew = sellTimeLocal.minusMinutes(5);
String sellTimeLocalNewStr = DateUtil.Formatter.yyyyMMddHHmmss.format(sellTimeLocalNew);
String stopSellTime = performanceVoData.getStopSellTime();
if (1 == DateUtil.compareStrDay(nowTimeStr, stopSellTime)) { // 超过售卖期 不推 删redis
log.info("超过售卖期:[nowTimeStr=[{}], [stopSellTime=[{}]",
nowTimeStr, stopSellTime);
return ResponseDto.failure("超过售卖期");
}
if (-1 == DateUtil.compareStrDay(nowTimeStr, sellTimeLocalNewStr)) { // 还没到售卖期
log.info("还没到售卖期:[nowTimeStr=[{}], [sellTimeLocalNewStr=[{}]",
nowTimeStr, sellTimeLocalNewStr);
return ResponseDto.failure("还没到售卖期");
}
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
String sellTime = performanceVoData.getSellTime();
LocalDateTime sellTimeLocal = LocalDateTime.parse(sellTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime sellTimeLocalNew = sellTimeLocal.minusMinutes(5);
String sellTimeLocalNewStr = DateUtil.Formatter.yyyyMMddHHmmss.format(sellTimeLocalNew);
String stopSellTime = performanceVoData.getStopSellTime();
if (1 == DateUtil.compareStrDay(nowTimeStr, stopSellTime)) { // 超过售卖期 不推 删redis
log.info("超过售卖期:[nowTimeStr=[{}], [stopSellTime=[{}]",
nowTimeStr, stopSellTime);
msgIdList.add(msgId);
continue;
}
if (-1 == DateUtil.compareStrDay(nowTimeStr, sellTimeLocalNewStr)) { // 还没到售卖期
log.info("还没到售卖期:[nowTimeStr=[{}], [sellTimeLocalNewStr=[{}]",
nowTimeStr, sellTimeLocalNewStr);
continue;
}
// 发送订阅消息接口
boolean subMessage = sendSubMessage(info, performanceVoData);
if (subMessage) {
......@@ -203,6 +180,23 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType) {
String[] templateIdArray = templateId.split(",");
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_applet_sub_msg.insert"));
for (String id : templateIdArray) {
sqlsDataA.add(new Object[]{
IDGenerator.nextSnowId(), openId, id, targetId, appletType, activityType
});
}
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_REMIND_INSERT.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
return ResponseDto.success();
}
/**
* 微信小程序推送订阅消息
*/
......
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