Authored by Lixiaodi

预售价

... ... @@ -58,4 +58,6 @@ public interface StoragePriceMapper {
List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid);
int updateSkupHideStatus(@Param("uid") Integer uid, @Param("status") int status);
List<StoragePrice> selectLeastPricesByProductId(@Param("productId") Integer productId);
}
\ No newline at end of file
... ...
... ... @@ -98,6 +98,16 @@
</foreach>
and is_hide = 0
</select>
<select id="selectLeastPricesByProductId" resultMap="BaseResultMap">
select * from (
select id, skup, storage_id, price, status, pre_sale_flag
from storage_price
where status = 1 and product_id = #{productId} and is_hide = 0
order by storage_id,price asc limit 1000000
) a group by storage_id, pre_sale_flag
</select>
<select id="selectBySkupList" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
update_time, create_time
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.product.controller;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -82,6 +83,9 @@ public class ProductSearchController {
LOG.info("in method=ufo.product.search.list req={}", req.toString());
JSONObject resp = productSearchService.searchProductList(req);
if (resp != null) {
resp.put("rec_id", UUID.randomUUID());
}
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
... ... @@ -203,6 +207,9 @@ public class ProductSearchController {
LOG.info("in method=ufo.product.search.uvscoreProductList req={}", req.toString());
JSONObject resp = productSearchService.searchUvscoreProductList(req);
if (resp != null) {
resp.put("rec_id", UUID.randomUUID());
}
return new ApiResponse.ApiResponseBuilder().code(200).message("uvscoreProductList List.").data(resp).build();
}
... ...
... ... @@ -608,7 +608,13 @@ public class ProductServiceImpl implements ProductService {
}
return storagePriceMap;
}
private Map<String, StoragePrice> getStorageLeastPriceInfo(Integer productId) {
List<StoragePrice> storagePrices = storagePriceMapper.selectLeastPricesByProductId(productId);
return storagePrices.stream()
.collect(Collectors.toMap(s -> s.getStorageId() + "_" + s.getPreSaleFlag(), Function.identity()));
}
private List<GoodsBO> getGoodsList(Integer productId, BigDecimal sellMinPrice, BigDecimal maxPrice) {
List<GoodsBO> goodsBOs = new ArrayList<>();
... ... @@ -629,10 +635,11 @@ public class ProductServiceImpl implements ProductService {
List<Storage> storageList = storageMapper.selectByGoodsId(goods.getId());
if (!CollectionUtils.isEmpty(storageList)) {
Map<Integer, Size> sizeMap = getSizeMap(storageList);
Map<Integer, StoragePrice> storagePriceMap = getStoragePriceMap(storageList);
Map<String, StoragePrice> storagePriceMap = getStorageLeastPriceInfo(productId);
for (Storage storage : storageList) {
StoragePrice storagePrice = storagePriceMap.get(storage.getId());
StoragePrice storagePrice = storagePriceMap.get(storage.getId() + "_0");
StoragePrice storagePricePre = storagePriceMap.get(storage.getId() + "_1");
GoodsSize goodsSize = new GoodsSize();
goodsSize.setId(storage.getId());
... ... @@ -641,7 +648,6 @@ public class ProductServiceImpl implements ProductService {
goodsSize.setSizeName(size == null ? "" : size.getSizeName());
goodsSize.setOrderBy(size == null ? Integer.valueOf(0) : size.getOrderBy());
goodsSize.setSellLeastPrice(sellMinPrice);
goodsSize.setMaxPrice(maxPrice);
goodsSize.setSuggestLowPrice(storage.getSuggestLowPrice());
... ... @@ -652,13 +658,18 @@ public class ProductServiceImpl implements ProductService {
if (null != storagePrice && null != storage.getSuggestHighPrice() && storagePrice.getPrice().compareTo(storage.getSuggestHighPrice()) > 0) {
goodsSize.setStorageNum(0);
goodsSize.setSkup(0);
continue;
} else {
goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus());
//goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());
goodsSize.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
goodsSize.setStorageNum(goodsSize.getSkup() == null || goodsSize.getSkup() == 0 ? 0 : 1);
}
goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus());
//goodsSize.setStorageNum(storagePrice == null ? 0 : storage.getStorageNum());
goodsSize.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
goodsSize.setStorageNum(goodsSize.getSkup() == null || goodsSize.getSkup() == 0 ? 0 : 1);
goodsSize.setPreSaleLeastPrice(storagePricePre == null ? null : storagePrice.getPrice());
goodsSize.setPreSaleStatus(storagePrice == null ? null : storagePricePre.getStatus());
goodsSize.setPreSaleSkup(storagePrice == null ? 0 : storagePricePre.getSkup());
goodsSize.setPreSaleStorageNum(goodsSize.getPreSaleSkup() == null || goodsSize.getPreSaleSkup() == 0 ? 0 : 1);
}
}
}
... ...