Authored by Lixiaodi

增加预售区分

... ... @@ -33,6 +33,8 @@ public interface StoragePriceMapper {
int updateDepotNum(@Param("skup") Integer skup, @Param("depotNum") Integer depotNum);
StoragePrice selectLeastPrice(Integer storageId);
StoragePrice selectPreSaleLeastPrice(Integer storageId);
List<StoragePrice> selectByStorageIds(List<Integer> storageIds);
... ... @@ -54,6 +56,8 @@ public interface StoragePriceMapper {
* @return
*/
List<StoragePrice> selectBatchLeastPrice(@Param("skuList") Collection<Integer> skuList);
List<StoragePrice> selectPreSaleBatchLeastPrice(@Param("skuList") Collection<Integer> skuList);
List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid);
... ...
... ... @@ -86,7 +86,10 @@
where skup = #{skup,jdbcType=INTEGER} and status = 2
</update>
<select id="selectLeastPrice" resultMap="BaseResultMap">
select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 and is_hide = 0 order by price limit 1
select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 and is_hide = 0 and pre_sale_flag=0 order by price limit 1
</select>
<select id="selectPreSaleLeastPrice" resultMap="BaseResultMap">
select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 and is_hide = 0 and pre_sale_flag=1 order by price limit 1
</select>
<select id="selectByStorageIds" resultMap="BaseResultMap">
select id, skup, storage_id, price, status
... ... @@ -160,7 +163,16 @@
storage_id in
<foreach item="storageId" index="index" collection="skuList" open="(" separator="," close=")">
#{storageId, jdbcType=INTEGER}
</foreach> and status = 1
</foreach> and status = 1 and is_hide = 0 and pre_sale_flag=0
group by storage_id
</select>
<select id="selectBatchPreSaleLeastPrice" resultMap="BaseResultMap">
select storage_id , min(price) as price from storage_price where
storage_id in
<foreach item="storageId" index="index" collection="skuList" open="(" separator="," close=")">
#{storageId, jdbcType=INTEGER}
</foreach> and status = 1 and is_hide = 0 and pre_sale_flag=1
group by storage_id
</select>
... ...
... ... @@ -15,6 +15,11 @@ public class StorageLeastPriceResp {
private BigDecimal leastPrice;
private Integer skup;
@JSONField(name = "pre_sale_least_price")
private BigDecimal preSaleLeastPrice;
private Integer preSaleSkup;
@JSONField(name="suggest_low_price")
private BigDecimal suggestLowPrice;
... ...
... ... @@ -110,6 +110,11 @@ public class ProductServiceImpl implements ProductService {
BigDecimal leastPrice = leastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setLeastPrice(leastPrice);
}
List<BigDecimal> preSaleLeastPriceList = goodsSizes.stream().map(GoodsSize::getPreSaleLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(preSaleLeastPriceList)) {
BigDecimal preSaleLeastPrice = preSaleLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setPreSaleLeastPrice(preSaleLeastPrice);
}
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
}
}
... ... @@ -130,6 +135,14 @@ public class ProductServiceImpl implements ProductService {
resp.setStorageId(storageId);
resp.setLeastPrice(storagePrice.getPrice());
resp.setSkup(storagePrice.getSkup());
StoragePrice preSaleStoragePrice = storagePriceMapper.selectPreSaleLeastPrice(storageId);
if (null != preSaleStoragePrice) {
resp.setPreSaleLeastPrice(preSaleStoragePrice.getPrice());
resp.setPreSaleSkup(preSaleStoragePrice.getSkup());
}
return resp;
}
... ... @@ -151,6 +164,12 @@ public class ProductServiceImpl implements ProductService {
resp.setLeastPrice(storagePrice.getPrice());
resp.setSkup(storagePrice.getSkup());
}
StoragePrice preSaleStoragePrice = storagePriceMapper.selectPreSaleLeastPrice(storageId);
if (null != preSaleStoragePrice) {
resp.setPreSaleLeastPrice(preSaleStoragePrice.getPrice());
resp.setPreSaleSkup(preSaleStoragePrice.getSkup());
}
return resp;
}
... ... @@ -187,6 +206,13 @@ public class ProductServiceImpl implements ProductService {
resp.setSuggestLowPrice(storage.getSuggestLowPrice());
resp.setSuggestHighPrice(storage.getSuggestHighPrice());
resp.setLeastPrice(null == storagePrice ? null : storagePrice.getPrice());
StoragePrice preSaleStoragePrice = storagePriceMapper.selectPreSaleLeastPrice(storageId);
if (null != preSaleStoragePrice) {
resp.setPreSaleLeastPrice(preSaleStoragePrice.getPrice());
}
return resp;
}
... ... @@ -202,8 +228,12 @@ public class ProductServiceImpl implements ProductService {
}
List<StoragePrice> storagePrices = storagePriceMapper.selectBatchLeastPrice(skuList);
List<StoragePrice> preSaleStoragePrices = storagePriceMapper.selectPreSaleBatchLeastPrice(skuList);
Map<Integer, BigDecimal> priceMap = storagePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
Map<Integer, BigDecimal> preSalePriceMap = preSaleStoragePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
List<StorageInfoResp> resp = Lists.newArrayList();
storageList.stream().forEach(item -> {
StorageInfoResp storageInfoResp = new StorageInfoResp();
... ... @@ -212,6 +242,7 @@ public class ProductServiceImpl implements ProductService {
storageInfoResp.setSuggestLowPrice(item.getSuggestLowPrice());
storageInfoResp.setStorageId(item.getId());
storageInfoResp.setLeastPrice(priceMap.get(item.getId()));
storageInfoResp.setPreSaleLeastPrice(preSalePriceMap.get(item.getId()));
resp.add(storageInfoResp);
});
... ...