Authored by mali

Merge branch 'hotfix_超时' into gray

  1 +package com.yohoufo.dal.order;
  2 +
  3 +import com.yohoufo.dal.order.model.OrderOverTime;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface OrderOverTimeMapper {
  9 +
  10 + int insertDeliveryTime(OrderOverTime record);
  11 +
  12 + int insertShamSendTime(OrderOverTime record);
  13 +
  14 + List<OrderOverTime> selectByOrderCodes(@Param(value = "orderCodeList") List<Long> orderCodeList);
  15 +
  16 + OrderOverTime selectByOrderCode(@Param(value = "orderCode")Long orderCode);
  17 +}
  1 +package com.yohoufo.dal.order.model;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +
  5 +public class OrderOverTime {
  6 + private Integer id;
  7 +
  8 + private Long orderCode;
  9 +
  10 + private Integer deliveryTime;
  11 +
  12 + private Integer deliveryMinutes;
  13 +
  14 + private Integer shamSendTime;
  15 +
  16 + public OrderOverTime() {
  17 + }
  18 +
  19 + public OrderOverTime(Long orderCode, Integer deliveryTime, Integer deliveryMinute) {
  20 + this.orderCode = orderCode;
  21 + this.deliveryTime = deliveryTime;
  22 + this.deliveryMinutes = deliveryMinute;
  23 + }
  24 +
  25 + public OrderOverTime(Integer shamSendTime, Long orderCode) {
  26 + this.shamSendTime = shamSendTime;
  27 + this.orderCode = orderCode;
  28 + }
  29 +
  30 + public Integer getDeliveryMinutes() {
  31 + return deliveryMinutes;
  32 + }
  33 +
  34 + public void setDeliveryMinutes(Integer deliveryMinutes) {
  35 + this.deliveryMinutes = deliveryMinutes;
  36 + }
  37 +
  38 + public Integer getId() {
  39 + return id;
  40 + }
  41 +
  42 + public void setId(Integer id) {
  43 + this.id = id;
  44 + }
  45 +
  46 + public Long getOrderCode() {
  47 + return orderCode;
  48 + }
  49 +
  50 + public void setOrderCode(Long orderCode) {
  51 + this.orderCode = orderCode;
  52 + }
  53 +
  54 + public Integer getDeliveryTime() {
  55 + return deliveryTime;
  56 + }
  57 +
  58 + public void setDeliveryTime(Integer deliveryTime) {
  59 + this.deliveryTime = deliveryTime;
  60 + }
  61 +
  62 + public Integer getShamSendTime() {
  63 + return shamSendTime;
  64 + }
  65 +
  66 + public void setShamSendTime(Integer shamSendTime) {
  67 + this.shamSendTime = shamSendTime;
  68 + }
  69 +
  70 + @Override
  71 + public String toString() {
  72 + return JSONObject.toJSONString(this);
  73 + }
  74 +}
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yohoufo.dal.order.OrderOverTimeMapper" >
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.OrderOverTime" >
  5 + <id column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="order_code" property="orderCode" jdbcType="BIGINT" />
  7 + <result column="delivery_time" property="deliveryTime" jdbcType="INTEGER" />
  8 + <result column="delivery_minutes" property="deliveryMinutes" jdbcType="INTEGER" />
  9 + <result column="sham_send_time" property="shamSendTime" jdbcType="INTEGER" />
  10 + </resultMap>
  11 + <sql id="Base_Column_List" >
  12 + id, order_code, delivery_time, delivery_minutes, sham_send_time
  13 + </sql>
  14 + <insert id="insertDeliveryTime" parameterType="com.yohoufo.dal.order.model.OrderOverTime" >
  15 + insert into order_over_time (order_code, delivery_time, delivery_minutes)
  16 + values (#{orderCode,jdbcType=BIGINT}, #{deliveryTime,jdbcType=INTEGER}, #{deliveryMinutes,jdbcType=INTEGER})
  17 + ON DUPLICATE KEY UPDATE delivery_time = #{deliveryTime, jdbcType=INTEGER}, delivery_minutes = #{deliveryMinutes,jdbcType=INTEGER}
  18 + </insert>
  19 + <insert id="insertShamSendTime" parameterType="com.yohoufo.dal.order.model.OrderOverTime" >
  20 + insert into order_over_time (order_code, sham_send_time)
  21 + values (#{orderCode,jdbcType=BIGINT}, #{shamSendTime,jdbcType=INTEGER})
  22 + ON DUPLICATE KEY UPDATE sham_send_time = #{shamSendTime,jdbcType=INTEGER}
  23 + </insert>
  24 + <select id="selectByOrderCodes" resultMap="BaseResultMap">
  25 + select
  26 + <include refid="Base_Column_List" />
  27 + from order_over_time
  28 + where order_code IN
  29 + <foreach collection="orderCodeList" open="(" close=")" separator="," item="item">
  30 + #{item, jdbcType=BIGINT}
  31 + </foreach>
  32 +
  33 + </select>
  34 + <select id="selectByOrderCode" resultMap="BaseResultMap">
  35 + select
  36 + <include refid="Base_Column_List" />
  37 + from order_over_time where order_code = #{orderCode, jdbcType=BIGINT}
  38 + </select>
  39 +</mapper>
@@ -20,4 +20,6 @@ public interface DelayTime { @@ -20,4 +20,6 @@ public interface DelayTime {
20 20
21 //瑕疵等待用户确认的超时时间,24小时 21 //瑕疵等待用户确认的超时时间,24小时
22 int MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE=24*60; 22 int MINI_FAULT_CONFIRM_OUTER_TIME_MINUTE=24*60;
  23 +
  24 + int MINUTES_120_HOURS = 120 * 60;
23 } 25 }
@@ -121,7 +121,10 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { @@ -121,7 +121,10 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
121 BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode); 121 BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
122 int skup = buyerOrderGoods.getSkup(); 122 int skup = buyerOrderGoods.getSkup();
123 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup); 123 SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
124 - int deliveryHours = deliveryMinutesService.getDeliverMinutesThird_hours();//把分钟转小时 124 +
  125 + int ts = DateUtil.getCurrentTimeSecond();
  126 + int deliveryHours = deliveryMinutesService.getDeliverMinutesThird_hours(ts);//把分钟转小时
  127 +
125 inBoxFacade.sellerSkupPaidByBuyer(sellerOrderGoods,orderCode,deliveryHours); 128 inBoxFacade.sellerSkupPaidByBuyer(sellerOrderGoods,orderCode,deliveryHours);
126 129
127 //离发货截止12小时提醒 130 //离发货截止12小时提醒
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.handler; @@ -2,6 +2,7 @@ package com.yohoufo.order.service.handler;
2 2
3 import com.google.common.eventbus.Subscribe; 3 import com.google.common.eventbus.Subscribe;
4 import com.yohoufo.common.alarm.IEventHandler; 4 import com.yohoufo.common.alarm.IEventHandler;
  5 +import com.yohoufo.common.utils.DateUtil;
5 import com.yohoufo.order.event.DeliverNoticeEvent; 6 import com.yohoufo.order.event.DeliverNoticeEvent;
6 import com.yohoufo.order.mq.DelayTime; 7 import com.yohoufo.order.mq.DelayTime;
7 import com.yohoufo.order.mq.TopicConstants; 8 import com.yohoufo.order.mq.TopicConstants;
@@ -35,9 +36,9 @@ public class DeliverNoticeAsyncHandler implements IEventHandler<DeliverNoticeEve @@ -35,9 +36,9 @@ public class DeliverNoticeAsyncHandler implements IEventHandler<DeliverNoticeEve
35 @Override 36 @Override
36 @Subscribe 37 @Subscribe
37 public void handle(DeliverNoticeEvent event) { 38 public void handle(DeliverNoticeEvent event) {
38 - int minutes = deliveryMinutesService.getDeliverMinutesSecond();  
39 - //String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE;  
40 - String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE_108; 39 + int ts = DateUtil.getCurrentTimeSecond();
  40 + int minutes = deliveryMinutesService.getDeliverMinutesSecond(ts);
  41 + String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE;
41 logger.info("in DeliverNoticeAsyncHandler handler, topic {},minutes {} ,msg {}",topic, minutes,event); 42 logger.info("in DeliverNoticeAsyncHandler handler, topic {},minutes {} ,msg {}",topic, minutes,event);
42 tradeMqSender.send(topic, event, minutes); 43 tradeMqSender.send(topic, event, minutes);
43 } 44 }
@@ -3,10 +3,13 @@ package com.yohoufo.order.service.handler; @@ -3,10 +3,13 @@ package com.yohoufo.order.service.handler;
3 import com.google.common.eventbus.Subscribe; 3 import com.google.common.eventbus.Subscribe;
4 import com.yoho.core.config.ConfigReader; 4 import com.yoho.core.config.ConfigReader;
5 import com.yohoufo.common.alarm.IEventHandler; 5 import com.yohoufo.common.alarm.IEventHandler;
  6 +import com.yohoufo.common.utils.DateUtil;
  7 +import com.yohoufo.dal.order.model.OrderOverTime;
6 import com.yohoufo.order.event.SellerCancelDeliverEvent; 8 import com.yohoufo.order.event.SellerCancelDeliverEvent;
7 import com.yohoufo.order.mq.DelayTime; 9 import com.yohoufo.order.mq.DelayTime;
8 import com.yohoufo.order.mq.TopicConstants; 10 import com.yohoufo.order.mq.TopicConstants;
9 import com.yohoufo.order.mq.producer.TradeMqSender; 11 import com.yohoufo.order.mq.producer.TradeMqSender;
  12 +import com.yohoufo.order.service.impl.OrderOverTimeService;
10 import com.yohoufo.order.service.proxy.DeliveryMinutesService; 13 import com.yohoufo.order.service.proxy.DeliveryMinutesService;
11 import com.yohoufo.order.utils.LoggerUtils; 14 import com.yohoufo.order.utils.LoggerUtils;
12 import org.slf4j.Logger; 15 import org.slf4j.Logger;
@@ -29,14 +32,20 @@ public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDel @@ -29,14 +32,20 @@ public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDel
29 @Autowired 32 @Autowired
30 private DeliveryMinutesService deliveryMinutesService; 33 private DeliveryMinutesService deliveryMinutesService;
31 34
  35 + @Autowired
  36 + private OrderOverTimeService orderOverTimeService;
  37 +
32 @Override 38 @Override
33 @Subscribe 39 @Subscribe
34 public void handle(SellerCancelDeliverEvent event) { 40 public void handle(SellerCancelDeliverEvent event) {
35 - int minutes = deliveryMinutesService.getDeliverMinutesThird();  
36 - //String topic = TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;  
37 - String topic = TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER_120; 41 + int ts = DateUtil.getCurrentTimeSecond();
  42 + int minutes = deliveryMinutesService.getDeliverMinutesThird(ts);
  43 + String topic = TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;
38 logger.info("Subscribe Buyer Confirm delay msg,topic {}, delay minutes {} , event {}",topic,minutes, event); 44 logger.info("Subscribe Buyer Confirm delay msg,topic {}, delay minutes {} , event {}",topic,minutes, event);
39 45
40 tradeMqSender.send(topic, event, minutes); 46 tradeMqSender.send(topic, event, minutes);
  47 +
  48 + // 记录此订单的发货超时时间期限点
  49 + orderOverTimeService.insertDeliveryTime(new OrderOverTime(event.getOrderCode(), ts + minutes * 60, minutes));
41 } 50 }
42 } 51 }
@@ -48,9 +48,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen @@ -48,9 +48,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
48 @Autowired 48 @Autowired
49 protected OrdersPayService ordersPayService; 49 protected OrdersPayService ordersPayService;
50 50
51 - @Autowired  
52 - private DeliveryMinutesService deliveryMinutesService;  
53 -  
54 abstract BuyerOrder getBuyerOrder(int uid, long orderCode); 51 abstract BuyerOrder getBuyerOrder(int uid, long orderCode);
55 52
56 abstract BuyerOrderMeta getBuyerOrderMeta(int uid, long orderCode, String metaKey); 53 abstract BuyerOrderMeta getBuyerOrderMeta(int uid, long orderCode, String metaKey);
@@ -110,15 +107,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen @@ -110,15 +107,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
110 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 107 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
111 } 108 }
112 109
113 - /*if(orderStatus.getCode() == OrderStatus.HAS_PAYED.getCode() || orderStatus.getCode() == OrderStatus.SEND_OUT_TIMEOUT.getCode()){  
114 - TimeoutBo timeoutBo = ordersPayService.getDeliverLeftTime(uid, orderCode);  
115 - if(timeoutBo!=null && timeoutBo.getTimelimit().intValue() != DelayTime.MINUTES_36_HOURS * 60  
116 - && timeoutBo.getStartTime()!=null && timeoutBo.getStartTime().intValue()>=deliveryMinutesService.getOnlineTime()){  
117 - logger.info("getOrderDetail resetDescForSeller , uid is {}, buyerUid {} orderCode is {}", uid,  
118 - buyerUid, orderCode);  
119 - OrderStatus.resetDescForSeller(orderStatus);  
120 - }  
121 - }*/  
122 110
123 BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(buyerUid, orderCode); 111 BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(buyerUid, orderCode);
124 if (buyerOrderGoods == null){ 112 if (buyerOrderGoods == null){
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yohoufo.dal.order.OrderOverTimeMapper;
  4 +import com.yohoufo.dal.order.model.OrderOverTime;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.stereotype.Service;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by li.ma on 2019/1/30.
  12 + */
  13 +@Service
  14 +public class OrderOverTimeService {
  15 + @Autowired
  16 + private OrderOverTimeMapper orderOverTimeMapper;
  17 +
  18 + public int insertDeliveryTime(OrderOverTime record) {
  19 + return orderOverTimeMapper.insertDeliveryTime(record);
  20 + }
  21 +
  22 + public int insertShamSendTime(OrderOverTime record) {
  23 + return orderOverTimeMapper.insertShamSendTime(record);
  24 + }
  25 +
  26 + public List<OrderOverTime> selectByOrderCodes(List<Long> orderCodeList) {
  27 + return orderOverTimeMapper.selectByOrderCodes(orderCodeList);
  28 + }
  29 +
  30 + public OrderOverTime selectByOrderCode(Long orderCode) {
  31 + return orderOverTimeMapper.selectByOrderCode(orderCode);
  32 + }
  33 +}
@@ -4,6 +4,7 @@ import com.yohobuy.ufo.model.order.bo.TimeoutBo; @@ -4,6 +4,7 @@ import com.yohobuy.ufo.model.order.bo.TimeoutBo;
4 import com.yohobuy.ufo.model.order.constants.TimeoutCase; 4 import com.yohobuy.ufo.model.order.constants.TimeoutCase;
5 import com.yohoufo.common.utils.DateUtil; 5 import com.yohoufo.common.utils.DateUtil;
6 import com.yohoufo.dal.order.OrdersPayMapper; 6 import com.yohoufo.dal.order.OrdersPayMapper;
  7 +import com.yohoufo.dal.order.model.OrderOverTime;
7 import com.yohoufo.dal.order.model.OrdersPay; 8 import com.yohoufo.dal.order.model.OrdersPay;
8 import com.yohoufo.order.mq.DelayTime; 9 import com.yohoufo.order.mq.DelayTime;
9 import com.yohoufo.order.service.proxy.DeliveryMinutesService; 10 import com.yohoufo.order.service.proxy.DeliveryMinutesService;
@@ -12,6 +13,9 @@ import org.slf4j.LoggerFactory; @@ -12,6 +13,9 @@ import org.slf4j.LoggerFactory;
12 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.stereotype.Service; 14 import org.springframework.stereotype.Service;
14 15
  16 +import java.util.Objects;
  17 +import java.util.Optional;
  18 +
15 /** 19 /**
16 * Created by chao.chen on 2018/11/23. 20 * Created by chao.chen on 2018/11/23.
17 */ 21 */
@@ -24,8 +28,15 @@ public class OrdersPayService { @@ -24,8 +28,15 @@ public class OrdersPayService {
24 @Autowired 28 @Autowired
25 private DeliveryMinutesService deliveryMinutesService; 29 private DeliveryMinutesService deliveryMinutesService;
26 30
  31 + @Autowired
  32 + private OrderOverTimeService orderOverTimeService;
27 33
28 - 34 + /**
  35 + * 需要根据配置进行算配置时间点之前的剩余时长
  36 + * @param buyerUid
  37 + * @param orderCode
  38 + * @return
  39 + */
29 public TimeoutBo getDeliverLeftTime(int buyerUid, long orderCode){ 40 public TimeoutBo getDeliverLeftTime(int buyerUid, long orderCode){
30 OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid); 41 OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid);
31 if (ordersPay == null){ 42 if (ordersPay == null){
@@ -34,18 +45,26 @@ public class OrdersPayService { @@ -34,18 +45,26 @@ public class OrdersPayService {
34 45
35 Integer createTime = ordersPay.getCreateTime(); 46 Integer createTime = ordersPay.getCreateTime();
36 47
  48 + OrderOverTime orderOverTime = Optional.ofNullable(orderCode).map(orderOverTimeService::selectByOrderCode).orElse(null);
  49 + //Integer deliverMinute = Optional.ofNullable(orderOverTime).map(OrderOverTime::getDeliveryMinutes).orElse(null); // 对于老订单来说,超时表记录无数据,则默认120小时
  50 + Integer deliverMinute = Optional.ofNullable(orderOverTime).map(OrderOverTime::getDeliveryMinutes).orElse(DelayTime.MINUTES_120_HOURS ); // 对于老订单来说,超时表记录无数据,则默认120小时
  51 + //把分钟转为秒
  52 + int timelimit = deliverMinute * 60;
  53 + /**
37 //订单的支付时间如果大于上线时间,则120小时算,否则还是36小时 54 //订单的支付时间如果大于上线时间,则120小时算,否则还是36小时
38 int timelimit; 55 int timelimit;
39 - int onLineTime = deliveryMinutesService.getOnlineTime();  
40 - if(createTime.intValue()>=onLineTime){ 56 + int onLineTime = deliveryMinutesService.getOnlineTime(); //
  57 + if(Objects.isNull(deliverMinute)){
41 logger.info("OrdersPayService createTime bigger than online time ,set 120 hours ,orderCode {},createTime {} ,onLineTime {}",orderCode,createTime,onLineTime); 58 logger.info("OrdersPayService createTime bigger than online time ,set 120 hours ,orderCode {},createTime {} ,onLineTime {}",orderCode,createTime,onLineTime);
42 - timelimit = deliveryMinutesService.getDeliverMinutesThird()* 60; 59 + timelimit = DelayTime.MINUTES_120_HOURS * 60;
43 }else{ 60 }else{
44 logger.info("OrdersPayService createTime smaller than online time ,set 36 hours ,orderCode {},createTime {} ,onLineTime {}",orderCode,createTime,onLineTime); 61 logger.info("OrdersPayService createTime smaller than online time ,set 36 hours ,orderCode {},createTime {} ,onLineTime {}",orderCode,createTime,onLineTime);
45 - timelimit = DelayTime.MINUTES_36_HOURS * 60; 62 + //timelimit = deliveryMinutesService.getDeliverMinutesThird()* 60;
  63 + timelimit = deliverMinute;
46 } 64 }
47 //int timelimit = DelayTime.MINUTES_36_HOURS * 60; 65 //int timelimit = DelayTime.MINUTES_36_HOURS * 60;
48 //int timelimit = deliveryMinutesService.getDeliverMinutesThird()* 60; 66 //int timelimit = deliveryMinutesService.getDeliverMinutesThird()* 60;
  67 + */
49 68
50 int left = timelimit - (DateUtil.getCurrentTimeSecond()-createTime); 69 int left = timelimit - (DateUtil.getCurrentTimeSecond()-createTime);
51 TimeoutBo timeoutBo = new TimeoutBo(); 70 TimeoutBo timeoutBo = new TimeoutBo();
@@ -42,10 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -42,10 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.stereotype.Service; 42 import org.springframework.stereotype.Service;
43 43
44 import java.math.BigDecimal; 44 import java.math.BigDecimal;
45 -import java.util.ArrayList;  
46 -import java.util.Arrays;  
47 -import java.util.List;  
48 -import java.util.Objects; 45 +import java.util.*;
49 46
50 /** 47 /**
51 * Created by chenchao on 2018/9/20. 48 * Created by chenchao on 2018/9/20.
@@ -93,7 +90,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -93,7 +90,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
93 90
94 91
95 @Autowired 92 @Autowired
96 - private DeliveryMinutesService deliveryMinutesService; 93 + private OrderOverTimeService orderOverTimeService;
97 94
98 private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL, 95 private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
99 SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL, 96 SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL,
@@ -395,14 +392,18 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -395,14 +392,18 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
395 .build(); 392 .build();
396 393
397 if(orderStatus.getCode() == OrderStatus.HAS_PAYED.getCode() || orderStatus.getCode() == OrderStatus.SEND_OUT_TIMEOUT.getCode()){ 394 if(orderStatus.getCode() == OrderStatus.HAS_PAYED.getCode() || orderStatus.getCode() == OrderStatus.SEND_OUT_TIMEOUT.getCode()){
398 - TimeoutBo timeoutBo = ordersPayService.getDeliverLeftTime(buyerOrder.getUid(), buyerOrder.getOrderCode());  
399 - if(timeoutBo!=null && timeoutBo.getTimelimit().intValue() != DelayTime.MINUTES_36_HOURS * 60  
400 - && timeoutBo.getStartTime()!=null && timeoutBo.getStartTime().intValue()>=deliveryMinutesService.getOnlineTime()){  
401 - logger.info("getStatusDetail resetDescForSeller , buyerUid {} orderCode is {},statusDetail {}", buyerOrder.getUid(),  
402 - buyerOrder.getOrderCode(),statusDetail);  
403 - statusDetail.setDetailDesc(statusDetail.getDetailDesc().replace("36","120"));  
404 - logger.info("getStatusDetail resetDescForSeller after, buyerUid {} orderCode is {},statusDetail {}", buyerOrder.getUid(),  
405 - buyerOrder.getOrderCode(),statusDetail); 395 + //TimeoutBo timeoutBo = ordersPayService.getDeliverLeftTime(buyerOrder.getUid(), buyerOrder.getOrderCode());
  396 +
  397 + //orderOverTimeService
  398 + OrderOverTime orderOverTime = Optional.ofNullable(buyerOrder.getOrderCode()).map(orderOverTimeService::selectByOrderCode).orElse(null);
  399 + Integer deliverMinute = Optional.ofNullable(orderOverTime).map(OrderOverTime::getDeliveryMinutes).orElse(DelayTime.MINUTES_120_HOURS ); // 对于老订单来说,超时表记录无数据,则默认120小时
  400 + int delayHours = deliverMinute/60 ;//发货延迟的时间 : 单位 分钟
  401 + logger.info("getStatusDetail resetDescForSeller , buyerUid {} orderCode is {},statusDetail {},orderOverTime {}, deliverMinute {} ", buyerOrder.getUid(),
  402 + buyerOrder.getOrderCode(),statusDetail,orderOverTime,deliverMinute);
  403 + if(delayHours!=36){
  404 + statusDetail.setDetailDesc(statusDetail.getDetailDesc().replace("36",""+delayHours));
  405 + logger.info("getStatusDetail resetDescForSeller after, buyerUid {} orderCode is {},statusDetail {},orderOverTime {} ", buyerOrder.getUid(),
  406 + buyerOrder.getOrderCode(),statusDetail,orderOverTime);
406 } 407 }
407 } 408 }
408 409
@@ -14,6 +14,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService; @@ -14,6 +14,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService;
14 import org.slf4j.Logger; 14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
16 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.beans.factory.annotation.Value;
17 import org.springframework.stereotype.Component; 18 import org.springframework.stereotype.Component;
18 19
19 import javax.annotation.PostConstruct; 20 import javax.annotation.PostConstruct;
@@ -26,70 +27,62 @@ import java.util.concurrent.TimeUnit; @@ -26,70 +27,62 @@ import java.util.concurrent.TimeUnit;
26 @Component 27 @Component
27 public class DeliveryMinutesService { 28 public class DeliveryMinutesService {
28 private static final Logger logger = LoggerFactory.getLogger(DeliveryMinutesService.class); 29 private static final Logger logger = LoggerFactory.getLogger(DeliveryMinutesService.class);
  30 +
  31 + //缓存
  32 + private LocalCache localCache_onlineTimeEx = new LocalCache();
  33 + private static final String ONLINE_TIME_EX_CACHE_KEY = "sellerDeliverNewOnlineTimeExCacheKey";
  34 +
29 @Autowired 35 @Autowired
30 private ConfigReader configReader; 36 private ConfigReader configReader;
31 37
32 - //缓存  
33 - private LocalCache localCache_onlineTime = new LocalCache();  
34 - private static final String ONLINE_TIME_CACHE_KEY = "sellerDeliverNewOnlineTimeCacheKey";  
35 38
36 - private LocalCache localCache_second = new LocalCache();  
37 - private static final String SECOND_CACHE_KEY = "sellerDeliverNoticeSecondCacheKey"; 39 + @Value("${mq.seller.deliverNotice.second}")
  40 + private int minutes_deliverNotice_second;
38 41
39 - private LocalCache localCache_third = new LocalCache();  
40 - private static final String THIRD_CACHE_KEY = "sellerDeliverNoticeThirdCacheKey"; 42 + @Value("${mq.seller.deliverNotice.old.second}")
  43 + private int minutes_deliverNotice_second_old;
41 44
42 - @PostConstruct  
43 - private void init() {  
44 - localCache_onlineTime.init(ONLINE_TIME_CACHE_KEY, 8, TimeUnit.HOURS, (String s, Object o) -> {  
45 - logger.info("init ONLINE_TIME_CACHE_KEY s = {}, o = {}", s, o);  
46 - return configReader.getInt("ufo.order.sellerDeliverNewOnlineTime",1548756000);  
47 - }); 45 + @Value("${mq.seller.deliverNotice.third}")
  46 + private int minutes_deliverNotice_third;
48 47
49 - localCache_second.init(SECOND_CACHE_KEY, 9, TimeUnit.HOURS, (String s, Object o) -> {  
50 - logger.info("init SECOND_CACHE_KEY s = {}, o = {}", s, o);  
51 - return configReader.getInt("ufo.order.sellerDeliverNoticeSecond",108*60);  
52 - }); 48 + @Value("${mq.seller.deliverNotice.old.third}")
  49 + private int minutes_deliverNotice_third_old;
  50 +
  51 + //默认的生效时间:优先加在zk的配置值 2019-2-15 0:0:0
  52 + private int defaultSellerDeliverNewOnlineTimeEx = 1550160000;
53 53
54 - localCache_third.init(THIRD_CACHE_KEY, 10, TimeUnit.HOURS, (String s, Object o) -> {  
55 - logger.info("init THIRD_CACHE_KEY s = {}, o = {}", s, o);  
56 - return configReader.getInt("ufo.order.sellerDeliverNoticeThird",120*60); 54 + @PostConstruct
  55 + private void init() {
  56 + localCache_onlineTimeEx.init(ONLINE_TIME_EX_CACHE_KEY, 5, TimeUnit.MINUTES, (String s, Object o) -> {
  57 + logger.info("init ONLINE_TIME_EX_CACHE_KEY s = {}, o = {}", s, o);
  58 + return configReader.getInt("ufo.order.sellerDeliverNewOnlineTimeEx",defaultSellerDeliverNewOnlineTimeEx);
57 }); 59 });
58 } 60 }
59 61
60 - public int getDeliverMinutesSecond(){  
61 - Object value=localCache_second.get(SECOND_CACHE_KEY); 62 + private int getOnlineTime(){
  63 + Object value=localCache_onlineTimeEx.get(ONLINE_TIME_EX_CACHE_KEY);
62 if(null == value) { 64 if(null == value) {
63 - return 108*60; 65 + return defaultSellerDeliverNewOnlineTimeEx;
64 } 66 }
65 return (Integer) value; 67 return (Integer) value;
66 } 68 }
67 69
68 - public int getDeliverMinutesThird(){  
69 - Object value=localCache_third.get(THIRD_CACHE_KEY);  
70 - if(null == value) {  
71 - return 120*60; 70 + public int getDeliverMinutesSecond(int ts){
  71 + if(ts<getOnlineTime()){
  72 + return minutes_deliverNotice_second_old;
72 } 73 }
73 - return (Integer) value;  
74 - }  
75 -  
76 - /**  
77 - * 发货时间 : 单位小时  
78 - * @return  
79 - */  
80 - public int getDeliverMinutesThird_hours(){  
81 - int minutes = getDeliverMinutesThird();  
82 - return minutes/60 ; 74 + return minutes_deliverNotice_second;
83 } 75 }
84 76
85 - //上线时间 : 新的时间戳  
86 - public int getOnlineTime(){  
87 - Object value=localCache_onlineTime.get(ONLINE_TIME_CACHE_KEY);  
88 - if(null == value) {  
89 - return 1548756000; 77 + public int getDeliverMinutesThird(int ts){
  78 + if(ts<getOnlineTime()){
  79 + return minutes_deliverNotice_third_old;
90 } 80 }
91 - return (Integer) value; 81 + return minutes_deliverNotice_third;
92 } 82 }
93 83
94 - 84 + public int getDeliverMinutesThird_hours(int ts){
  85 + int minutes = getDeliverMinutesThird(ts);
  86 + return minutes/60 ;
  87 + }
95 } 88 }
@@ -123,7 +123,15 @@ rabbit_host=192.168.102.45:5672 @@ -123,7 +123,15 @@ rabbit_host=192.168.102.45:5672
123 rabbit_user=yoho 123 rabbit_user=yoho
124 rabbit_password=yoho 124 rabbit_password=yoho
125 125
126 - 126 +#二次发货提醒 24*60 minutes
  127 +mq.seller.deliverNotice.second=1440
  128 +#发货失败提醒 36*60 minutes
  129 +mq.seller.deliverNotice.third=2160
  130 +
  131 +#old 二次发货提醒 108*60 minutes
  132 +mq.seller.deliverNotice.old.second=6480
  133 +#old发货失败提醒 120*60
  134 +mq.seller.deliverNotice.old.third=7200
127 135
128 yoho.gateway.url=http://api-test3.dev.yohocorp.com 136 yoho.gateway.url=http://api-test3.dev.yohocorp.com
129 137
@@ -80,6 +80,7 @@ datasources: @@ -80,6 +80,7 @@ datasources:
80 - com.yohoufo.dal.order.SellerEnterApplyMapper 80 - com.yohoufo.dal.order.SellerEnterApplyMapper
81 - com.yohoufo.dal.order.SellerFuncMapper 81 - com.yohoufo.dal.order.SellerFuncMapper
82 - com.yohoufo.dal.order.SellerLevelFuncMapper 82 - com.yohoufo.dal.order.SellerLevelFuncMapper
  83 + - com.yohoufo.dal.order.OrderOverTimeMapper
83 84
84 ufo_promotion: 85 ufo_promotion:
85 servers: 86 servers:
@@ -18,4 +18,6 @@ ufo.order.sellerDeliverNoticeSecond = 6480 @@ -18,4 +18,6 @@ ufo.order.sellerDeliverNoticeSecond = 6480
18 #发货失败提醒 120*60 minutes 18 #发货失败提醒 120*60 minutes
19 ufo.order.sellerDeliverNoticeThird = 7200 19 ufo.order.sellerDeliverNoticeThird = 7200
20 #新的发货上线时间 20190129 18:00:00 20 #新的发货上线时间 20190129 18:00:00
21 -ufo.order.sellerDeliverNewOnlineTime = 1548756000  
  21 +ufo.order.sellerDeliverNewOnlineTime = 1548756000
  22 +
  23 +ufo.order.sellerDeliverNewOnlineTimeEx = 1550160000
@@ -23,11 +23,6 @@ consumer: @@ -23,11 +23,6 @@ consumer:
23 delay: 23 delay:
24 interval: 1440 24 interval: 1440
25 25
26 - - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer  
27 - topic: sellerOrder.autoCancelDeliver  
28 - delay:  
29 - interval: 2160  
30 -  
31 - class: com.yohoufo.order.mq.consumer.NotPaidNoticeDelayMsgConsumer 26 - class: com.yohoufo.order.mq.consumer.NotPaidNoticeDelayMsgConsumer
32 topic: order.notPaidNotice 27 topic: order.notPaidNotice
33 delay: 28 delay:
@@ -38,18 +33,23 @@ consumer: @@ -38,18 +33,23 @@ consumer:
38 delay: 33 delay:
39 interval: 1440 34 interval: 1440
40 35
41 - #春节期间发货时间延长的120小时  
42 - - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer120  
43 - topic: sellerOrder.autoCancelDeliver_120 36 + - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer
  37 + topic: sellerOrder.autoCancelDeliver
44 delay: 38 delay:
45 - interval: 7200 39 + interval: 2160
46 40
47 - #春节期间二次发货提醒时间延长的108小时 41 + #春节期间二次发货提醒时间延长的108小时 ,后续不再使用,6.8.6以后的版本可以去掉
48 - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer 42 - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer
49 topic: order.notDeliver_108 43 topic: order.notDeliver_108
50 delay: 44 delay:
51 interval: 6480 45 interval: 6480
52 46
  47 + #春节期间发货时间延长的120小时 ,后续不再使用,6.8.6以后的版本可以去掉
  48 + - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer120
  49 + topic: sellerOrder.autoCancelDeliver_120
  50 + delay:
  51 + interval: 7200
  52 +
53 #更新物流调拨信息 53 #更新物流调拨信息
54 - address: 192.168.102.45:5672 54 - address: 192.168.102.45:5672
55 username: yoho 55 username: yoho
@@ -98,6 +98,15 @@ rabbit_host=${rabbit_ufo} @@ -98,6 +98,15 @@ rabbit_host=${rabbit_ufo}
98 rabbit_user=${rabbit_ufo_user} 98 rabbit_user=${rabbit_ufo_user}
99 rabbit_password=${rabbit_ufo_password} 99 rabbit_password=${rabbit_ufo_password}
100 100
  101 +#二次发货提醒 24*60 minutes 1440
  102 +mq.seller.deliverNotice.second=1440
  103 +#发货失败提醒 36*60 minutes 2160
  104 +mq.seller.deliverNotice.third=2160
  105 +
  106 +#old 二次发货提醒 108*60 minutes
  107 +mq.seller.deliverNotice.old.second=6480
  108 +#old发货失败提醒 120*60
  109 +mq.seller.deliverNotice.old.third=7200
101 110
102 111
103 yoho.gateway.url=${yoho.gateway.url} 112 yoho.gateway.url=${yoho.gateway.url}
@@ -80,6 +80,7 @@ datasources: @@ -80,6 +80,7 @@ datasources:
80 - com.yohoufo.dal.order.SellerEnterApplyMapper 80 - com.yohoufo.dal.order.SellerEnterApplyMapper
81 - com.yohoufo.dal.order.SellerFuncMapper 81 - com.yohoufo.dal.order.SellerFuncMapper
82 - com.yohoufo.dal.order.SellerLevelFuncMapper 82 - com.yohoufo.dal.order.SellerLevelFuncMapper
  83 + - com.yohoufo.dal.order.OrderOverTimeMapper
83 84
84 ufo_promotion: 85 ufo_promotion:
85 servers: 86 servers:
@@ -23,11 +23,6 @@ consumer: @@ -23,11 +23,6 @@ consumer:
23 delay: 23 delay:
24 interval: 1440 24 interval: 1440
25 25
26 - - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer  
27 - topic: sellerOrder.autoCancelDeliver  
28 - delay:  
29 - interval: 2160  
30 -  
31 #order.notPaidNotice 26 #order.notPaidNotice
32 - class: com.yohoufo.order.mq.consumer.NotPaidNoticeDelayMsgConsumer 27 - class: com.yohoufo.order.mq.consumer.NotPaidNoticeDelayMsgConsumer
33 topic: order.notPaidNotice 28 topic: order.notPaidNotice
@@ -39,18 +34,39 @@ consumer: @@ -39,18 +34,39 @@ consumer:
39 delay: 34 delay:
40 interval: 1440 35 interval: 1440
41 36
42 - #春节期间发货时间延长的120小时  
43 - - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer120  
44 - topic: sellerOrder.autoCancelDeliver_120 37 + - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer
  38 + topic: sellerOrder.autoCancelDeliver
  39 + delay:
  40 + interval: 2160
  41 +
  42 + #春节期间二次发货恢复成24小时,
  43 + #在系统发布后未生效之前.需要该队列,后续不再使用,
  44 + #6.8.6以后的版本可以去掉
  45 + - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer
  46 + topic: order.notDeliver
  47 + delay:
  48 + interval: 6480
  49 +
  50 + #春节期间发货时间恢复成36小时,
  51 + #在系统发布后未生效之前.需要该队列,
  52 + #后续不再使用,6.8.6以后的版本可以去掉
  53 + - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer
  54 + topic: sellerOrder.autoCancelDeliver
45 delay: 55 delay:
46 interval: 7200 56 interval: 7200
47 57
48 - #春节期间二次发货提醒时间延长的108小时 58 + #春节期间二次发货提醒时间延长的108小时 ,后续不再使用,6.8.6以后的版本可以去掉
49 - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer 59 - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer
50 topic: order.notDeliver_108 60 topic: order.notDeliver_108
51 delay: 61 delay:
52 interval: 6480 62 interval: 6480
53 63
  64 + #春节期间发货时间延长的120小时 ,后续不再使用,6.8.6以后的版本可以去掉
  65 + - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer120
  66 + topic: sellerOrder.autoCancelDeliver_120
  67 + delay:
  68 + interval: 7200
  69 +
54 - address: ${rabbit_ufo} 70 - address: ${rabbit_ufo}
55 username: ${rabbit_ufo_user} 71 username: ${rabbit_ufo_user}
56 password: ${rabbit_ufo_password} 72 password: ${rabbit_ufo_password}