Authored by mali

闲鱼详情

... ... @@ -91,4 +91,11 @@ public interface StoragePriceMapper {
* @return
*/
int updateBatchDepotNum(@Param("skupList") List<Integer> skupList, @Param("depotNum") Integer depotNo);
/**
* 查询现货各尺码的最低价
* @param productId
* @return
*/
List<StoragePrice> selectInStockLeastPByProductId(@Param("productId") Integer productId);
}
\ No newline at end of file
... ...
... ... @@ -270,4 +270,13 @@
#{item}
</foreach>
</update>
<select id="selectInStockLeastPByProductId" resultMap="BaseResultMap">
select * from (
select id, skup, storage_id, price, status, pre_sale_flag, region
from storage_price
where status = 1 and product_id = #{productId} and is_hide = 0 and region = 0 and pre_sale_flag = 0
order by storage_id,price asc limit 1000000
) a group by storage_id
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -158,6 +158,9 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private StorageService storageService;
@Autowired
private StoragePriceService storagePriceService;
@Override
public ProductDetailResp queryProductDetailById(Integer productId) {
ProductDetailResp productDetailResp = new ProductDetailResp();
... ... @@ -2253,6 +2256,8 @@ public class ProductServiceImpl implements ProductService {
if (!CollectionUtils.isEmpty(goodsBOList)) {
List<GoodsSize> goodsSizes = storageService.getSizeList(productId, goodsBOList.get(0));
storagePriceService.setStoragePrice(goodsSizes, productId); // 设置库存,最低价 skup等信息
goodsBOList.get(0).setSizeList(goodsSizes);
storageService.setMaxMinPrice(goodsSizes, product.getMinPrice(), product.getMaxPrice()); //设置商品最高价和最低价
... ...
package com.yohoufo.product.service.impl;
import com.yohobuy.ufo.model.GoodsSize;
import com.yohoufo.dal.product.StoragePriceMapper;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.cache.UfoProductCacheService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Created by li.ma on 2019/6/27.
... ... @@ -24,4 +31,34 @@ public class StoragePriceService {
}
/**
* 查询现货各尺码的最低价
* @param productId
* @return
*/
private Map<Integer, StoragePrice> selectInStockLeastPByProductId(@Param("productId") Integer productId) {
return storagePriceMapper.selectInStockLeastPByProductId(productId).stream().collect(Collectors.toMap(StoragePrice::getStorageId, Function.identity()));
}
public void setStoragePrice(List<GoodsSize> goodsSizes, Integer productId) {
if (CollectionUtils.isEmpty(goodsSizes)) {
return;
}
Map<Integer, StoragePrice> storagePriceMap = selectInStockLeastPByProductId(productId);
goodsSizes.stream().forEach(item -> {
StoragePrice storagePrice = storagePriceMap.get(item.getId());//大陆现货
if (null != storagePrice && null != item.getSuggestHighPrice()
&& storagePrice.getPrice().compareTo(item.getSuggestHighPrice()) > 0) { //高于建议价,不展示skup
item.setStorageNum(0);
item.setSkup(0);
} else {
item.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
item.setStatus(storagePrice == null ? null : storagePrice.getStatus());
item.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
item.setStorageNum(item.getSkup() == null || item.getSkup() == 0 ? 0 : 1);
}
});
}
}
... ...