Showing
17 changed files
with
402 additions
and
3 deletions
1 | package com.yoho.ufo.dal; | 1 | package com.yoho.ufo.dal; |
2 | 2 | ||
3 | import com.yoho.ufo.dal.model.Goods; | 3 | import com.yoho.ufo.dal.model.Goods; |
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
4 | import java.util.List; | 6 | import java.util.List; |
5 | 7 | ||
6 | public interface GoodsMapper { | 8 | public interface GoodsMapper { |
@@ -15,4 +17,6 @@ public interface GoodsMapper { | @@ -15,4 +17,6 @@ public interface GoodsMapper { | ||
15 | int updateByPrimaryKey(Goods record); | 17 | int updateByPrimaryKey(Goods record); |
16 | 18 | ||
17 | List<Goods> selectByProductId(List<Integer> productIds); | 19 | List<Goods> selectByProductId(List<Integer> productIds); |
20 | + | ||
21 | + List<Goods> selectByIds(@Param("goodsIdList")List<Integer> goodsIdList); | ||
18 | } | 22 | } |
@@ -2,6 +2,7 @@ package com.yoho.ufo.dal; | @@ -2,6 +2,7 @@ package com.yoho.ufo.dal; | ||
2 | 2 | ||
3 | import java.util.List; | 3 | import java.util.List; |
4 | 4 | ||
5 | +import com.yoho.ufo.model.brand.Brand; | ||
5 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
6 | 7 | ||
7 | import com.yoho.ufo.dal.model.Product; | 8 | import com.yoho.ufo.dal.model.Product; |
@@ -60,4 +61,7 @@ public interface ProductMapper { | @@ -60,4 +61,7 @@ public interface ProductMapper { | ||
60 | @Param("sellerUid") Integer sellerUid, | 61 | @Param("sellerUid") Integer sellerUid, |
61 | @Param("hasStock") Integer hasStock, | 62 | @Param("hasStock") Integer hasStock, |
62 | @Param("skup") Integer skup); | 63 | @Param("skup") Integer skup); |
64 | + | ||
65 | + // 根据Id列表查询商品列表 | ||
66 | + List<Product> selectProductListByIds(@Param("productIdList")List<Integer> productIdList); | ||
63 | } | 67 | } |
@@ -22,4 +22,5 @@ public interface StorageMapper { | @@ -22,4 +22,5 @@ public interface StorageMapper { | ||
22 | 22 | ||
23 | int addStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum); | 23 | int addStorageNum(@Param("storageId")Integer storageId, @Param("storageNum")Integer storageNum); |
24 | 24 | ||
25 | + List<Storage> selectByIds(@Param("storageIdList")List<Integer> storageIdList); | ||
25 | } | 26 | } |
@@ -2,6 +2,7 @@ package com.yoho.ufo.dal; | @@ -2,6 +2,7 @@ package com.yoho.ufo.dal; | ||
2 | 2 | ||
3 | import java.util.List; | 3 | import java.util.List; |
4 | 4 | ||
5 | +import com.yoho.ufo.dal.model.Product; | ||
5 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
6 | 7 | ||
7 | import com.yoho.ufo.dal.model.StoragePrice; | 8 | import com.yoho.ufo.dal.model.StoragePrice; |
@@ -36,5 +37,12 @@ public interface StoragePriceMapper { | @@ -36,5 +37,12 @@ public interface StoragePriceMapper { | ||
36 | StoragePrice selectBySkup(Integer skup); | 37 | StoragePrice selectBySkup(Integer skup); |
37 | 38 | ||
38 | int cancelSaleSkup(Integer skup); | 39 | int cancelSaleSkup(Integer skup); |
39 | - | 40 | + |
41 | + int selectProductStorageCount(@Param("product")Product product); | ||
42 | + | ||
43 | + List<Product> selectProductStorageList(@Param("product")Product product, @Param("start")int start, @Param("rows")Integer rows); | ||
44 | + | ||
45 | + int selectStoragePriceCount(@Param("storagePrice")StoragePrice storagePrice); | ||
46 | + | ||
47 | + List<StoragePrice> selectStoragePriceList(@Param("storagePrice")StoragePrice storagePrice, @Param("start")int start, @Param("rows")Integer rows); | ||
40 | } | 48 | } |
@@ -55,4 +55,10 @@ public interface UfoProductColorMapper { | @@ -55,4 +55,10 @@ public interface UfoProductColorMapper { | ||
55 | * @return | 55 | * @return |
56 | */ | 56 | */ |
57 | List<ProductColor> getProductColorPageList(@Param("productColor") ProductColor productColor, @Param("page") PageModel pageModel); | 57 | List<ProductColor> getProductColorPageList(@Param("productColor") ProductColor productColor, @Param("page") PageModel pageModel); |
58 | + | ||
59 | + /** | ||
60 | + * 查询所有的颜色列表 | ||
61 | + * @return | ||
62 | + */ | ||
63 | + List<ProductColor> selectAllColor(); | ||
58 | } | 64 | } |
@@ -64,5 +64,10 @@ public interface UfoSizeMapper { | @@ -64,5 +64,10 @@ public interface UfoSizeMapper { | ||
64 | */ | 64 | */ |
65 | List<Size> selectAllSizeBySortId(@Param("sortId") Integer sortId); | 65 | List<Size> selectAllSizeBySortId(@Param("sortId") Integer sortId); |
66 | 66 | ||
67 | + /** | ||
68 | + * 根据尺码ID查询尺码信息 | ||
69 | + * @param idList | ||
70 | + * @return | ||
71 | + */ | ||
67 | List<Size> selectByIdList(@Param("list")List<Integer> idList); | 72 | List<Size> selectByIdList(@Param("list")List<Integer> idList); |
68 | } | 73 | } |
@@ -49,4 +49,11 @@ | @@ -49,4 +49,11 @@ | ||
49 | #{item} | 49 | #{item} |
50 | </foreach> | 50 | </foreach> |
51 | </select> | 51 | </select> |
52 | + <select id="selectByIds" resultMap="BaseResultMap"> | ||
53 | + select id, product_id, color_id, color_name, goods_name, color_image, is_default | ||
54 | + from goods where id in | ||
55 | + <foreach item="item" index="index" collection="goodsIdList" open="(" separator="," close=")"> | ||
56 | + #{item} | ||
57 | + </foreach> | ||
58 | + </select> | ||
52 | </mapper> | 59 | </mapper> |
@@ -157,4 +157,14 @@ | @@ -157,4 +157,14 @@ | ||
157 | and sp.skup = #{skup} | 157 | and sp.skup = #{skup} |
158 | </if> | 158 | </if> |
159 | </sql> | 159 | </sql> |
160 | + | ||
161 | + <select id="selectProductListByIds" resultMap="BaseResultMap"> | ||
162 | + select id, product_name, product_code, max_sort_id, mid_sort_id, brand_id, series_id, | ||
163 | + gender, sale_time, min_price, max_price, create_time, update_time, shelve_time, edit_time, | ||
164 | + shelve_status, storage, key_words, del_status | ||
165 | + from product where id in | ||
166 | + <foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")"> | ||
167 | + #{item} | ||
168 | + </foreach> | ||
169 | + </select> | ||
160 | </mapper> | 170 | </mapper> |
@@ -91,7 +91,7 @@ | @@ -91,7 +91,7 @@ | ||
91 | select <include refid="queryColumns"/> | 91 | select <include refid="queryColumns"/> |
92 | from product_sort | 92 | from product_sort |
93 | </select> | 93 | </select> |
94 | - <select id=selectSortByIdList resultMap="productSortMap"> | 94 | + <select id="selectSortByIdList" resultMap="productSortMap"> |
95 | select id,sort_name | 95 | select id,sort_name |
96 | from product_sort where id in | 96 | from product_sort where id in |
97 | <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> | 97 | <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> |
@@ -57,4 +57,11 @@ | @@ -57,4 +57,11 @@ | ||
57 | update_time = #{updateTime,jdbcType=INTEGER}, | 57 | update_time = #{updateTime,jdbcType=INTEGER}, |
58 | where id = #{storageId,jdbcType=INTEGER} | 58 | where id = #{storageId,jdbcType=INTEGER} |
59 | </update> | 59 | </update> |
60 | + <select id="selectByIds" resultMap="BaseResultMap"> | ||
61 | + select id, product_id, goods_id, size_id, storage_num, update_time, create_time | ||
62 | + from storage where id in | ||
63 | + <foreach item="item" index="index" collection="storageIdList" open="(" separator="," close=")"> | ||
64 | + #{item} | ||
65 | + </foreach> | ||
66 | + </select> | ||
60 | </mapper> | 67 | </mapper> |
@@ -107,4 +107,33 @@ | @@ -107,4 +107,33 @@ | ||
107 | from storage_price | 107 | from storage_price |
108 | where skup = #{skup,jdbcType=INTEGER} | 108 | where skup = #{skup,jdbcType=INTEGER} |
109 | </select> | 109 | </select> |
110 | + | ||
111 | + <select id="selectStoragePriceCount" resultMap="java.lang.Integer"> | ||
112 | + select count(*) from from storage_price where <include refid="skupPageCondition" /> | ||
113 | + </select> | ||
114 | + | ||
115 | + <select id="selectStoragePriceList" resultMap="BaseResultMap"> | ||
116 | + select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status, | ||
117 | + update_time, create_time | ||
118 | + from storage_price | ||
119 | + where <include refid="skupPageCondition" /> limit #{start},#{rows} | ||
120 | + </select> | ||
121 | + | ||
122 | + <sql id="skupPageCondition" > | ||
123 | + <if test="storagePrice.status != null and storagePrice.status > -1"> | ||
124 | + and status = #{storagePrice.status} | ||
125 | + </if> | ||
126 | + <if test="storagePrice.storageId != null and storagePrice.storageId > 0"> | ||
127 | + and storage_id = #{storagePrice.storageId} | ||
128 | + </if> | ||
129 | + <if test="storagePrice.sellerUid != null and storagePrice.sellerUid > 0"> | ||
130 | + and seller_uid = #{storagePrice.sellerUid} | ||
131 | + </if> | ||
132 | + <if test="storagePrice.productId != null and storagePrice.productId > 0"> | ||
133 | + and product_id = #{storagePrice.productId} | ||
134 | + </if> | ||
135 | + <if test="storagePrice.skup != null and storagePrice.skup > 0"> | ||
136 | + and skup = #{storagePrice.skup} | ||
137 | + </if> | ||
138 | + </sql> | ||
110 | </mapper> | 139 | </mapper> |
@@ -71,4 +71,8 @@ | @@ -71,4 +71,8 @@ | ||
71 | limit #{page.startIndex}, #{page.pageSize} | 71 | limit #{page.startIndex}, #{page.pageSize} |
72 | </select> | 72 | </select> |
73 | 73 | ||
74 | + <select id="selectAllColor" resultMap="productColorMap"> | ||
75 | + select <include refid="queryColumns" /> | ||
76 | + from product_color limit 100 | ||
77 | + </select> | ||
74 | </mapper> | 78 | </mapper> |
@@ -91,5 +91,12 @@ | @@ -91,5 +91,12 @@ | ||
91 | #{item} | 91 | #{item} |
92 | </foreach> | 92 | </foreach> |
93 | </select> | 93 | </select> |
94 | - | 94 | + |
95 | + <select id="selectByIdList" resultMap="sizeMap"> | ||
96 | + select id, size_name | ||
97 | + from size where id in | ||
98 | + <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> | ||
99 | + #{item} | ||
100 | + </foreach> | ||
101 | + </select> | ||
95 | </mapper> | 102 | </mapper> |
1 | +package com.yoho.ufo.controller.product; | ||
2 | + | ||
3 | +import com.yoho.ufo.service.IProductService; | ||
4 | +import com.yoho.ufo.service.impl.StorageService; | ||
5 | +import com.yohobuy.ufo.model.common.ApiResponse; | ||
6 | +import com.yohobuy.ufo.model.common.PageResponseBO; | ||
7 | +import com.yohobuy.ufo.model.request.product.ProductRequestBo; | ||
8 | +import com.yohobuy.ufo.model.resp.product.ProductResponceBo; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.slf4j.LoggerFactory; | ||
11 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
12 | +import org.springframework.web.bind.annotation.RestController; | ||
13 | + | ||
14 | +import javax.annotation.Resource; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by li.ma on 2018/9/18. | ||
18 | + */ | ||
19 | +@RestController | ||
20 | +@RequestMapping(value = "/storage") | ||
21 | +public class StorageController { | ||
22 | + private static final Logger LOGGER = LoggerFactory.getLogger(StorageController.class); | ||
23 | + | ||
24 | + @Resource | ||
25 | + private StorageService storageService; | ||
26 | + | ||
27 | + @RequestMapping(value = "/storageList") | ||
28 | + public ApiResponse<PageResponseBO<ProductResponceBo>> storageList(ProductRequestBo bo) { | ||
29 | + LOGGER.info("StorageController.storageList param = {}", bo); | ||
30 | + return new ApiResponse(storageService.storageList(bo)); | ||
31 | + } | ||
32 | + | ||
33 | + | ||
34 | + @RequestMapping(value = "/storagePriceList") | ||
35 | + public ApiResponse<PageResponseBO<ProductResponceBo>> storagePriceList(ProductRequestBo bo) { | ||
36 | + LOGGER.info("StorageController.storagePriceList param = {}", bo); | ||
37 | + return new ApiResponse(storageService.storagePriceList(bo)); | ||
38 | + } | ||
39 | +} |
1 | +package com.yoho.ufo.convert; | ||
2 | + | ||
3 | +import com.yoho.core.common.utils.DateUtil; | ||
4 | +import com.yoho.ufo.dal.model.StoragePrice; | ||
5 | +import com.yohobuy.ufo.model.request.product.ProductRequestBo; | ||
6 | +import com.yohobuy.ufo.model.resp.product.ProductResponceBo; | ||
7 | +import org.springframework.stereotype.Service; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by li.ma on 2018/9/18. | ||
11 | + */ | ||
12 | +@Service | ||
13 | +public class ProductConvertService { | ||
14 | + | ||
15 | + public StoragePrice convertBo2Skup(ProductRequestBo bo) { | ||
16 | + StoragePrice storagePrice = new StoragePrice(); | ||
17 | + if (null == bo) { | ||
18 | + return storagePrice; | ||
19 | + } | ||
20 | + | ||
21 | + storagePrice.setSellerUid(bo.getSellerUid()); | ||
22 | + storagePrice.setStatus(bo.getStatus()); | ||
23 | + storagePrice.setStorageId(bo.getStorageId()); | ||
24 | + storagePrice.setSkup(bo.getSkup()); | ||
25 | + return storagePrice; | ||
26 | + } | ||
27 | + | ||
28 | + public ProductResponceBo convertSkupDo2Bo(StoragePrice storagePrice) { | ||
29 | + ProductResponceBo bo = new ProductResponceBo(); | ||
30 | + if (null == storagePrice) { | ||
31 | + return bo; | ||
32 | + } | ||
33 | + bo.setGoodsId(storagePrice.getGoodsId()); | ||
34 | + bo.setSkup(storagePrice.getSkup()); | ||
35 | + bo.setStorageId(storagePrice.getStorageId()); | ||
36 | + bo.setSkupPrice(storagePrice.getPrice().toString()); | ||
37 | + bo.setStatus(storagePrice.getStatus()); | ||
38 | + bo.setSkupCreateTime(DateUtil.getDateStrBySecond(storagePrice.getCreateTime(), DateUtil.DATE_TIME_FORMAT)); | ||
39 | + bo.setSellerUid(storagePrice.getSellerUid()); | ||
40 | + bo.setId(storagePrice.getProductId()); | ||
41 | + return bo; | ||
42 | + } | ||
43 | +} |
1 | +package com.yoho.ufo.service.impl; | ||
2 | + | ||
3 | +import com.yoho.ufo.dal.*; | ||
4 | +import com.yoho.ufo.dal.model.Goods; | ||
5 | +import com.yoho.ufo.dal.model.Product; | ||
6 | +import com.yoho.ufo.dal.model.Storage; | ||
7 | +import com.yoho.ufo.model.brand.Brand; | ||
8 | +import com.yoho.ufo.model.commoditybasicrole.category.ProductSort; | ||
9 | +import com.yoho.ufo.model.commoditybasicrole.color.ProductColor; | ||
10 | +import com.yoho.ufo.model.commoditybasicrole.size.Size; | ||
11 | +import com.yoho.ufo.util.CollectionUtil; | ||
12 | +import com.yohobuy.ufo.model.resp.product.ProductResponceBo; | ||
13 | +import org.apache.commons.collections.CollectionUtils; | ||
14 | +import org.apache.commons.lang3.StringUtils; | ||
15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
16 | +import org.springframework.stereotype.Service; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | +import java.util.Map; | ||
21 | + | ||
22 | +/** | ||
23 | + * Created by li.ma on 2018/9/18. | ||
24 | + */ | ||
25 | +@Service | ||
26 | +public class ProductAssistService { | ||
27 | + | ||
28 | + @Autowired | ||
29 | + private ProductSortMapper productSortMapper; | ||
30 | + | ||
31 | + @Autowired | ||
32 | + private ProductMapper productMapper; | ||
33 | + | ||
34 | + @Autowired | ||
35 | + private BrandMapper brandMapper; | ||
36 | + | ||
37 | + @Autowired | ||
38 | + private GoodsMapper goodsMapper; | ||
39 | + | ||
40 | + @Autowired | ||
41 | + private GoodsImagesMapper goodsImagesMapper; | ||
42 | + | ||
43 | + @Autowired | ||
44 | + private UfoProductColorMapper productColorMapper; | ||
45 | + | ||
46 | + @Autowired | ||
47 | + private StorageMapper storageMapper; | ||
48 | + | ||
49 | + @Autowired | ||
50 | + private StoragePriceMapper storagePriceMapper; | ||
51 | + | ||
52 | + @Autowired | ||
53 | + private UfoSizeMapper sizeMapper; | ||
54 | + | ||
55 | + // 商品列表填充品牌名称 | ||
56 | + public ProductAssistService fillBrandName(List<ProductResponceBo> productResponceBos) { | ||
57 | + if (CollectionUtils.isEmpty(productResponceBos)) { | ||
58 | + return this; | ||
59 | + } | ||
60 | + | ||
61 | + //List<Integer> productIdList = CollectionUtil.distinct(productResponceBos, ProductResponceBo::getId); | ||
62 | + //List<Goods> goodsList = goodsMapper.selectByProductId(productIdList); | ||
63 | + //Map<Integer, Goods> goodsMap = CollectionUtil.extractMap(goodsList, Goods::getProductId); | ||
64 | + List<Brand> brandList = brandMapper.selectBrandByIdList(CollectionUtil.distinct(productResponceBos, ProductResponceBo::getBrandId)); | ||
65 | + Map<Integer, Brand> brandMap = CollectionUtil.extractMap(brandList, Brand::getId); | ||
66 | + //List<Integer> sortIdList = CollectionUtil.distinct(productList, Product::getMaxSortId); | ||
67 | + //sortIdList.addAll(CollectionUtil.distinct(productList, Product::getMidSortId)); | ||
68 | + //List<ProductSort> productSortList = productSortMapper.selectSortByIdList(sortIdList); | ||
69 | + //Map<Integer, ProductSort> productSortMap = CollectionUtil.extractMap(productSortList, ProductSort::getId); | ||
70 | + productResponceBos.forEach(respBo -> { | ||
71 | + Brand brand = brandMap.get(respBo.getBrandId()); | ||
72 | + if (brand != null) { | ||
73 | + respBo.setBrandName(brand.getBrandName()); | ||
74 | + } | ||
75 | + }); | ||
76 | + | ||
77 | + return this; | ||
78 | + } | ||
79 | + | ||
80 | + | ||
81 | + // 商品列表填充商品表信息 | ||
82 | + public ProductAssistService fillProductDetail(List<ProductResponceBo> productResponceBos) { | ||
83 | + if (CollectionUtils.isEmpty(productResponceBos)) { | ||
84 | + return this; | ||
85 | + } | ||
86 | + | ||
87 | + List<Integer> productIdList = CollectionUtil.distinct(productResponceBos, ProductResponceBo::getId); | ||
88 | + List<Product> products = productMapper.selectProductListByIds(productIdList); | ||
89 | + Map<Integer, Product> productMap = CollectionUtil.extractMap(products, Product::getId); | ||
90 | + productResponceBos.forEach(respBo -> { | ||
91 | + Product item = productMap.get(respBo.getId()); | ||
92 | + if (item != null) { | ||
93 | + respBo.setBrandId(item.getBrandId()); | ||
94 | + respBo.setMaxSortId(item.getMaxSortId()); | ||
95 | + respBo.setMaxSortId(item.getMidSortId()); | ||
96 | + } | ||
97 | + }); | ||
98 | + return this; | ||
99 | + } | ||
100 | + | ||
101 | + | ||
102 | + // 商品列表填充商品表信息 | ||
103 | + public ProductAssistService fillGoodsColor(List<ProductResponceBo> productResponceBos) { | ||
104 | + if (CollectionUtils.isEmpty(productResponceBos)) { | ||
105 | + return this; | ||
106 | + } | ||
107 | + | ||
108 | + List<Integer> goodsIdList = CollectionUtil.distinct(productResponceBos, ProductResponceBo::getGoodsId); | ||
109 | + List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList); | ||
110 | + Map<Integer, String> goodsNamesMap = CollectionUtil.extractMap(goodsList, Goods::getId, Goods::getGoodsName); | ||
111 | + | ||
112 | + productResponceBos.forEach(respBo -> { | ||
113 | + respBo.setGoodsName(goodsNamesMap.get(respBo.getGoodsId())); | ||
114 | + }); | ||
115 | + return this; | ||
116 | + } | ||
117 | + | ||
118 | + | ||
119 | + // 商品列表填充商品表信息 | ||
120 | + public ProductAssistService fillSortName(List<ProductResponceBo> productResponceBos) { | ||
121 | + if (CollectionUtils.isEmpty(productResponceBos)) { | ||
122 | + return this; | ||
123 | + } | ||
124 | + | ||
125 | + List<Integer> storageIdList = CollectionUtil.distinct(productResponceBos, ProductResponceBo::getStorageId); | ||
126 | + List<Storage> storageList = storageMapper.selectByIds(storageIdList); | ||
127 | + Map<Integer, Integer> storageMap = CollectionUtil.extractMap(storageList, Storage::getId, Storage::getSizeId); | ||
128 | + | ||
129 | + | ||
130 | + List<Size> sizes = sizeMapper.selectByIdList(new ArrayList<>(storageMap.values())); | ||
131 | + Map<Integer, String> sizeNameMap = CollectionUtil.extractMap(sizes, Size::getId, Size::getSizeName); | ||
132 | + | ||
133 | + | ||
134 | + productResponceBos.forEach(respBo -> { | ||
135 | + Integer storageId = respBo.getStorageId(); | ||
136 | + String sizeName = sizeNameMap.get(storageMap.get(storageId)); | ||
137 | + respBo.setSizeName(sizeName); | ||
138 | + }); | ||
139 | + return this; | ||
140 | + } | ||
141 | +} |
1 | +package com.yoho.ufo.service.impl; | ||
2 | + | ||
3 | +import com.yoho.core.common.utils.DateUtil; | ||
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 com.yoho.ufo.model.goodsmanage.ProductPool; | ||
9 | +import com.yoho.ufo.util.OrikaUtils; | ||
10 | +import com.yohobuy.ufo.model.common.ApiResponse; | ||
11 | +import com.yohobuy.ufo.model.common.PageModel; | ||
12 | +import com.yohobuy.ufo.model.common.PageResponseBO; | ||
13 | +import com.yohobuy.ufo.model.request.product.ProductRequestBo; | ||
14 | +import com.yohobuy.ufo.model.request.productpool.ProductPoolResponseBo; | ||
15 | +import com.yohobuy.ufo.model.resp.product.ProductResponceBo; | ||
16 | +import org.slf4j.Logger; | ||
17 | +import org.slf4j.LoggerFactory; | ||
18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
19 | +import org.springframework.stereotype.Service; | ||
20 | + | ||
21 | +import java.util.ArrayList; | ||
22 | +import java.util.List; | ||
23 | + | ||
24 | +/** | ||
25 | + * Created by li.ma on 2018/9/18. | ||
26 | + */ | ||
27 | +@Service | ||
28 | +public class StorageService { | ||
29 | + private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class); | ||
30 | + | ||
31 | + @Autowired | ||
32 | + private ProductConvertService productConvertService; | ||
33 | + | ||
34 | + @Autowired | ||
35 | + private StoragePriceMapper storagePriceMapper; | ||
36 | + | ||
37 | + @Autowired | ||
38 | + private ProductAssistService productAssistService; | ||
39 | + | ||
40 | + | ||
41 | + public PageResponseBO<ProductResponceBo> storageList(ProductRequestBo bo) { | ||
42 | + LOGGER.info("StorageService storageList param = {}", bo); | ||
43 | + | ||
44 | + Product product = OrikaUtils.map(bo, Product.class); | ||
45 | + int count = storagePriceMapper.selectProductStorageCount(product); | ||
46 | + if (count == 0) { | ||
47 | + LOGGER.warn("StorageService storageList count is 0.param = {}", bo); | ||
48 | + return new PageResponseBO<>(); | ||
49 | + } | ||
50 | + | ||
51 | + List<Product> productList = storagePriceMapper.selectProductStorageList(product, bo.getStart(), bo.getRows()); | ||
52 | + List<ProductResponceBo> responseBos = new ArrayList<>(); | ||
53 | + ProductResponceBo productResponseBo; | ||
54 | + for (Product productItem : productList) { | ||
55 | + productResponseBo = OrikaUtils.map(productItem, ProductResponceBo.class); | ||
56 | + //productResponseBo.setCreateTime(DateUtil.getDateStrBySecond(productItem.getCreateTime(), DateUtil.DATE_TIME_FORMAT)); | ||
57 | + responseBos.add(productResponseBo); | ||
58 | + } | ||
59 | + return new PageResponseBO<>(count, responseBos, bo.getPage(), bo.getRows()); | ||
60 | + } | ||
61 | + | ||
62 | + public PageResponseBO<ProductResponceBo> storagePriceList(ProductRequestBo bo) { | ||
63 | + LOGGER.info("StorageService storagePriceList param = {}", bo); | ||
64 | + | ||
65 | + StoragePrice storagePrice = productConvertService.convertBo2Skup(bo); | ||
66 | + int count = storagePriceMapper.selectStoragePriceCount(storagePrice); | ||
67 | + if (count == 0) { | ||
68 | + LOGGER.warn("StorageService storagePriceList count is 0.param = {}", bo); | ||
69 | + return new PageResponseBO<>(); | ||
70 | + } | ||
71 | + | ||
72 | + List<StoragePrice> storagePriceList = storagePriceMapper.selectStoragePriceList(storagePrice, bo.getStart(), bo.getRows()); | ||
73 | + List<ProductResponceBo> responseBos = new ArrayList<>(); | ||
74 | + ProductResponceBo productResponseBo; | ||
75 | + for (StoragePrice storagePriceItem : storagePriceList) { | ||
76 | + productResponseBo = productConvertService.convertSkupDo2Bo(storagePriceItem); | ||
77 | + responseBos.add(productResponseBo); | ||
78 | + } | ||
79 | + | ||
80 | + productAssistService.fillProductDetail(responseBos).fillGoodsColor(responseBos).fillSortName(responseBos); | ||
81 | + | ||
82 | + return new PageResponseBO<>(count, responseBos, bo.getPage(), bo.getRows()); | ||
83 | + } | ||
84 | +} |
-
Please register or login to post a comment