Authored by 周少峰

Merge branch 'dev_极速发货' of git.yoho.cn:ufo/yohoufo-fore into dev_极速发货

... ... @@ -24,6 +24,7 @@ import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.cache.Cachable;
import com.yohoufo.common.cache.ControllerCacheAop;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.StringUtil;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.model.SkupInfo;
import com.yohoufo.product.response.*;
... ... @@ -44,10 +45,7 @@ import org.springframework.web.servlet.ModelAndView;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
... ... @@ -716,6 +714,19 @@ public class ProductController {
return productService.queryProductLeastFlashSalePrice(productId);
}
@ApiOperation(name = "ufo.product.storage.leastOnSalePrice", desc = "在售现货各尺码最低价")
@RequestMapping(params = "method=ufo.product.storage.leastOnSalePrice")
@Cachable(expire = 180)
public List<StorageInfoResp> queryLeastOnSalePrice(@RequestParam(value = "productCode", required = true) String productCode) {
if (StringUtils.isBlank(productCode)) {
LOG.info("in method=ufo.product.storage.leastOnSalePrice productCode Is Null");
return new ArrayList<>();
}
LOG.info("in method=ufo.product.storage.leastOnSalePrice productCode={}", productCode);
return productService.queryLeastOnSalePrice(productCode);
}
/**
* 门店UFO小程序扫码购买时调用
* @param skup
... ...
... ... @@ -135,6 +135,8 @@ public interface ProductService {
List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList);
List<StorageInfoResp> queryLeastOnSalePrice(String productCode);
/**
* 根据货号尺码查询storage
* @param reqList
... ...
... ... @@ -204,7 +204,13 @@ public class ProductServiceImpl implements ProductService {
BigDecimal flashLeastPrice = flashLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setFlashLeastPrice(flashLeastPrice);
}
List<BigDecimal> quickDeliveryLeastPriceList = goodsSizes.stream().map(GoodsSize::getQuickDeliveryPrice).filter(Objects::nonNull).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(quickDeliveryLeastPriceList)) {
BigDecimal quickDeliveryLeastPrice = quickDeliveryLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setQuickDeliveryPrice(quickDeliveryLeastPrice);
}
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
if(!CollectionUtils.isEmpty(otherAddSizeList)) {
... ... @@ -511,6 +517,50 @@ public class ProductServiceImpl implements ProductService {
return storagePrices.stream().filter(price -> price.getPreSaleFlag() == 3).collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
}
public List<StorageInfoResp> queryLeastOnSalePrice(String productCode) {
List<Product> productList = productMapper.selectByProductCode(productCode);
if (productList.isEmpty()) {
return new ArrayList<>();
}
Product product = null;
for (Product p : productList) {
if (p.getDelStatus() == 0 && p.getShelveStatus() == 1) {
product = p;
break;
}
}
if (product == null) {
return new ArrayList<>();
}
List<StoragePrice> storagePrices = storagePriceMapper.selectLeastPricesByProductId(product.getId());
storagePrices = storagePrices.stream().filter(s -> s.getPreSaleFlag() == 0).collect(Collectors.toList());
Map<Integer, StoragePrice> storagePriceMap = storagePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, Function.identity(), BinaryOperator.minBy(Comparator.comparing(StoragePrice::getPrice))));
if (storagePriceMap.isEmpty()) {
return new ArrayList<>();
}
List<Storage> storageList = storageMapper.selectByIds(storagePriceMap.keySet());
List<Size> sizeList = sizeMapper.selectByIds(storageList.stream().map(Storage::getSizeId).collect(Collectors.toList()));
Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, Function.identity()));
Map<Integer, Size> sizeMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Function.identity()));
List<StorageInfoResp> resp = new ArrayList<>();
for (Integer spId : storagePriceMap.keySet()) {
StoragePrice sp = storagePriceMap.get(spId);
StorageInfoResp storageInfoResp = new StorageInfoResp();
storageInfoResp.setLeastPrice(sp.getPrice());
storageInfoResp.setStorageId(sp.getStorageId());
Storage storage = storageMap.get(sp.getStorageId());
if (storage == null) {
continue;
}
Size size = sizeMap.get(storage.getSizeId());
if (size != null) {
storageInfoResp.setSizeName(size.getSizeName());
}
resp.add(storageInfoResp);
}
return resp;
}
@Override
public StoragePrice getStoragePriceBySkup(Integer skup) {
return storagePriceMapper.selectBySkup(skup);
... ... @@ -976,6 +1026,11 @@ public class ProductServiceImpl implements ProductService {
StoragePrice storagePriceFlash = storagePriceMap.get(storage.getId() + "_3_0");//大陆闪购
StoragePrice storagePriceQuickDelivery = storagePriceMap.get(storage.getId() + "_9_0");//大陆极速发货
StoragePrice storagePriceQuickDeliveryHk = storagePriceMap.get(storage.getId() + "_9_1");//香港极速发货
storagePriceQuickDelivery = getMinNotNull(storagePriceQuickDelivery, storagePriceQuickDeliveryHk);
GoodsSize goodsSize = new GoodsSize();
goodsSize.setId(storage.getId());
goodsSize.setSizeId(storage.getSizeId());
... ... @@ -1020,6 +1075,11 @@ public class ProductServiceImpl implements ProductService {
goodsSize.setFlashStatus(storagePriceFlash == null ? null : storagePriceFlash.getStatus());
goodsSize.setFlashSkup(storagePriceFlash == null ? null : storagePriceFlash.getSkup());
goodsSize.setFlashStorageNum(goodsSize.getFlashSkup() == null || goodsSize.getFlashSkup() == 0 ? 0: 1);
goodsSize.setQuickDeliveryPrice(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getPrice());
goodsSize.setQuickDeliveryStatus(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getStatus());
goodsSize.setQuickDeliverySkup(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getSkup());
goodsSize.setQuickDeliveryNum(goodsSize.getQuickDeliverySkup() == null || goodsSize.getQuickDeliverySkup() == 0 ? 0 : 1);
}
}
}
... ... @@ -2019,6 +2079,19 @@ public class ProductServiceImpl implements ProductService {
return resp;
}
private StoragePrice getMinNotNull(StoragePrice sp1, StoragePrice sp2) {
if (sp1 == null) {
return sp2;
}
if (sp2 == null) {
return sp1;
}
if (sp1.getPrice().compareTo(sp2.getPrice()) < 0) {
return sp1;
}
return sp2;
}
@Override
public List<StorageCheckResp> getStorageByCodeAndColorName(List<ProductRequestBo> reqList) {
List<StorageCheckResp> result = new ArrayList<>();
... ...