Commit 93659227 authored by shiyu's avatar shiyu

发送商品订阅消息2

parent be9d2368
......@@ -148,42 +148,39 @@ public class SpecialPerformanceNoticeJob {
return;
}
SpecialPerformance specialPerformance = specialPerformanceList.get(0);
String abortStartKey = SPECIAL_PERFORMANCE_START_NOTICE_KEY + specialPerformance.getId();
if (!redisUtils.hasKey(abortStartKey)) {
/* if ("dev".equals(env)) {
logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行专场即将开始通知任务<<<<<<<<<<<<<<<<<<<<<");
return;
}*/
logger.info("当前即将开始的专场id:{}, 名称为 {} ", specialPerformance.getId(), specialPerformance.getTitle());
//发送专场开始订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(Long.valueOf(specialPerformance.getId()));
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.PRE_START.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + specialPerformance.getId());
String msg = specialPerformance.getTitle() + "将在" + DateUtils.toString(specialPerformance.getStartTime()) + "开始,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
logger.info("当前即将开始的专场id:{}, 名称为 {} ", specialPerformance.getId(), specialPerformance.getTitle());
//发送专场开始订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(Long.valueOf(specialPerformance.getId()));
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.PRE_START.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + specialPerformance.getId());
String msg = specialPerformance.getTitle() + "将在" + DateUtils.toString(specialPerformance.getStartTime()) + "开始,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
String abortStartKey = SPECIAL_PERFORMANCE_START_NOTICE_KEY + disposableSubscribeRecord.getUserId() + ":" + specialPerformance.getId();
if (!redisUtils.hasKey(abortStartKey)) {
sendStartSubscribeMsg(specialPerformance, disposableSubscribeRecord, msg);
}
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送专场开始订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
redisUtils.set(abortStartKey, specialPerformance.getId(), 3600 * 24);
} else {
logger.info("============= 发送专场开始订阅消息循环结束 =============");
break;
logger.info("================专场id: {}, 即将开始通知任务已经完成,无需重复发送 ==============", specialPerformance.getId());
}
}
logger.info("================专场id: {}, 即将开始通知消息全部发送成功 ==============", specialPerformance.getId());
redisUtils.set(abortStartKey, specialPerformance.getId(), 3600 * 24);
} else {
logger.info("================专场id: {}, 即将开始通知任务已经完成,无需重复发送 ==============", specialPerformance.getId());
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送专场开始订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
} else {
logger.info("============= 发送专场开始订阅消息循环结束 =============");
break;
}
}
logger.info("================专场id: {}, 即将开始通知消息全部发送成功 ==============", specialPerformance.getId());
}
......@@ -220,38 +217,37 @@ public class SpecialPerformanceNoticeJob {
handleItemSubscribeMsg(specialPerformance, auctionConfigList);
//如果有即将截拍的商品,就可以发送所属专场即将结束的通知
String abortEndKey = SPECIAL_PERFORMANCE_END_NOTICE_KEY + specialPerformance.getId();
if (!redisUtils.hasKey(abortEndKey)) {
logger.info("当前即将结束的专场id:{}, 名称为 {} ", specialPerformance.getId(), specialPerformance.getTitle());
//发送专场即将结束订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(Long.valueOf(specialPerformance.getId()));
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.PRE_END.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + specialPerformance.getId());
String msg = specialPerformance.getTitle() + "将在" + DateUtils.toString(specialPerformance.getEndTime()) + "结束,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
logger.info("当前即将结束的专场id:{}, 名称为 {} ", specialPerformance.getId(), specialPerformance.getTitle());
//发送专场即将结束订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(Long.valueOf(specialPerformance.getId()));
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.PRE_END.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.SPECIAL_PERFORMANCE_URL,"specialId=" + specialPerformance.getId());
String msg = specialPerformance.getTitle() + "将在" + DateUtils.toString(specialPerformance.getEndTime()) + "结束,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
String abortEndKey = SPECIAL_PERFORMANCE_END_NOTICE_KEY + disposableSubscribeRecord.getUserId() + ":" + specialPerformance.getId();
if (!redisUtils.hasKey(abortEndKey)) {
sendEndSubscribeMsg(specialPerformance, disposableSubscribeRecord, msg);
}
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送专场结束订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
redisUtils.set(abortEndKey, specialPerformance.getId(), 3600 * 24);
} else {
logger.info("============= 发送专场结束订阅消息循环结束 =============");
break;
logger.info("================用户id:{}, 专场id: {}, 即将结束通知任务已经完成,无需重复发送 ==============", disposableSubscribeRecord.getUserId(), specialPerformance.getId());
}
}
logger.info("================专场id: {}, 即将结束通知消息全部发送成功 ==============", specialPerformance.getId());
redisUtils.set(abortEndKey, specialPerformance.getId(), 3600 * 24);
} else {
logger.info("================专场id: {}, 即将结束通知任务已经完成,无需重复发送 ==============", specialPerformance.getId());
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送专场结束订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
} else {
logger.info("============= 发送专场结束订阅消息循环结束 =============");
break;
}
}
logger.info("================专场id: {}, 即将结束通知消息全部发送成功 ==============", specialPerformance.getId());
}
}
......@@ -264,40 +260,40 @@ public class SpecialPerformanceNoticeJob {
private void handleItemSubscribeMsg(SpecialPerformance specialPerformance, List<AuctionConfig> auctionConfigList) {
for (AuctionConfig auctionConfig : auctionConfigList) {
long itemId = auctionConfig.getItemId();
String abortEndKey = ITEM_OF_SPECIAL_PERFORMANCE_END_NOTICE_KEY + itemId;
if (!redisUtils.hasKey(abortEndKey)) {
SupplierItem supplierItem = supplierItemDao.findById(itemId);
logger.info("当前即将截拍的商品id:{}, 商品名称:{}, 专场名称为 {} ", itemId, supplierItem.getName(), specialPerformance.getTitle());
//发送专场即将结束订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(itemId);
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.ITEM_PRE_END.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.ITEM_OF_SPECIAL_PERFORMANCE_URL,"itemId=" + itemId);
String msg = "商品'" + supplierItem.getName() + "'将在" + DateUtils.toString(auctionConfig.getRealEndTime()) + "结束,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
SupplierItem supplierItem = supplierItemDao.findById(itemId);
logger.info("当前即将截拍的商品id:{}, 商品名称:{}, 专场名称为 {} ", itemId, supplierItem.getName(), specialPerformance.getTitle());
//发送专场即将结束订阅通知
DisposableSubscribeRecordRequestDto disposableSubscribeRecordRequestDto = new DisposableSubscribeRecordRequestDto();
disposableSubscribeRecordRequestDto.setTargetId(itemId);
disposableSubscribeRecordRequestDto.setType(DisposableSubscribeRecordEnum.TypeEnum.ITEM_PRE_END.getType());
boolean hasNextPage = true;
int page = 1;
String url = wxAppletApi.getUrlLink(CommConsts.ITEM_OF_SPECIAL_PERFORMANCE_URL,"itemId=" + itemId);
String msg = "商品'" + supplierItem.getName() + "'将在" + DateUtils.toString(auctionConfig.getRealEndTime()) + "结束,请前往"+ url + "查看";
while (hasNextPage) {
List<DisposableSubscribeRecord> disposableSubscribeRecordList = disposableSubscribeRecordDao.findList(disposableSubscribeRecordRequestDto);
PageInfo pageInfo = new PageInfo(disposableSubscribeRecordList);
for (DisposableSubscribeRecord disposableSubscribeRecord : disposableSubscribeRecordList) {
String abortEndKey = ITEM_OF_SPECIAL_PERFORMANCE_END_NOTICE_KEY + disposableSubscribeRecord.getUserId() + ":" + itemId;
if (!redisUtils.hasKey(abortEndKey)) {
sendItemEndSubscribeMsg(supplierItem, specialPerformance, disposableSubscribeRecord, msg);
}
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送商品截拍订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
redisUtils.set(abortEndKey, itemId, 3600 * 24);
} else {
logger.info("============= 发送商品截拍订阅消息循环结束 =============");
break;
logger.info("================ 用户ID:{}, 商品id: {}, 商品截拍任务已经完成,无需重复发送 ==============", disposableSubscribeRecord.getUserId(), disposableSubscribeRecord.getTargetId());
}
}
logger.info("================专场id: {}, 商品截拍通知消息全部发送成功 ==============", specialPerformance.getId());
redisUtils.set(abortEndKey, itemId, 3600 * 24);
} else {
logger.info("================专场id: {}, 商品截拍任务已经完成,无需重复发送 ==============", specialPerformance.getId());
if (pageInfo.isHasNextPage()) {
page = page + 1;
disposableSubscribeRecordRequestDto.setPage(page);
logger.info("要发送商品截拍订阅消息的用户数据总页数为 : {}, 当前为 : {}", pageInfo.getPages(), page);
} else {
logger.info("============= 发送商品截拍订阅消息循环结束 =============");
break;
}
}
}
logger.info("================专场id: {}, 商品截拍通知消息全部发送成功 ==============", specialPerformance.getId());
}
......
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