Authored by Lixiaodi

预售价

@@ -58,4 +58,6 @@ public interface StoragePriceMapper { @@ -58,4 +58,6 @@ public interface StoragePriceMapper {
58 List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid); 58 List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid);
59 59
60 int updateSkupHideStatus(@Param("uid") Integer uid, @Param("status") int status); 60 int updateSkupHideStatus(@Param("uid") Integer uid, @Param("status") int status);
  61 +
  62 + List<StoragePrice> selectLeastPricesByProductId(@Param("productId") Integer productId);
61 } 63 }
@@ -98,6 +98,16 @@ @@ -98,6 +98,16 @@
98 </foreach> 98 </foreach>
99 and is_hide = 0 99 and is_hide = 0
100 </select> 100 </select>
  101 +
  102 + <select id="selectLeastPricesByProductId" resultMap="BaseResultMap">
  103 + select * from (
  104 + select id, skup, storage_id, price, status, pre_sale_flag
  105 + from storage_price
  106 + where status = 1 and product_id = #{productId} and is_hide = 0
  107 + order by storage_id,price asc limit 1000000
  108 + ) a group by storage_id, pre_sale_flag
  109 + </select>
  110 +
101 <select id="selectBySkupList" resultMap="BaseResultMap"> 111 <select id="selectBySkupList" resultMap="BaseResultMap">
102 select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status, 112 select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
103 update_time, create_time 113 update_time, create_time
@@ -3,6 +3,7 @@ package com.yohoufo.product.controller; @@ -3,6 +3,7 @@ package com.yohoufo.product.controller;
3 import java.text.SimpleDateFormat; 3 import java.text.SimpleDateFormat;
4 import java.util.Calendar; 4 import java.util.Calendar;
5 import java.util.Map; 5 import java.util.Map;
  6 +import java.util.UUID;
6 7
7 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -82,6 +83,9 @@ public class ProductSearchController { @@ -82,6 +83,9 @@ public class ProductSearchController {
82 LOG.info("in method=ufo.product.search.list req={}", req.toString()); 83 LOG.info("in method=ufo.product.search.list req={}", req.toString());
83 84
84 JSONObject resp = productSearchService.searchProductList(req); 85 JSONObject resp = productSearchService.searchProductList(req);
  86 + if (resp != null) {
  87 + resp.put("rec_id", UUID.randomUUID());
  88 + }
85 return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build(); 89 return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
86 } 90 }
87 91
@@ -203,6 +207,9 @@ public class ProductSearchController { @@ -203,6 +207,9 @@ public class ProductSearchController {
203 LOG.info("in method=ufo.product.search.uvscoreProductList req={}", req.toString()); 207 LOG.info("in method=ufo.product.search.uvscoreProductList req={}", req.toString());
204 208
205 JSONObject resp = productSearchService.searchUvscoreProductList(req); 209 JSONObject resp = productSearchService.searchUvscoreProductList(req);
  210 + if (resp != null) {
  211 + resp.put("rec_id", UUID.randomUUID());
  212 + }
206 return new ApiResponse.ApiResponseBuilder().code(200).message("uvscoreProductList List.").data(resp).build(); 213 return new ApiResponse.ApiResponseBuilder().code(200).message("uvscoreProductList List.").data(resp).build();
207 } 214 }
208 215
@@ -608,7 +608,13 @@ public class ProductServiceImpl implements ProductService { @@ -608,7 +608,13 @@ public class ProductServiceImpl implements ProductService {
608 } 608 }
609 return storagePriceMap; 609 return storagePriceMap;
610 } 610 }
611 - 611 +
  612 + private Map<String, StoragePrice> getStorageLeastPriceInfo(Integer productId) {
  613 + List<StoragePrice> storagePrices = storagePriceMapper.selectLeastPricesByProductId(productId);
  614 + return storagePrices.stream()
  615 + .collect(Collectors.toMap(s -> s.getStorageId() + "_" + s.getPreSaleFlag(), Function.identity()));
  616 + }
  617 +
