...
|
...
|
@@ -14,6 +14,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService; |
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
...
|
...
|
@@ -26,70 +27,62 @@ import java.util.concurrent.TimeUnit; |
|
|
@Component
|
|
|
public class DeliveryMinutesService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DeliveryMinutesService.class);
|
|
|
|
|
|
//缓存
|
|
|
private LocalCache localCache_onlineTimeEx = new LocalCache();
|
|
|
private static final String ONLINE_TIME_EX_CACHE_KEY = "sellerDeliverNewOnlineTimeExCacheKey";
|
|
|
|
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
//缓存
|
|
|
private LocalCache localCache_onlineTime = new LocalCache();
|
|
|
private static final String ONLINE_TIME_CACHE_KEY = "sellerDeliverNewOnlineTimeCacheKey";
|
|
|
|
|
|
private LocalCache localCache_second = new LocalCache();
|
|
|
private static final String SECOND_CACHE_KEY = "sellerDeliverNoticeSecondCacheKey";
|
|
|
@Value("${mq.seller.deliverNotice.second}")
|
|
|
private int minutes_deliverNotice_second;
|
|
|
|
|
|
private LocalCache localCache_third = new LocalCache();
|
|
|
private static final String THIRD_CACHE_KEY = "sellerDeliverNoticeThirdCacheKey";
|
|
|
@Value("${mq.seller.deliverNotice.old.second}")
|
|
|
private int minutes_deliverNotice_second_old;
|
|
|
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
localCache_onlineTime.init(ONLINE_TIME_CACHE_KEY, 8, TimeUnit.HOURS, (String s, Object o) -> {
|
|
|
logger.info("init ONLINE_TIME_CACHE_KEY s = {}, o = {}", s, o);
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNewOnlineTime",1548756000);
|
|
|
});
|
|
|
@Value("${mq.seller.deliverNotice.third}")
|
|
|
private int minutes_deliverNotice_third;
|
|
|
|
|
|
localCache_second.init(SECOND_CACHE_KEY, 9, TimeUnit.HOURS, (String s, Object o) -> {
|
|
|
logger.info("init SECOND_CACHE_KEY s = {}, o = {}", s, o);
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNoticeSecond",108*60);
|
|
|
});
|
|
|
@Value("${mq.seller.deliverNotice.old.third}")
|
|
|
private int minutes_deliverNotice_third_old;
|
|
|
|
|
|
//默认的生效时间:优先加在zk的配置值 2019-2-15 0:0:0
|
|
|
private int defaultSellerDeliverNewOnlineTimeEx = 1550160000;
|
|
|
|
|
|
localCache_third.init(THIRD_CACHE_KEY, 10, TimeUnit.HOURS, (String s, Object o) -> {
|
|
|
logger.info("init THIRD_CACHE_KEY s = {}, o = {}", s, o);
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNoticeThird",120*60);
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
localCache_onlineTimeEx.init(ONLINE_TIME_EX_CACHE_KEY, 5, TimeUnit.MINUTES, (String s, Object o) -> {
|
|
|
logger.info("init ONLINE_TIME_EX_CACHE_KEY s = {}, o = {}", s, o);
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNewOnlineTimeEx",defaultSellerDeliverNewOnlineTimeEx);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public int getDeliverMinutesSecond(){
|
|
|
Object value=localCache_second.get(SECOND_CACHE_KEY);
|
|
|
private int getOnlineTime(){
|
|
|
Object value=localCache_onlineTimeEx.get(ONLINE_TIME_EX_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 108*60;
|
|
|
return defaultSellerDeliverNewOnlineTimeEx;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
public int getDeliverMinutesThird(){
|
|
|
Object value=localCache_third.get(THIRD_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 120*60;
|
|
|
public int getDeliverMinutesSecond(int ts){
|
|
|
if(ts<getOnlineTime()){
|
|
|
return minutes_deliverNotice_second_old;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发货时间 : 单位小时
|
|
|
* @return
|
|
|
*/
|
|
|
public int getDeliverMinutesThird_hours(){
|
|
|
int minutes = getDeliverMinutesThird();
|
|
|
return minutes/60 ;
|
|
|
return minutes_deliverNotice_second;
|
|
|
}
|
|
|
|
|
|
//上线时间 : 新的时间戳
|
|
|
public int getOnlineTime(){
|
|
|
Object value=localCache_onlineTime.get(ONLINE_TIME_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 1548756000;
|
|
|
public int getDeliverMinutesThird(int ts){
|
|
|
if(ts<getOnlineTime()){
|
|
|
return minutes_deliverNotice_third_old;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
return minutes_deliverNotice_third;
|
|
|
}
|
|
|
|
|
|
|
|
|
public int getDeliverMinutesThird_hours(int ts){
|
|
|
int minutes = getDeliverMinutesThird(ts);
|
|
|
return minutes/60 ;
|
|
|
}
|
|
|
} |
...
|
...
|
|