Merge branch 'master' of http://git.yoho.cn/ufo/yohoufo-fore
Showing
21 changed files
with
232 additions
and
61 deletions
@@ -13,4 +13,6 @@ public interface GoodsImagesMapper { | @@ -13,4 +13,6 @@ public interface GoodsImagesMapper { | ||
13 | List<GoodsImages> selectAll(); | 13 | List<GoodsImages> selectAll(); |
14 | 14 | ||
15 | int updateByPrimaryKey(GoodsImages record); | 15 | int updateByPrimaryKey(GoodsImages record); |
16 | + | ||
17 | + List<GoodsImages> selectByGoodsId(Integer goodsId); | ||
16 | } | 18 | } |
@@ -13,4 +13,6 @@ public interface GoodsMapper { | @@ -13,4 +13,6 @@ public interface GoodsMapper { | ||
13 | List<Goods> selectAll(); | 13 | List<Goods> selectAll(); |
14 | 14 | ||
15 | int updateByPrimaryKey(Goods record); | 15 | int updateByPrimaryKey(Goods record); |
16 | + | ||
17 | + List<Goods> selectByProductId(Integer productId); | ||
16 | } | 18 | } |
@@ -16,5 +16,5 @@ public interface StorageMapper { | @@ -16,5 +16,5 @@ public interface StorageMapper { | ||
16 | 16 | ||
17 | int updateByPrimaryKey(Storage record); | 17 | int updateByPrimaryKey(Storage record); |
18 | 18 | ||
19 | - StorageGoodProductSize selectStroageProductInfo(Integer id); | 19 | + List<Storage> selectByGoodsId(Integer goodsId); |
20 | } | 20 | } |
@@ -22,4 +22,6 @@ public interface StoragePriceMapper { | @@ -22,4 +22,6 @@ public interface StoragePriceMapper { | ||
22 | int cancelSaleSkup(Integer skup); | 22 | int cancelSaleSkup(Integer skup); |
23 | 23 | ||
24 | StoragePrice selectLeastPrice(Integer storageId); | 24 | StoragePrice selectLeastPrice(Integer storageId); |
25 | + | ||
26 | + List<StoragePrice> selectByStorageIds(List<Integer> storageIds); | ||
25 | } | 27 | } |
@@ -7,7 +7,7 @@ public class Brand { | @@ -7,7 +7,7 @@ public class Brand { | ||
7 | 7 | ||
8 | private String brandNameEn; | 8 | private String brandNameEn; |
9 | 9 | ||
10 | - private String brandLog; | 10 | + private String brandLogo; |
11 | 11 | ||
12 | private String brandSearch; | 12 | private String brandSearch; |
13 | 13 | ||
@@ -45,12 +45,12 @@ public class Brand { | @@ -45,12 +45,12 @@ public class Brand { | ||
45 | this.brandNameEn = brandNameEn; | 45 | this.brandNameEn = brandNameEn; |
46 | } | 46 | } |
47 | 47 | ||
48 | - public String getBrandLog() { | ||
49 | - return brandLog; | 48 | + public String getBrandLogo() { |
49 | + return brandLogo; | ||
50 | } | 50 | } |
51 | 51 | ||
52 | - public void setBrandLog(String brandLog) { | ||
53 | - this.brandLog = brandLog; | 52 | + public void setBrandLogo(String brandLogo) { |
53 | + this.brandLogo = brandLogo; | ||
54 | } | 54 | } |
55 | 55 | ||
56 | public String getBrandSearch() { | 56 | public String getBrandSearch() { |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <id column="id" jdbcType="INTEGER" property="id" /> | 5 | <id column="id" jdbcType="INTEGER" property="id" /> |
6 | <result column="brand_name" jdbcType="VARCHAR" property="brandName" /> | 6 | <result column="brand_name" jdbcType="VARCHAR" property="brandName" /> |
7 | <result column="brand_name_en" jdbcType="VARCHAR" property="brandNameEn" /> | 7 | <result column="brand_name_en" jdbcType="VARCHAR" property="brandNameEn" /> |
8 | - <result column="brand_log" jdbcType="VARCHAR" property="brandLog" /> | 8 | + <result column="brand_logo" jdbcType="VARCHAR" property="brandLogo" /> |
9 | <result column="brand_search" jdbcType="VARCHAR" property="brandSearch" /> | 9 | <result column="brand_search" jdbcType="VARCHAR" property="brandSearch" /> |
10 | <result column="status" jdbcType="INTEGER" property="status" /> | 10 | <result column="status" jdbcType="INTEGER" property="status" /> |
11 | <result column="create_time" jdbcType="INTEGER" property="createTime" /> | 11 | <result column="create_time" jdbcType="INTEGER" property="createTime" /> |
@@ -19,11 +19,11 @@ | @@ -19,11 +19,11 @@ | ||
19 | </delete> | 19 | </delete> |
20 | <insert id="insert" parameterType="com.yohoufo.dal.product.model.Brand"> | 20 | <insert id="insert" parameterType="com.yohoufo.dal.product.model.Brand"> |
21 | insert into brand (id, brand_name, brand_name_en, | 21 | insert into brand (id, brand_name, brand_name_en, |
22 | - brand_log, brand_search, status, | 22 | + brand_logo, brand_search, status, |
23 | create_time, edit_time, edit_pid, order_by | 23 | create_time, edit_time, edit_pid, order_by |
24 | ) | 24 | ) |
25 | values (#{id,jdbcType=INTEGER}, #{brandName,jdbcType=VARCHAR}, #{brandNameEn,jdbcType=VARCHAR}, | 25 | values (#{id,jdbcType=INTEGER}, #{brandName,jdbcType=VARCHAR}, #{brandNameEn,jdbcType=VARCHAR}, |
26 | - #{brandLog,jdbcType=VARCHAR}, #{brandSearch,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, | 26 | + #{brandLogo,jdbcType=VARCHAR}, #{brandSearch,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, |
27 | #{createTime,jdbcType=INTEGER}, #{editTime,jdbcType=INTEGER}, #{editPid,jdbcType=INTEGER}, #{orderBy,jdbcType=INTEGER} | 27 | #{createTime,jdbcType=INTEGER}, #{editTime,jdbcType=INTEGER}, #{editPid,jdbcType=INTEGER}, #{orderBy,jdbcType=INTEGER} |
28 | ) | 28 | ) |
29 | </insert> | 29 | </insert> |
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | update brand | 31 | update brand |
32 | set brand_name = #{brandName,jdbcType=VARCHAR}, | 32 | set brand_name = #{brandName,jdbcType=VARCHAR}, |
33 | brand_name_en = #{brandNameEn,jdbcType=VARCHAR}, | 33 | brand_name_en = #{brandNameEn,jdbcType=VARCHAR}, |
34 | - brand_log = #{brandLog,jdbcType=VARCHAR}, | 34 | + brand_logo = #{brandLogo,jdbcType=VARCHAR}, |
35 | brand_search = #{brandSearch,jdbcType=VARCHAR}, | 35 | brand_search = #{brandSearch,jdbcType=VARCHAR}, |
36 | status = #{status,jdbcType=INTEGER}, | 36 | status = #{status,jdbcType=INTEGER}, |
37 | create_time = #{createTime,jdbcType=INTEGER}, | 37 | create_time = #{createTime,jdbcType=INTEGER}, |
@@ -41,13 +41,13 @@ | @@ -41,13 +41,13 @@ | ||
41 | where id = #{id,jdbcType=INTEGER} | 41 | where id = #{id,jdbcType=INTEGER} |
42 | </update> | 42 | </update> |
43 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 43 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> |
44 | - select id, brand_name, brand_name_en, brand_log, brand_search, status, create_time, | 44 | + select id, brand_name, brand_name_en, brand_logo, brand_search, status, create_time, |
45 | edit_time, edit_pid, order_by | 45 | edit_time, edit_pid, order_by |
46 | from brand | 46 | from brand |
47 | where id = #{id,jdbcType=INTEGER} | 47 | where id = #{id,jdbcType=INTEGER} |
48 | </select> | 48 | </select> |
49 | <select id="selectAll" resultMap="BaseResultMap"> | 49 | <select id="selectAll" resultMap="BaseResultMap"> |
50 | - select id, brand_name, brand_name_en, brand_log, brand_search, status, create_time, | 50 | + select id, brand_name, brand_name_en, brand_logo, brand_search, status, create_time, |
51 | edit_time, edit_pid, order_by | 51 | edit_time, edit_pid, order_by |
52 | from brand | 52 | from brand |
53 | </select> | 53 | </select> |
@@ -39,4 +39,8 @@ | @@ -39,4 +39,8 @@ | ||
39 | select id, goods_id, product_id, is_default, image_url, order_by | 39 | select id, goods_id, product_id, is_default, image_url, order_by |
40 | from goods_images | 40 | from goods_images |
41 | </select> | 41 | </select> |
42 | + <select id="selectByGoodsId" resultMap="BaseResultMap"> | ||
43 | + select image_url | ||
44 | + from goods_images where goods_id = #{goodsId,jdbcType=INTEGER} order BY order_by; | ||
45 | + </select> | ||
42 | </mapper> | 46 | </mapper> |
@@ -41,4 +41,8 @@ | @@ -41,4 +41,8 @@ | ||
41 | select id, product_id, color_id, color_name, goods_name, color_image, is_default | 41 | select id, product_id, color_id, color_name, goods_name, color_image, is_default |
42 | from goods | 42 | from goods |
43 | </select> | 43 | </select> |
44 | + <select id="selectByProductId" resultMap="BaseResultMap"> | ||
45 | + select id, product_id, color_name, goods_name | ||
46 | + from goods where product_id = #{productId,jdbcType=INTEGER} | ||
47 | + </select> | ||
44 | </mapper> | 48 | </mapper> |
@@ -32,11 +32,20 @@ | @@ -32,11 +32,20 @@ | ||
32 | </update> | 32 | </update> |
33 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 33 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> |
34 | select id, size_name, sort_id, order_by, create_time, update_time | 34 | select id, size_name, sort_id, order_by, create_time, update_time |
35 | - from size | 35 | + from `size` |
36 | where id = #{id,jdbcType=INTEGER} | 36 | where id = #{id,jdbcType=INTEGER} |
37 | </select> | 37 | </select> |
38 | <select id="selectAll" resultMap="BaseResultMap"> | 38 | <select id="selectAll" resultMap="BaseResultMap"> |
39 | select id, size_name, sort_id, order_by, create_time, update_time | 39 | select id, size_name, sort_id, order_by, create_time, update_time |
40 | - from size | 40 | + from `size` |
41 | + </select> | ||
42 | + <select id="selectByIds" resultMap="BaseResultMap"> | ||
43 | + select id, size_name, order_by | ||
44 | + from `size` where id in | ||
45 | + <foreach item="item" index="index" collection="list" | ||
46 | + open="(" separator="," close=")"> | ||
47 | + #{item} | ||
48 | + </foreach> | ||
49 | + order by order_by | ||
41 | </select> | 50 | </select> |
42 | </mapper> | 51 | </mapper> |
@@ -53,10 +53,8 @@ | @@ -53,10 +53,8 @@ | ||
53 | select id, product_id, goods_id, size_id, storage_num, update_time, create_time | 53 | select id, product_id, goods_id, size_id, storage_num, update_time, create_time |
54 | from storage | 54 | from storage |
55 | </select> | 55 | </select> |
56 | - <select id="selectStroageProductInfo" parameterType="java.lang.Integer" resultMap="StorageGoodProductSizeResultMap"> | ||
57 | - select * from | ||
58 | - (select s.product_id, p.product_name, g.color_id,g.color_name,g.color_image, s.size_id,sz.size_name from | ||
59 | - (select * from `storage` s where s.id=#{id,jdbcType=INTEGER}) as s left JOIN goods g on s.goods_id = g.id | ||
60 | - left JOIN product p on s.product_id = p.id left JOIN `size` sz on sz.id =s.size_id) r | 56 | + <select id="selectByGoodsId" resultMap="BaseResultMap"> |
57 | + select id, product_id, goods_id, size_id, storage_num | ||
58 | + from storage where goods_id=#{goodsId,jdbcType=INTEGER} | ||
61 | </select> | 59 | </select> |
62 | </mapper> | 60 | </mapper> |
@@ -72,4 +72,15 @@ | @@ -72,4 +72,15 @@ | ||
72 | <select id="selectLeastPrice" resultMap="BaseResultMap"> | 72 | <select id="selectLeastPrice" resultMap="BaseResultMap"> |
73 | select MIN(price) price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 | 73 | select MIN(price) price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 |
74 | </select> | 74 | </select> |
75 | + <select id="selectByStorageIds" resultMap="BaseResultMap"> | ||
76 | + select id, skup, storage_id, price, status | ||
77 | + from storage_price | ||
78 | + where storage_id in | ||
79 | + <foreach item="item" index="index" collection="list" | ||
80 | + open="(" separator="," close=")"> | ||
81 | + #{item} | ||
82 | + </foreach> | ||
83 | + group by storage_id order by price | ||
84 | + </select> | ||
85 | + | ||
75 | </mapper> | 86 | </mapper> |
@@ -26,5 +26,9 @@ | @@ -26,5 +26,9 @@ | ||
26 | <groupId>com.yohoufo.fore</groupId> | 26 | <groupId>com.yohoufo.fore</groupId> |
27 | <artifactId>yohoufo-fore-dal</artifactId> | 27 | <artifactId>yohoufo-fore-dal</artifactId> |
28 | </dependency> | 28 | </dependency> |
29 | + <dependency> | ||
30 | + <groupId>com.yohoufo.fore</groupId> | ||
31 | + <artifactId>yohoufo-fore-resource</artifactId> | ||
32 | + </dependency> | ||
29 | </dependencies> | 33 | </dependencies> |
30 | </project> | 34 | </project> |
@@ -49,7 +49,9 @@ public class ProductController { | @@ -49,7 +49,9 @@ public class ProductController { | ||
49 | if (null == productId) { | 49 | if (null == productId) { |
50 | return new ApiResponse(500, "product_id Is Null", null); | 50 | return new ApiResponse(500, "product_id Is Null", null); |
51 | } | 51 | } |
52 | - LOG.info("queryProductDetailById method=ufo.product.data productId is:{},productId is:{}", productId); | 52 | + |
53 | + ProductDetailResp resp = productService.queryProductDetailById(productId); | ||
54 | + | ||
53 | return new ApiResponse.ApiResponseBuilder().data(mockProductDetail(productId)).code(200).message("product data").build(); | 55 | return new ApiResponse.ApiResponseBuilder().data(mockProductDetail(productId)).code(200).message("product data").build(); |
54 | } | 56 | } |
55 | 57 |
@@ -4,9 +4,9 @@ import com.alibaba.fastjson.annotation.JSONField; | @@ -4,9 +4,9 @@ import com.alibaba.fastjson.annotation.JSONField; | ||
4 | 4 | ||
5 | import java.util.List; | 5 | import java.util.List; |
6 | 6 | ||
7 | -public class Goods { | 7 | +public class GoodsBO { |
8 | 8 | ||
9 | - @JSONField(name="goods_id") | 9 | + @JSONField(name = "goods_id") |
10 | private Integer id; | 10 | private Integer id; |
11 | 11 | ||
12 | @JSONField(name = "goods_name") | 12 | @JSONField(name = "goods_name") |
@@ -15,13 +15,10 @@ public class Goods { | @@ -15,13 +15,10 @@ public class Goods { | ||
15 | @JSONField(name = "color_name") | 15 | @JSONField(name = "color_name") |
16 | private String colorName; | 16 | private String colorName; |
17 | 17 | ||
18 | - @JSONField(name="status") | ||
19 | - private Integer status; | ||
20 | - | ||
21 | @JSONField(name = "image_list") | 18 | @JSONField(name = "image_list") |
22 | - private List<GoodsImage> imageList; | 19 | + private List<GoodsImageBO> imageList; |
23 | 20 | ||
24 | - @JSONField(name="size_list") | 21 | + @JSONField(name = "size_list") |
25 | private List<GoodsSize> sizeList; | 22 | private List<GoodsSize> sizeList; |
26 | 23 | ||
27 | public Integer getId() { | 24 | public Integer getId() { |
@@ -48,11 +45,11 @@ public class Goods { | @@ -48,11 +45,11 @@ public class Goods { | ||
48 | this.colorName = colorName; | 45 | this.colorName = colorName; |
49 | } | 46 | } |
50 | 47 | ||
51 | - public List<GoodsImage> getImageList() { | 48 | + public List<GoodsImageBO> getImageList() { |
52 | return imageList; | 49 | return imageList; |
53 | } | 50 | } |
54 | 51 | ||
55 | - public void setImageList(List<GoodsImage> imageList) { | 52 | + public void setImageList(List<GoodsImageBO> imageList) { |
56 | this.imageList = imageList; | 53 | this.imageList = imageList; |
57 | } | 54 | } |
58 | 55 | ||
@@ -63,12 +60,4 @@ public class Goods { | @@ -63,12 +60,4 @@ public class Goods { | ||
63 | public void setSizeList(List<GoodsSize> sizeList) { | 60 | public void setSizeList(List<GoodsSize> sizeList) { |
64 | this.sizeList = sizeList; | 61 | this.sizeList = sizeList; |
65 | } | 62 | } |
66 | - | ||
67 | - public Integer getStatus() { | ||
68 | - return status; | ||
69 | - } | ||
70 | - | ||
71 | - public void setStatus(Integer status) { | ||
72 | - this.status = status; | ||
73 | - } | ||
74 | } | 63 | } |
@@ -8,11 +8,17 @@ import java.io.Serializable; | @@ -8,11 +8,17 @@ import java.io.Serializable; | ||
8 | * 商品图片信息VO | 8 | * 商品图片信息VO |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | -public class GoodsImage { | 11 | +public class GoodsImageBO { |
12 | 12 | ||
13 | @JSONField(name="image_url") | 13 | @JSONField(name="image_url") |
14 | private String imageUrl; | 14 | private String imageUrl; |
15 | 15 | ||
16 | + public static GoodsImageBO create(String imageUrl){ | ||
17 | + GoodsImageBO goodsImageBO = new GoodsImageBO(); | ||
18 | + goodsImageBO.setImageUrl(imageUrl); | ||
19 | + return goodsImageBO; | ||
20 | + } | ||
21 | + | ||
16 | public String getImageUrl() { | 22 | public String getImageUrl() { |
17 | return imageUrl; | 23 | return imageUrl; |
18 | } | 24 | } |
@@ -29,7 +29,7 @@ public class ProductInfo { | @@ -29,7 +29,7 @@ public class ProductInfo { | ||
29 | private BigDecimal leastPrice; | 29 | private BigDecimal leastPrice; |
30 | 30 | ||
31 | @JSONField(name="goods_list") | 31 | @JSONField(name="goods_list") |
32 | - private List<Goods> goodsList; | 32 | + private List<GoodsBO> goodsList; |
33 | 33 | ||
34 | public Integer getProductId() { | 34 | public Integer getProductId() { |
35 | return productId; | 35 | return productId; |
@@ -79,11 +79,11 @@ public class ProductInfo { | @@ -79,11 +79,11 @@ public class ProductInfo { | ||
79 | this.productCode = productCode; | 79 | this.productCode = productCode; |
80 | } | 80 | } |
81 | 81 | ||
82 | - public List<Goods> getGoodsList() { | 82 | + public List<GoodsBO> getGoodsList() { |
83 | return goodsList; | 83 | return goodsList; |
84 | } | 84 | } |
85 | 85 | ||
86 | - public void setGoodsList(List<Goods> goodsList) { | 86 | + public void setGoodsList(List<GoodsBO> goodsList) { |
87 | this.goodsList = goodsList; | 87 | this.goodsList = goodsList; |
88 | } | 88 | } |
89 | 89 |
1 | package com.yohoufo.product.service.impl; | 1 | package com.yohoufo.product.service.impl; |
2 | 2 | ||
3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
4 | +import java.util.ArrayList; | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.List; | ||
7 | +import java.util.Map; | ||
8 | +import java.util.function.Function; | ||
9 | +import java.util.stream.Collectors; | ||
4 | 10 | ||
5 | -import com.yohoufo.dal.product.StorageMapper; | ||
6 | -import com.yohoufo.dal.product.model.StorageGoodProductSize; | 11 | +import com.yoho.core.common.helpers.ImagesHelper; |
12 | +import com.yohoufo.dal.product.*; | ||
13 | +import com.yohoufo.dal.product.model.*; | ||
14 | +import com.yohoufo.product.model.GoodsImageBO; | ||
7 | import com.yohoufo.product.model.GoodsSize; | 15 | import com.yohoufo.product.model.GoodsSize; |
16 | +import com.yohoufo.product.model.GoodsBO; | ||
17 | +import com.yohoufo.product.model.ProductInfo; | ||
8 | import com.yohoufo.product.response.StorageDataResp; | 18 | import com.yohoufo.product.response.StorageDataResp; |
9 | import com.yohoufo.product.response.StorageLeastPriceResp; | 19 | import com.yohoufo.product.response.StorageLeastPriceResp; |
20 | +import org.apache.commons.lang3.StringUtils; | ||
10 | import org.slf4j.Logger; | 21 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 22 | import org.slf4j.LoggerFactory; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 23 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
14 | 25 | ||
15 | import com.yoho.error.exception.ServiceException; | 26 | import com.yoho.error.exception.ServiceException; |
16 | -import com.yohoufo.dal.product.ProductMapper; | ||
17 | -import com.yohoufo.dal.product.StoragePriceMapper; | ||
18 | -import com.yohoufo.dal.product.model.Product; | ||
19 | -import com.yohoufo.dal.product.model.StoragePrice; | ||
20 | import com.yohoufo.product.request.StoragePriceBo; | 27 | import com.yohoufo.product.request.StoragePriceBo; |
21 | import com.yohoufo.product.response.ProductDetailResp; | 28 | import com.yohoufo.product.response.ProductDetailResp; |
22 | import com.yohoufo.product.service.ProductService; | 29 | import com.yohoufo.product.service.ProductService; |
23 | - | 30 | +import com.yohoufo.resource.util.DateUtils; |
31 | +import org.springframework.util.CollectionUtils; | ||
24 | 32 | ||
25 | 33 | ||
26 | @Service | 34 | @Service |
@@ -37,11 +45,118 @@ public class ProductServiceImpl implements ProductService{ | @@ -37,11 +45,118 @@ public class ProductServiceImpl implements ProductService{ | ||
37 | @Autowired | 45 | @Autowired |
38 | private StorageMapper storageMapper; | 46 | private StorageMapper storageMapper; |
39 | 47 | ||
48 | + @Autowired | ||
49 | + private BrandMapper brandMapper; | ||
50 | + | ||
51 | + @Autowired | ||
52 | + private BrandSeriesMapper brandSeriesMapper; | ||
53 | + | ||
54 | + @Autowired | ||
55 | + private GoodsMapper goodsMapper; | ||
56 | + | ||
57 | + @Autowired | ||
58 | + private GoodsImagesMapper goodsImagesMapper; | ||
59 | + | ||
60 | + @Autowired | ||
61 | + private SizeMapper sizeMapper; | ||
62 | + | ||
40 | @Override | 63 | @Override |
41 | public ProductDetailResp queryProductDetailById(Integer productId) { | 64 | public ProductDetailResp queryProductDetailById(Integer productId) { |
42 | - return null; | 65 | + |
66 | + ProductDetailResp productDetailResp = new ProductDetailResp(); | ||
67 | + | ||
68 | + Product product = productMapper.selectByPrimaryKey(productId); | ||
69 | + if (product != null) { | ||
70 | + ProductInfo productInfo = new ProductInfo(); | ||
71 | + productInfo.setProductId(product.getId()); | ||
72 | + productInfo.setProductName(product.getProductName()); | ||
73 | + productInfo.setProductCode(product.getProductCode()); | ||
74 | + productInfo.setSaleTime(DateUtils.getDateString(product.getSaleTime())); | ||
75 | + | ||
76 | + if (product.getBrandId() != null) { | ||
77 | + Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId()); | ||
78 | + if (brand != null) { | ||
79 | + productInfo.setBrandName(brand.getBrandName()); | ||
80 | + } | ||
81 | + } | ||
82 | + if (product.getSeriesId() != null) { | ||
83 | + BrandSeries series = brandSeriesMapper.selectByPrimaryKey(product.getSeriesId()); | ||
84 | + if (series != null) { | ||
85 | + productInfo.setSeriesName(series.getSeriesName()); | ||
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | + List<Goods> goodsList = goodsMapper.selectByProductId(productId); | ||
90 | + if (!CollectionUtils.isEmpty(goodsList) && goodsList.get(0) != null) { | ||
91 | + Goods goods = goodsList.get(0); | ||
92 | + | ||
93 | + List<GoodsBO> goodsBOs = new ArrayList<>(); | ||
94 | + GoodsBO goodsBO = new GoodsBO(); | ||
95 | + goodsBO.setId(goods.getId()); | ||
96 | + goodsBO.setColorName(goods.getColorName()); | ||
97 | + goodsBO.setGoodsName(goods.getGoodsName()); | ||
98 | + List<GoodsImageBO> imageList = new ArrayList<>(); | ||
99 | + goodsBO.setImageList(imageList); | ||
100 | + List<GoodsSize> goodSizeList = new ArrayList<>(); | ||
101 | + goodsBO.setSizeList(goodSizeList); | ||
102 | + goodsBOs.add(goodsBO); | ||
103 | + | ||
104 | + List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goods.getId()); | ||
105 | + if (!CollectionUtils.isEmpty(goodsImages)) { | ||
106 | + List<String> imageUrlList = goodsImages.stream().map(GoodsImages::getImageUrl).filter(StringUtils::isBlank).map(this::buildImageFullUrl).collect(Collectors.toList()); | ||
107 | + imageUrlList.forEach(e -> imageList.add(GoodsImageBO.create(e))); | ||
108 | + } | ||
109 | + | ||
110 | + List<Storage> storageList = storageMapper.selectByGoodsId(goods.getId()); | ||
111 | + if (!CollectionUtils.isEmpty(storageList)) { | ||
112 | + Map<Integer, Size> sizeMap = new HashMap<>(); | ||
113 | + List<Integer> sizeIds = storageList.stream().map(Storage::getSizeId).filter(e -> e != null && 0 != e).collect(Collectors.toList()); | ||
114 | + if (!CollectionUtils.isEmpty(sizeIds)) { | ||
115 | + List<Size> sizes = sizeMapper.selectByIds(sizeIds); | ||
116 | + if (!CollectionUtils.isEmpty(sizes)) { | ||
117 | + sizeMap = sizes.stream().collect(Collectors.toMap(Size::getId, Function.identity())); | ||
118 | + } | ||
119 | + } | ||
120 | + | ||
121 | + Map<Integer, StoragePrice> storagePriceMap = new HashMap<>(); | ||
122 | + List<Integer> storageIds = storageList.stream().map(Storage::getId).collect(Collectors.toList()); | ||
123 | + List<StoragePrice> storagePrices = storagePriceMapper.selectByStorageIds(storageIds); | ||
124 | + if (!CollectionUtils.isEmpty(storagePrices)) { | ||
125 | + storagePriceMap = storagePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, Function.identity())); | ||
126 | + } | ||
127 | + | ||
128 | + for (Storage storage : storageList) { | ||
129 | + GoodsSize goodsSize = new GoodsSize(); | ||
130 | + goodsSize.setId(storage.getId()); | ||
131 | + goodsSize.setStorageNum(storage.getStorageNum()); | ||
132 | + goodsSize.setSizeId(storage.getSizeId()); | ||
133 | + Size size = sizeMap.get(storage.getSizeId()); | ||
134 | + goodsSize.setSizeName(size == null ? "" : size.getSizeName()); | ||
135 | + goodsSize.setOrderBy(size == null ? 0 : size.getOrderBy()); | ||
136 | + | ||
137 | + StoragePrice storagePrice = storagePriceMap.get(storage.getId()); | ||
138 | + goodsSize.setLeastPrice(storagePrice == null ? null : storagePrice.getPrice()); | ||
139 | + goodsSize.setStatus(storagePrice == null ? null : storagePrice.getStatus()); | ||
140 | + goodSizeList.add(goodsSize); | ||
141 | + } | ||
142 | + } | ||
143 | + } | ||
144 | + productDetailResp.setProduct_info(productInfo); | ||
145 | + } | ||
146 | + | ||
147 | + return productDetailResp; | ||
43 | } | 148 | } |
44 | 149 | ||
150 | + private String buildImageFullUrl(String url) { | ||
151 | + if (!StringUtils.startsWith(url, "http")){ | ||
152 | + return ImagesHelper.template2(url, ImagesHelper.SYS_BUCKET.get(ImagesHelper.SYS_GOODS_NAME)).replaceAll("extent\\/\\{width}x\\{height}\\/",""); | ||
153 | + }else{ | ||
154 | + return url; | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + | ||
159 | + | ||
45 | @Override | 160 | @Override |
46 | public StorageLeastPriceResp queryStorageLeastPrice(Integer storageId) { | 161 | public StorageLeastPriceResp queryStorageLeastPrice(Integer storageId) { |
47 | StoragePrice storagePrice = storagePriceMapper.selectLeastPrice(storageId); | 162 | StoragePrice storagePrice = storagePriceMapper.selectLeastPrice(storageId); |
@@ -57,21 +172,30 @@ public class ProductServiceImpl implements ProductService{ | @@ -57,21 +172,30 @@ public class ProductServiceImpl implements ProductService{ | ||
57 | 172 | ||
58 | @Override | 173 | @Override |
59 | public StorageDataResp queryStorageInfo(Integer storageId) { | 174 | public StorageDataResp queryStorageInfo(Integer storageId) { |
60 | - StorageGoodProductSize sgps = storageMapper.selectStroageProductInfo(storageId); | ||
61 | - if (sgps == null) { | 175 | + StorageDataResp resp = new StorageDataResp(); |
176 | + Storage storage = storageMapper.selectByPrimaryKey(storageId); | ||
177 | + if (storage == null) { | ||
62 | return null; | 178 | return null; |
63 | } | 179 | } |
64 | - StorageDataResp resp = new StorageDataResp(); | ||
65 | - resp.setProductId(sgps.getProductId()); | ||
66 | - resp.setProductName(sgps.getProductName()); | ||
67 | - resp.setColorId(sgps.getColorId() + ""); | ||
68 | - resp.setColorName(sgps.getColorName()); | ||
69 | - resp.setImageUrl(sgps.getColorImage()); | ||
70 | GoodsSize goodsSize = new GoodsSize(); | 180 | GoodsSize goodsSize = new GoodsSize(); |
71 | - goodsSize.setSizeId(sgps.getSizeId()); | ||
72 | - goodsSize.setSizeName(sgps.getSizeName()); | 181 | + goodsSize.setSizeId(storage.getSizeId()); |
182 | + Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId()); | ||
183 | + if (size != null) { | ||
184 | + goodsSize.setSizeName(size.getSizeName()); | ||
185 | + } | ||
73 | resp.setSize(goodsSize); | 186 | resp.setSize(goodsSize); |
187 | + Goods goods = goodsMapper.selectByPrimaryKey(storage.getGoodsId()); | ||
188 | + if (goods != null) { | ||
189 | + resp.setColorId(goods.getColorId().toString()); | ||
190 | + resp.setColorName(goods.getColorName()); | ||
191 | + resp.setImageUrl(goods.getColorImage()); | ||
74 | 192 | ||
193 | + Product product = productMapper.selectByPrimaryKey(goods.getProductId()); | ||
194 | + if (product != null) { | ||
195 | + resp.setProductId(product.getId()); | ||
196 | + resp.setProductName(product.getProductName()); | ||
197 | + } | ||
198 | + } | ||
75 | return resp; | 199 | return resp; |
76 | } | 200 | } |
77 | 201 |
@@ -15,7 +15,9 @@ public final class DateUtils { | @@ -15,7 +15,9 @@ public final class DateUtils { | ||
15 | private final static String DEFAULT_FOMARTPATTER="yyyy-MM-dd HH:mm:ss"; | 15 | private final static String DEFAULT_FOMARTPATTER="yyyy-MM-dd HH:mm:ss"; |
16 | 16 | ||
17 | public final static String DEFAULT_FOMART_DATE="yyyy-MM-dd"; | 17 | public final static String DEFAULT_FOMART_DATE="yyyy-MM-dd"; |
18 | - | 18 | + |
19 | + public final static String FOMART_DATE_DOT="yyyy.MM.dd"; | ||
20 | + | ||
19 | /** | 21 | /** |
20 | * 将数据库中的UNIX_Time(该时间是距离1970年的秒数,在转换过程中先要换算成毫秒)转换成UTC时间 | 22 | * 将数据库中的UNIX_Time(该时间是距离1970年的秒数,在转换过程中先要换算成毫秒)转换成UTC时间 |
21 | * @param time | 23 | * @param time |
@@ -19,7 +19,12 @@ datasources: | @@ -19,7 +19,12 @@ datasources: | ||
19 | - com.yohoufo.dal.product.StoragePriceMapper | 19 | - com.yohoufo.dal.product.StoragePriceMapper |
20 | - com.yohoufo.dal.product.StorageMapper | 20 | - com.yohoufo.dal.product.StorageMapper |
21 | - com.yohoufo.dal.product.ProductMapper | 21 | - com.yohoufo.dal.product.ProductMapper |
22 | - | 22 | + - com.yohoufo.dal.product.GoodsMapper |
23 | + - com.yohoufo.dal.product.GoodsImagesMapper | ||
24 | + - com.yohoufo.dal.product.SizeMapper | ||
25 | + - com.yohoufo.dal.product.BrandMapper | ||
26 | + - com.yohoufo.dal.product.BrandSeriesMapper | ||
27 | + | ||
23 | yh_inbox: | 28 | yh_inbox: |
24 | servers: | 29 | servers: |
25 | - 192.168.102.219:3306 | 30 | - 192.168.102.219:3306 |
@@ -19,6 +19,11 @@ datasources: | @@ -19,6 +19,11 @@ datasources: | ||
19 | - com.yohoufo.dal.product.StoragePriceMapper | 19 | - com.yohoufo.dal.product.StoragePriceMapper |
20 | - com.yohoufo.dal.product.StorageMapper | 20 | - com.yohoufo.dal.product.StorageMapper |
21 | - com.yohoufo.dal.product.ProductMapper | 21 | - com.yohoufo.dal.product.ProductMapper |
22 | + - com.yohoufo.dal.product.GoodsMapper | ||
23 | + - com.yohoufo.dal.product.GoodsImagesMapper | ||
24 | + - com.yohoufo.dal.product.SizeMapper | ||
25 | + - com.yohoufo.dal.product.BrandMapper | ||
26 | + - com.yohoufo.dal.product.BrandSeriesMapper | ||
22 | 27 | ||
23 | yh_inbox: | 28 | yh_inbox: |
24 | servers: | 29 | servers: |
-
Please register or login to post a comment