...
|
...
|
@@ -2,7 +2,9 @@ package com.yohoufo.order.mq.consumer; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.rabbitmq.YhConsumer;
|
|
|
import com.yohobuy.ufo.model.order.bo.IntervalBo;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
...
|
...
|
@@ -10,6 +12,7 @@ import com.yohoufo.dal.order.model.BuyerOrder; |
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohoufo.order.event.DeliverNoticeEvent;
|
|
|
import com.yohoufo.order.mq.TopicConstants;
|
|
|
import com.yohoufo.order.service.proxy.DeliveryMinutesService;
|
|
|
import com.yohoufo.order.service.proxy.SellerNoticeFacade;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -35,11 +38,21 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
|
|
/**
|
|
|
* 当前通知的次数
|
|
|
*/
|
|
|
private static final int defaultTimes = 2;
|
|
|
/**
|
|
|
* 单位 : 小时
|
|
|
*/
|
|
|
private static final int defaultLeftTime = 12;
|
|
|
|
|
|
private static final int MAX_TIMES = 3;
|
|
|
|
|
|
@Override
|
|
|
public void handleMessage(Object o) throws Exception {
|
|
|
LOGGER.info("in topic {}, msg {}", TopicConstants.ORDER_NOT_DELIVER_NOTICE, o);
|
|
|
final String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE;
|
|
|
LOGGER.info("in topic {}, msg {}", topic, o);
|
|
|
if (Objects.isNull(o)){
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -48,11 +61,40 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
int buyerUid;
|
|
|
long orderCode;
|
|
|
if ((buyerUid = msg.getBuyerUid()) < 0 || (orderCode=msg.getOrderCode())< 0L){
|
|
|
LOGGER.warn("fail in {}, msg {}", TopicConstants.ORDER_NOT_DELIVER_NOTICE, msg);
|
|
|
LOGGER.warn("fail in {}, msg {}", topic, msg);
|
|
|
return;
|
|
|
}
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, buyerUid);
|
|
|
if(OrderStatus.HAS_PAYED.getCode() == buyerOrder.getStatus().intValue()){
|
|
|
//之前没有这个属性,兼容老数据
|
|
|
final Integer currentTimes = msg.getTimes() == null ? defaultTimes : msg.getTimes();
|
|
|
final int maxTimes = MAX_TIMES;
|
|
|
IntervalBo intervalBo = null;
|
|
|
if (maxTimes>currentTimes){
|
|
|
intervalBo = DeliveryMinutesService.calculateNextInterval(currentTimes, DeliveryMinutesService.getTotalMinutes(), DeliveryMinutesService.getDelayTime());
|
|
|
LOGGER.info("in topic {}, msg {} intervalBo {}", topic, msg, intervalBo);
|
|
|
}
|
|
|
int leftHours = msg.getMinutesOfLeft() == null ? defaultLeftTime : minutes2Hour(msg.getMinutesOfLeft());
|
|
|
|
|
|
//
|
|
|
|
|
|
if (intervalBo != null){
|
|
|
//
|
|
|
//离发货截止12小时提醒
|
|
|
DeliverNoticeEvent deliverNoticeEvent = DeliverNoticeEvent.builder()
|
|
|
.skup(msg.getSkup())
|
|
|
.sellerOrderGoods(msg.getSellerOrderGoods())
|
|
|
.orderAttributes(msg.getOrderAttributes())
|
|
|
.sellerUid(msg.getSellerUid())
|
|
|
.buyerUid(msg.getBuyerUid())
|
|
|
.prdName(msg.getPrdName())
|
|
|
.orderCode(orderCode)
|
|
|
.minutesOfLeft(intervalBo.getMinutesOfLeft())
|
|
|
.times(intervalBo.getTimes())
|
|
|
.build();
|
|
|
EventBusPublisher.publishEvent(deliverNoticeEvent);
|
|
|
|
|
|
}
|
|
|
SellerOrderGoods sog = msg.getSellerOrderGoods();
|
|
|
if (sog == null){
|
|
|
sog = sellerOrderGoodsMapper.selectByPrimaryKey(msg.getSkup());
|
...
|
...
|
@@ -63,9 +105,15 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
sog.setProductName(msg.getPrdName());
|
|
|
}
|
|
|
LOGGER.info("ready notice sellerDeliverWithTimes, msg {}", msg);
|
|
|
sellerNoticeFacade.sellerDeliverWithTimes(sog, buyerOrder, 2, 12, DateUtil.UNIT_HOURS);
|
|
|
|
|
|
sellerNoticeFacade.sellerDeliverWithTimes(sog, buyerOrder, currentTimes, leftHours, DateUtil.UNIT_HOURS);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private int minutes2Hour(int minutes){
|
|
|
return minutes/60;
|
|
|
}
|
|
|
} |
...
|
...
|
|