Showing
3 changed files
with
101 additions
and
17 deletions
@@ -88,4 +88,11 @@ public interface ProductMapper { | @@ -88,4 +88,11 @@ public interface ProductMapper { | ||
88 | 88 | ||
89 | List<Product> selectByProductCode(@Param("productCode") String productCode); | 89 | List<Product> selectByProductCode(@Param("productCode") String productCode); |
90 | 90 | ||
91 | + int selectProductStockNotZeroCount(@Param("status") Integer status, @Param("sellerList") List<Integer> sellerUid, @Param("product") Product product); | ||
92 | + | ||
93 | + List<Product> selectProductStockNotZeroList(@Param("status") Integer status, | ||
94 | + @Param("sellerList") List<Integer> sellerUid, | ||
95 | + @Param("product") Product product, | ||
96 | + @Param("start") int start, | ||
97 | + @Param("rows") int rows); | ||
91 | } | 98 | } |
@@ -253,4 +253,83 @@ | @@ -253,4 +253,83 @@ | ||
253 | #{item} | 253 | #{item} |
254 | </foreach> | 254 | </foreach> |
255 | </select> | 255 | </select> |
256 | + | ||
257 | + | ||
258 | + <select id="selectProductStockNotZeroCount" resultType="java.lang.Integer"> | ||
259 | + select count(p.id) | ||
260 | + from product p | ||
261 | + where 1 = 1 | ||
262 | + and p.id in ( | ||
263 | + select distinct product_id | ||
264 | + from storage_price s | ||
265 | + where 1 = 1 | ||
266 | + and s.status = #{status} | ||
267 | + and s.seller_uid in | ||
268 | + <foreach item="sellerItem" index="index" collection="sellerList" open="(" separator="," close=")"> | ||
269 | + #{sellerItem} | ||
270 | + </foreach> | ||
271 | + <if test="product.storageId != null and product.storageId > 0"> | ||
272 | + and s.storage_id = #{product.storageId} | ||
273 | + </if> | ||
274 | + <if test="product.skup != null and product.skup > 0"> | ||
275 | + and s.skup = #{product.skup} | ||
276 | + </if> | ||
277 | + ) | ||
278 | + <if test="product.id != null and product.id > 0"> | ||
279 | + and p.id = #{product.id} | ||
280 | + </if> | ||
281 | + <if test="product.productName != null and product.productName != '' "> | ||
282 | + and p.product_name like concat('%', #{product.productName}, '%') | ||
283 | + </if> | ||
284 | + <if test="product.maxSortId != null and product.maxSortId > 0"> | ||
285 | + and p.max_sort_id = #{product.maxSortId} | ||
286 | + </if> | ||
287 | + <if test="product.midSortId != null and product.midSortId > 0"> | ||
288 | + and p.mid_sort_id = #{product.midSortId} | ||
289 | + </if> | ||
290 | + <if test="product.brandId != null and product.brandId > 0"> | ||
291 | + and p.brand_id = #{product.brandId} | ||
292 | + </if> | ||
293 | + </select> | ||
294 | + | ||
295 | + | ||
296 | + <select id="selectProductStockNotZeroList" resultMap="BaseResultMap"> | ||
297 | + select p.id, p.brand_id, p.product_name, p.max_sort_id, p.mid_sort_id | ||
298 | + from product p | ||
299 | + where 1 = 1 | ||
300 | + and p.id in ( | ||
301 | + select distinct product_id | ||
302 | + from storage_price s | ||
303 | + where 1 = 1 | ||
304 | + and s.status = #{status} | ||
305 | + and s.seller_uid in | ||
306 | + <foreach item="sellerItem" index="index" collection="sellerList" open="(" separator="," close=")"> | ||
307 | + #{sellerItem} | ||
308 | + </foreach> | ||
309 | + <if test="product.storageId != null and product.storageId > 0"> | ||
310 | + and s.storage_id = #{product.storageId} | ||
311 | + </if> | ||
312 | + <if test="product.skup != null and product.skup > 0"> | ||
313 | + and s.skup = #{product.skup} | ||
314 | + </if> | ||
315 | + ) | ||
316 | + <if test="product.id != null and product.id > 0"> | ||
317 | + and p.id = #{product.id} | ||
318 | + </if> | ||
319 | + <if test="product.productName != null and product.productName != '' "> | ||
320 | + and p.product_name like concat('%', #{product.productName}, '%') | ||
321 | + </if> | ||
322 | + <if test="product.maxSortId != null and product.maxSortId > 0"> | ||
323 | + and p.max_sort_id = #{product.maxSortId} | ||
324 | + </if> | ||
325 | + <if test="product.midSortId != null and product.midSortId > 0"> | ||
326 | + and p.mid_sort_id = #{product.midSortId} | ||
327 | + </if> | ||
328 | + <if test="product.brandId != null and product.brandId > 0"> | ||
329 | + and p.brand_id = #{product.brandId} | ||
330 | + </if> | ||
331 | + limit #{start}, #{rows} | ||
332 | + </select> | ||
333 | + | ||
334 | + | ||
256 | </mapper> | 335 | </mapper> |
1 | package com.yoho.ufo.service.impl; | 1 | package com.yoho.ufo.service.impl; |
2 | 2 | ||
3 | -import com.google.common.collect.Lists; | ||
4 | import com.yoho.core.common.utils.DateUtil; | 3 | import com.yoho.core.common.utils.DateUtil; |
5 | import com.yoho.product.model.SecondhandImages; | 4 | import com.yoho.product.model.SecondhandImages; |
6 | import com.yoho.product.model.SecondhandInfo; | 5 | import com.yoho.product.model.SecondhandInfo; |
@@ -106,27 +105,26 @@ public class StorageService { | @@ -106,27 +105,26 @@ public class StorageService { | ||
106 | * @return | 105 | * @return |
107 | */ | 106 | */ |
108 | public PageResponseBO<ProductResponceBo> storageListPlus(ProductRequestBo bo, List<Integer> sellerUid) { | 107 | public PageResponseBO<ProductResponceBo> storageListPlus(ProductRequestBo bo, List<Integer> sellerUid) { |
109 | - Product product = OrikaUtils.map(bo, Product.class); | ||
110 | - /** | ||
111 | - * 获取 productId | ||
112 | - */ | ||
113 | - List<Integer> integerList = storagePriceService.selectProductIdByPlus(product, sellerUid); | ||
114 | - if (null != integerList && integerList.isEmpty()) { | ||
115 | - // 返回空列表 代表查询了storage_price 但查询的接口是空 再联合查询肯定也是空 | ||
116 | - return new PageResponseBO<>(); | ||
117 | - } | ||
118 | - product.setProductIdList(integerList); | ||
119 | - int count = productMapper.selectProductStorageCount(product); | 108 | + final Product product = OrikaUtils.map(bo, Product.class); |
109 | + final int count = productMapper.selectProductStockNotZeroCount( | ||
110 | + DEFAULT_SKUP_STATUS, | ||
111 | + sellerUid, | ||
112 | + product | ||
113 | + ); | ||
120 | if (count == 0) { | 114 | if (count == 0) { |
121 | LOGGER.warn("StorageService storageListPlus count is 0.param = {}, sellerUid = {}", bo, sellerUid); | 115 | LOGGER.warn("StorageService storageListPlus count is 0.param = {}, sellerUid = {}", bo, sellerUid); |
122 | return new PageResponseBO<>(); | 116 | return new PageResponseBO<>(); |
123 | } | 117 | } |
124 | - List<Product> productList = productMapper.selectProductStorageList(product, bo.getStartIndex(), bo.getRows()); | ||
125 | - List<ProductResponceBo> responseBos = new ArrayList<>(); | ||
126 | - ProductResponceBo productResponseBo; | 118 | + final List<Product> productList = productMapper.selectProductStockNotZeroList( |
119 | + DEFAULT_SKUP_STATUS, | ||
120 | + sellerUid, | ||
121 | + product, | ||
122 | + bo.getStartIndex(), | ||
123 | + bo.getRows() | ||
124 | + ); | ||
125 | + final List<ProductResponceBo> responseBos = new ArrayList<>(); | ||
127 | for (Product productItem : productList) { | 126 | for (Product productItem : productList) { |
128 | - productResponseBo = productConvertService.convertProductDo2Bo(productItem); | ||
129 | - responseBos.add(productResponseBo); | 127 | + responseBos.add(productConvertService.convertProductDo2Bo(productItem)); |
130 | } | 128 | } |
131 | productAssistService.fillBrandName(responseBos).fillSkupInfo(responseBos); | 129 | productAssistService.fillBrandName(responseBos).fillSkupInfo(responseBos); |
132 | return new PageResponseBO<>(count, responseBos, bo.getPage(), bo.getRows()); | 130 | return new PageResponseBO<>(count, responseBos, bo.getPage(), bo.getRows()); |
-
Please register or login to post a comment