Authored by peuei

线下店门店商品库存为0不展示 fix

... ... @@ -88,4 +88,11 @@ public interface ProductMapper {
List<Product> selectByProductCode(@Param("productCode") String productCode);
int selectProductStockNotZeroCount(@Param("status") Integer status, @Param("sellerList") List<Integer> sellerUid, @Param("product") Product product);
List<Product> selectProductStockNotZeroList(@Param("status") Integer status,
@Param("sellerList") List<Integer> sellerUid,
@Param("product") Product product,
@Param("start") int start,
@Param("rows") int rows);
}
\ No newline at end of file
... ...
... ... @@ -253,4 +253,83 @@
#{item}
</foreach>
</select>
<select id="selectProductStockNotZeroCount" resultType="java.lang.Integer">
select count(p.id)
from product p
where 1 = 1
and p.id in (
select distinct product_id
from storage_price s
where 1 = 1
and s.status = #{status}
and s.seller_uid in
<foreach item="sellerItem" index="index" collection="sellerList" open="(" separator="," close=")">
#{sellerItem}
</foreach>
<if test="product.storageId != null and product.storageId > 0">
and s.storage_id = #{product.storageId}
</if>
<if test="product.skup != null and product.skup > 0">
and s.skup = #{product.skup}
</if>
)
<if test="product.id != null and product.id > 0">
and p.id = #{product.id}
</if>
<if test="product.productName != null and product.productName != '' ">
and p.product_name like concat('%', #{product.productName}, '%')
</if>
<if test="product.maxSortId != null and product.maxSortId > 0">
and p.max_sort_id = #{product.maxSortId}
</if>
<if test="product.midSortId != null and product.midSortId > 0">
and p.mid_sort_id = #{product.midSortId}
</if>
<if test="product.brandId != null and product.brandId > 0">
and p.brand_id = #{product.brandId}
</if>
</select>
<select id="selectProductStockNotZeroList" resultMap="BaseResultMap">
select p.id, p.brand_id, p.product_name, p.max_sort_id, p.mid_sort_id
from product p
where 1 = 1
and p.id in (
select distinct product_id
from storage_price s
where 1 = 1
and s.status = #{status}
and s.seller_uid in
<foreach item="sellerItem" index="index" collection="sellerList" open="(" separator="," close=")">
#{sellerItem}
</foreach>
<if test="product.storageId != null and product.storageId > 0">
and s.storage_id = #{product.storageId}
</if>
<if test="product.skup != null and product.skup > 0">
and s.skup = #{product.skup}
</if>
)
<if test="product.id != null and product.id > 0">
and p.id = #{product.id}
</if>
<if test="product.productName != null and product.productName != '' ">
and p.product_name like concat('%', #{product.productName}, '%')
</if>
<if test="product.maxSortId != null and product.maxSortId > 0">
and p.max_sort_id = #{product.maxSortId}
</if>
<if test="product.midSortId != null and product.midSortId > 0">
and p.mid_sort_id = #{product.midSortId}
</if>
<if test="product.brandId != null and product.brandId > 0">
and p.brand_id = #{product.brandId}
</if>
limit #{start}, #{rows}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.service.impl;
import com.google.common.collect.Lists;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.product.model.SecondhandImages;
import com.yoho.product.model.SecondhandInfo;
... ... @@ -106,27 +105,26 @@ public class StorageService {
* @return
*/
public PageResponseBO<ProductResponceBo> storageListPlus(ProductRequestBo bo, List<Integer> sellerUid) {
Product product = OrikaUtils.map(bo, Product.class);
/**
* 获取 productId
*/
List<Integer> integerList = storagePriceService.selectProductIdByPlus(product, sellerUid);
if (null != integerList && integerList.isEmpty()) {
// 返回空列表 代表查询了storage_price 但查询的接口是空 再联合查询肯定也是空
return new PageResponseBO<>();
}
product.setProductIdList(integerList);
int count = productMapper.selectProductStorageCount(product);
final Product product = OrikaUtils.map(bo, Product.class);
final int count = productMapper.selectProductStockNotZeroCount(
DEFAULT_SKUP_STATUS,
sellerUid,
product
);
if (count == 0) {
LOGGER.warn("StorageService storageListPlus count is 0.param = {}, sellerUid = {}", bo, sellerUid);
return new PageResponseBO<>();
}
List<Product> productList = productMapper.selectProductStorageList(product, bo.getStartIndex(), bo.getRows());
List<ProductResponceBo> responseBos = new ArrayList<>();
ProductResponceBo productResponseBo;
final List<Product> productList = productMapper.selectProductStockNotZeroList(
DEFAULT_SKUP_STATUS,
sellerUid,
product,
bo.getStartIndex(),
bo.getRows()
);
final List<ProductResponceBo> responseBos = new ArrayList<>();
for (Product productItem : productList) {
productResponseBo = productConvertService.convertProductDo2Bo(productItem);
responseBos.add(productResponseBo);
responseBos.add(productConvertService.convertProductDo2Bo(productItem));
}
productAssistService.fillBrandName(responseBos).fillSkupInfo(responseBos);
return new PageResponseBO<>(count, responseBos, bo.getPage(), bo.getRows());
... ...