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

Commit 75a07099 authored by jiangxiulong's avatar jiangxiulong

sendOfMid

parent 4df47a3c
...@@ -17,4 +17,6 @@ public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> { ...@@ -17,4 +17,6 @@ public interface ISweetAppletSubMsgService extends IService<SweetAppletSubMsg> {
ResponseDto sendMsg(Integer type, String targetId); ResponseDto sendMsg(Integer type, String targetId);
ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType); ResponseDto<Boolean> create(String openId, String templateId, String targetId, Integer appletType, Integer activityType);
ResponseDto sendOfMid(Integer type, String midList, String targetId);
} }
...@@ -39,6 +39,16 @@ public class SweetAppletSubMsgController { ...@@ -39,6 +39,16 @@ public class SweetAppletSubMsgController {
return subMsgService.sendMsg(type, targetId); return subMsgService.sendMsg(type, targetId);
} }
@GetMapping("sendOfMid")
@ApiOperation("发送模版消息OfMid")
public ResponseDto sendOfMid(
@RequestParam Integer type,
@RequestParam String midList,
@RequestParam String targetId
) {
return subMsgService.sendOfMid(type, midList, targetId);
}
// 一次订阅 可以多次发 直到用户取消订阅 所以正规做法应该是记录订阅模版 不关联任何推送数据 等推送的时候查是否订阅某模版 // 一次订阅 可以多次发 直到用户取消订阅 所以正规做法应该是记录订阅模版 不关联任何推送数据 等推送的时候查是否订阅某模版
// 然后发送判断失败是用户取消了 删除订阅记录 或者看取消是否有回调 利用回调处理也可 // 然后发送判断失败是用户取消了 删除订阅记录 或者看取消是否有回调 利用回调处理也可
// 现在的理解有误 已写完 先用 // 现在的理解有误 已写完 先用
......
...@@ -61,19 +61,21 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -61,19 +61,21 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
.eq(SweetAppletSubMsg::getIsPush, 1) .eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type) .eq(SweetAppletSubMsg::getActivityType, type)
); );
ArrayList<String> msgIdList = CollectionUtil.arrayListString();
if (!CollectionUtils.isEmpty(msgList)) {
for (SweetAppletSubMsg info : msgList) {
try {
String msgId = info.getMsgId();
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, ""); ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData(); KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) { if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[getPerformancesId=[{}]", info.getTargetId()); log.info("无演出数据:[getPerformancesId=[{}]", targetId);
continue; return ResponseDto.success();
} }
KylinTicketTimesVo kylinTicketTimesVo = performanceVoData.getTicketTimeList().get(0); 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(); LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime); String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
String sellTime = performanceVoData.getSellTime(); String sellTime = performanceVoData.getSellTime();
...@@ -134,6 +136,73 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM ...@@ -134,6 +136,73 @@ public class SweetAppletSubMsgServiceImpl extends ServiceImpl<SweetAppletSubMsgM
return ResponseDto.success(); return ResponseDto.success();
} }
@Override
public ResponseDto sendOfMid(Integer type, String midList, String targetId) {
String[] midListArray = midList.split(",");
List<SweetAppletSubMsg> msgList = subMsgMapper.selectList(
Wrappers.lambdaQuery(SweetAppletSubMsg.class)
.eq(SweetAppletSubMsg::getIsPush, 1)
.eq(SweetAppletSubMsg::getActivityType, type)
.in(SweetAppletSubMsg::getMid, midListArray)
);
ResponseDto<KylinPerformanceVo> kylinPerformanceVo = feignKylinPerformancesClient.detail(targetId, 0, 0, "");
KylinPerformanceVo performanceVoData = kylinPerformanceVo.getData();
if (null == performanceVoData || ObjectUtils.isEmpty(performanceVoData)) {
log.info("无演出数据:[getPerformancesId=[{}]", targetId);
return ResponseDto.failure("无演出数据");
}
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) {
msgIdList.add(msgId);
}
} catch (Exception e) {
log.error("小程序演出订阅提醒消息处理异常", e);
}
}
if (!CollectionUtils.isEmpty(msgIdList)) {
SweetAppletSubMsg update = new SweetAppletSubMsg();
update.setIsPush(2);
update.setTargetId(targetId);
update.setUpdatedAt(LocalDateTime.now());
subMsgMapper.update(
update,
Wrappers.lambdaUpdate(SweetAppletSubMsg.class)
.in(SweetAppletSubMsg::getMsgId, msgIdList)
);
}
}
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