Authored by 周少峰

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

@@ -24,6 +24,7 @@ import com.yohoufo.common.annotation.IgnoreSignature; @@ -24,6 +24,7 @@ import com.yohoufo.common.annotation.IgnoreSignature;
24 import com.yohoufo.common.cache.Cachable; 24 import com.yohoufo.common.cache.Cachable;
25 import com.yohoufo.common.cache.ControllerCacheAop; 25 import com.yohoufo.common.cache.ControllerCacheAop;
26 import com.yohoufo.common.caller.UfoServiceCaller; 26 import com.yohoufo.common.caller.UfoServiceCaller;
  27 +import com.yohoufo.common.utils.StringUtil;
27 import com.yohoufo.dal.product.model.StoragePrice; 28 import com.yohoufo.dal.product.model.StoragePrice;
28 import com.yohoufo.product.model.SkupInfo; 29 import com.yohoufo.product.model.SkupInfo;
29 import com.yohoufo.product.response.*; 30 import com.yohoufo.product.response.*;
@@ -44,10 +45,7 @@ import org.springframework.web.servlet.ModelAndView; @@ -44,10 +45,7 @@ import org.springframework.web.servlet.ModelAndView;
44 45
45 import java.lang.reflect.Method; 46 import java.lang.reflect.Method;
46 import java.math.BigDecimal; 47 import java.math.BigDecimal;
47 -import java.util.Collection;  
48 -import java.util.HashMap;  
49 -import java.util.List;  
50 -import java.util.Map; 48 +import java.util.*;
51 import java.util.concurrent.ExecutorService; 49 import java.util.concurrent.ExecutorService;
52 import java.util.concurrent.Executors; 50 import java.util.concurrent.Executors;
53 import java.util.stream.Collectors; 51 import java.util.stream.Collectors;
@@ -716,6 +714,19 @@ public class ProductController { @@ -716,6 +714,19 @@ public class ProductController {
716 return productService.queryProductLeastFlashSalePrice(productId); 714 return productService.queryProductLeastFlashSalePrice(productId);
717 } 715 }
718 716
  717 + @ApiOperation(name = "ufo.product.storage.leastOnSalePrice", desc = "在售现货各尺码最低价")
  718 + @RequestMapping(params = "method=ufo.product.storage.leastOnSalePrice")
  719 + @Cachable(expire = 180)
  720 + public List<StorageInfoResp> queryLeastOnSalePrice(@RequestParam(value = "productCode", required = true) String productCode) {
  721 +
  722 + if (StringUtils.isBlank(productCode)) {
  723 + LOG.info("in method=ufo.product.storage.leastOnSalePrice productCode Is Null");
  724 + return new ArrayList<>();
  725 + }
  726 + LOG.info("in method=ufo.product.storage.leastOnSalePrice productCode={}", productCode);
  727 + return productService.queryLeastOnSalePrice(productCode);
  728 + }
  729 +
