|
|
package com.yoho.search.consumer.service.logic;
|
|
|
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.consumer.service.base.ProductService;
|
|
|
import com.yoho.search.consumer.service.base.ProductTimingService;
|
|
|
import com.yoho.search.consumer.service.base.StorageService;
|
|
|
import com.yoho.search.dal.ProductMapper;
|
|
|
import com.yoho.search.dal.model.ProductTiming;
|
|
|
import com.yoho.search.dal.model.StorageUpdateTime;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -14,6 +13,7 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2016/11/22.
|
...
|
...
|
@@ -24,15 +24,14 @@ public class StorageUpdateTimeLogicService { |
|
|
private final Logger logger = LoggerFactory.getLogger(StorageUpdateTimeLogicService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
@Autowired
|
|
|
private StorageService storageService;
|
|
|
@Autowired
|
|
|
private ProductTimingService productTimingService;
|
|
|
@Autowired
|
|
|
private ProductService productService;
|
|
|
|
|
|
public List<StorageUpdateTime> getData(List<Integer> productIds) {
|
|
|
if (CollectionUtils.isEmpty(productIds)) {
|
|
|
logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]","productIds is empty");
|
|
|
public List<StorageUpdateTime> getData(List<Integer> productIds,List<Integer> productSkns) {
|
|
|
if (CollectionUtils.isEmpty(productIds)||CollectionUtils.isEmpty(productSkns)) {
|
|
|
return new ArrayList<StorageUpdateTime>();
|
|
|
}
|
|
|
//查询Product对应的StorageUpdateTime
|
...
|
...
|
@@ -41,21 +40,18 @@ public class StorageUpdateTimeLogicService { |
|
|
logger.warn("[class=StorageUpdateTimeLogicService][fun=getData][message={}]","storageUpdateTimes is empty");
|
|
|
return new ArrayList<StorageUpdateTime>();
|
|
|
}
|
|
|
|
|
|
//获取多少天后过期Map,key:skn value:outsaletime
|
|
|
Map<Integer,Integer> outSaleTimeMap = productTimingService.selectBySkns(productSkns);
|
|
|
//key:productId value:productSkn
|
|
|
Map<Integer,Integer> productSknMap =productService.selectSknsByProductIds(productIds);
|
|
|
for (StorageUpdateTime storageUpdateTime : storageUpdateTimes) {
|
|
|
//获取多少天后过期
|
|
|
Integer productSkn = productMapper.selectSknByProductId(storageUpdateTime.getProductId());
|
|
|
ProductTiming productTiming = productTimingService.getBySkn(productSkn);
|
|
|
Integer outSaleTime = new Integer(0);
|
|
|
if (productTiming != null && productTiming.getOutSaleTime() != null) {
|
|
|
outSaleTime = productTiming.getOutSaleTime();
|
|
|
}
|
|
|
|
|
|
Integer outSaleTime = outSaleTimeMap.get(productSknMap.get(storageUpdateTime.getProductId()));
|
|
|
//当前的updateTime+过期天数,再取到那天的23:59
|
|
|
Integer updateTime = storageUpdateTime.getStorageUpdateTime();
|
|
|
updateTime = DateUtil.addTimeSecondByDayAmount(updateTime, outSaleTime);
|
|
|
updateTime = DateUtil.getLastTimeSecond(outSaleTime);
|
|
|
|
|
|
if(updateTime==null){
|
|
|
updateTime = new Integer(0);
|
|
|
}
|
|
|
updateTime = DateUtil.getLastTimeSecond(DateUtil.addTimeSecondByDayAmount(updateTime, outSaleTime));
|
|
|
storageUpdateTime.setStorageUpdateTime(updateTime);
|
|
|
}
|
|
|
return storageUpdateTimes;
|
...
|
...
|
|