|
|
package com.yohoufo.order.service.proxy;
|
|
|
|
|
|
import com.google.common.cache.Cache;
|
|
|
import com.google.common.cache.CacheBuilder;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.cache.LocalCache;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yohobuy.ufo.model.order.resp.ExpressCompanyRespBo;
|
|
|
import com.yohoufo.common.utils.OrikaUtils;
|
|
|
import com.yohoufo.dal.order.model.ExpressCompany;
|
|
|
import com.yohoufo.order.model.bo.TradeBillsSummaryBo;
|
|
|
import com.yohoufo.order.model.response.AppraiseAddressResp;
|
|
|
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.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 动态获取发货时间
|
|
|
*/
|
|
|
@Component
|
|
|
public class DeliveryMinutesService {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DeliveryMinutesService.class);
|
|
|
@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";
|
|
|
|
|
|
private LocalCache localCache_third = new LocalCache();
|
|
|
private static final String THIRD_CACHE_KEY = "sellerDeliverNoticeThirdCacheKey";
|
|
|
|
|
|
@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);
|
|
|
});
|
|
|
|
|
|
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);
|
|
|
});
|
|
|
|
|
|
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);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public int getDeliverMinutesSecond(){
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNoticeSecond",108*60);
|
|
|
Object value=localCache_second.get(SECOND_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 108*60;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
public int getDeliverMinutesThird(){
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNoticeThird",120*60);
|
|
|
Object value=localCache_third.get(THIRD_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 120*60;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -31,7 +84,11 @@ public class DeliveryMinutesService { |
|
|
|
|
|
//上线时间 : 新的时间戳
|
|
|
public int getOnlineTime(){
|
|
|
return configReader.getInt("ufo.order.sellerDeliverNewOnlineTime",1548756000);
|
|
|
Object value=localCache_onlineTime.get(ONLINE_TIME_CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 1548756000;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|