|
|
package com.yohoufo.order.mq.consumer;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.rabbitmq.YhConsumer;
|
|
|
import com.yohobuy.ufo.model.order.bo.IntervalBo;
|
|
|
import com.yohobuy.ufo.model.order.bo.TimeResult;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.constants.OrderConstant;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
...
|
...
|
@@ -14,6 +17,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods; |
|
|
import com.yohoufo.order.event.DeliverNoticeEvent;
|
|
|
import com.yohoufo.order.model.dto.DTNode;
|
|
|
import com.yohoufo.order.mq.TopicConstants;
|
|
|
import com.yohoufo.order.service.impl.BuyerOrderAssistant;
|
|
|
import com.yohoufo.order.service.proxy.DeliveryMinutesService;
|
|
|
import com.yohoufo.order.service.proxy.SellerNoticeFacade;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
...
|
...
|
@@ -21,6 +25,7 @@ import org.slf4j.Logger; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -43,7 +48,7 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
/**
|
|
|
* 当前通知的次数
|
|
|
*/
|
|
|
private static final int defaultTimes = 2;
|
|
|
private static final int defaultTimes = OrderConstant.SellerDeliverNotice.SECOND_TIME;
|
|
|
/**
|
|
|
* 单位 : 小时
|
|
|
*/
|
...
|
...
|
@@ -54,8 +59,36 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
@Autowired
|
|
|
private DeliveryMinutesService deliveryMinutesService;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderAssistant buyerOrderAssistant;
|
|
|
/**
|
|
|
* 现货
|
|
|
* 预售
|
|
|
* 二手 全新瑕疵
|
|
|
* 现货寄存
|
|
|
* 寄存转现货
|
|
|
*/
|
|
|
private static final List<Integer> supportOrderAttributes = Lists.newArrayList(
|
|
|
OrderAttributes.COMMON_IN_STOCK.getCode(),
|
|
|
OrderAttributes.ADVANCE_SALE.getCode(),
|
|
|
OrderAttributes.FLAW.getCode(),
|
|
|
OrderAttributes.SECOND_HAND.getCode()
|
|
|
|
|
|
);
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param preparedData
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean doNoticeAsLastTimeNecessary(BuyerOrderAssistant.PreparedData preparedData){
|
|
|
BuyerOrder pbo;
|
|
|
boolean isInstockDepositOrder = buyerOrderAssistant.isInstockDepositOrder(pbo=preparedData.getBuyerOrder(), preparedData.getSellerOrderGoods());
|
|
|
return supportOrderAttributes.contains(pbo.getAttributes()) || isInstockDepositOrder;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void handleMessage(Object o) throws Exception {
|
|
|
public void handleMessage(Object o) {
|
|
|
final String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE;
|
|
|
LOGGER.info("in topic {}, msg {}", topic, o);
|
|
|
if (Objects.isNull(o)){
|
...
|
...
|
@@ -69,7 +102,8 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
LOGGER.warn("fail in {}, msg {}", topic, msg);
|
|
|
return;
|
|
|
}
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, buyerUid);
|
|
|
BuyerOrderAssistant.PreparedData preparedData = buyerOrderAssistant.prepare(orderCode);
|
|
|
final BuyerOrder buyerOrder = preparedData.getBuyerOrder();
|
|
|
if(OrderStatus.HAS_PAYED.getCode() == buyerOrder.getStatus().intValue()){
|
|
|
//之前没有这个属性,兼容老数据
|
|
|
final Integer currentTimes = msg.getTimes() == null ? defaultTimes : msg.getTimes();
|
...
|
...
|
@@ -81,7 +115,7 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
}
|
|
|
int leftMinutes = msg.getMinutesOfLeft() == null ? defaultLeftTime*60 : msg.getMinutesOfLeft();
|
|
|
//
|
|
|
if (intervalBo != null){
|
|
|
if (intervalBo != null && doNoticeAsLastTimeNecessary(preparedData)){
|
|
|
//
|
|
|
//离发货截止12小时提醒
|
|
|
DeliverNoticeEvent deliverNoticeEvent = DeliverNoticeEvent.builder()
|
...
|
...
|
@@ -94,6 +128,7 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer { |
|
|
.orderCode(orderCode)
|
|
|
//important properties
|
|
|
.minutesOfLeft(intervalBo.getMinutesOfLeft())
|
|
|
.minutesOfDelay(intervalBo.getMinutesofDelay())
|
|
|
.times(intervalBo.getTimes())
|
|
|
.build();
|
|
|
EventBusPublisher.publishEvent(deliverNoticeEvent);
|
...
|
...
|
|