719 /** 730 /**
720 * 门店UFO小程序扫码购买时调用 731 * 门店UFO小程序扫码购买时调用
721 * @param skup 732 * @param skup
@@ -135,6 +135,8 @@ public interface ProductService { @@ -135,6 +135,8 @@ public interface ProductService {
135 135
136 List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList); 136 List<StorageDataResp> queryStorageListInfo(List<Integer> storageIdList);
137 137
  138 + List<StorageInfoResp> queryLeastOnSalePrice(String productCode);
  139 +
138 /** 140 /**
139 * 根据货号尺码查询storage 141 * 根据货号尺码查询storage
140 * @param reqList 142 * @param reqList
@@ -204,7 +204,13 @@ public class ProductServiceImpl implements ProductService { @@ -204,7 +204,13 @@ public class ProductServiceImpl implements ProductService {
204 BigDecimal flashLeastPrice = flashLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get(); 204 BigDecimal flashLeastPrice = flashLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
205 productInfo.setFlashLeastPrice(flashLeastPrice); 205 productInfo.setFlashLeastPrice(flashLeastPrice);
206 } 206 }
207 - 207 +
  208 + List<BigDecimal> quickDeliveryLeastPriceList = goodsSizes.stream().map(GoodsSize::getQuickDeliveryPrice).filter(Objects::nonNull).collect(Collectors.toList());
  209 + if(!CollectionUtils.isEmpty(quickDeliveryLeastPriceList)) {
  210 + BigDecimal quickDeliveryLeastPrice = quickDeliveryLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
  211 + productInfo.setQuickDeliveryPrice(quickDeliveryLeastPrice);
  212 + }
  213 +
208 goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy)); 214 goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
209 List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes); 215 List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
210 if(!CollectionUtils.isEmpty(otherAddSizeList)) { 216 if(!CollectionUtils.isEmpty(otherAddSizeList)) {
@@ -511,6 +517,50 @@ public class ProductServiceImpl implements ProductService { @@ -511,6 +517,50 @@ public class ProductServiceImpl implements ProductService {
511 return storagePrices.stream().filter(price -> price.getPreSaleFlag() == 3).collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice)); 517 return storagePrices.stream().filter(price -> price.getPreSaleFlag() == 3).collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
512 } 518 }
513 519
  520 + public List<StorageInfoResp> queryLeastOnSalePrice(String productCode) {
  521 + List<Product> productList = productMapper.selectByProductCode(productCode);
  522 + if (productList.isEmpty()) {
  523 + return new ArrayList<>();
  524 + }
  525 + Product product = null;
  526 + for (Product p : productList) {
  527 + if (p.getDelStatus() == 0 && p.getShelveStatus() == 1) {
  528 + product = p;
  529 + break;
  530 + }
  531 + }
  532 + if (product == null) {
  533 + return new ArrayList<>();
  534 + }
  535 + List<StoragePrice> storagePrices = storagePriceMapper.selectLeastPricesByProductId(product.getId());
  536 + storagePrices = storagePrices.stream().filter(s -> s.getPreSaleFlag() == 0).collect(Collectors.toList());
  537 + Map<Integer, StoragePrice> storagePriceMap = storagePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, Function.identity(), BinaryOperator.minBy(Comparator.comparing(StoragePrice::getPrice))));
  538 + if (storagePriceMap.isEmpty()) {
  539 + return new ArrayList<>();
  540 + }
  541 + List<Storage> storageList = storageMapper.selectByIds(storagePriceMap.keySet());
  542 + List<Size> sizeList = sizeMapper.selectByIds(storageList.stream().map(Storage::getSizeId).collect(Collectors.toList()));
  543 + Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, Function.identity()));
  544 + Map<Integer, Size> sizeMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Function.identity()));
  545 + List<StorageInfoResp> resp = new ArrayList<>();
  546 + for (Integer spId : storagePriceMap.keySet()) {
  547 + StoragePrice sp = storagePriceMap.get(spId);
  548 + StorageInfoResp storageInfoResp = new StorageInfoResp();
  549 + storageInfoResp.setLeastPrice(sp.getPrice());
  550 + storageInfoResp.setStorageId(sp.getStorageId());
  551 + Storage storage = storageMap.get(sp.getStorageId());
  552 + if (storage == null) {
  553 + continue;
  554 + }
  555 + Size size = sizeMap.get(storage.getSizeId());
  556 + if (size != null) {
  557 + storageInfoResp.setSizeName(size.getSizeName());
  558 + }
  559 + resp.add(storageInfoResp);
  560 + }
  561 + return resp;
  562 + }
  563 +
514 @Override 564 @Override
515 public StoragePrice getStoragePriceBySkup(Integer skup) { 565 public StoragePrice getStoragePriceBySkup(Integer skup) {
516 return storagePriceMapper.selectBySkup(skup); 566 return storagePriceMapper.selectBySkup(skup);
@@ -976,6 +1026,11 @@ public class ProductServiceImpl implements ProductService { @@ -976,6 +1026,11 @@ public class ProductServiceImpl implements ProductService {
976 1026
977 StoragePrice storagePriceFlash = storagePriceMap.get(storage.getId() + "_3_0");//大陆闪购 1027 StoragePrice storagePriceFlash = storagePriceMap.get(storage.getId() + "_3_0");//大陆闪购
978 1028
  1029 +
  1030 + StoragePrice storagePriceQuickDelivery = storagePriceMap.get(storage.getId() + "_9_0");//大陆极速发货
  1031 + StoragePrice storagePriceQuickDeliveryHk = storagePriceMap.get(storage.getId() + "_9_1");//香港极速发货
  1032 + storagePriceQuickDelivery = getMinNotNull(storagePriceQuickDelivery, storagePriceQuickDeliveryHk);
  1033 +
979 GoodsSize goodsSize = new GoodsSize(); 1034 GoodsSize goodsSize = new GoodsSize();
980 goodsSize.setId(storage.getId()); 1035 goodsSize.setId(storage.getId());
981 goodsSize.setSizeId(storage.getSizeId()); 1036 goodsSize.setSizeId(storage.getSizeId());
@@ -1020,6 +1075,11 @@ public class ProductServiceImpl implements ProductService { @@ -1020,6 +1075,11 @@ public class ProductServiceImpl implements ProductService {
1020 goodsSize.setFlashStatus(storagePriceFlash == null ? null : storagePriceFlash.getStatus()); 1075 goodsSize.setFlashStatus(storagePriceFlash == null ? null : storagePriceFlash.getStatus());
1021 goodsSize.setFlashSkup(storagePriceFlash == null ? null : storagePriceFlash.getSkup()); 1076 goodsSize.setFlashSkup(storagePriceFlash == null ? null : storagePriceFlash.getSkup());
1022 goodsSize.setFlashStorageNum(goodsSize.getFlashSkup() == null || goodsSize.getFlashSkup() == 0 ? 0: 1); 1077 goodsSize.setFlashStorageNum(goodsSize.getFlashSkup() == null || goodsSize.getFlashSkup() == 0 ? 0: 1);
  1078 +
  1079 + goodsSize.setQuickDeliveryPrice(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getPrice());
  1080 + goodsSize.setQuickDeliveryStatus(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getStatus());
  1081 + goodsSize.setQuickDeliverySkup(storagePriceQuickDelivery == null ? null : storagePriceQuickDelivery.getSkup());
  1082 + goodsSize.setQuickDeliveryNum(goodsSize.getQuickDeliverySkup() == null || goodsSize.getQuickDeliverySkup() == 0 ? 0 : 1);
1023 } 1083 }
1024 } 1084 }
1025 } 1085 }
@@ -2019,6 +2079,19 @@ public class ProductServiceImpl implements ProductService { @@ -2019,6 +2079,19 @@ public class ProductServiceImpl implements ProductService {
2019 return resp; 2079 return resp;
2020 } 2080 }
2021 2081
  2082 + private StoragePrice getMinNotNull(StoragePrice sp1, StoragePrice sp2) {
  2083 + if (sp1 == null) {
  2084 + return sp2;
  2085 + }
  2086 + if (sp2 == null) {
  2087 + return sp1;
  2088 + }
  2089 + if (sp1.getPrice().compareTo(sp2.getPrice()) < 0) {
  2090 + return sp1;
  2091 + }
  2092 + return sp2;
  2093 + }
  2094 +
2022 @Override 2095 @Override
2023 public List<StorageCheckResp> getStorageByCodeAndColorName(List<ProductRequestBo> reqList) { 2096 public List<StorageCheckResp> getStorageByCodeAndColorName(List<ProductRequestBo> reqList) {
2024 List<StorageCheckResp> result = new ArrayList<>(); 2097 List<StorageCheckResp> result = new ArrayList<>();