Showing
9 changed files
with
145 additions
and
35 deletions
@@ -44,4 +44,7 @@ public interface StoragePriceMapper { | @@ -44,4 +44,7 @@ public interface StoragePriceMapper { | ||
44 | 44 | ||
45 | // 查询状态可售的skup集合 | 45 | // 查询状态可售的skup集合 |
46 | List<StoragePrice> selectByProductIds(@Param("list")List<Integer> productIdList); | 46 | List<StoragePrice> selectByProductIds(@Param("list")List<Integer> productIdList); |
47 | + | ||
48 | + // 根据SKup等信息查询其所属productId列表 最多查询出最新的300 productId | ||
49 | + List<Integer> selectProductIdsBySkupInfo(@Param("storagePrice")StoragePrice storagePrice); | ||
47 | } | 50 | } |
1 | package com.yoho.ufo.dal.model; | 1 | package com.yoho.ufo.dal.model; |
2 | 2 | ||
3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
4 | +import java.util.List; | ||
4 | 5 | ||
5 | public class Product { | 6 | public class Product { |
6 | private Integer id; | 7 | private Integer id; |
@@ -42,46 +43,18 @@ public class Product { | @@ -42,46 +43,18 @@ public class Product { | ||
42 | // 0未删除 1已删除 | 43 | // 0未删除 1已删除 |
43 | private Integer delStatus; | 44 | private Integer delStatus; |
44 | 45 | ||
45 | - public Integer getStorageId() { | ||
46 | - return storageId; | ||
47 | - } | ||
48 | - | ||
49 | - public void setStorageId(Integer storageId) { | ||
50 | - this.storageId = storageId; | ||
51 | - } | ||
52 | - | ||
53 | - public Integer getSellerUid() { | ||
54 | - return sellerUid; | ||
55 | - } | ||
56 | - | ||
57 | - public void setSellerUid(Integer sellerUid) { | ||
58 | - this.sellerUid = sellerUid; | ||
59 | - } | ||
60 | - | ||
61 | - public Integer getStatus() { | ||
62 | - return status; | ||
63 | - } | ||
64 | - | ||
65 | - public void setStatus(Integer status) { | ||
66 | - this.status = status; | ||
67 | - } | ||
68 | - | ||
69 | - public Integer getSkup() { | ||
70 | - return skup; | ||
71 | - } | ||
72 | - | ||
73 | - public void setSkup(Integer skup) { | ||
74 | - this.skup = skup; | ||
75 | - } | ||
76 | - | ||
77 | private Integer storageId; | 46 | private Integer storageId; |
78 | 47 | ||
79 | private Integer sellerUid; | 48 | private Integer sellerUid; |
80 | 49 | ||
81 | private Integer status; | 50 | private Integer status; |
82 | 51 | ||
52 | + private Integer storageNum; | ||
53 | + | ||
83 | private Integer skup; | 54 | private Integer skup; |
84 | 55 | ||
56 | + private List<Integer> productIdList; | ||
57 | + | ||
85 | public Integer getId() { | 58 | public Integer getId() { |
86 | return id; | 59 | return id; |
87 | } | 60 | } |
@@ -233,4 +206,52 @@ public class Product { | @@ -233,4 +206,52 @@ public class Product { | ||
233 | public void setDelStatus(Integer delStatus) { | 206 | public void setDelStatus(Integer delStatus) { |
234 | this.delStatus = delStatus; | 207 | this.delStatus = delStatus; |
235 | } | 208 | } |
209 | + | ||
210 | + public Integer getStorageId() { | ||
211 | + return storageId; | ||
212 | + } | ||
213 | + | ||
214 | + public void setStorageId(Integer storageId) { | ||
215 | + this.storageId = storageId; | ||
216 | + } | ||
217 | + | ||
218 | + public Integer getSellerUid() { | ||
219 | + return sellerUid; | ||
220 | + } | ||
221 | + | ||
222 | + public void setSellerUid(Integer sellerUid) { | ||
223 | + this.sellerUid = sellerUid; | ||
224 | + } | ||
225 | + | ||
226 | + public Integer getStatus() { | ||
227 | + return status; | ||
228 | + } | ||
229 | + | ||
230 | + public void setStatus(Integer status) { | ||
231 | + this.status = status; | ||
232 | + } | ||
233 | + | ||
234 | + public Integer getSkup() { | ||
235 | + return skup; | ||
236 | + } | ||
237 | + | ||
238 | + public void setSkup(Integer skup) { | ||
239 | + this.skup = skup; | ||
240 | + } | ||
241 | + | ||
242 | + public Integer getStorageNum() { | ||
243 | + return storageNum; | ||
244 | + } | ||
245 | + | ||
246 | + public void setStorageNum(Integer storageNum) { | ||
247 | + this.storageNum = storageNum; | ||
248 | + } | ||
249 | + | ||
250 | + public List<Integer> getProductIdList() { | ||
251 | + return productIdList; | ||
252 | + } | ||
253 | + | ||
254 | + public void setProductIdList(List<Integer> productIdList) { | ||
255 | + this.productIdList = productIdList; | ||
256 | + } | ||
236 | } | 257 | } |
1 | package com.yoho.ufo.dal.model; | 1 | package com.yoho.ufo.dal.model; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | + | ||
3 | import java.math.BigDecimal; | 5 | import java.math.BigDecimal; |
4 | 6 | ||
5 | public class StoragePrice { | 7 | public class StoragePrice { |
@@ -122,4 +124,9 @@ public class StoragePrice { | @@ -122,4 +124,9 @@ public class StoragePrice { | ||
122 | public void setSizeId(Integer sizeId) { | 124 | public void setSizeId(Integer sizeId) { |
123 | this.sizeId = sizeId; | 125 | this.sizeId = sizeId; |
124 | } | 126 | } |
127 | + | ||
128 | + @Override | ||
129 | + public String toString() { | ||
130 | + return JSONObject.toJSONString(this); | ||
131 | + } | ||
125 | } | 132 | } |
@@ -201,5 +201,11 @@ | @@ -201,5 +201,11 @@ | ||
201 | <if test="product.brandId != null and product.brandId > 0"> | 201 | <if test="product.brandId != null and product.brandId > 0"> |
202 | and p.brand_id = #{product.brandId} | 202 | and p.brand_id = #{product.brandId} |
203 | </if> | 203 | </if> |
204 | + <if test="product.productIdList != null and product.productIdList.size()>0"> | ||
205 | + And b.id in | ||
206 | + <foreach collection="product.productIdList" item="productID" open="(" close=")" separator=","> | ||
207 | + #{productID} | ||
208 | + </foreach> | ||
209 | + </if> | ||
204 | </sql> | 210 | </sql> |
205 | </mapper> | 211 | </mapper> |
@@ -148,4 +148,17 @@ | @@ -148,4 +148,17 @@ | ||
148 | #{item} | 148 | #{item} |
149 | </foreach> limit 5000 <!-- 防止太多的数据,导致内存扛不住 --> | 149 | </foreach> limit 5000 <!-- 防止太多的数据,导致内存扛不住 --> |
150 | </select> | 150 | </select> |
151 | + <select id="selectProductIdsBySkupInfo" resultType="java.lang.Integer"> | ||
152 | + select DISTINCT product_id from storage_price where 1 = 1 | ||
153 | + <if test="storagePrice.sellerUid != null and storagePrice.sellerUid > 0"> | ||
154 | + and seller_uid = #{storagePrice.sellerUid} | ||
155 | + </if> | ||
156 | + <if test="storagePrice.storageId != null and storagePrice.storageId > 0"> | ||
157 | + and storage_id = #{storagePrice.storageId} | ||
158 | + </if> | ||
159 | + <if test="storagePrice.skup != null and storagePrice.skup > 0"> | ||
160 | + and skup = #{storagePrice.skup} | ||
161 | + </if> | ||
162 | + order by create_time desc limit 300 | ||
163 | + </select> | ||
151 | </mapper> | 164 | </mapper> |
@@ -59,4 +59,15 @@ public class ProductConvertService { | @@ -59,4 +59,15 @@ public class ProductConvertService { | ||
59 | bo.setProductName(productItem.getProductName()); | 59 | bo.setProductName(productItem.getProductName()); |
60 | return bo; | 60 | return bo; |
61 | } | 61 | } |
62 | + | ||
63 | + public StoragePrice convertProduct2Skup(Product product) { | ||
64 | + StoragePrice storagePrice = new StoragePrice(); | ||
65 | + if (null == product) { | ||
66 | + return storagePrice; | ||
67 | + } | ||
68 | + storagePrice.setSkup(product.getSkup()); | ||
69 | + storagePrice.setStorageId(product.getStorageId()); | ||
70 | + storagePrice.setSellerUid(product.getSellerUid()); | ||
71 | + return storagePrice; | ||
72 | + } | ||
62 | } | 73 | } |
1 | +package com.yoho.ufo.service.impl; | ||
2 | + | ||
3 | +import com.google.common.collect.Lists; | ||
4 | +import com.yoho.ufo.convert.ProductConvertService; | ||
5 | +import com.yoho.ufo.dal.StoragePriceMapper; | ||
6 | +import com.yoho.ufo.dal.model.Product; | ||
7 | +import com.yoho.ufo.dal.model.StoragePrice; | ||
8 | +import org.apache.commons.collections.CollectionUtils; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.slf4j.LoggerFactory; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.stereotype.Service; | ||
13 | + | ||
14 | +import java.util.List; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by li.ma on 2018/9/20. | ||
18 | + */ | ||
19 | +@Service | ||
20 | +public class StoragePriceService { | ||
21 | + private static final Logger LOGGER = LoggerFactory.getLogger(StoragePriceService.class); | ||
22 | + | ||
23 | + @Autowired | ||
24 | + private StoragePriceMapper storagePriceMapper; | ||
25 | + | ||
26 | + @Autowired | ||
27 | + private ProductConvertService productConvertService; | ||
28 | + | ||
29 | + public List<Integer> selectProductIdBySkupInfo(Product product) { | ||
30 | + if (null == product || (null == product.getStorageId() && null == product.getSkup() && null == product.getSellerUid())) { | ||
31 | + return Lists.newArrayList(); | ||
32 | + } | ||
33 | + | ||
34 | + StoragePrice storagePrice = productConvertService.convertProduct2Skup(product); | ||
35 | + | ||
36 | + List<Integer> productIds = storagePriceMapper.selectProductIdsBySkupInfo(storagePrice); | ||
37 | + | ||
38 | + LOGGER.info("result selectProductIdBySkupInfo is {}, storagePrice is {}", productIds, storagePrice); | ||
39 | + | ||
40 | + return CollectionUtils.isEmpty(productIds) ? Lists.newArrayList() : productIds; | ||
41 | + } | ||
42 | +} |
@@ -36,6 +36,9 @@ public class StorageService { | @@ -36,6 +36,9 @@ public class StorageService { | ||
36 | private StoragePriceMapper storagePriceMapper; | 36 | private StoragePriceMapper storagePriceMapper; |
37 | 37 | ||
38 | @Autowired | 38 | @Autowired |
39 | + private StoragePriceService storagePriceService; | ||
40 | + | ||
41 | + @Autowired | ||
39 | private ProductMapper productMapper; | 42 | private ProductMapper productMapper; |
40 | 43 | ||
41 | @Autowired | 44 | @Autowired |
@@ -46,6 +49,10 @@ public class StorageService { | @@ -46,6 +49,10 @@ public class StorageService { | ||
46 | LOGGER.info("StorageService storageList param = {}", bo); | 49 | LOGGER.info("StorageService storageList param = {}", bo); |
47 | 50 | ||
48 | Product product = OrikaUtils.map(bo, Product.class); | 51 | Product product = OrikaUtils.map(bo, Product.class); |
52 | + | ||
53 | + // 如果查询条件含storage_price,先根据条件查询出productId列表 ,再到product表中联合查询 | ||
54 | + product.setProductIdList(storagePriceService.selectProductIdBySkupInfo(product)); | ||
55 | + | ||
49 | int count = productMapper.selectProductStorageCount(product); | 56 | int count = productMapper.selectProductStorageCount(product); |
50 | if (count == 0) { | 57 | if (count == 0) { |
51 | LOGGER.warn("StorageService storageList count is 0.param = {}", bo); | 58 | LOGGER.warn("StorageService storageList count is 0.param = {}", bo); |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | <script src="/ufoPlatform/js/ajaxfileupload.js"></script> | 7 | <script src="/ufoPlatform/js/ajaxfileupload.js"></script> |
8 | </head> | 8 | </head> |
9 | <body class="easyui-layout" fit="true"> | 9 | <body class="easyui-layout" fit="true"> |
10 | -<div region="north" style="height: 190px"> | 10 | +<div region="north" style="height: 220px"> |
11 | <script> | 11 | <script> |
12 | document.write(addHead('商品库存信息', '')); | 12 | document.write(addHead('商品库存信息', '')); |
13 | </script> | 13 | </script> |
@@ -204,10 +204,10 @@ | @@ -204,10 +204,10 @@ | ||
204 | var skup = $('#skup').textbox('getValue'); | 204 | var skup = $('#skup').textbox('getValue'); |
205 | var param = {}; | 205 | var param = {}; |
206 | if (undefined !== brandName && null !== brandName && "" !== brandName) { | 206 | if (undefined !== brandName && null !== brandName && "" !== brandName) { |
207 | - param.brandName = brandName; | 207 | + param.brandId = brandName; |
208 | } | 208 | } |
209 | if (undefined !== storageNum && null !== storageNum && "" !== storageNum) { | 209 | if (undefined !== storageNum && null !== storageNum && "" !== storageNum) { |
210 | - param.storage = storageNum; | 210 | + param.storageNum = storageNum; |
211 | } | 211 | } |
212 | if (undefined !== id && null !== id && "" !== id) { | 212 | if (undefined !== id && null !== id && "" !== id) { |
213 | param.id = id; | 213 | param.id = id; |
-
Please register or login to post a comment