612 private List<GoodsBO> getGoodsList(Integer productId, BigDecimal sellMinPrice, BigDecimal maxPrice) { 618 private List<GoodsBO> getGoodsList(Integer productId, BigDecimal sellMinPrice, BigDecimal maxPrice) {
613 List<GoodsBO> goodsBOs = new ArrayList<>(); 619 List<GoodsBO> goodsBOs = new ArrayList<>();
614 620
@@ -629,10 +635,11 @@ public class ProductServiceImpl implements ProductService { @@ -629,10 +635,11 @@ public class ProductServiceImpl implements ProductService {
629 List<Storage> storageList = storageMapper.selectByGoodsId(goods.getId()); 635 List<Storage> storageList = storageMapper.selectByGoodsId(goods.getId());
630 if (!CollectionUtils.isEmpty(storageList)) { 636 if (!CollectionUtils.isEmpty(storageList)) {
631 Map<Integer, Size> sizeMap = getSizeMap(storageList); 637 Map<Integer, Size> sizeMap = getSizeMap(storageList);
632 - Map<Integer, StoragePrice> storagePriceMap = getStoragePriceMap(storageList); 638 + Map<String, StoragePrice> storagePriceMap = getStorageLeastPriceInfo(productId);
633 639
634 for (Storage storage : storageList) { 640 for (Storage storage : storageList) {
635 - StoragePrice storagePrice = storagePriceMap.get(storage.getId()); 641 + StoragePrice storagePrice = storagePriceMap.get(storage.getId() + "_0");
  642 + StoragePrice storagePricePre = storagePriceMap.get(storage.getId() + "_1");
636 643
637 GoodsSize goodsSize = new GoodsSize(); 644 GoodsSize goodsSize = new GoodsSize();
638 goodsSize.setId(storage.getId()); 645 goodsSize.setId(storage.getId());
@@ -641,7 +648,6 @@ public class ProductServiceImpl implements ProductService { @@ -641,7 +648,6 @@ public class ProductServiceImpl implements ProductService {
641 goodsSize.setSizeName(size == null ? "" : size.getSizeName()); 648 goodsSize.setSizeName(size == null ? "" : size.getSizeName());
642 goodsSize.setOrderBy(size == null ? Integer.valueOf(0) : size.getOrderBy()); 649 goodsSize.setOrderBy(size == null ? Integer.valueOf(0) : size.getOrderBy());
643 650
644 -  
645 goodsSize.setSellLeastPrice(sellMinPrice); 651 goodsSize.setSellLeastPrice(sellMinPrice);
646 goodsSize.setMaxPrice(maxPrice); 652 goodsSize.setMaxPrice(maxPrice);
647 goodsSize.setSuggestLowPrice(storage.getSuggestLowPrice()); 653 goodsSize.setSuggestLowPrice(storage.getSuggestLowPrice());
@@ -652,13 +658,18 @@ public class ProductServiceImpl implements ProductService { @@ -652,13 +658,18 @@ public class ProductServiceImpl implements ProductService {
652 if (null != storagePrice && null != storage.getSuggestHighPrice() && storagePrice.getPrice().compareTo(storage.getSuggestHighPrice()) > 0) { 658 if (null != storagePrice && null != storage.getSuggestHighPrice() && storagePrice.getPrice().compareTo(storage.getSuggestHighPrice()) > 0) {
653 goodsSize.setStorageNum(0); 659 goodsSize.setStorageNum(0);
654 goodsSize.setSkup(0); 660 goodsSize.setSkup(0);
655 - continue; 661 + } else {
  662 + goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
  663 + goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus());
  664 + //goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());
  665 + goodsSize.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
  666 + goodsSize.setStorageNum(goodsSize.getSkup() == null || goodsSize.getSkup() == 0 ? 0 : 1);
656 } 667 }
657 - goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());  
658 - goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus());  
659 - //goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());  
660 - goodsSize.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());  
661 - goodsSize.setStorageNum(goodsSize.getSkup() == null || goodsSize.getSkup() == 0 ? 0 : 1); 668 +
  669 + goodsSize.setPreSaleLeastPrice(storagePricePre == null ? null : storagePrice.getPrice());
  670 + goodsSize.setPreSaleStatus(storagePrice == null ? null : storagePricePre.getStatus());
  671 + goodsSize.setPreSaleSkup(storagePrice == null ? 0 : storagePricePre.getSkup());
  672 + goodsSize.setPreSaleStorageNum(goodsSize.getPreSaleSkup() == null || goodsSize.getPreSaleSkup() == 0 ? 0 : 1);
662 } 673 }
663 } 674 }
664 } 675 }