From bd0f1f0b237c42b27aae7fd8709e430cf707e3e0 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Oct 2022 11:54:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=80=E8=BF=98?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E6=97=B6=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E9=80=80=E8=BF=98=E5=95=86=E5=AE=B6=E5=92=8C?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/event/impl/MemberCouponExecute.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberCouponExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberCouponExecute.java index d32c3fdb..8ab710c1 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberCouponExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberCouponExecute.java @@ -36,7 +36,8 @@ public class MemberCouponExecute implements OrderStatusChangeEvent { Order order = orderService.getBySn(orderMessage.getOrderSn()); if (CharSequenceUtil.isNotEmpty(order.getUseStoreMemberCouponIds())) { memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUseStoreMemberCouponIds().split(","))); - } else if (CharSequenceUtil.isNotEmpty(order.getUsePlatformMemberCouponId())) { + } + if (CharSequenceUtil.isNotEmpty(order.getUsePlatformMemberCouponId())) { memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUsePlatformMemberCouponId().split(","))); } } From 0ba493d71da8e161d422eda8268750ab69021f26 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Oct 2022 11:55:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=A0=87=E7=AD=BE=E6=8E=92=E5=BA=8F=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java index 6d5f9a0e..4d7f6801 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java @@ -58,6 +58,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl label.getParentId() != null && label.getParentId().equals(storeGoodsLabel.getId())) .forEach(storeGoodsLabelChild -> storeGoodsLabelVOChildList.add(new StoreGoodsLabelVO(storeGoodsLabelChild.getId(), storeGoodsLabelChild.getLabelName(), storeGoodsLabelChild.getLevel(), storeGoodsLabelChild.getSortOrder()))); + storeGoodsLabelVOChildList.sort(Comparator.comparing(StoreGoodsLabelVO::getSortOrder)); storeGoodsLabelVO.setChildren(storeGoodsLabelVOChildList); storeGoodsLabelVOList.add(storeGoodsLabelVO); }); From 6c87de7a97ef96cc0b3dc6f786a7a33b4ca58bf9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Oct 2022 11:56:16 +0800 Subject: [PATCH 3/5] =?UTF-8?q?pref:=20=E4=BC=98=E5=8C=96=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E6=97=A5=E5=BF=97=EF=BC=8C=E7=8A=B6=E6=80=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/aftersale/aop/AfterSaleLogPoint.java | 7 +++++++ .../order/aftersale/aop/AfterSaleOperationLogAspect.java | 5 +++++ .../order/aftersale/serviceimpl/AfterSaleServiceImpl.java | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleLogPoint.java b/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleLogPoint.java index 1e6c2965..5cbfde6a 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleLogPoint.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleLogPoint.java @@ -27,4 +27,11 @@ public @interface AfterSaleLogPoint { */ String sn(); + + /** + * + * @return 售后状态 + */ + String serviceStatus() default ""; + } diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleOperationLogAspect.java b/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleOperationLogAspect.java index 263c4006..660d76b2 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleOperationLogAspect.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/aop/AfterSaleOperationLogAspect.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.aftersale.aop; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; @@ -7,6 +8,7 @@ import cn.lili.common.utils.SpelUtil; import cn.lili.common.utils.ThreadPoolUtil; import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog; import cn.lili.modules.order.aftersale.service.AfterSaleLogService; +import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; @@ -67,6 +69,9 @@ public class AfterSaleOperationLogAspect { AfterSaleLogPoint afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLogPoint.class); String description = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.description()); String sn = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.sn()); + if (CharSequenceUtil.isNotEmpty(afterSaleLogPoint.serviceStatus())) { + description += AfterSaleStatusEnum.valueOf(SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.serviceStatus())).description(); + } result.put("description", description); result.put("sn", sn); return result; diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java index 768a6e94..22d9b33d 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java @@ -179,7 +179,7 @@ public class AfterSaleServiceImpl extends ServiceImpl Date: Thu, 13 Oct 2022 12:02:02 +0800 Subject: [PATCH 4/5] pref: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化商品草稿/商品模版,sku和批发规则保存规则。 BREAKING CHANGE: li_wholesale 表 增加 template_id(商品模版id)字段 --- DB/version4.2.4toMASTER.sql | 2 + .../modules/goods/entity/dos/DraftGoods.java | 2 +- .../lili/modules/goods/entity/dos/Goods.java | 25 +++++++ .../modules/goods/entity/dos/Wholesale.java | 2 + .../goods/entity/dto/DraftGoodsDTO.java | 6 ++ .../entity/dto/DraftGoodsSearchParams.java | 4 +- .../goods/entity/dto/GoodsOperationDTO.java | 8 +- .../goods/entity/dto/GoodsSearchParams.java | 6 +- .../goods/entity/dto/WholesaleDTO.java | 7 ++ .../goods/entity/vos/DraftGoodsVO.java | 7 ++ .../goods/service/GoodsSkuService.java | 8 ++ .../goods/service/WholesaleService.java | 5 ++ .../serviceimpl/DraftGoodsServiceImpl.java | 75 +++++-------------- .../serviceimpl/GoodsSkuServiceImpl.java | 9 ++- .../serviceimpl/WholesaleServiceImpl.java | 17 +++++ .../modules/goods/sku/GoodsSkuBuilder.java | 53 +++++-------- .../impl/WholesaleSaleModelRenderImpl.java | 4 +- 17 files changed, 137 insertions(+), 103 deletions(-) diff --git a/DB/version4.2.4toMASTER.sql b/DB/version4.2.4toMASTER.sql index c243f814..ace62c2d 100644 --- a/DB/version4.2.4toMASTER.sql +++ b/DB/version4.2.4toMASTER.sql @@ -44,3 +44,5 @@ CREATE TABLE `li_wholesale` PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '批发规则表'; +ALTER TABLE li_wholesale + ADD template_id bigint DEFAULT NULL COMMENT '商品模版id'; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java index da2dbed2..589d9dc8 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java @@ -111,7 +111,7 @@ public class DraftGoods extends BaseEntity { private String goodsVideo; @ApiModelProperty(value = "是否为推荐商品") - private boolean recommend; + private Boolean recommend; /** * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index e65af1cf..6f175250 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -6,6 +6,7 @@ import cn.hutool.http.HtmlUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; +import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; @@ -204,6 +205,30 @@ public class Goods extends BaseEntity { } } + public Goods(DraftGoodsDTO goodsDTO) { + this.goodsName = goodsDTO.getGoodsName(); + this.categoryPath = goodsDTO.getCategoryPath(); + this.storeCategoryPath = goodsDTO.getStoreCategoryPath(); + this.brandId = goodsDTO.getBrandId(); + this.templateId = goodsDTO.getTemplateId(); + this.recommend = goodsDTO.getRecommend(); + this.sellingPoint = goodsDTO.getSellingPoint(); + this.salesModel = goodsDTO.getSalesModel(); + this.goodsUnit = goodsDTO.getGoodsUnit(); + this.intro = goodsDTO.getIntro(); + this.mobileIntro = goodsDTO.getMobileIntro(); + this.goodsVideo = goodsDTO.getGoodsVideo(); + this.price = goodsDTO.getPrice(); + if (goodsDTO.getGoodsParamsDTOList() != null && goodsDTO.getGoodsParamsDTOList().isEmpty()) { + this.params = JSONUtil.toJsonStr(goodsDTO.getGoodsParamsDTOList()); + } + //如果立即上架则 + this.marketEnable = GoodsStatusEnum.DOWN.name(); + this.goodsType = goodsDTO.getGoodsType(); + this.grade = 100D; + + } + public String getIntro() { if (CharSequenceUtil.isNotEmpty(intro)) { return HtmlUtil.unescape(intro); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java index 1838d006..4bc804b3 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java @@ -23,6 +23,8 @@ public class Wholesale extends BaseIdEntity { private String goodsId; @ApiModelProperty(value = "SkuID") private String skuId; + @ApiModelProperty(value = "模版id") + private String templateId; @ApiModelProperty(value = "数量") private Integer num; @ApiModelProperty(value = "金额") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java index b1517e6b..0030cc4a 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsDTO.java @@ -30,4 +30,10 @@ public class DraftGoodsDTO extends DraftGoods { @Valid private List> skuList; + /** + * 批发商品规则 + */ + @ApiModelProperty(value = "批发商品规则") + private List wholesaleList; + } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsSearchParams.java index d22a583b..40ce2759 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/DraftGoodsSearchParams.java @@ -1,6 +1,6 @@ package cn.lili.modules.goods.entity.dto; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.goods.entity.enums.DraftGoodsSaveType; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; @@ -26,7 +26,7 @@ public class DraftGoodsSearchParams extends GoodsSearchParams { @Override public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = super.queryWrapper(); - if (StrUtil.isNotEmpty(saveType)) { + if (CharSequenceUtil.isNotEmpty(saveType)) { queryWrapper.eq("save_type", saveType); } return queryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index 6981372e..1f647e94 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -2,8 +2,7 @@ package cn.lili.modules.goods.entity.dto; import cn.lili.common.validation.EnumValue; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.ToString; +import lombok.*; import org.hibernate.validator.constraints.Length; import javax.validation.Valid; @@ -20,6 +19,9 @@ import java.util.Map; */ @Data @ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder public class GoodsOperationDTO implements Serializable { private static final long serialVersionUID = -509667581371776913L; @@ -116,6 +118,8 @@ public class GoodsOperationDTO implements Serializable { @Valid private List> skuList; + @ApiModelProperty(value = "是否为商品模版") + private Boolean goodsTemplateFlag = false; /** * 批发商品规则 */ diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java index 679c03d8..7f10d1f7 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java @@ -6,8 +6,7 @@ import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; +import lombok.*; import java.util.Arrays; @@ -19,6 +18,9 @@ import java.util.Arrays; */ @EqualsAndHashCode(callSuper = true) @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class GoodsSearchParams extends PageVO { private static final long serialVersionUID = 2544015852728566887L; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java index 31cbd0bb..988b81db 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java @@ -3,6 +3,8 @@ package cn.lili.modules.goods.entity.dto; import cn.lili.modules.goods.entity.dos.Wholesale; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springframework.beans.BeanUtils; /** * @author paulG @@ -10,7 +12,12 @@ import lombok.EqualsAndHashCode; **/ @Data @EqualsAndHashCode(callSuper = true) +@NoArgsConstructor public class WholesaleDTO extends Wholesale { + private static final long serialVersionUID = 853297561151783335L; + public WholesaleDTO(Wholesale wholesale) { + BeanUtils.copyProperties(wholesale, this); + } } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java index ad1a47ce..ecb45353 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/DraftGoodsVO.java @@ -1,6 +1,7 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.DraftGoods; +import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -29,4 +30,10 @@ public class DraftGoodsVO extends DraftGoods { @ApiModelProperty(value = "sku列表") private List skuList; + + /** + * 批发商品规则 + */ + @ApiModelProperty(value = "批发商品规则") + private List wholesaleList; } diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java index 2d52036d..f31247c8 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java @@ -241,4 +241,12 @@ public interface GoodsSkuService extends IService { * @return sku总数 */ Long countSkuNum(String storeId); + + /** + * 批量渲染商品sku + * + * @param goodsSkuList SKU基础数据列表 + * @param goodsOperationDTO 商品操作信息 + */ + void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java b/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java index 37346af0..b1a3164c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java @@ -14,8 +14,13 @@ public interface WholesaleService extends IService { List findByGoodsId(String goodsId); + List findByTemplateId(String templateId); + Boolean removeByGoodsId(String goodsId); + + Boolean removeByTemplateId(String templateId); + /** * 匹配批发规则 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index cb80a2e1..02072469 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -1,29 +1,27 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.convert.Convert; +import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; -import cn.lili.modules.goods.entity.dos.Category; -import cn.lili.modules.goods.entity.dos.DraftGoods; -import cn.lili.modules.goods.entity.dos.GoodsGallery; -import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.*; import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.vos.DraftGoodsVO; import cn.lili.modules.goods.mapper.DraftGoodsMapper; -import cn.lili.modules.goods.service.CategoryService; -import cn.lili.modules.goods.service.DraftGoodsService; -import cn.lili.modules.goods.service.GoodsGalleryService; -import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.*; +import cn.lili.modules.goods.sku.GoodsSkuBuilder; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** * 草稿商品业务层实现 @@ -49,6 +47,9 @@ public class DraftGoodsServiceImpl extends ServiceImpl goodsSkus = GoodsSkuBuilder.buildBatch(new Goods(draftGoods), draftGoods.getSkuList()); + goodsSkuService.renderGoodsSkuList(goodsSkus, GoodsOperationDTO.builder().goodsTemplateFlag(true).wholesaleList(draftGoods.getWholesaleList()).salesModel(draftGoods.getSalesModel()).build()); + draftGoods.setSkuListJson(JSONUtil.toJsonStr(goodsSkus)); draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList())); this.saveOrUpdate(draftGoods); } @@ -83,6 +87,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl list = JSONUtil.toList(jsonArray, GoodsSku.class); draftGoodsVO.setSkuList(goodsSkuService.getGoodsSkuVOList(list)); + List wholesaleList = wholesaleService.findByTemplateId(draftGoods.getId()); + if (CollUtil.isNotEmpty(wholesaleList)) { + draftGoodsVO.setWholesaleList(wholesaleList); + } return draftGoodsVO; } @@ -112,48 +121,4 @@ public class DraftGoodsServiceImpl extends ServiceImpl getGoodsSkuList(List> skuList) { - List skus = new ArrayList<>(); - for (Map skuVO : skuList) { - GoodsSku add = this.add(skuVO); - skus.add(add); - } - return skus; - } - - private GoodsSku add(Map map) { - Map specMap = new LinkedHashMap<>(); - GoodsSku sku = new GoodsSku(); - for (Map.Entry m : map.entrySet()) { - switch (m.getKey()) { - case "sn": - sku.setSn(m.getValue() != null ? m.getValue().toString() : ""); - break; - case "cost": - sku.setCost(Convert.toDouble(m.getValue())); - break; - case "price": - sku.setPrice(Convert.toDouble(m.getValue())); - break; - case "quantity": - sku.setQuantity(Convert.toInt(m.getValue())); - break; - case "weight": - sku.setWeight(Convert.toDouble(m.getValue())); - break; - default: - specMap.put(m.getKey(), m.getValue()); - break; - } - } - sku.setSpecs(JSONUtil.toJsonStr(specMap)); - return sku; - } - } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 2f5827a2..84236cda 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -132,7 +132,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU); } // 检查是否需要生成索引 - List goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO); + List goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO.getSkuList()); renderGoodsSkuList(goodsSkus, goodsOperationDTO); if (!goodsSkus.isEmpty()) { @@ -151,7 +151,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i List skuList; //删除旧的sku信息 if (Boolean.TRUE.equals(goodsOperationDTO.getRegeneratorSkuFlag())) { - skuList = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO); + skuList = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO.getSkuList()); renderGoodsSkuList(skuList, goodsOperationDTO); List goodsListByGoodsId = getGoodsListByGoodsId(goods.getId()); List oldSkuIds = new ArrayList<>(); @@ -170,7 +170,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } else { skuList = new ArrayList<>(); for (Map map : goodsOperationDTO.getSkuList()) { - GoodsSku sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); + GoodsSku sku = GoodsSkuBuilder.build(goods, map); renderGoodsSku(sku, goodsOperationDTO); skuList.add(sku); //如果商品状态值不对,则es索引移除 @@ -639,7 +639,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goodsSkuList sku集合 * @param goodsOperationDTO 商品操作DTO */ - void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO) { + @Override + public void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO) { // 商品销售模式渲染器 salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO)); for (GoodsSku goodsSku : goodsSkuList) { diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java index d8c2b98c..1fbc89bd 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java @@ -36,6 +36,23 @@ public class WholesaleServiceImpl extends ServiceImpl findByTemplateId(String templateId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Wholesale::getTemplateId, templateId); + return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList()); + } + + @Override + @CacheEvict(key = "#templateId+'_template'") + public Boolean removeByTemplateId(String templateId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Wholesale::getTemplateId, templateId); + cache.remove("{wholesale}_" + templateId + "_template"); + return this.remove(queryWrapper); + } + @Override @CacheEvict(key = "#goodsId") public Boolean removeByGoodsId(String goodsId) { diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java index 3af6d183..f7fb9771 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java @@ -6,7 +6,6 @@ import cn.hutool.core.lang.Assert; import cn.hutool.json.JSONUtil; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; -import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import org.springframework.stereotype.Component; import java.util.*; @@ -25,48 +24,42 @@ public class GoodsSkuBuilder { /** * 构建商品sku * - * @param goods 商品 - * @param skuInfo sku信息列表 - * @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空) + * @param goods 商品 + * @param skuInfo sku信息列表 * @return 商品sku */ - public static GoodsSku build(Goods goods, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { + public static GoodsSku build(Goods goods, Map skuInfo) { GoodsSku goodsSku = new GoodsSku(goods); - builderSingle(goodsSku, skuInfo, goodsOperationDTO); + builderSingle(goodsSku, skuInfo); return goodsSku; } /** * 批量构建商品sku * - * @param goods 商品 - * @param goodsOperationDTO 商品操作信息 + * @param goods 商品 * @return 商品sku */ - public static List buildBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) { - return builderBatch(goods, goodsOperationDTO); + public static List buildBatch(Goods goods, List> skuList) { + Assert.notEmpty(skuList, "skuList不能为空"); + Assert.notNull(goods, "goods不能为空"); + List goodsSkus = new ArrayList<>(); + for (Map skuInfo : skuList) { + GoodsSku goodsSku = new GoodsSku(goods); + builderSingle(goodsSku, skuInfo); + goodsSkus.add(goodsSku); + } + return goodsSkus; } - /** - * 从已有的商品sku中构建商品sku - * - * @param goodsSku 原商品sku - * @param skuInfo sku信息列表 - * @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空) - * @return 商品sku - */ - public static GoodsSku build(GoodsSku goodsSku, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { - builderSingle(goodsSku, skuInfo, goodsOperationDTO); - return goodsSku; - } - private static void builderSingle(GoodsSku goodsSku, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { + private static void builderSingle(GoodsSku goodsSku, Map skuInfo) { Assert.notNull(goodsSku, "goodsSku不能为空"); Assert.notEmpty(skuInfo, "skuInfo不能为空"); //规格简短信息 StringBuilder simpleSpecs = new StringBuilder(); //商品名称 - StringBuilder goodsName = new StringBuilder(goodsOperationDTO.getGoodsName()); + StringBuilder goodsName = new StringBuilder(goodsSku.getGoodsName()); //规格值 Map specMap = new LinkedHashMap<>(); @@ -100,17 +93,5 @@ public class GoodsSkuBuilder { goodsSku.setSimpleSpecs(simpleSpecs.toString()); } - private static List builderBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) { - Assert.notEmpty(goodsOperationDTO.getSkuList(), "goodsOperationDTO.getSkuList()不能为空"); - Assert.notNull(goods, "goods不能为空"); - List goodsSkus = new ArrayList<>(); - for (Map skuInfo : goodsOperationDTO.getSkuList()) { - GoodsSku goodsSku = new GoodsSku(goods); - builderSingle(goodsSku, skuInfo, goodsOperationDTO); - goodsSkus.add(goodsSku); - } - return goodsSkus; - } - } diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java index 93337ce0..55a95bb2 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java @@ -55,7 +55,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { skus.setPrice(collect.get(0).getPrice()); skus.setCost(collect.get(0).getPrice()); } - wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId()); + if (Boolean.FALSE.equals(goodsOperationDTO.getGoodsTemplateFlag())) { + wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId()); + } wholesaleService.saveOrUpdateBatch(collect); } From a76cc4693fafd96fd15a84e164b432c9aca63f37 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 13 Oct 2022 12:03:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=A7=92=E6=9D=80=E6=B4=BB=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=9C=89=E6=97=B6=E4=BC=9A=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/SeckillApplyServiceImpl.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 1b7b8f55..c34b7bba 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -74,20 +74,30 @@ public class SeckillApplyServiceImpl extends ServiceImpl getSeckillTimeline() { - //秒杀活动缓存key - return getSeckillTimelineInfo(); + try { + //秒杀活动缓存key + return getSeckillTimelineInfo(); + } catch (Exception e) { + log.error("获取秒杀时间轴失败", e); + return new ArrayList<>(); + } } @Override public List getSeckillGoods(Integer timeline) { - List seckillGoodsVoS = new ArrayList<>(); - //获取 - List seckillTimelineToCache = getSeckillTimelineInfo(); - Optional first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst(); - if (first.isPresent()) { - seckillGoodsVoS = first.get().getSeckillGoodsList(); + try { + List seckillGoodsVoS = new ArrayList<>(); + //获取 + List seckillTimelineToCache = getSeckillTimelineInfo(); + Optional first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst(); + if (first.isPresent()) { + seckillGoodsVoS = first.get().getSeckillGoodsList(); + } + return seckillGoodsVoS; + } catch (Exception e) { + log.error("获取秒杀商品失败", e); + return new ArrayList<>(); } - return seckillGoodsVoS; } @Override