Commit ebec5f245a67d3391847195135a165da9765dd56

Authored by dengwei
1 parent 722e35b6

feat 商品发圈信息

etrade-shop/src/main/java/com/diligrp/etrade/shop/constant/Constant.java
... ... @@ -79,4 +79,6 @@ public interface Constant {
79 79 * 库存配置百分比默认值
80 80 */
81 81 BigDecimal STOCK_CONFIG_JMSF_DEFAULT = BigDecimal.valueOf(100.00);
  82 +
  83 + Integer IMAGE_GLOBAL_TYPE_SHARE = 1;
82 84 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/dao/ProductImageMapper.java
... ... @@ -19,4 +19,8 @@ public interface ProductImageMapper extends MybatisMapperSupport {
19 19 int removeByProductIdFromPage(ProductImageDo entity);
20 20  
21 21 void removeByMarketIdAndCategoryId(Long marketId, Long categoryId);
  22 +
  23 + void globalInsertBatch(List<ProductImageDo> entities);
  24 +
  25 + void removeGlobalByProductId(ProductImageDo entity);
22 26 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/domain/request/ProductCo.java
... ... @@ -76,6 +76,12 @@ public class ProductCo implements Serializable {
76 76 private String remark;
77 77  
78 78 /**
  79 + * 分享文案
  80 + */
  81 + @Length(max = 250, message = "分享文案最多只能包含{max}个字符")
  82 + private String share;
  83 +
  84 + /**
79 85 * 操作人主键
80 86 */
81 87 @NotNull(message = "操作人主键不能为空")
... ... @@ -107,6 +113,12 @@ public class ProductCo implements Serializable {
107 113 @Valid
108 114 private List<ProductImageCo> images;
109 115  
  116 + /**
  117 + * 全局附件信息
  118 + */
  119 + @Valid
  120 + private List<ProductImageCo> imageGlobals;
  121 +
110 122 public Long getCategoryId() {
111 123 return categoryId;
112 124 }
... ... @@ -235,4 +247,20 @@ public class ProductCo implements Serializable {
235 247 public void setLabel(List<Integer> label) {
236 248 this.label = label;
237 249 }
  250 +
  251 + public String getShare() {
  252 + return share;
  253 + }
  254 +
  255 + public void setShare(String share) {
  256 + this.share = share;
  257 + }
  258 +
  259 + public List<ProductImageCo> getImageGlobals() {
  260 + return imageGlobals;
  261 + }
  262 +
  263 + public void setImageGlobals(List<ProductImageCo> imageGlobals) {
  264 + this.imageGlobals = imageGlobals;
  265 + }
238 266 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/domain/request/ProductUpdateCo.java
... ... @@ -59,6 +59,11 @@ public class ProductUpdateCo implements Serializable {
59 59 private String remark;
60 60  
61 61 /**
  62 + * 分享文案
  63 + */
  64 + private String share;
  65 +
  66 + /**
62 67 * 别名
63 68 */
64 69 @Length(max = 50, message = "商品码别名不能超过{max}")
... ... @@ -85,6 +90,12 @@ public class ProductUpdateCo implements Serializable {
85 90 @Valid
86 91 private List<ProductImageCo> images;
87 92  
  93 + /**
  94 + * 全局附件信息
  95 + */
  96 + @Valid
  97 + private List<ProductImageCo> imageGlobals;
  98 +
88 99 public Long getId() {
89 100 return id;
90 101 }
... ... @@ -188,4 +199,20 @@ public class ProductUpdateCo implements Serializable {
188 199 public void setNamePath(String namePath) {
189 200 this.namePath = namePath;
190 201 }
  202 +
  203 + public String getShare() {
  204 + return share;
  205 + }
  206 +
  207 + public void setShare(String share) {
  208 + this.share = share;
  209 + }
  210 +
  211 + public List<ProductImageCo> getImageGlobals() {
  212 + return imageGlobals;
  213 + }
  214 +
  215 + public void setImageGlobals(List<ProductImageCo> imageGlobals) {
  216 + this.imageGlobals = imageGlobals;
  217 + }
191 218 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/domain/response/ProductDetailVo.java
... ... @@ -101,6 +101,11 @@ public class ProductDetailVo implements Serializable {
101 101 private String remark;
102 102  
103 103 /**
  104 + * 分享文案
  105 + */
  106 + private String share;
  107 +
  108 + /**
104 109 * 操作人主键
105 110 */
106 111 private Long operaterId;
... ... @@ -130,6 +135,11 @@ public class ProductDetailVo implements Serializable {
130 135 */
131 136 private List<ProductImageVo> images;
132 137  
  138 + /**
  139 + * 商品全局图片信息 type=1分享
  140 + */
  141 + private List<ProductImageVo> imageGlobals;
  142 +
133 143 public Long getId() {
134 144 return id;
135 145 }
... ... @@ -313,4 +323,20 @@ public class ProductDetailVo implements Serializable {
313 323 public void setCategoryIdPath(String categoryIdPath) {
314 324 this.categoryIdPath = categoryIdPath;
315 325 }
  326 +
  327 + public String getShare() {
  328 + return share;
  329 + }
  330 +
  331 + public void setShare(String share) {
  332 + this.share = share;
  333 + }
  334 +
  335 + public List<ProductImageVo> getImageGlobals() {
  336 + return imageGlobals;
  337 + }
  338 +
  339 + public void setImageGlobals(List<ProductImageVo> imageGlobals) {
  340 + this.imageGlobals = imageGlobals;
  341 + }
316 342 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/domain/response/ProductImageVo.java
... ... @@ -17,6 +17,11 @@ public class ProductImageVo implements Serializable {
17 17 */
18 18 private String url;
19 19  
  20 + /**
  21 + * 类型
  22 + */
  23 + private Integer type;
  24 +
20 25 public Long getId() {
21 26 return id;
22 27 }
... ... @@ -32,4 +37,12 @@ public class ProductImageVo implements Serializable {
32 37 public void setUrl(String url) {
33 38 this.url = url;
34 39 }
  40 +
  41 + public Integer getType() {
  42 + return type;
  43 + }
  44 +
  45 + public void setType(Integer type) {
  46 + this.type = type;
  47 + }
35 48 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/model/ProductDo.java
... ... @@ -2,6 +2,7 @@ package com.diligrp.etrade.shop.model;
2 2  
3 3 import com.diligrp.etrade.admin.type.YesOrNoState;
4 4 import com.diligrp.etrade.core.type.YnType;
  5 +import com.diligrp.etrade.shop.domain.request.ProductImageCo;
5 6 import com.diligrp.etrade.shop.type.ProductSourceType;
6 7  
7 8 import java.util.List;
... ... @@ -83,6 +84,11 @@ public class ProductDo extends BaseHasUserDo {
83 84 private String remark;
84 85  
85 86 /**
  87 + * 共享文案
  88 + */
  89 + private String share;
  90 +
  91 + /**
86 92 * 操作人主键
87 93 */
88 94 private Long operaterId;
... ... @@ -103,6 +109,11 @@ public class ProductDo extends BaseHasUserDo {
103 109 private List<ProductImageDo> images;
104 110  
105 111 /**
  112 + * 全局附件信息
  113 + */
  114 + private List<ProductImageDo> imageGlobals;
  115 +
  116 + /**
106 117 * 允许重复
107 118 *
108 119 * @see YesOrNoState
... ... @@ -261,4 +272,20 @@ public class ProductDo extends BaseHasUserDo {
261 272 public void setLabel(List<Integer> label) {
262 273 this.label = label;
263 274 }
  275 +
  276 + public String getShare() {
  277 + return share;
  278 + }
  279 +
  280 + public void setShare(String share) {
  281 + this.share = share;
  282 + }
  283 +
  284 + public List<ProductImageDo> getImageGlobals() {
  285 + return imageGlobals;
  286 + }
  287 +
  288 + public void setImageGlobals(List<ProductImageDo> imageGlobals) {
  289 + this.imageGlobals = imageGlobals;
  290 + }
264 291 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/service/ProductImageService.java
... ... @@ -21,4 +21,8 @@ public interface ProductImageService {
21 21 Message<Integer> removeByProductIdFromPage(Long productId);
22 22  
23 23 void removeByMarketIdAndCategoryId(Long marketId,Long categoryId);
  24 +
  25 + void globalInsertBatch(List<ProductImageDo> imageGlobals);
  26 +
  27 + void removeGlobalByProductId(Long productId, Integer type);
24 28 }
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/service/impl/ProductImageServiceImpl.java
... ... @@ -5,6 +5,7 @@ import com.diligrp.etrade.shop.dao.ProductImageMapper;
5 5 import com.diligrp.etrade.shop.model.ProductImageDo;
6 6 import com.diligrp.etrade.shop.service.ProductImageService;
7 7 import jakarta.annotation.Resource;
  8 +import org.apache.commons.collections4.CollectionUtils;
8 9 import org.slf4j.Logger;
9 10 import org.slf4j.LoggerFactory;
10 11 import org.springframework.stereotype.Service;
... ... @@ -28,6 +29,14 @@ public class ProductImageServiceImpl implements ProductImageService {
28 29 return Message.success(mapper.insertBatch(entities));
29 30 }
30 31  
  32 + @Transactional
  33 + @Override
  34 + public void globalInsertBatch(List<ProductImageDo> imageGlobals) {
  35 + if (CollectionUtils.isEmpty(imageGlobals)) {
  36 + return;
  37 + }
  38 + mapper.globalInsertBatch(imageGlobals);
  39 + }
31 40  
32 41 @Transactional
33 42 @Override
... ... @@ -40,6 +49,15 @@ public class ProductImageServiceImpl implements ProductImageService {
40 49  
41 50 @Transactional
42 51 @Override
  52 + public void removeGlobalByProductId(Long productId, Integer type) {
  53 + ProductImageDo pi = new ProductImageDo();
  54 + pi.setProductId(productId);
  55 + pi.setType(type);
  56 + mapper.removeGlobalByProductId(pi);
  57 + }
  58 +
  59 + @Transactional
  60 + @Override
43 61 public Message<Integer> removeByProductIdFromPage(Long productId) {
44 62 logger.info("删除商品图片信息 from 页面:productId={}", productId);
45 63 ProductImageDo pi = new ProductImageDo();
... ...
etrade-shop/src/main/java/com/diligrp/etrade/shop/service/impl/ProductServiceImpl.java
... ... @@ -8,6 +8,7 @@ import com.diligrp.etrade.rpc.basicdata.CategoryRpc;
8 8 import com.diligrp.etrade.rpc.dto.response.CusCategoryDTO;
9 9 import com.diligrp.etrade.shared.service.OrderSharedService;
10 10 import com.diligrp.etrade.shop.config.PropertiesConfig;
  11 +import com.diligrp.etrade.shop.constant.Constant;
11 12 import com.diligrp.etrade.shop.dao.ProductMapper;
12 13 import com.diligrp.etrade.shop.domain.request.*;
13 14 import com.diligrp.etrade.shop.domain.response.*;
... ... @@ -115,6 +116,16 @@ public class ProductServiceImpl implements ProductService {
115 116 productImageService.insertBatch(entity.getImages());
116 117 }
117 118  
  119 + // 全局图片处理
  120 + productImageService.removeGlobalByProductId(entity.getId(), Constant.IMAGE_GLOBAL_TYPE_SHARE);
  121 + if (CollectionUtils.isNotEmpty(entity.getImageGlobals())) {
  122 + for (ProductImageDo image : entity.getImageGlobals()) {
  123 + image.setProductId(entity.getId());
  124 + image.setType(Constant.IMAGE_GLOBAL_TYPE_SHARE);
  125 + }
  126 + productImageService.globalInsertBatch(entity.getImageGlobals());
  127 + }
  128 +
118 129 productAuditService.reSubmit(entity.getId(), ProductAuditState.PASSED);
119 130 return Message.success();
120 131 }
... ... @@ -156,6 +167,14 @@ public class ProductServiceImpl implements ProductService {
156 167 }
157 168 productPresetService.insertBatch(entity.getPresets());
158 169 }
  170 +
  171 + if (CollectionUtils.isNotEmpty(entity.getImageGlobals())) {
  172 + for (ProductImageDo imageGlobal : entity.getImageGlobals()) {
  173 + imageGlobal.setType(Constant.IMAGE_GLOBAL_TYPE_SHARE);
  174 + imageGlobal.setProductId(entity.getId());
  175 + }
  176 + productImageService.globalInsertBatch(entity.getImageGlobals());
  177 + }
159 178 }
160 179 return ans;
161 180 }
... ...
etrade-shop/src/main/resources/com/diligrp/etrade/dao/mapper/ProductImageMapper.xml
... ... @@ -21,6 +21,21 @@
21 21 </foreach>
22 22 </insert>
23 23  
  24 + <insert id="globalInsertBatch">
  25 + INSERT INTO product_image_global (
  26 + product_id,
  27 + type,
  28 + url
  29 + ) VALUES
  30 + <foreach collection="entities" item="entity" separator=",">
  31 + (
  32 + #{entity.productId},
  33 + #{entity.type},
  34 + #{entity.url}
  35 + )
  36 + </foreach>
  37 + </insert>
  38 +
24 39  
25 40 <update id="removeByProductId">
26 41 UPDATE product_image SET deleted = 0,modifier_id = #{modifierId} WHERE product_id = #{productId} AND deleted = 1
... ... @@ -41,4 +56,11 @@
41 56 AND pi.deleted = 1
42 57 AND pi.deleted = 1
43 58 </update>
  59 +
  60 + <delete id="removeGlobalByProductId">
  61 + UPDATE product_image_global SET deleted = 0
  62 + WHERE product_id = #{productId}
  63 + AND type = #{type}
  64 + AND deleted = 1
  65 + </delete>
44 66 </mapper>
45 67 \ No newline at end of file
... ...
etrade-shop/src/main/resources/com/diligrp/etrade/dao/mapper/ProductMapper.xml
... ... @@ -58,6 +58,7 @@
58 58 <result column="p.label" property="label" typeHandler="com.diligrp.etrade.core.mybatis.JsonArrayTypeHandler"/>
59 59 <result column="p.source" property="source"/>
60 60 <result column="p.remark" property="remark"/>
  61 + <result column="p.share" property="share"/>
61 62 <result column="p.version" property="version"/>
62 63 <result column="p.operater_id" property="operaterId"/>
63 64 <result column="p.operater_name" property="operaterName"/>
... ... @@ -89,6 +90,12 @@
89 90 <id column="pi.id" property="id"/>
90 91 <result column="pi.url" property="url"/>
91 92 </collection>
  93 +
  94 + <collection property="imageGlobals" ofType="com.diligrp.etrade.shop.domain.response.ProductImageVo">
  95 + <id column="pig.id" property="id"/>
  96 + <result column="pig.url" property="url"/>
  97 + <result column="pig.type" property="type"/>
  98 + </collection>
92 99 </resultMap>
93 100  
94 101 <sql id="listWhere">
... ... @@ -133,6 +140,7 @@
133 140 shop_id,
134 141 source,
135 142 remark,
  143 + share,
136 144 operater_id,
137 145 operater_name)
138 146 VALUES (#{createrId},
... ... @@ -150,6 +158,7 @@
150 158 #{shopId},
151 159 #{source},
152 160 #{remark},
  161 + #{share},
153 162 #{operaterId},
154 163 #{operaterName})
155 164 </insert>
... ... @@ -185,6 +194,7 @@
185 194 label = #{label,typeHandler=com.diligrp.etrade.core.mybatis.JsonArrayTypeHandler},
186 195 </if>
187 196 remark = #{remark},
  197 + share = #{share},
188 198 operater_id = #{operaterId},
189 199 operater_name = #{operaterName},
190 200 version = version + 1
... ... @@ -525,6 +535,7 @@
525 535 , p.label AS "p.label"
526 536 , p.source AS "p.source"
527 537 , p.remark AS "p.remark"
  538 + , p.share AS "p.share"
528 539 , p.version AS "p.version"
529 540 , p.operater_id AS "p.operater_id"
530 541 , p.operater_name AS "p.operater_name"
... ... @@ -543,6 +554,9 @@
543 554 , pp.piece_weight AS "pp.piece_weight"
544 555 , pi.id AS "pi.id"
545 556 , pi.url AS "pi.url"
  557 + , pig.id AS "pig.id"
  558 + , pig.type AS "pig.type"
  559 + , pig.url AS "pig.url"
546 560 , s.id AS "s.id"
547 561 , s.name AS "s.name"
548 562 , s.customer_id AS "s.customer_id"
... ... @@ -550,6 +564,7 @@
550 564 FROM product p
551 565 LEFT JOIN product_preset pp ON pp.product_id = p.id AND pp.deleted = 1
552 566 LEFT JOIN product_image pi ON pi.product_id = p.id AND pi.deleted = 1
  567 + LEFT JOIN product_image_global pig ON pig.product_id = p.id AND pig.deleted = 1
553 568 LEFT JOIN product_audit pa ON pa.product_id = p.id AND pa.deleted = 1
554 569 LEFT JOIN shop s ON s.id = p.shop_id
555 570 LEFT JOIN stock st ON st.product_id = p.id
... ... @@ -570,6 +585,7 @@
570 585 , p.label AS "p.label"
571 586 , p.source AS "p.source"
572 587 , p.remark AS "p.remark"
  588 + , p.share AS "p.share"
573 589 , p.version AS "p.version"
574 590 , p.operater_id AS "p.operater_id"
575 591 , p.operater_name AS "p.operater_name"
... ... @@ -588,6 +604,9 @@
588 604 , pp.piece_weight AS "pp.piece_weight"
589 605 , pi.id AS "pi.id"
590 606 , pi.url AS "pi.url"
  607 + , pig.id AS "pig.id"
  608 + , pig.type AS "pig.type"
  609 + , pig.url AS "pig.url"
591 610 , s.id AS "s.id"
592 611 , s.name AS "s.name"
593 612 , s.customer_id AS "s.customer_id"
... ... @@ -596,6 +615,7 @@
596 615 LEFT JOIN product_preset pp ON pp.product_id = p.id AND pp.deleted = 0 AND pp.page_deleted = 1
597 616 LEFT JOIN product_image pi ON pi.product_id = p.id AND pi.deleted = 0 AND pi.page_deleted = 1
598 617 LEFT JOIN product_audit pa ON pa.product_id = p.id AND pa.deleted = 0 AND pa.page_deleted = 1
  618 + LEFT JOIN product_image_global pig ON pig.product_id = p.id AND pig.deleted = 1
599 619 LEFT JOIN shop s ON s.id = p.shop_id
600 620 LEFT JOIN stock st ON st.product_id = p.id
601 621 WHERE p.deleted = 0
... ...