diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index 8615bf34..a04b60c9 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -28,7 +28,6 @@ import org.springframework.web.context.request.async.DeferredResult; import javax.validation.constraints.NotNull; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -96,7 +95,7 @@ public class MemberBuyerController { deferredResult.setResult(new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK)); Thread.currentThread().interrupt(); } - }, Executors.newCachedThreadPool()); + }); return deferredResult; } diff --git a/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java index e505cb58..88574374 100644 --- a/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/promotion/CouponBuyerController.java @@ -64,6 +64,9 @@ public class CouponBuyerController { @GetMapping("/activity") @ApiOperation(value = "自动领取优惠券") public ResultMessage> activity() { + if (UserContext.getCurrentUser() == null) { + return ResultUtil.success(); + } return ResultUtil.data(couponActivityService.trigger( CouponActivityTrigger.builder() .couponActivityTypeEnum(CouponActivityTypeEnum.AUTO_COUPON) diff --git a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java index 6736cbe0..023f8d14 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -322,8 +322,6 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { for (int i = 0; i < skuStocks.size(); i++) { goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString())); } - //批量修改商品库存 - goodsSkuService.updateBatchById(goodsSkus); //促销库存处理 if (!promotionKey.isEmpty()) { @@ -336,7 +334,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { promotionGoodsService.updatePromotionGoodsStock(promotionGoods); } //商品库存,包含sku库存集合,批量更新商品库存相关 - goodsSkuService.updateGoodsStuck(goodsSkus); + goodsSkuService.updateGoodsStock(goodsSkus); log.info("订单确认,库存同步:商品信息--{};促销信息---{}", goodsSkus, promotionGoods); @@ -369,8 +367,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { } log.info("订单取消,库存还原:{}", goodsSkus); //批量修改商品库存 - goodsSkuService.updateBatchById(goodsSkus); - goodsSkuService.updateGoodsStuck(goodsSkus); + goodsSkuService.updateGoodsStock(goodsSkus); } } diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 8ed979cb..e9057121 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -492,7 +492,7 @@ public class GoodsMessageListener implements RocketMQListener { } int buyCount = goodsSku.getBuyCount() + goodsCompleteMessage.getBuyNum(); goodsSku.setBuyCount(buyCount); - goodsSkuService.update(goodsSku); + goodsSkuService.updateGoodsSkuBuyCount(goodsSku.getId(), buyCount); this.goodsIndexService.updateIndex(MapUtil.builder(new HashMap()).put("id", goodsCompleteMessage.getSkuId()).build(), MapUtil.builder(new HashMap()).put("buyCount", buyCount).build()); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/CategorySearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/CategorySearchParams.java index 01921d86..a6ce1656 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/CategorySearchParams.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/CategorySearchParams.java @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dto; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,4 +33,18 @@ public class CategorySearchParams { @ApiModelProperty(value = "父节点名称") private String parentTitle; + @ApiModelProperty(value = "是否禁用") + private Boolean deleteFlag; + + public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.like(name != null, "name", name); + queryWrapper.like(parentTitle != null, "parent_title", parentTitle); + queryWrapper.eq(parentId != null, "parent_id", parentId); + queryWrapper.eq(level != null, "level", level); + queryWrapper.eq(sortOrder != null, "sort_order", sortOrder); + queryWrapper.eq(commissionRate != null, "commission_rate", commissionRate); + queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag); + return queryWrapper; + } } diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index f3d99e24..b795f160 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -2,7 +2,6 @@ package cn.lili.modules.goods.entity.dto; import cn.lili.common.validation.EnumValue; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; -import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsTypeEnum; import io.swagger.annotations.ApiModelProperty; import lombok.*; @@ -96,7 +95,8 @@ public class GoodsOperationDTO implements Serializable { @ApiModelProperty(value = "是否有规格", hidden = true) private String haveSpec; - @ApiModelProperty(value = "销售模式", required = true) + @ApiModelProperty(value = "商品单位", required = true) + @NotEmpty(message = "商品单位不能为空") private String goodsUnit; @ApiModelProperty(value = "商品描述") 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 7f10d1f7..27bb3bb9 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 @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dto; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; @@ -9,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.*; import java.util.Arrays; +import java.util.List; /** * 商品查询条件 @@ -34,6 +36,9 @@ public class GoodsSearchParams extends PageVO { @ApiModelProperty(value = "商品编号") private String id; + @ApiModelProperty(value = "商品编号") + private List ids; + @ApiModelProperty(value = "商家ID") private String storeId; @@ -133,6 +138,8 @@ public class GoodsSearchParams extends PageVO { queryWrapper.eq("sales_model", salesModel); } + queryWrapper.in(CollUtil.isNotEmpty(ids), "id", ids); + queryWrapper.eq("delete_flag", false); this.betweenWrapper(queryWrapper); return queryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuStockDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuStockDTO.java index 694df3c9..97181f83 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuStockDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuStockDTO.java @@ -12,6 +12,9 @@ import lombok.Data; @Data public class GoodsSkuStockDTO { + @ApiModelProperty(value = "商品id") + private String goodsId; + @ApiModelProperty(value = "商品skuId") private String skuId; diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java index e17f6d41..90bc010e 100644 --- a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java @@ -2,6 +2,7 @@ package cn.lili.modules.goods.mapper; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; +import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -114,4 +115,6 @@ public interface GoodsSkuMapper extends BaseMapper { @Select("SELECT *,g.params as params FROM li_goods_sku gs inner join li_goods g on gs.goods_id = g.id ${ew.customSqlSegment}") IPage queryByParams(IPage page, @Param(Constants.WRAPPER) Wrapper queryWrapper); + @Select("SELECT id as sku_id, quantity, goods_id FROM li_goods_sku ${ew.customSqlSegment}") + List queryStocks(@Param(Constants.WRAPPER) Wrapper queryWrapper); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java index d356381e..4031c1dd 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java @@ -2,6 +2,7 @@ package cn.lili.modules.goods.service; import cn.lili.modules.goods.entity.dos.Category; +import cn.lili.modules.goods.entity.dto.CategorySearchParams; import cn.lili.modules.goods.entity.vos.CategoryVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -69,9 +70,10 @@ public interface CategoryService extends IService { * 查询所有的分类,父子关系 * 数据库获取 * + * @param categorySearchParams 查询参数 * @return 所有的分类,父子关系 */ - List listAllChildren(); + List listAllChildren(CategorySearchParams categorySearchParams); /** * 获取指定分类的分类名称 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 f31247c8..3447cb4e 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 @@ -209,7 +209,7 @@ public interface GoodsSkuService extends IService { * * @param goodsSkus */ - void updateGoodsStuck(List goodsSkus); + void updateGoodsStock(List goodsSkus); /** * 更新SKU评价数量 @@ -249,4 +249,21 @@ public interface GoodsSkuService extends IService { * @param goodsOperationDTO 商品操作信息 */ void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO); + + /** + * 更新商品sku购买数量 + * + * @param skuId skuId + * @param buyCount 购买数量 + */ + void updateGoodsSkuBuyCount(String skuId, int buyCount); + + /** + * 更新商品sku评分 + * + * @param skuId skuId + * @param grade 评分 + * @param commentNum 评论数量 + */ + void updateGoodsSkuGrade(String skuId, double grade,int commentNum); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index a14d773d..18c4b574 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.Category; +import cn.lili.modules.goods.entity.dto.CategorySearchParams; import cn.lili.modules.goods.entity.vos.CategoryVO; import cn.lili.modules.goods.mapper.CategoryMapper; import cn.lili.modules.goods.service.CategoryBrandService; @@ -165,10 +166,10 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override - public List listAllChildren() { + public List listAllChildren(CategorySearchParams categorySearchParams) { //获取全部分类 - List list = this.list(); + List list = this.list(categorySearchParams.queryWrapper()); //构造分类树 List categoryVOList = new ArrayList<>(); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 6029998a..bab43739 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -26,7 +26,7 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.mapper.GoodsMapper; import cn.lili.modules.goods.service.*; -import cn.lili.modules.member.entity.dos.MemberEvaluation; +import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.service.MemberEvaluationService; import cn.lili.modules.store.entity.dos.FreightTemplate; @@ -446,19 +446,19 @@ public class GoodsServiceImpl extends ServiceImpl implements //获取商品信息 Goods goods = this.getById(goodsId); - //修改商品评价数量 - goods.setCommentNum(goods.getCommentNum() + 1); - //修改商品好评率 - LambdaQueryWrapper goodEvaluationQueryWrapper = new LambdaQueryWrapper<>(); - goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId); - goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name()); + //修改商品评价数量 + long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).build()); + goods.setCommentNum((int) (commentNum)); + //好评数量 - long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper); + long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).grade(EvaluationGradeEnum.GOOD.name()).build()); //好评率 double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100); goods.setGrade(grade); this.updateById(goods); + + cache.remove(CachePrefix.GOODS.getPrefix() + goodsId); } /** 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 1c9c134f..6ace49da 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 @@ -3,7 +3,6 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; @@ -148,7 +147,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i if (!goodsSkus.isEmpty()) { this.saveOrUpdateBatch(goodsSkus); - this.updateStock(goodsSkus); + this.updateGoodsStock(goodsSkus); } } @@ -199,7 +198,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i skuList.stream().map(BaseEntity::getId).collect(Collectors.toList())); this.remove(unnecessarySkuIdsQuery); this.saveOrUpdateBatch(skuList); - this.updateStock(skuList); + this.updateGoodsStock(skuList); } } @@ -385,7 +384,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i List goodsSkus = this.getGoodsSkuListByGoodsId(goods.getId()); for (GoodsSku sku : goodsSkus) { cache.remove(GoodsSkuService.getCacheKeys(sku.getId())); - cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku); + if (GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) && GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { + cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku); + } } } } @@ -520,8 +521,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public void updateStocks(List goodsSkuStockDTOS) { - for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) { - this.updateStock(goodsSkuStockDTO.getSkuId(), goodsSkuStockDTO.getQuantity()); + List skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList()); + List goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper()); + Map> groupByGoodsIds = goodsSkuStockList.stream().collect(Collectors.groupingBy(GoodsSkuStockDTO::getGoodsId)); + + //统计每个商品的库存 + for (Map.Entry> entry : groupByGoodsIds.entrySet()) { + //库存 + Integer quantity = 0; + for (GoodsSkuStockDTO goodsSku : entry.getValue()) { + goodsSkuStockDTOS.stream().filter(i -> i.getSkuId().equals(goodsSku.getSkuId())).findFirst().ifPresent(i -> goodsSku.setQuantity(i.getQuantity())); + if (entry.getKey().equals(goodsSku.getGoodsId())) { + quantity += goodsSku.getQuantity(); + } + this.updateStock(goodsSku.getSkuId(), goodsSku.getQuantity()); + } + //保存商品库存结果 + goodsService.updateStock(entry.getKey(), quantity); } } @@ -531,28 +547,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl i GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId); if (goodsSku != null) { //判断商品sku是否已经下架(修改商品库存为0时 会自动下架商品),再次更新商品库存时 需更新商品索引 - Boolean isFlag = goodsSku.getQuantity()<= 0; + boolean isFlag = goodsSku.getQuantity() <= 0; goodsSku.setQuantity(quantity); - boolean update = - this.update(new LambdaUpdateWrapper().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity)); + boolean update = this.update(new LambdaUpdateWrapper().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity)); if (update) { cache.remove(CachePrefix.GOODS.getPrefix() + goodsSku.getGoodsId()); } cache.put(GoodsSkuService.getCacheKeys(skuId), goodsSku); cache.put(GoodsSkuService.getStockCacheKey(skuId), quantity); - //更新商品库存 - List goodsSkus = new ArrayList<>(); - goodsSkus.add(goodsSku); - this.updateGoodsStuck(goodsSkus); this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity); //商品库存为0是删除商品索引 if (quantity <= 0) { goodsIndexService.deleteIndexById(goodsSku.getId()); } //商品SKU库存为0并且商品sku状态为上架时更新商品库存 - if(isFlag && StrUtil.equals(goodsSku.getMarketEnable(),GoodsStatusEnum.UPPER.name())) { + if (isFlag && CharSequenceUtil.equals(goodsSku.getMarketEnable(), GoodsStatusEnum.UPPER.name())) { List goodsIds = new ArrayList<>(); goodsIds.add(goodsSku.getGoodsId()); applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds)); @@ -575,22 +586,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) - public void updateGoodsStuck(List goodsSkus) { - Map> groupByGoodsIds = - goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId)); - //获取相关的sku集合 - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(GoodsSku::getGoodsId, groupByGoodsIds.keySet()); - List goodsSkuList = this.list(lambdaQueryWrapper); + public void updateGoodsStock(List goodsSkus) { + Map> groupByGoodsIds = goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId)); //统计每个商品的库存 for (String goodsId : groupByGoodsIds.keySet()) { //库存 Integer quantity = 0; - for (GoodsSku goodsSku : goodsSkuList) { + for (GoodsSku goodsSku : goodsSkus) { if (goodsId.equals(goodsSku.getGoodsId())) { quantity += goodsSku.getQuantity(); } + this.updateStock(goodsSku.getId(), goodsSku.getQuantity()); } //保存商品库存结果 goodsService.updateStock(goodsId, quantity); @@ -605,20 +612,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取商品信息 GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); - EvaluationQueryParams queryParams = new EvaluationQueryParams(); - queryParams.setGrade(EvaluationGradeEnum.GOOD.name()); - queryParams.setSkuId(goodsSku.getId()); //好评数量 - long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams); + long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().grade(EvaluationGradeEnum.GOOD.name()).skuId(skuId).build()); //更新商品评价数量 - goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1); + long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().skuId(skuId).build()); + goodsSku.setCommentNum((int) commentNum); //好评率 double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100); goodsSku.setGrade(grade); //修改规格 - this.update(goodsSku); + this.updateGoodsSkuGrade(skuId, grade, goodsSku.getCommentNum()); //修改规格索引,发送mq消息 @@ -633,6 +638,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //修改商品的评价数量 goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); + clearCache(skuId); } /** @@ -667,22 +673,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return this.count(queryWrapper); } - /** - * 修改库存 - * - * @param goodsSkus 商品SKU - */ - private void updateStock(List goodsSkus) { - //总库存数量 - Integer quantity = 0; - for (GoodsSku sku : goodsSkus) { - this.updateStock(sku.getId(), sku.getQuantity()); - quantity += sku.getQuantity(); - } - //修改商品库存 - goodsService.updateStock(goodsSkus.get(0).getGoodsId(), quantity); - } - /** * 批量渲染商品sku @@ -700,6 +690,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } } + @Override + public void updateGoodsSkuBuyCount(String skuId, int buyCount) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(GoodsSku::getId, skuId); + updateWrapper.set(GoodsSku::getBuyCount, buyCount); + this.update(updateWrapper); + } + + @Override + public void updateGoodsSkuGrade(String skuId, double grade, int commentNum) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(GoodsSku::getId, skuId); + updateWrapper.set(GoodsSku::getGrade, grade); + updateWrapper.set(GoodsSku::getCommentNum, commentNum); + this.update(updateWrapper); + } + /** * 渲染商品sku * diff --git a/framework/src/main/java/cn/lili/modules/im/entity/dto/IMTalkQueryParams.java b/framework/src/main/java/cn/lili/modules/im/entity/dto/IMTalkQueryParams.java new file mode 100644 index 00000000..6557c6b8 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/im/entity/dto/IMTalkQueryParams.java @@ -0,0 +1,47 @@ +package cn.lili.modules.im.entity.dto; + +import cn.hutool.core.text.CharSequenceUtil; +import cn.lili.modules.im.entity.dos.ImTalk; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author paulG + * @since 2023/2/6 + **/ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class IMTalkQueryParams { + + @ApiModelProperty("用户1 id") + private String userId1; + + @ApiModelProperty("用户2 id") + private String userId2; + + @ApiModelProperty("用户1 name") + private String name1; + + @ApiModelProperty("用户2 name") + private String name2; + + @ApiModelProperty("关键字") + private String userName; + + + public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId1), "user_id1", this.userId1); + queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId2), "user_id2", this.userId2); + queryWrapper.eq(CharSequenceUtil.isNotEmpty(name1), "name1", this.name1); + queryWrapper.eq(CharSequenceUtil.isNotEmpty(name2), "name2", this.name2); + queryWrapper.nested(CharSequenceUtil.isNotEmpty(userName), i -> i.like("name1", userName).or().like("name2", userName)); + return queryWrapper; + } +} diff --git a/framework/src/main/java/cn/lili/modules/im/entity/dto/ImQueryParams.java b/framework/src/main/java/cn/lili/modules/im/entity/dto/ImQueryParams.java index 8dc1f0fa..26fde23c 100644 --- a/framework/src/main/java/cn/lili/modules/im/entity/dto/ImQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/im/entity/dto/ImQueryParams.java @@ -6,15 +6,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; /** * @author chc * @since 2022/6/2114:46 */ +@EqualsAndHashCode(callSuper = true) @Data @ApiModel public class ImQueryParams extends PageVO { + private static final long serialVersionUID = 5792718094087541134L; + @ApiModelProperty("用户Id") private String memberId; @@ -29,7 +33,7 @@ public class ImQueryParams extends PageVO { if (CharSequenceUtil.isNotEmpty(storeId)) { queryWrapper.eq("store_id", storeId); } - queryWrapper.eq("delete_flag",false); + queryWrapper.eq("delete_flag", false); queryWrapper.orderByDesc("create_time"); return queryWrapper; } diff --git a/framework/src/main/java/cn/lili/modules/im/entity/dto/MessageQueryParams.java b/framework/src/main/java/cn/lili/modules/im/entity/dto/MessageQueryParams.java index 372522c1..f9743302 100644 --- a/framework/src/main/java/cn/lili/modules/im/entity/dto/MessageQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/im/entity/dto/MessageQueryParams.java @@ -1,12 +1,13 @@ package cn.lili.modules.im.entity.dto; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.im.entity.dos.ImMessage; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.Data; +import lombok.EqualsAndHashCode; /** * MessageQueryParams @@ -15,8 +16,12 @@ import lombok.Data; * @version v1.0 * 2022-01-20 17:16 */ +@EqualsAndHashCode(callSuper = true) @Data public class MessageQueryParams extends PageVO { + + private static final long serialVersionUID = 3504156704697214077L; + /** * 聊天窗口 */ @@ -31,7 +36,7 @@ public class MessageQueryParams extends PageVO { private Integer num; public LambdaQueryWrapper initQueryWrapper() { - if (StringUtils.isEmpty(talkId)) { + if (CharSequenceUtil.isEmpty(talkId)) { throw new ServiceException(ResultCode.ERROR); } if (num == null || num > 50) { @@ -40,7 +45,7 @@ public class MessageQueryParams extends PageVO { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(ImMessage::getTalkId, talkId); - if (StringUtils.isNotEmpty(lastMessageId)) { + if (CharSequenceUtil.isNotEmpty(lastMessageId)) { lambdaQueryWrapper.lt(ImMessage::getId, lastMessageId); } lambdaQueryWrapper.orderByDesc(ImMessage::getCreateTime); diff --git a/framework/src/main/java/cn/lili/modules/im/service/ImTalkService.java b/framework/src/main/java/cn/lili/modules/im/service/ImTalkService.java index b648a393..122776fc 100644 --- a/framework/src/main/java/cn/lili/modules/im/service/ImTalkService.java +++ b/framework/src/main/java/cn/lili/modules/im/service/ImTalkService.java @@ -1,6 +1,7 @@ package cn.lili.modules.im.service; import cn.lili.modules.im.entity.dos.ImTalk; +import cn.lili.modules.im.entity.dto.IMTalkQueryParams; import cn.lili.modules.im.entity.vo.ImTalkVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -45,13 +46,13 @@ public interface ImTalkService extends IService { /** * 获取用户聊天列表 - * @return + * @return 用户聊天列表 */ - List getUserTalkList(); + List getUserTalkList(IMTalkQueryParams imTalkQueryParams); /** * 获取商家聊天列表 - * @return + * @return 商家聊天列表 */ - List getStoreTalkList(); + List getStoreTalkList(IMTalkQueryParams imTalkQueryParams); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/im/serviceimpl/ImTalkServiceImpl.java b/framework/src/main/java/cn/lili/modules/im/serviceimpl/ImTalkServiceImpl.java index b5a4b17f..a4ec61f8 100644 --- a/framework/src/main/java/cn/lili/modules/im/serviceimpl/ImTalkServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/im/serviceimpl/ImTalkServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.im.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.AuthUser; @@ -7,6 +8,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.modules.im.entity.dos.ImMessage; import cn.lili.modules.im.entity.dos.ImTalk; +import cn.lili.modules.im.entity.dto.IMTalkQueryParams; import cn.lili.modules.im.entity.vo.ImTalkVO; import cn.lili.modules.im.mapper.ImTalkMapper; import cn.lili.modules.im.service.ImMessageService; @@ -51,35 +53,35 @@ public class ImTalkServiceImpl extends ServiceImpl impleme //登录用户的Id String selfId = ""; //查看当前用户角色对Id进行赋值 - if(UserEnums.STORE.equals(currentUser.getRole())){ + if (UserEnums.STORE.equals(currentUser.getRole())) { selfId = currentUser.getStoreId(); - }else if(UserEnums.MEMBER.equals(currentUser.getRole())){ + } else if (UserEnums.MEMBER.equals(currentUser.getRole())) { selfId = currentUser.getId(); } //小数在前保证永远是同一个对话 String finalSelfId = selfId; - queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId)); + queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId)); ImTalk imTalk = this.getOne(queryWrapper); //如果没有聊天,则创建聊天 if (imTalk == null) { //当自己为店铺时 - if(UserEnums.STORE.equals(currentUser.getRole())){ + if (UserEnums.STORE.equals(currentUser.getRole())) { Store selfStore = storeService.getById(selfId); //没有这个用户信息 Member other = memberService.getById(userId); - if(other == null){ + if (other == null) { return null; } //自己为店铺其他人必定为用户 - imTalk = new ImTalk(other,selfStore); - }else if(UserEnums.MEMBER.equals(currentUser.getRole())){ + imTalk = new ImTalk(other, selfStore); + } else if (UserEnums.MEMBER.equals(currentUser.getRole())) { //没有这个店铺信息 Member self = memberService.getById(selfId); Member otherMember = memberService.getById(userId); Store otherStore = storeService.getById(userId); - if(otherStore != null){ + if (otherStore != null) { imTalk = new ImTalk(self, otherStore); - }else if (otherMember != null){ + } else if (otherMember != null) { imTalk = new ImTalk(self, otherMember); } } @@ -95,41 +97,41 @@ public class ImTalkServiceImpl extends ServiceImpl impleme //登录用户的Id String selfId = ""; //查看当前用户角色对Id进行赋值 - if(UserEnums.STORE.equals(currentUser.getRole())){ + if (UserEnums.STORE.equals(currentUser.getRole())) { selfId = currentUser.getStoreId(); - }else if(UserEnums.MEMBER.equals(currentUser.getRole())){ + } else if (UserEnums.MEMBER.equals(currentUser.getRole())) { selfId = currentUser.getId(); } //小数在前保证永远是同一个对话 String finalSelfId = selfId; - queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId)); + queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId)); ImTalk imTalk = this.getOne(queryWrapper); //如果没有聊天,则创建聊天 if (imTalk == null) { //当自己为店铺时 - if(UserEnums.STORE.equals(currentUser.getRole())){ + if (UserEnums.STORE.equals(currentUser.getRole())) { Store selfStore = storeService.getById(selfId); //没有这个用户信息 Member other = memberService.getById(userId); - if(other == null){ + if (other == null) { return null; } //自己为店铺其他人必定为用户 - imTalk = new ImTalk(other,selfStore); - }else if(UserEnums.MEMBER.equals(currentUser.getRole())){ + imTalk = new ImTalk(other, selfStore); + } else if (UserEnums.MEMBER.equals(currentUser.getRole())) { //没有这个店铺信息 Member self = memberService.getById(selfId); Member otherMember = memberService.getById(userId); Store otherStore = storeService.getById(userId); - if(otherStore != null){ + if (otherStore != null) { imTalk = new ImTalk(self, otherStore); - }else if (otherMember != null){ + } else if (otherMember != null) { imTalk = new ImTalk(self, otherMember); } } this.save(imTalk); } - return new ImTalkVO(imTalk,currentUser.getId()); + return new ImTalkVO(imTalk, currentUser.getId()); } /** @@ -173,13 +175,16 @@ public class ImTalkServiceImpl extends ServiceImpl impleme } @Override - public List getUserTalkList() { + public List getUserTalkList(IMTalkQueryParams imTalkQueryParams) { AuthUser authUser = UserContext.getCurrentUser(); - if(authUser == null){ + if (authUser == null) { throw new ServiceException(ResultCode.USER_NOT_LOGIN); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.and(wq-> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2,authUser.getId())); + queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2, authUser.getId())); + if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) { + queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getId()).like(ImTalk::getName2, imTalkQueryParams.getUserName())); + } queryWrapper.orderByDesc(ImTalk::getLastTalkTime); List imTalks = this.list(queryWrapper); List imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getId())).collect(Collectors.toList()); @@ -188,33 +193,33 @@ public class ImTalkServiceImpl extends ServiceImpl impleme } @Override - public List getStoreTalkList() { + public List getStoreTalkList(IMTalkQueryParams imTalkQueryParams) { AuthUser authUser = UserContext.getCurrentUser(); - if(authUser == null){ + if (authUser == null) { throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.and(wq->{ - wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2,authUser.getStoreId()); - }); + queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2, authUser.getStoreId())); + if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) { + queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getStoreId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getStoreId()).like(ImTalk::getName2, imTalkQueryParams.getUserName())); + } queryWrapper.orderByDesc(ImTalk::getLastTalkTime); List imTalks = this.list(queryWrapper); - List imTalkVOList = imTalks.stream().map(imTalk -> { - return new ImTalkVO(imTalk, authUser.getStoreId()); - }).collect(Collectors.toList()); + List imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getStoreId())).collect(Collectors.toList()); getUnread(imTalkVOList); return imTalkVOList; } /** * 获取未读消息数量 + * * @param imTalkVOList 消息列表 */ - private void getUnread(List imTalkVOList){ - if(!imTalkVOList.isEmpty()){ + private void getUnread(List imTalkVOList) { + if (!imTalkVOList.isEmpty()) { for (ImTalkVO imTalkVO : imTalkVOList) { - long count = imMessageService.count(new LambdaQueryWrapper().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId,imTalkVO.getId()).eq(ImMessage::getIsRead, false)); + long count = imMessageService.count(new LambdaQueryWrapper().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId, imTalkVO.getId()).eq(ImMessage::getIsRead, false)); imTalkVO.setUnread(count); } } diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java index 90cbbdf7..80e0cde3 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java @@ -4,8 +4,7 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.vo.PageVO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; +import lombok.*; /** * 评价查询条件 @@ -15,8 +14,13 @@ import lombok.EqualsAndHashCode; */ @EqualsAndHashCode(callSuper = true) @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class EvaluationQueryParams extends PageVO { + private static final long serialVersionUID = 2038158669175297129L; + @ApiModelProperty(value = "ID") private String id; diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java index 2e137778..b0127cb0 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberEvaluationServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; +import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; @@ -31,7 +32,6 @@ import cn.lili.modules.order.order.entity.enums.CommentStatusEnum; import cn.lili.modules.order.order.service.OrderItemService; import cn.lili.modules.order.order.service.OrderService; import cn.lili.mybatis.util.PageUtil; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -40,8 +40,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,17 +77,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl managerQuery(EvaluationQueryParams queryParams) { //获取评价分页 @@ -133,8 +131,8 @@ public class MemberEvaluationServiceImpl extends ServiceImpl QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); + if (CharSequenceUtil.isNotEmpty(keywords)) { + queryWrapper.and(wrapper -> wrapper.like("sn", keywords).or().like("order_sn", keywords).or().like("goods_name", keywords)); + } + if (CharSequenceUtil.isNotEmpty(sn)) { queryWrapper.like("sn", sn); } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderComplaintSearchParams.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderComplaintSearchParams.java index 7b676630..9a5982ad 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderComplaintSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderComplaintSearchParams.java @@ -1,6 +1,6 @@ package cn.lili.modules.order.order.entity.vo; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.order.aftersale.entity.enums.ComplaintStatusEnum; import cn.lili.modules.order.order.entity.dos.OrderComplaint; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -39,22 +39,22 @@ public class OrderComplaintSearchParams { public LambdaQueryWrapper lambdaQueryWrapper() { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - if (StrUtil.isNotEmpty(status)) { + if (CharSequenceUtil.isNotEmpty(status)) { queryWrapper.eq(OrderComplaint::getComplainStatus, status); } - if (StrUtil.isNotEmpty(orderSn)) { - queryWrapper.eq(OrderComplaint::getOrderSn, orderSn); + if (CharSequenceUtil.isNotEmpty(orderSn)) { + queryWrapper.like(OrderComplaint::getOrderSn, orderSn); } - if (StrUtil.isNotEmpty(storeName)) { + if (CharSequenceUtil.isNotEmpty(storeName)) { queryWrapper.like(OrderComplaint::getStoreName, storeName); } - if (StrUtil.isNotEmpty(storeId)) { + if (CharSequenceUtil.isNotEmpty(storeId)) { queryWrapper.eq(OrderComplaint::getStoreId, storeId); } - if (StrUtil.isNotEmpty(memberName)) { + if (CharSequenceUtil.isNotEmpty(memberName)) { queryWrapper.like(OrderComplaint::getMemberName, memberName); } - if (StrUtil.isNotEmpty(memberId)) { + if (CharSequenceUtil.isNotEmpty(memberId)) { queryWrapper.eq(OrderComplaint::getMemberId, memberId); } queryWrapper.eq(OrderComplaint::getDeleteFlag, false); diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java index bc5ebcaf..469f61e5 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java @@ -255,12 +255,6 @@ public class OrderComplaintServiceImpl extends ServiceImpl { * @return 页面数量 */ @Select("SELECT COUNT(id) FROM li_page_data ${ew.customSqlSegment}") - Integer getPageDataNum(@Param(Constants.WRAPPER) Wrapper queryWrapper); + Integer getPageDataNum(@Param(Constants.WRAPPER) Wrapper queryWrapper); /** * 获取页面数据分页 diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java index 1f102713..3767004d 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java @@ -6,6 +6,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.SystemSettingProperties; +import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.vo.PageVO; @@ -27,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Objects; + /** * 楼层装修管理业务层实现 * @@ -63,21 +66,17 @@ public class PageDataServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public PageData addPageData(PageData pageData) { - - + AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); //演示站点判定 - if (systemSettingProperties.getDemoSite()) { - //如果开启页面,并且是平台楼层装修 - if (pageData.getPageShow().equals(SwitchEnum.OPEN.name()) && pageData.getPageType().equals(PageEnum.INDEX.name())) { + if (Boolean.TRUE.equals(systemSettingProperties.getDemoSite()) && (pageData.getPageShow().equals(SwitchEnum.OPEN.name()) && pageData.getPageType().equals(PageEnum.INDEX.name()))) { pageData.setPageShow(SwitchEnum.CLOSE.name()); - } - } + } //如果页面为发布,则关闭其他页面,开启此页面 if (pageData.getPageShow().equals(SwitchEnum.OPEN.name())) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); - lambdaUpdateWrapper.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum + lambdaUpdateWrapper.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getNum , UserContext.getCurrentUser().getStoreId()); lambdaUpdateWrapper.eq(PageData::getPageType, pageData.getPageType()); lambdaUpdateWrapper.eq(PageData::getPageClientType, pageData.getPageClientType()); @@ -93,6 +92,7 @@ public class PageDataServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public PageData updatePageData(PageData pageData) { + AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); //如果页面为发布,则关闭其他页面,开启此页面 if (pageData.getPageShow() != null && pageData.getPageShow().equals(SwitchEnum.OPEN.name())) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); @@ -101,7 +101,7 @@ public class PageDataServiceImpl extends ServiceImpl i pageData.getPageClientType()); //如果是管理员,则判定页面num为null - if (UserContext.getCurrentUser().getRole().name().equals(UserEnums.MANAGER.name())) { + if (currentUser.getRole().name().equals(UserEnums.MANAGER.name())) { lambdaUpdateWrapper.isNull(PageData::getNum); } else { lambdaUpdateWrapper.eq(PageData::getNum, pageData.getNum()); @@ -127,12 +127,7 @@ public class PageDataServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public PageData releasePageData(String id) { - PageData pageData = this.getOne(new LambdaQueryWrapper() - .eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getPageType, - PageEnum.STORE.name()) - .eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum, - UserContext.getCurrentUser().getStoreId()) - .eq(PageData::getId, id)); + PageData pageData = this.getCurrentPageData(id); if (pageData == null) { throw new ServiceException(ResultCode.PAGE_NOT_EXIST); } @@ -164,12 +159,7 @@ public class PageDataServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public boolean removePageData(String id) { - PageData pageData = this.getOne(new LambdaQueryWrapper() - .eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getPageType, - PageEnum.STORE.name()) - .eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum, - UserContext.getCurrentUser().getStoreId()) - .eq(PageData::getId, id)); + PageData pageData = this.getCurrentPageData(id); if (pageData == null) { throw new ServiceException(ResultCode.PAGE_NOT_EXIST); } @@ -183,12 +173,12 @@ public class PageDataServiceImpl extends ServiceImpl i throw new ServiceException(ResultCode.PAGE_OPEN_DELETE_ERROR); } //判断是否有其他页面,如果没有其他的页面则无法进行删除 - QueryWrapper queryWrapper = Wrappers.query(); - queryWrapper.eq(pageData.getPageType() != null, "page_type", pageData.getPageType()); - queryWrapper.eq(pageData.getPageClientType() != null, "page_client_type", pageData.getPageClientType()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PageData::getPageType, pageData.getPageType()); + queryWrapper.eq(pageData.getPageClientType() != null, PageData::getPageClientType, pageData.getPageClientType()); //如果为店铺页面需要设置店铺ID if (pageData.getPageType().equals(PageEnum.STORE.name())) { - queryWrapper.eq(pageData.getNum() != null, "num", pageData.getNum()); + queryWrapper.eq(pageData.getNum() != null, PageData::getNum, pageData.getNum()); } //判断是否为唯一的页面 if (this.baseMapper.getPageDataNum(queryWrapper) == 1) { @@ -205,7 +195,7 @@ public class PageDataServiceImpl extends ServiceImpl i throw new ServiceException(ResultCode.PAGE_NOT_EXIST); } QueryWrapper queryWrapper = Wrappers.query(); - queryWrapper.eq(pageDataDTO.getPageType() != null, "page_type", pageDataDTO.getPageType()); + queryWrapper.eq("page_type", pageDataDTO.getPageType()); queryWrapper.eq(pageDataDTO.getNum() != null, "num", pageDataDTO.getNum()); queryWrapper.eq("page_show", SwitchEnum.OPEN.name()); @@ -229,4 +219,13 @@ public class PageDataServiceImpl extends ServiceImpl i public PageData getSpecial(String id) { return this.getById(id); } + + private PageData getCurrentPageData(String id) { + AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); + return this.getOne(new LambdaQueryWrapper() + .eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getPageType, PageEnum.STORE.name()) + .eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getNum, UserContext.getCurrentUser().getStoreId()) + .eq(PageData::getId, id), false); + + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java index 0131aa3e..ad45aba4 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java @@ -71,7 +71,11 @@ public class BasePromotionsSearchParams { queryWrapper.eq("scope_type", scopeType); } if (CharSequenceUtil.isNotEmpty(storeId)) { - queryWrapper.in("store_id", Arrays.asList(storeId.split(","))); + if ("store".equals(storeId)) { + queryWrapper.ne("store_id", PromotionTools.PLATFORM_ID); + } else { + queryWrapper.in("store_id", Arrays.asList(storeId.split(","))); + } } queryWrapper.eq("delete_flag", false); return queryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java index 108931e9..2a3afc29 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java @@ -213,6 +213,9 @@ public class PintuanServiceImpl extends AbstractPromotionsServiceImpl orders, PintuanShareVO pintuanShareVO, String skuId) { for (Order order : orders) { + if (pintuanShareVO.getPintuanMemberVOS().stream().anyMatch(i -> i.getMemberId().equals(order.getMemberId()))) { + continue; + } Member member = memberService.getById(order.getMemberId()); PintuanMemberVO memberVO = new PintuanMemberVO(member); if (CharSequenceUtil.isEmpty(order.getParentOrderSn())) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index c9c7fba5..c9cef67a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -245,6 +245,9 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl> getUserTalkList() { - return ResultUtil.data(imTalkService.getUserTalkList()); + public ResultMessage> getUserTalkList(IMTalkQueryParams imTalkQueryParams) { + return ResultUtil.data(imTalkService.getUserTalkList(imTalkQueryParams)); } @GetMapping("/store/list") @ApiOperation(value = "分页获取商家聊天") - public ResultMessage> getStoreTalkList() { - return ResultUtil.data(imTalkService.getStoreTalkList()); + public ResultMessage> getStoreTalkList(IMTalkQueryParams imTalkQueryParams) { + return ResultUtil.data(imTalkService.getStoreTalkList(imTalkQueryParams)); } @DeleteMapping(value = "/{id}") diff --git a/manager-api/src/main/java/cn/lili/controller/goods/CategoryManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/CategoryManagerController.java index 8b9e6fb9..daa8af5b 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/CategoryManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/CategoryManagerController.java @@ -6,6 +6,7 @@ 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.Category; +import cn.lili.modules.goods.entity.dto.CategorySearchParams; import cn.lili.modules.goods.entity.vos.CategoryVO; import cn.lili.modules.goods.service.CategoryService; import cn.lili.modules.goods.service.GoodsService; @@ -54,8 +55,8 @@ public class CategoryManagerController { @ApiOperation(value = "查询全部分类列表") @GetMapping(value = "/allChildren") - public ResultMessage> list() { - return ResultUtil.data(this.categoryService.listAllChildren()); + public ResultMessage> list(CategorySearchParams categorySearchParams) { + return ResultUtil.data(this.categoryService.listAllChildren(categorySearchParams)); } @PostMapping diff --git a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java index 9862fa33..a4037c71 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java @@ -117,7 +117,7 @@ public class GoodsStoreController { @ApiOperation(value = "修改商品") @PutMapping(value = "/update/{goodsId}", consumes = "application/json", produces = "application/json") - public ResultMessage update(@RequestBody GoodsOperationDTO goodsOperationDTO, @PathVariable String goodsId) { + public ResultMessage update(@Valid @RequestBody GoodsOperationDTO goodsOperationDTO, @PathVariable String goodsId) { goodsService.editGoods(goodsOperationDTO, goodsId); return ResultUtil.success(); }