From 51c4161f68d849c1c04a33cc3bb7b01865a70d3e Mon Sep 17 00:00:00 2001 From: misworga831 Date: Thu, 24 Aug 2023 18:54:10 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E7=AE=80=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=89=AB=E7=A0=81=E7=99=BB=E5=BD=95=EF=BC=8C=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=A4=9A=E4=B8=AA=E7=BA=BF=E7=A8=8B=E6=B1=A0=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=80=A7=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/passport/MemberBuyerController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 8615bf34f..a04b60c9a 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; } From e9d9a95cb4f48b8ab39dae2553850ebded22fc2e Mon Sep 17 00:00:00 2001 From: misworga831 Date: Thu, 14 Sep 2023 17:04:30 +0800 Subject: [PATCH 02/13] =?UTF-8?q?improve:=20=E4=BC=98=E5=8C=96=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8A=95=E8=AF=89=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vo/OrderComplaintSearchParams.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 7b676630e..9a5982add 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); From 061d924d463f37d05c624f554bed3ccf43702a90 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 18 Sep 2023 10:00:44 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=BC=83?= =?UTF-8?q?=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/aftersale/entity/enums/ComplaintStatusEnum.java | 8 -------- .../order/serviceimpl/OrderComplaintServiceImpl.java | 6 ------ 2 files changed, 14 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/enums/ComplaintStatusEnum.java b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/enums/ComplaintStatusEnum.java index 67d173bfd..ecdb5abe3 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/enums/ComplaintStatusEnum.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/enums/ComplaintStatusEnum.java @@ -16,14 +16,6 @@ public enum ComplaintStatusEnum { * 已撤销 */ CANCEL("已撤销"), - /** - * 待申诉 - */ - WAIT_APPEAL("待申诉"), - /** - * 对话中 - */ - COMMUNICATION("对话中"), /** * 等待仲裁 */ 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 bc5ebcaf9..469f61e5a 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 Date: Mon, 18 Sep 2023 16:50:46 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E4=BF=83?= =?UTF-8?q?=E9=94=80=E6=B4=BB=E5=8A=A8=EF=BC=8C=E6=B4=BB=E5=8A=A8=E8=B5=B7?= =?UTF-8?q?=E5=A7=8B=E6=97=B6=E9=97=B4=E5=B0=8F=E4=BA=8E=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/promotion/tools/PromotionTools.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 6dc91f2fc..19f711b05 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 @@ -55,9 +55,9 @@ public class PromotionTools { DateTime now = DateUtil.date(); //如果活动起始时间小于现在时间 - if (now.after(startTime)) { - throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR); - } +// if (now.after(startTime)) { +// throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR); +// } //如果活动结束时间小于现在时间 if (endTime != null && now.after(endTime)) { throw new ServiceException(ResultCode.PROMOTION_END_TIME_ERROR); From 7db7afad4a0af758e0aa199e268f18a454e3f957 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Tue, 19 Sep 2023 17:09:14 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8D=95=E4=BD=8D=E4=B8=8D=E8=83=BD=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f3d99e241..b795f1606 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 = "商品描述") From 02dd37c87f4925dfea5911ef35a1bfe8bf79d4ad Mon Sep 17 00:00:00 2001 From: misworga831 Date: Tue, 19 Sep 2023 17:12:28 +0800 Subject: [PATCH 06/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8D=95=E4=BD=8D=E4=B8=8D=E8=83=BD=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/controller/goods/GoodsStoreController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9862fa33d..a4037c719 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(); } From bdd9045fc1ca73c82a35b337c52bcd6ee08c1777 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Wed, 27 Sep 2023 09:16:49 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E3=80=81=E5=94=AE=E5=90=8E=E5=8F=8A?= =?UTF-8?q?=E6=8B=BC=E5=9B=A2=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/entity/dto/CategorySearchParams.java | 15 +++++++++++++++ .../modules/goods/service/CategoryService.java | 4 +++- .../goods/serviceimpl/CategoryServiceImpl.java | 5 +++-- .../entity/vo/AfterSaleSearchParams.java | 5 +++++ .../promotion/serviceimpl/PintuanServiceImpl.java | 3 +++ .../modules/store/entity/dto/StoreSettingDTO.java | 3 --- .../goods/CategoryManagerController.java | 5 +++-- 7 files changed, 32 insertions(+), 8 deletions(-) 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 01921d86a..a6ce1656c 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/service/CategoryService.java b/framework/src/main/java/cn/lili/modules/goods/service/CategoryService.java index d356381e8..4031c1dde 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/serviceimpl/CategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java index a14d773d4..18c4b5749 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/order/aftersale/entity/vo/AfterSaleSearchParams.java b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java index 66e912310..05f351402 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java @@ -22,6 +22,11 @@ import java.util.Date; @Data public class AfterSaleSearchParams extends PageVO { + private static final long serialVersionUID = 28604026820923515L; + + @ApiModelProperty(value = "关键字") + private String keyword; + @ApiModelProperty(value = "售后服务单号") private String sn; 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 108931e95..2a3afc299 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/store/entity/dto/StoreSettingDTO.java b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreSettingDTO.java index dff11df5e..67f5cd1af 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreSettingDTO.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreSettingDTO.java @@ -3,8 +3,6 @@ package cn.lili.modules.store.entity.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import javax.validation.constraints.NotEmpty; - /** * 店铺设置 * @@ -29,7 +27,6 @@ public class StoreSettingDTO { @ApiModelProperty(value = "详细地址") private String storeAddressDetail; - @NotEmpty @ApiModelProperty(value = "经纬度") private String storeCenter; 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 8b9e6fb9d..daa8af5b4 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 From 7c64e1f11d274027f36dbddf9cbad3059097d712 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 16 Oct 2023 11:48:52 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=EF=BC=8C=E9=94=80?= =?UTF-8?q?=E9=87=8F=EF=BC=8C=E8=AF=84=E8=AE=BA=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/StockUpdateExecute.java | 7 +- .../lili/listener/GoodsMessageListener.java | 2 +- .../goods/entity/dto/GoodsSearchParams.java | 7 ++ .../goods/entity/dto/GoodsSkuStockDTO.java | 3 + .../modules/goods/mapper/GoodsSkuMapper.java | 3 + .../goods/service/GoodsSkuService.java | 19 +++- .../serviceimpl/GoodsSkuServiceImpl.java | 86 ++++++++++--------- 7 files changed, 81 insertions(+), 46 deletions(-) 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 6736cbe0d..023f8d147 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 8ed979cba..e90571213 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/GoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSearchParams.java index 7f10d1f70..27bb3bb98 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 694df3c97..97181f83d 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 e17f6d41a..90bc010ed 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/GoodsSkuService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java index f31247c88..3447cb4ec 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/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 1c9c134f1..17aa75460 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); @@ -618,7 +625,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i 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消息 @@ -667,22 +674,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 +691,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 * From b30909942a662905024a890ad3a03b8afabfa5db Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 16 Oct 2023 11:49:42 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96im=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../im/entity/dto/IMTalkQueryParams.java | 47 ++++++++++++ .../modules/im/entity/dto/ImQueryParams.java | 6 +- .../im/entity/dto/MessageQueryParams.java | 11 ++- .../modules/im/service/ImTalkService.java | 9 +-- .../im/serviceimpl/ImTalkServiceImpl.java | 71 ++++++++++--------- .../lili/controller/im/ImTalkController.java | 9 +-- 6 files changed, 108 insertions(+), 45 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/im/entity/dto/IMTalkQueryParams.java 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 000000000..6557c6b87 --- /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 8dc1f0fad..26fde23ca 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 372522c16..f97433024 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 b648a393f..122776fce 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 b5a4b17f3..a4ec61f8f 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/im-api/src/main/java/cn/lili/controller/im/ImTalkController.java b/im-api/src/main/java/cn/lili/controller/im/ImTalkController.java index eee31a4a7..9a6137f46 100644 --- a/im-api/src/main/java/cn/lili/controller/im/ImTalkController.java +++ b/im-api/src/main/java/cn/lili/controller/im/ImTalkController.java @@ -4,6 +4,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; 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.service.ImTalkService; import io.swagger.annotations.Api; @@ -58,14 +59,14 @@ public class ImTalkController { @GetMapping("/list") @ApiOperation(value = "分页获取用户聊天") - public ResultMessage> 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}") From fa696e6c1126a77f85ca556e904677187e3293e7 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 16 Oct 2023 16:40:20 +0800 Subject: [PATCH 10/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA,=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=AE=9E=E6=97=B6=E7=BB=9F=E8=AE=A1=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=80=BB=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/GoodsServiceImpl.java | 16 ++++++++-------- .../goods/serviceimpl/GoodsSkuServiceImpl.java | 9 ++++----- .../member/entity/dto/EvaluationQueryParams.java | 8 ++++++-- .../serviceimpl/MemberEvaluationServiceImpl.java | 16 +++++++--------- 4 files changed, 25 insertions(+), 24 deletions(-) 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 6029998aa..bab43739b 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 17aa75460..6ace49da8 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 @@ -612,14 +612,12 @@ 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); @@ -640,6 +638,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //修改商品的评价数量 goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); + clearCache(skuId); } /** 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 90cbbdf77..80e0cde34 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 2e137778a..b0127cb0a 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 Date: Mon, 16 Oct 2023 16:40:37 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=A5=BC?= =?UTF-8?q?=E5=B1=82=E8=A3=85=E4=BF=AE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/page/mapper/PageDataMapper.java | 2 +- .../page/serviceimpl/PageDataServiceImpl.java | 51 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/page/mapper/PageDataMapper.java b/framework/src/main/java/cn/lili/modules/page/mapper/PageDataMapper.java index e1c6956d5..7415142d6 100644 --- a/framework/src/main/java/cn/lili/modules/page/mapper/PageDataMapper.java +++ b/framework/src/main/java/cn/lili/modules/page/mapper/PageDataMapper.java @@ -34,7 +34,7 @@ public interface PageDataMapper extends BaseMapper { * @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 1f1027134..3767004da 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 From f9b3001eb3a1ba9e5f535c788b03420d0f16ec86 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 16 Oct 2023 18:34:21 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/aftersale/entity/vo/AfterSaleSearchParams.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java index 05f351402..369ce2f29 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/entity/vo/AfterSaleSearchParams.java @@ -25,7 +25,7 @@ public class AfterSaleSearchParams extends PageVO { private static final long serialVersionUID = 28604026820923515L; @ApiModelProperty(value = "关键字") - private String keyword; + private String keywords; @ApiModelProperty(value = "售后服务单号") private String sn; @@ -76,6 +76,10 @@ public class AfterSaleSearchParams extends PageVO { public 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); } From 8b61d40ff8ad81ea38d50d495b39b42bf244e8de Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 16 Oct 2023 18:34:55 +0800 Subject: [PATCH 13/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BC=98=E6=83=A0=E5=88=B8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=8F=8A=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/promotion/CouponBuyerController.java | 3 +++ .../entity/dto/search/BasePromotionsSearchParams.java | 6 +++++- .../modules/promotion/serviceimpl/SeckillServiceImpl.java | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) 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 e505cb586..885743745 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/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 0131aa3e3..ad45aba4f 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/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index c9c7fba50..c9cef67aa 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