From 348f362b3048fc8a0be14cbfd09488e87733d5ee Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 7 Mar 2022 14:43:17 +0800 Subject: [PATCH 001/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=97=B6=E6=89=A7=E8=A1=8C=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/impl/SkuPromotionRender.java | 2 +- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 1 - .../promotion/serviceimpl/PromotionGoodsServiceImpl.java | 2 -- .../modules/promotion/serviceimpl/PromotionServiceImpl.java | 2 -- .../modules/promotion/serviceimpl/SeckillServiceImpl.java | 5 ++++- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index 82f3cde9..765b9192 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -74,7 +74,7 @@ public class SkuPromotionRender implements CartRenderStep { renderBasePrice(tradeDTO); //渲染单品促销 renderSkuPromotion(tradeDTO); - + //检查促销库存 checkPromotionQuantity(tradeDTO); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 1e8367ce..ccf3e7d8 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -185,7 +185,6 @@ public class CartServiceImpl implements CartService { //购物车中不存在此商品,则新建立一个 CartSkuVO cartSkuVO = new CartSkuVO(dataSku, promotionMap); - this.checkSetGoodsQuantity(cartSkuVO, skuId, num); cartSkuVO.setCartType(cartTypeEnum); //检测购物车数据 checkCart(cartTypeEnum, cartSkuVO, skuId, num); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 21917405..cc2a993f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -232,8 +232,6 @@ public class PromotionGoodsServiceImpl extends ServiceImpl seckillApplyList = seckillApplyService.getSeckillApplyList(searchParams); if (seckillApplyList != null && !seckillApplyList.isEmpty()) { - SeckillApply seckillApply = seckillApplyList.get(0); String[] split = seckill.getHours().split(","); int[] hoursSored = Arrays.stream(split).mapToInt(Integer::parseInt).toArray(); Arrays.sort(hoursSored); @@ -158,7 +157,6 @@ public class PromotionServiceImpl implements PromotionService { seckill.setEndTime(promotionGoods.getEndTime()); promotionMap.put(esPromotionKey, seckill); } - } } \ No newline at end of file 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 4341caaf..b344e684 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 @@ -146,8 +146,11 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl Date: Mon, 7 Mar 2022 14:54:15 +0800 Subject: [PATCH 002/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=97=B6=E6=89=A7=E8=A1=8C=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/serviceimpl/SeckillApplyServiceImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 9e757376..0e774de5 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -276,12 +276,13 @@ public class SeckillApplyServiceImpl extends ServiceImpl promotionGoods = PromotionTools.promotionGoodsInit(promotionGoodsList, seckill, PromotionTypeEnum.SECKILL); result = promotionGoodsService.saveBatch(promotionGoods); this.seckillService.updateEsGoodsSeckill(seckill, list); + + LambdaQueryWrapper deleteWrapper = new LambdaQueryWrapper<>(); + deleteWrapper.eq(SeckillApply::getSeckillId, seckill.getId()); + deleteWrapper.notIn(SeckillApply::getSkuId, promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList())); + this.remove(deleteWrapper); } - LambdaQueryWrapper deleteWrapper = new LambdaQueryWrapper<>(); - deleteWrapper.eq(SeckillApply::getSeckillId, seckill.getId()); - deleteWrapper.notIn(SeckillApply::getSkuId, promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList())); - this.remove(deleteWrapper); seckillService.updateSeckillGoodsNum(seckill.getId()); return result; From ee5355668d0909c238387ad2dc77b8a7fd9048e0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 8 Mar 2022 11:57:48 +0800 Subject: [PATCH 003/185] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=87=AA=E5=8A=A8=E6=8F=92=E5=85=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86=EF=BC=8C=E7=AD=BE=E5=88=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AE=BF=E9=97=AE=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/controller/member/MemberSignBuyerController.java | 2 ++ .../cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java index 758f60cf..c645fd21 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.cache.limit.annotation.LimitPoint; import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; @@ -32,6 +33,7 @@ public class MemberSignBuyerController { @PreventDuplicateSubmissions @PostMapping @ApiOperation(value = "会员签到") + @LimitPoint(limit = 1) public ResultMessage memberSign() { return ResultUtil.data(memberSignService.memberSign()); } diff --git a/framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java b/framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java index 691daacc..5451c8e1 100644 --- a/framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java +++ b/framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java @@ -22,11 +22,15 @@ public class MyMetaObjectHandler implements MetaObjectHandler { AuthUser authUser = UserContext.getCurrentUser(); if (authUser != null) { this.setFieldValByName("createBy", authUser.getUsername(), metaObject); - }else{ + } else { this.setFieldValByName("createBy", "SYSTEM", metaObject); } - this.setFieldValByName("createTime", new Date(), metaObject); + //有创建时间字段,切字段值为空 + if (metaObject.hasGetter("createTime") + && metaObject.getValue("createTime") == null) { + this.setFieldValByName("createTime", new Date(), metaObject); + } //有值,则写入 if (metaObject.hasGetter("deleteFlag")) { this.setFieldValByName("deleteFlag", false, metaObject); From ac475ca4567fc2544d964eefa850508417263c30 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 8 Mar 2022 12:08:12 +0800 Subject: [PATCH 004/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=83=E9=94=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=9B=B4=E6=96=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 9eacac60..db1bc01c 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -636,6 +636,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { promotionMap = goodsIndex.getPromotionMap(); } + + log.info("ES修改商品活动索引-活动信息:{}", promotion); + log.info("ES修改商品活动索引-活动信息状态:{}", promotion.getPromotionStatus()); + log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex); + log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap); //如果活动已结束 if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {//如果存在活动 //删除活动 @@ -643,6 +648,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { promotionMap.put(key, promotion); } + log.info("ES修改商品活动索引-过滤后商品索引活动信息:{}", promotionMap); return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); } @@ -678,7 +684,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements if (responses.hasFailures()) { log.info("批量更新商品索引的促销信息中出现部分异常:{}", responses.buildFailureMessage()); } else { - log.info("批量更新商品索引的促销信息结果:{}", responses.status()); + log.info("批量更新商品索引的促销信息结果:{}", responses); } } catch (IOException e) { log.error("批量更新商品索引的促销信息出现异常!", e); From 72e7941230987ce682cf7e5f23b25be20f403e21 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Tue, 8 Mar 2022 14:19:22 +0800 Subject: [PATCH 005/185] =?UTF-8?q?'=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/token/ManagerTokenGenerate.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java index ab8d82f0..ec13d030 100644 --- a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java @@ -110,19 +110,24 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { * @param queryPermissions 查询权限 */ void initPermission(List superPermissions, List queryPermissions) { - //用户信息维护 - superPermissions.add("/manager/user/info*"); - superPermissions.add("/manager/user/edit*"); - superPermissions.add("/manager/user/editPassword*"); + //TODO 用户信息维护--操作权限 + //获取当前登录用户 + superPermissions.add("/manager/passport/user/info*"); + //修改用户资料 + superPermissions.add("/manager/passport/user/edit*"); + //修改密码 + superPermissions.add("/manager/passport/user/editPassword*"); + //退出 + superPermissions.add("/manager/passport/user/logout*"); //统计查看权限 queryPermissions.add("/manager/statistics*"); //菜单查看权限 - queryPermissions.add("/manager/menu*"); + queryPermissions.add("/manager/permission/menu*"); //商品分类查看权限 queryPermissions.add("/manager/goods/category*"); //查看地区接口 - queryPermissions.add("/manager/region*"); + queryPermissions.add("/manager/setting/region*"); } From c7154228146951069be1a387c5ba90cba1d4a146 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 8 Mar 2022 20:37:12 +0800 Subject: [PATCH 006/185] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=99=90=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/member/MemberSignBuyerController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java index c645fd21..32e93f2a 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java @@ -33,7 +33,7 @@ public class MemberSignBuyerController { @PreventDuplicateSubmissions @PostMapping @ApiOperation(value = "会员签到") - @LimitPoint(limit = 1) + @LimitPoint(limit = 2) public ResultMessage memberSign() { return ResultUtil.data(memberSignService.memberSign()); } From 9d0d318d665e48eac8534dcb615b52814c3ef529 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 9 Mar 2022 18:39:04 +0800 Subject: [PATCH 007/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0es?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=83=E9=94=80=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 17 ++++-- .../AbstractPromotionsServiceImpl.java | 4 +- .../serviceimpl/SeckillServiceImpl.java | 8 +-- .../search/service/EsGoodsIndexService.java | 12 +++- .../serviceimpl/EsGoodsIndexServiceImpl.java | 61 +++++++++++-------- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 8f9d2ed4..5cc77b32 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -144,11 +144,15 @@ public class GoodsMessageListener implements RocketMQListener { this.updateGoodsIndexPromotions(new String(messageExt.getBody())); break; case DELETE_GOODS_INDEX_PROMOTIONS: - BasePromotions promotions = JSONUtil.toBean(new String(messageExt.getBody()), BasePromotions.class); - if (CharSequenceUtil.isNotEmpty(promotions.getScopeId())) { - this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(Arrays.asList(promotions.getScopeId().split(",")), promotions.getId()); + JSONObject jsonObject = JSONUtil.parseObj(new String(messageExt.getBody())); + String promotionKey = jsonObject.getStr("promotionKey"); + if (CharSequenceUtil.isEmpty(promotionKey)) { + break; + } + if (CharSequenceUtil.isNotEmpty(jsonObject.getStr("scopeId"))) { + this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(Arrays.asList(jsonObject.getStr("scopeId").split(",")), promotionKey); } else { - this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(null, promotions.getId()); + this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(promotionKey); } break; case UPDATE_GOODS_INDEX: @@ -252,16 +256,17 @@ public class GoodsMessageListener implements RocketMQListener { searchParams.setPromotionId(promotions.getId()); List promotionGoodsList = this.promotionGoodsService.listFindAll(searchParams); List skuIds = promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList()); - this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId()); + this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(skuIds, esPromotionKey); this.goodsIndexService.updateEsGoodsIndexByList(promotionGoodsList, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(promotions.getScopeType())) { GoodsSearchParams searchParams = new GoodsSearchParams(); searchParams.setCategoryPath(promotions.getScopeId()); List goodsSkuByList = this.goodsSkuService.getGoodsSkuByList(searchParams); List skuIds = goodsSkuByList.stream().map(GoodsSku::getId).collect(Collectors.toList()); - this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId()); + this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(skuIds, esPromotionKey); this.goodsIndexService.updateEsGoodsIndexPromotions(skuIds, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) { + this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(esPromotionKey); this.goodsIndexService.updateEsGoodsIndexAllByList(promotions, esPromotionKey); } } catch (Exception e) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 1baa838a..c46eb258 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.promotion.serviceimpl; +import cn.hutool.core.map.MapBuilder; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; @@ -254,10 +255,11 @@ public abstract class AbstractPromotionsServiceImpl, T e @Override public void updateEsGoodsIndex(T promotions) { if (promotions.getStartTime() == null && promotions.getEndTime() == null) { + Map build = MapBuilder.create().put("promotionKey", this.getPromotionType() + "-" + promotions.getId()).put("scopeId", promotions.getScopeId()).build(); //删除商品促销消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(); //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(promotions), RocketmqSendCallbackBuilder.commonCallback()); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(build), RocketmqSendCallbackBuilder.commonCallback()); } else { String esPromotionKey = this.getPromotionType().name() + "-" + promotions.getId(); 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 b344e684..72b061a3 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 @@ -3,6 +3,7 @@ package cn.lili.modules.promotion.serviceimpl; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapBuilder; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.json.JSONUtil; @@ -14,7 +15,6 @@ import cn.lili.modules.promotion.entity.dos.Seckill; import cn.lili.modules.promotion.entity.dos.SeckillApply; import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsApplyStatusEnum; -import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.vos.SeckillVO; import cn.lili.modules.promotion.mapper.SeckillMapper; import cn.lili.modules.promotion.service.SeckillApplyService; @@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; +import java.util.Map; /** * 秒杀活动业务层实现 @@ -188,12 +189,11 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl skuIds) { - seckill.setScopeType(PromotionsScopeTypeEnum.PORTION_GOODS.name()); - seckill.setScopeId(ArrayUtil.join(skuIds.toArray(), ",")); + Map build = MapBuilder.create().put("promotionKey", this.getPromotionType() + "-" + seckill.getId()).put("scopeId", ArrayUtil.join(skuIds.toArray(), ",")).build(); //删除商品促销消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(); //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(seckill), RocketmqSendCallbackBuilder.commonCallback()); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(build), RocketmqSendCallbackBuilder.commonCallback()); } @Override diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index f40be6d4..ffe12d04 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -143,9 +143,17 @@ public interface EsGoodsIndexService { * 删除索引中指定的促销活动id的促销活动 * * @param skuIds 商品skuId - * @param promotionId 促销活动Id + * @param promotionsKey 促销活动Key */ - void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId); + void deleteEsGoodsPromotionByPromotionKey(List skuIds, String promotionsKey); + + + /** + * 删除索引中指定的促销活动id的促销活动 + * + * @param promotionsKey 促销活动Key + */ + void deleteEsGoodsPromotionByPromotionKey(String promotionsKey); /** * 清除所以商品索引的无效促销活动 diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index db1bc01c..d231f0df 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -389,9 +389,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void updateEsGoodsIndexPromotions(List ids, BasePromotions promotion, String key) { BulkRequest bulkRequest = new BulkRequest(); - log.info("修改商品活动索引"); + log.info("更新商品索引的促销信息----------"); log.info("商品ids: {}", ids); - log.info("活动关键字: {}", key); log.info("活动: {}", promotion); for (String id : ids) { UpdateRequest updateRequest = this.updateEsGoodsIndexPromotions(id, promotion, key); @@ -449,7 +448,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements goodsIndices = new ArrayList<>(IterableUtil.toCollection(all)); } List skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); - this.deleteEsGoodsPromotionByPromotionId(skuIds, promotion.getId()); this.updateEsGoodsIndexPromotions(skuIds, promotion, key); } @@ -475,47 +473,57 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } @Override - public void deleteEsGoodsPromotionByPromotionId(List skuIds, String promotionId) { + public void deleteEsGoodsPromotionByPromotionKey(List skuIds, String promotionsKey) { BulkRequest bulkRequest = new BulkRequest(); log.info("删除商品活动索引"); log.info("商品skuIds: {}", skuIds); - log.info("活动Id: {}", promotionId); - if (skuIds != null && !skuIds.isEmpty()) { - for (String skuId : skuIds) { - EsGoodsIndex goodsIndex = findById(skuId); - //商品索引不为空 - if (goodsIndex != null) { - UpdateRequest updateRequest = this.removePromotionByPromotionId(goodsIndex, promotionId); - if (updateRequest != null) { - bulkRequest.add(updateRequest); - } - } else { - log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); - } - } - } else { - for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { - UpdateRequest updateRequest = this.removePromotionByPromotionId(goodsIndex, promotionId); + log.info("活动Key: {}", promotionsKey); + if (skuIds == null || skuIds.isEmpty()) { + return; + } + for (String skuId : skuIds) { + EsGoodsIndex goodsIndex = findById(skuId); + //商品索引不为空 + if (goodsIndex != null) { + UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); if (updateRequest != null) { bulkRequest.add(updateRequest); } + } else { + log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); } } this.executeBulkUpdateRequest(bulkRequest); + } + /** + * 删除索引中指定的促销活动id的促销活动 + * + * @param promotionsKey 促销活动Key + */ + @Override + public void deleteEsGoodsPromotionByPromotionKey(String promotionsKey) { + BulkRequest bulkRequest = new BulkRequest(); + for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { + UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } + } + this.executeBulkUpdateRequest(bulkRequest); } /** * 从索引中删除指定促销活动id的促销活动 * * @param goodsIndex 索引 - * @param promotionId 促销活动id + * @param promotionsKey 促销活动key */ - private UpdateRequest removePromotionByPromotionId(EsGoodsIndex goodsIndex, String promotionId) { + private UpdateRequest removePromotionByPromotionKey(EsGoodsIndex goodsIndex, String promotionsKey) { Map promotionMap = goodsIndex.getPromotionMap(); if (promotionMap != null && !promotionMap.isEmpty()) { //如果存在同促销ID的活动删除 - List collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList()); + List collect = promotionMap.keySet().stream().filter(i -> i.equals(promotionsKey)).collect(Collectors.toList()); collect.forEach(promotionMap::remove); goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); @@ -662,7 +670,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements UpdateRequest updateRequest = new UpdateRequest(); updateRequest.index(getIndexName()); updateRequest.id(id); - updateRequest.retryOnConflict(5); +// updateRequest.retryOnConflict(5); +// updateRequest.version(promotionMap.size()); Map params = new HashMap<>(); params.put("promotionMap", JSONUtil.toJsonStr(promotionMap)); Script script = new Script(ScriptType.INLINE, "painless", "ctx._source.promotionMapJson=params.promotionMap;", params); @@ -684,7 +693,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements if (responses.hasFailures()) { log.info("批量更新商品索引的促销信息中出现部分异常:{}", responses.buildFailureMessage()); } else { - log.info("批量更新商品索引的促销信息结果:{}", responses); + log.info("批量更新商品索引的促销信息结果:{}", responses.status()); } } catch (IOException e) { log.error("批量更新商品索引的促销信息出现异常!", e); From 9ee76b532895486dd603db0164bfe5b3134386b4 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 10 Mar 2022 15:31:23 +0800 Subject: [PATCH 008/185] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=97=A0=E5=AE=9E=E9=99=85=E4=BD=9C=E7=94=A8=E7=9A=84=E9=99=90?= =?UTF-8?q?=E6=B5=81=E6=B3=A8=E8=A7=A3=20=E8=AE=A2=E5=8D=95=E4=B9=B0?= =?UTF-8?q?=E5=AE=B6=E7=AB=AF=E5=8F=AF=E4=BB=A5=E6=9F=A5=E8=AF=A2=E5=88=B0?= =?UTF-8?q?=E5=88=AB=E4=BA=BA=E7=9A=84=E8=AE=A2=E5=8D=95=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/member/MemberSignBuyerController.java | 1 - .../lili/modules/order/order/entity/dto/OrderSearchParams.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java index 32e93f2a..ea358e94 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberSignBuyerController.java @@ -33,7 +33,6 @@ public class MemberSignBuyerController { @PreventDuplicateSubmissions @PostMapping @ApiOperation(value = "会员签到") - @LimitPoint(limit = 2) public ResultMessage memberSign() { return ResultUtil.data(memberSignService.memberSign()); } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java index d9b25dab..0bae3935 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java @@ -121,7 +121,7 @@ public class OrderSearchParams extends PageVO { //关键字查询 if (CharSequenceUtil.isNotEmpty(keywords)) { - wrapper.like("o.sn", keywords).or().like("oi.goods_name", keywords); + wrapper.and(keyWrapper -> keyWrapper.like("o.sn", keywords).or().like("oi.goods_name", keywords)); } if (currentUser != null) { //按卖家查询 From 1625f7ca763668c859188443b097a0c4d176d59c Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 10 Mar 2022 15:52:12 +0800 Subject: [PATCH 009/185] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=AD=97=E6=AE=B5=E8=AF=BB=E5=8F=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetask/handler/impl/order/OrderEveryDayTaskExecute.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java index f0b8a077..ade5ea90 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/order/OrderEveryDayTaskExecute.java @@ -160,7 +160,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute { private void closeAfterSale(OrderSetting orderSetting) { //订单关闭售后申请时间 = 当前时间 - 自动关闭售后申请天数 - DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getAutoEvaluation()); + DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseAfterSale()); //关闭售后订单=未售后订单+小于订单关闭售后申请时间 QueryWrapper queryWrapper = new QueryWrapper(); From b7d418b5b74bc46d5c7f68b962e3834a17c1a5d2 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 14 Mar 2022 10:44:06 +0800 Subject: [PATCH 010/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=A0=B8=E9=94=80=E6=A0=A1=E9=AA=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/order/order/entity/dos/Order.java | 2 +- .../modules/order/order/serviceimpl/OrderServiceImpl.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java index 816cd62d..64e2ddaa 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java @@ -181,7 +181,7 @@ public class Order extends BaseEntity { @ApiModelProperty(value = "订单促销类型") private String orderPromotionType; - @ApiModelProperty(value = "价格详情") + @ApiModelProperty(value = "价格价格详情") private String priceDetail; @ApiModelProperty(value = "订单是否支持原路退回") diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 9abdbff3..24fbc9f8 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -944,15 +944,15 @@ public class OrderServiceImpl extends ServiceImpl implements throw new ServiceException(ResultCode.ORDER_NOT_EXIST); } //判断是否为虚拟订单 - else if (!order.getOrderType().equals(OrderTypeEnum.VIRTUAL.name())) { + if (!order.getOrderType().equals(OrderTypeEnum.VIRTUAL.name())) { throw new ServiceException(ResultCode.ORDER_TAKE_ERROR); } //判断虚拟订单状态 - else if (!order.getOrderStatus().equals(OrderStatusEnum.TAKE.name())) { + if (!order.getOrderStatus().equals(OrderStatusEnum.TAKE.name())) { throw new ServiceException(ResultCode.ORDER_TAKE_ERROR); } //判断验证码是否正确 - else if (!verificationCode.equals(order.getVerificationCode())) { + if (!verificationCode.equals(order.getVerificationCode())) { throw new ServiceException(ResultCode.ORDER_TAKE_ERROR); } } From 203a30a236617083c99517e694fb08994f5fad4d Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 14 Mar 2022 15:50:55 +0800 Subject: [PATCH 011/185] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/MemberEvaluationServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 393a2339..1a56ed86 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 @@ -113,13 +113,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl Date: Tue, 15 Mar 2022 17:16:24 +0800 Subject: [PATCH 012/185] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=B0=83=E7=94=A8=E6=97=B6=EF=BC=8C=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=EF=BC=8C=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=AD=A4=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/wechat/serviceimpl/WechatMessageServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java index 9c57334c..86f9b0fa 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java @@ -91,7 +91,7 @@ public class WechatMessageServiceImpl extends ServiceImpl { Map params = new HashMap<>(1); params.put("template_id", templateId); - String message = WechatMessageUtil.wechatHandler(HttpUtil.post(delMsgTpl + accessToken, params)); + String message = WechatMessageUtil.wechatHandler(HttpUtils.doPostWithJson(delMsgTpl + accessToken, params)); log.info("删除模版请求:{},删除模版响应:{}", params, message); }); } From 36ce7593a9e32dc691667ff7abc50b27ab54987b Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 18 Mar 2022 17:41:05 +0800 Subject: [PATCH 013/185] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E9=93=AD=E6=84=9F?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=BF=87=E6=BB=A4=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E7=AE=A1=E7=90=86=E7=AB=AF=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9=E4=BC=9A=E5=91=98=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/member/entity/dto/ManagerMemberEditDTO.java | 3 +++ .../lili/modules/member/serviceimpl/MemberServiceImpl.java | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java index 6b021869..8818ad4a 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java @@ -21,6 +21,9 @@ import java.util.Date; @Data public class ManagerMemberEditDTO { + @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) + @NotNull(message = "会员用户名不能为空") + private String id; @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) @NotNull(message = "会员用户名不能为空") private String username; diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 6bc75846..377b44ff 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -342,11 +342,6 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public Member updateMember(ManagerMemberEditDTO managerMemberEditDTO) { - //判断是否用户登录并且会员ID为当前登录会员ID - AuthUser tokenUser = UserContext.getCurrentUser(); - if (tokenUser == null) { - throw new ServiceException(ResultCode.USER_NOT_LOGIN); - } //过滤会员昵称敏感词 if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(managerMemberEditDTO.getNickName())) { managerMemberEditDTO.setNickName(SensitiveWordsFilter.filter(managerMemberEditDTO.getNickName())); @@ -356,7 +351,7 @@ public class MemberServiceImpl extends ServiceImpl impleme managerMemberEditDTO.setPassword(new BCryptPasswordEncoder().encode(managerMemberEditDTO.getPassword())); } //查询会员信息 - Member member = this.findByUsername(managerMemberEditDTO.getUsername()); + Member member = this.getById(managerMemberEditDTO.getId()); //传递修改会员信息 BeanUtil.copyProperties(managerMemberEditDTO, member); this.updateById(member); From 40e866aaddf076223385b321853ecfb52cb8f97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=A8=8B?= Date: Fri, 25 Mar 2022 18:12:40 +0800 Subject: [PATCH 014/185] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=85=8D?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=95=86=E5=93=81=E9=80=81=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/src/main/java/cn/lili/common/enums/ResultCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 7b61c34f..021c2b36 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -77,7 +77,7 @@ public enum ResultCode { MUST_HAVE_GOODS_SKU(11012, "规格必须要有一个!"), GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"), PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"), - VIRTUAL_GOODS_NOT_NEED_TEMP(11015, "实物商品需选择配送模板"), + VIRTUAL_GOODS_NOT_NEED_TEMP(11015, "虚拟商品无需选择配送模板"), GOODS_NOT_EXIST_STORE(11017, "当前用户无权操作此商品"), GOODS_TYPE_ERROR(11016, "需选择商品类型"), From de5e97ac3aa13df6e0bf26a11b44c5f5660fb0a0 Mon Sep 17 00:00:00 2001 From: *** <*****@***.***> Date: Sun, 27 Mar 2022 07:41:34 +0800 Subject: [PATCH 015/185] =?UTF-8?q?=E4=BC=98=E5=8C=96cn.lili.common.utils.?= =?UTF-8?q?CommonUtil.getRandomNum=E6=96=B9=E6=B3=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/utils/CommonUtil.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/utils/CommonUtil.java b/framework/src/main/java/cn/lili/common/utils/CommonUtil.java index 65c82bc8..61e7ebe9 100644 --- a/framework/src/main/java/cn/lili/common/utils/CommonUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/CommonUtil.java @@ -1,7 +1,7 @@ package cn.lili.common.utils; -import java.util.Random; import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; /** * 通用工具 @@ -9,6 +9,8 @@ import java.util.UUID; */ public class CommonUtil { + public static final String BASE_NUMBER = "0123456789"; + /** * 以UUID重命名 * @param fileName 文件名称 @@ -24,12 +26,12 @@ public class CommonUtil { * 随机6位数生成 */ public static String getRandomNum() { - - Random random = new Random(); - int num = random.nextInt(999999); - //不足六位前面补0 - String str = String.format("%06d", num); - return str; + StringBuilder sb = new StringBuilder(6); + for (int i = 0; i < 6; i++) { + int num = ThreadLocalRandom.current().nextInt(BASE_NUMBER.length()); + sb.append(BASE_NUMBER.charAt(num)); + } + return sb.toString(); } } From 6d014a01bcc329c5b672d633a482bed2a5f61cc4 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 29 Mar 2022 10:04:36 +0800 Subject: [PATCH 016/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=97=B6=E9=97=B4=E6=AE=B5=E4=B8=BA=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E3=80=82=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84es=E4=BB=A3=E7=A0=81=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98=E3=80=82improve=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 10 ---------- .../payment/kit/plugin/wallet/WalletPlugin.java | 2 -- .../promotion/serviceimpl/SeckillApplyServiceImpl.java | 2 +- .../search/serviceimpl/EsGoodsSearchServiceImpl.java | 6 ++++-- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/config/application.yml b/config/application.yml index 327cf008..703b96ae 100644 --- a/config/application.yml +++ b/config/application.yml @@ -25,15 +25,6 @@ spring: admin: client: url: http://192.168.0.116:8000 - # mongodb - data: - mongodb: - uri: 192.168.0.116:27017 - database: lilishop - username: root - password: lilishop - authentication-database: admin - # replica-set-name: mongoreplset cache: type: redis # Redis @@ -191,7 +182,6 @@ logging: cn.lili: info # org.hibernate: debug # org.springframework: debug - # org.springframework.data.mongodb.core: debug file: # 指定路径 path: logs diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java index 79245326..9a2d1edc 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java @@ -124,8 +124,6 @@ public class WalletPlugin implements Payment { //获取支付收银参数 CashierParam cashierParam = cashierSupport.cashierParam(payParam); this.callBack(payParam, cashierParam); - } catch (Exception e) { - throw e; } finally { lock.unlock(); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 0e774de5..11665dcb 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -338,7 +338,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl= hour || ((i + 1) < hoursSored.length && hoursSored[i + 1] > hour)); + boolean hoursSoredHour = (hoursSored[i] >= hour || ((i + 1) < hoursSored.length && hoursSored[i + 1] > hour) || hoursSored.length == 1); if (hoursSoredHour) { SimpleDateFormat format = new SimpleDateFormat(DatePattern.NORM_DATE_PATTERN); String date = format.format(new Date()); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index afbab567..85d669e0 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -240,7 +240,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { String brandName = ""; if (brandBuckets.get(i).getAggregations() != null && brandBuckets.get(i).getAggregations().get(ATTR_BRAND_NAME) != null) { - brandName = this.getAggregationsBrandOptions(brandBuckets.get(i).getAggregations().get(ATTR_BRAND_NAME)); + ParsedStringTerms aggregation = brandBuckets.get(i).getAggregations().get(ATTR_BRAND_NAME); + brandName = this.getAggregationsBrandOptions(aggregation); if (StringUtils.isEmpty(brandName)) { continue; } @@ -250,7 +251,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { if (brandUrlBuckets != null && !brandUrlBuckets.isEmpty() && brandUrlBuckets.get(i).getAggregations() != null && brandUrlBuckets.get(i).getAggregations().get(ATTR_BRAND_URL) != null) { - brandUrl = this.getAggregationsBrandOptions(brandUrlBuckets.get(i).getAggregations().get(ATTR_BRAND_URL)); + ParsedStringTerms aggregation = brandUrlBuckets.get(i).getAggregations().get(ATTR_BRAND_URL); + brandUrl = this.getAggregationsBrandOptions(aggregation); if (StringUtils.isEmpty(brandUrl)) { continue; } From bd9f7b8b9f3ebab9ca8b4b2a924f5a07414d7889 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 30 Mar 2022 11:54:56 +0800 Subject: [PATCH 017/185] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/order/serviceimpl/StoreFlowServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 6df5053f..3fdf030c 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -83,6 +83,8 @@ public class StoreFlowServiceImpl extends ServiceImpl Date: Wed, 30 Mar 2022 14:27:12 +0800 Subject: [PATCH 018/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=90=9C=E7=B4=A2es=E5=95=86=E5=93=81=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=8F=91=E7=94=9F=E7=9A=84date=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/elasticsearch/BaseElasticsearchService.java | 10 ++-------- .../lili/modules/search/entity/dos/EsGoodsIndex.java | 11 ++++------- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 5cc50ec4..11a20fab 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -165,14 +165,8 @@ public abstract class BaseElasticsearchService { " \"type\": \"long\"\n" + " },\n" + " \"releaseTime\": {\n" + - " \"type\": \"text\",\n" + - " \"fielddata\": true, \n" + - " \"fields\": {\n" + - " \"keyword\": {\n" + - " \"type\": \"keyword\",\n" + - " \"ignore_above\": 256\n" + - " }\n" + - " }\n" + + " \"type\": \"date\",\n" + + " \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" + " },\n" + " \"categoryPath\": {\n" + " \"type\": \"text\",\n" + diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index cd5372de..813249b3 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -6,14 +6,12 @@ import cn.lili.elasticsearch.EsSuffix; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.promotion.tools.PromotionTools; -import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.Accessors; import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.DateFormat; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; @@ -251,9 +249,8 @@ public class EsGoodsIndex implements Serializable { private String goodsVideo; @ApiModelProperty("商品发布时间") - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @Field(type = FieldType.Date, format = DateFormat.basic_date_time) - private Date releaseTime; + @Field(type = FieldType.Date) + private Long releaseTime; /** * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum @@ -309,7 +306,7 @@ public class EsGoodsIndex implements Serializable { this.grade = sku.getGrade(); this.recommend = sku.getRecommend(); this.goodsType = sku.getGoodsType(); - this.releaseTime = new Date(); + this.releaseTime = new Date().getTime(); } } @@ -374,7 +371,7 @@ public class EsGoodsIndex implements Serializable { this.authFlag = sku.getAuthFlag(); this.intro = sku.getIntro(); this.grade = sku.getGrade(); - this.releaseTime = new Date(); + this.releaseTime = new Date().getTime(); } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index d231f0df..ce342996 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -277,7 +277,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements UpdateRequest updateRequest = new UpdateRequest(indexName, goodsIndex.getId()); JSONObject jsonObject = JSONUtil.parseObj(goodsIndex); - jsonObject.set("releaseTime", goodsIndex.getReleaseTime().getTime()); + jsonObject.set("releaseTime", goodsIndex.getReleaseTime()); updateRequest.doc(jsonObject); request.add(updateRequest); } From c0932613690cf9dd19c6b5bfb13a1ccb12692c6d Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 30 Mar 2022 17:17:09 +0800 Subject: [PATCH 019/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=E4=BF=83=E9=94=80=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E7=9A=84=E4=BF=83=E9=94=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 2 +- .../search/entity/dos/EsGoodsIndex.java | 16 +++++--- .../search/service/EsGoodsIndexService.java | 8 ---- .../serviceimpl/EsGoodsIndexServiceImpl.java | 39 ++++--------------- 4 files changed, 19 insertions(+), 46 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 5cc77b32..558b7c30 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -394,7 +394,7 @@ public class GoodsMessageListener implements RocketMQListener { } } - if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { + if (goodsIndex.getOriginPromotionMap() == null || goodsIndex.getOriginPromotionMap().isEmpty()) { Map goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(goodsIndex.getStoreId(), goodsIndex.getId()); goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); } diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 813249b3..b4cdf3fd 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -97,42 +97,42 @@ public class EsGoodsIndex implements Serializable { /** * 品牌id */ - @Field(type = FieldType.Integer, fielddata = true) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("品牌id") private String brandId; /** * 品牌名称 */ - @Field(type = FieldType.Keyword, fielddata = true) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("品牌名称") private String brandName; /** * 品牌图片地址 */ - @Field(type = FieldType.Keyword, fielddata = true) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("品牌图片地址") private String brandUrl; /** * 分类path */ - @Field(type = FieldType.Keyword) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("分类path") private String categoryPath; /** * 分类名称path */ - @Field(type = FieldType.Keyword) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("分类名称path") private String categoryNamePath; /** * 店铺分类id */ - @Field(type = FieldType.Keyword) + @Field(type = FieldType.Text, fielddata = true) @ApiModelProperty("店铺分类id") private String storeCategoryPath; @@ -375,6 +375,10 @@ public class EsGoodsIndex implements Serializable { } } + public Map getOriginPromotionMap() { + return JSONUtil.parseObj(this.promotionMapJson); + } + public Map getPromotionMap() { return PromotionTools.filterInvalidPromotionsMap(JSONUtil.parseObj(this.promotionMapJson)); } diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index ffe12d04..3adff571 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -131,14 +131,6 @@ public interface EsGoodsIndexService { */ void updateEsGoodsIndexAllByList(BasePromotions promotion, String key); - /** - * 删除指定商品的促销信息 - * - * @param skuIds skuId列表 - * @param promotionType 促销类型 - */ - void deleteEsGoodsPromotionIndexByList(List skuIds, PromotionTypeEnum promotionType); - /** * 删除索引中指定的促销活动id的促销活动 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index ce342996..b249984e 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -451,27 +451,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements this.updateEsGoodsIndexPromotions(skuIds, promotion, key); } - @Override - public void deleteEsGoodsPromotionIndexByList(List skuIds, PromotionTypeEnum promotionType) { - //批量删除活动索引 - for (String skuId : skuIds) { - EsGoodsIndex goodsIndex = findById(skuId); - //商品索引不为空 - if (goodsIndex != null) { - Map promotionMap = goodsIndex.getPromotionMap(); - if (promotionMap != null && !promotionMap.isEmpty()) { - //如果存在同类型促销活动删除 - List collect = promotionMap.keySet().stream().filter(i -> i.contains(promotionType.name())).collect(Collectors.toList()); - collect.forEach(promotionMap::remove); - goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); - updateIndex(goodsIndex); - } - } else { - log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); - } - } - } - @Override public void deleteEsGoodsPromotionByPromotionKey(List skuIds, String promotionsKey) { BulkRequest bulkRequest = new BulkRequest(); @@ -520,13 +499,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements * @param promotionsKey 促销活动key */ private UpdateRequest removePromotionByPromotionKey(EsGoodsIndex goodsIndex, String promotionsKey) { - Map promotionMap = goodsIndex.getPromotionMap(); + Map promotionMap = goodsIndex.getOriginPromotionMap(); if (promotionMap != null && !promotionMap.isEmpty()) { //如果存在同促销ID的活动删除 - List collect = promotionMap.keySet().stream().filter(i -> i.equals(promotionsKey)).collect(Collectors.toList()); - collect.forEach(promotionMap::remove); - goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap)); - return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); + Map filterPromotionMap = promotionMap.entrySet().stream().filter(i -> !i.getKey().equals(promotionsKey)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), filterPromotionMap); } return null; } @@ -538,7 +515,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements public void cleanInvalidPromotion() { Iterable all = goodsIndexRepository.findAll(); for (EsGoodsIndex goodsIndex : all) { - Map promotionMap = goodsIndex.getPromotionMap(); + Map promotionMap = goodsIndex.getOriginPromotionMap(); //获取商品索引 if (promotionMap != null && !promotionMap.isEmpty()) { //促销不为空则进行清洗 @@ -574,7 +551,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //如果商品索引不为空,返回促销信息,否则返回空 if (goodsIndex != null) { - Map promotionMap = goodsIndex.getPromotionMap(); + Map promotionMap = goodsIndex.getOriginPromotionMap(); if (promotionMap == null || promotionMap.isEmpty()) { return new HashMap<>(16); } @@ -639,10 +616,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements private UpdateRequest updateGoodsIndexPromotion(EsGoodsIndex goodsIndex, String key, BasePromotions promotion) { Map promotionMap; //数据非空处理,如果空给一个新的信息 - if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) { + if (goodsIndex.getOriginPromotionMap() == null || goodsIndex.getOriginPromotionMap().isEmpty()) { promotionMap = new HashMap<>(1); } else { - promotionMap = goodsIndex.getPromotionMap(); + promotionMap = goodsIndex.getOriginPromotionMap(); } log.info("ES修改商品活动索引-活动信息:{}", promotion); @@ -670,7 +647,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements UpdateRequest updateRequest = new UpdateRequest(); updateRequest.index(getIndexName()); updateRequest.id(id); -// updateRequest.retryOnConflict(5); + updateRequest.retryOnConflict(3); // updateRequest.version(promotionMap.size()); Map params = new HashMap<>(); params.put("promotionMap", JSONUtil.toJsonStr(promotionMap)); From 210d56447c0e0d79a8fce43498b1fa4f75fd928b Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 30 Mar 2022 17:21:57 +0800 Subject: [PATCH 020/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsIndexServiceImpl.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index b249984e..8ae29f80 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -431,24 +431,26 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements */ @Override public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) { - List goodsIndices = new ArrayList<>(); - //如果storeId不为空,则表示是店铺活动 - if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) { - EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); - searchDTO.setStoreId(promotion.getStoreId()); - //查询出店铺商品 - SearchPage esGoodsIndices = goodsSearchService.searchGoods(searchDTO, null); - for (SearchHit searchHit : esGoodsIndices.getContent()) { - goodsIndices.add(searchHit.getContent()); + ThreadUtil.execAsync(() -> { + List goodsIndices = new ArrayList<>(); + //如果storeId不为空,则表示是店铺活动 + if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) { + EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); + searchDTO.setStoreId(promotion.getStoreId()); + //查询出店铺商品 + SearchPage esGoodsIndices = goodsSearchService.searchGoods(searchDTO, null); + for (SearchHit searchHit : esGoodsIndices.getContent()) { + goodsIndices.add(searchHit.getContent()); + } + } else { + //否则是平台活动 + Iterable all = goodsIndexRepository.findAll(); + //查询出全部商品 + goodsIndices = new ArrayList<>(IterableUtil.toCollection(all)); } - } else { - //否则是平台活动 - Iterable all = goodsIndexRepository.findAll(); - //查询出全部商品 - goodsIndices = new ArrayList<>(IterableUtil.toCollection(all)); - } - List skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); - this.updateEsGoodsIndexPromotions(skuIds, promotion, key); + List skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); + this.updateEsGoodsIndexPromotions(skuIds, promotion, key); + }); } @Override @@ -482,14 +484,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements */ @Override public void deleteEsGoodsPromotionByPromotionKey(String promotionsKey) { - BulkRequest bulkRequest = new BulkRequest(); - for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { - UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); - if (updateRequest != null) { - bulkRequest.add(updateRequest); + ThreadUtil.execAsync(() -> { + BulkRequest bulkRequest = new BulkRequest(); + for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { + UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey); + if (updateRequest != null) { + bulkRequest.add(updateRequest); + } } - } - this.executeBulkUpdateRequest(bulkRequest); + this.executeBulkUpdateRequest(bulkRequest); + }); } /** From bf667e2aa60cf81ac2d6a2acf47398e802e85336 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 31 Mar 2022 09:21:18 +0800 Subject: [PATCH 021/185] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.3to4.2.4.sql | 6 ++++-- ...version4.2.3toMASTER.sql => version4.2.4toMASTER.sql} | 0 .../src/main/java/cn/lili/common/utils/DateUtil.java | 9 +++++++++ .../cn/lili/modules/member/entity/dos/MemberSign.java | 4 ++++ .../member/serviceimpl/MemberSignServiceImpl.java | 4 ++-- .../cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java | 3 +-- 6 files changed, 20 insertions(+), 6 deletions(-) rename DB/{version4.2.3toMASTER.sql => version4.2.4toMASTER.sql} (100%) diff --git a/DB/version4.2.3to4.2.4.sql b/DB/version4.2.3to4.2.4.sql index 78764222..f8cfb17a 100644 --- a/DB/version4.2.3to4.2.4.sql +++ b/DB/version4.2.3to4.2.4.sql @@ -1,2 +1,4 @@ -/** 新增已退货数量 **/ -ALTER TABLE li_order_item ADD return_goods_number int DEFAULT 0 COMMENT '退货数量 '; \ No newline at end of file +/** 增加签到日期 **/ +ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 '; +ALTER TABLE li_member_sign DROP INDEX uk_member_day; +ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; \ No newline at end of file diff --git a/DB/version4.2.3toMASTER.sql b/DB/version4.2.4toMASTER.sql similarity index 100% rename from DB/version4.2.3toMASTER.sql rename to DB/version4.2.4toMASTER.sql diff --git a/framework/src/main/java/cn/lili/common/utils/DateUtil.java b/framework/src/main/java/cn/lili/common/utils/DateUtil.java index b07f0bde..34a29c89 100644 --- a/framework/src/main/java/cn/lili/common/utils/DateUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/DateUtil.java @@ -20,6 +20,15 @@ public class DateUtil { public static final String FULL_DATE = "yyyyMMddHHmmss"; + /** + * 当天的开始时间 + * + * @return 今天开始时间 + */ + public static Long getDayOfStart() { + return DateUtil.getDateline()/(60*24*60); + } + /** * 当天的开始时间 * diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberSign.java b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberSign.java index adec8b76..504975ca 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberSign.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberSign.java @@ -42,4 +42,8 @@ public class MemberSign extends BaseIdEntity { @ApiModelProperty(value = "连续签到天数") private Integer signDay; + + @ApiModelProperty(value = "签到日 为数字 从现在减去19700101 的日期") + private Integer day; + } diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java index fbac26ba..c25f4145 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberSignServiceImpl.java @@ -77,8 +77,8 @@ public class MemberSignServiceImpl extends ServiceImpl Date: Thu, 31 Mar 2022 14:04:56 +0800 Subject: [PATCH 022/185] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E6=81=A2=E5=A4=8D=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.3to4.2.4.sql | 68 ++++++++++++++++++++++++++++++++++--- DB/version4.2.4toMASTER.sql | 68 +++---------------------------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/DB/version4.2.3to4.2.4.sql b/DB/version4.2.3to4.2.4.sql index f8cfb17a..c34d6097 100644 --- a/DB/version4.2.3to4.2.4.sql +++ b/DB/version4.2.3to4.2.4.sql @@ -1,4 +1,64 @@ -/** 增加签到日期 **/ -ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 '; -ALTER TABLE li_member_sign DROP INDEX uk_member_day; -ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; \ No newline at end of file +/** 新增已退货数量 **/ +ALTER TABLE li_order_item ADD return_goods_number int DEFAULT 0 COMMENT '退货数量 '; + + +-- 促销重构sql +ALTER TABLE li_coupon DROP COLUMN promotion_status; + +ALTER TABLE li_coupon_activity DROP COLUMN promotion_status; +ALTER TABLE li_coupon_activity ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '范围关联的ID'; +ALTER TABLE li_coupon_activity ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; + +ALTER TABLE li_full_discount DROP COLUMN promotion_status; +ALTER TABLE li_full_discount ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_full_discount ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; + +ALTER TABLE li_kanjia_activity_goods DROP COLUMN promotion_status; +ALTER TABLE li_kanjia_activity_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_kanjia_activity_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; +ALTER TABLE li_kanjia_activity_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL; + +ALTER TABLE li_pintuan DROP COLUMN promotion_status; +ALTER TABLE li_pintuan ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_pintuan ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; + +ALTER TABLE li_points_goods DROP COLUMN promotion_status; +ALTER TABLE li_points_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_points_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; +ALTER TABLE li_points_goods ADD `original_price` double(10,2) DEFAULT NULL COMMENT '原价'; +ALTER TABLE li_points_goods ADD `thumbnail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '缩略图'; +ALTER TABLE li_points_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商品编号'; +ALTER TABLE li_points_goods ADD `goods_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '货品名称'; + +ALTER TABLE li_promotion_goods DROP COLUMN promotion_status; +ALTER TABLE li_promotion_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_promotion_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; +ALTER TABLE li_promotion_goods ADD `original_price` double(10,2) DEFAULT NULL COMMENT '原价'; +ALTER TABLE li_promotion_goods ADD `points` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '兑换积分'; +ALTER TABLE li_promotion_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商品编号'; + +ALTER TABLE li_seckill DROP COLUMN promotion_status; +ALTER TABLE li_seckill ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; +ALTER TABLE li_seckill ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; + +ALTER TABLE li_full_discount RENAME COLUMN is_coupon TO coupon_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_free_freight TO free_freight_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_full_minus TO full_minus_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_full_rate TO full_rate_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_gift TO gift_flag; +ALTER TABLE li_full_discount RENAME COLUMN is_point TO point_flag; + +ALTER TABLE li_member_coupon RENAME COLUMN is_platform TO platform_flag; + +ALTER TABLE li_goods RENAME COLUMN is_auth TO auth_flag; + +ALTER TABLE li_goods_sku RENAME COLUMN is_promotion TO promotion_flag; +ALTER TABLE li_goods_sku RENAME COLUMN is_auth TO auth_flag; + + +-- 增加会员表索引 +ALTER TABLE li_member ADD INDEX query_mobile (`mobile`) COMMENT 'query_member'; +-- 会员签到唯一索引 惠券查询索引 +ALTER TABLE li_member_sign ADD INDEX query_create_time (`create_time`) COMMENT 'query_create_time'; +ALTER TABLE li_member_sign ADD INDEX query_member_id (`member_id`) COMMENT 'query_member_id'; +ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day'; \ No newline at end of file diff --git a/DB/version4.2.4toMASTER.sql b/DB/version4.2.4toMASTER.sql index c34d6097..f8cfb17a 100644 --- a/DB/version4.2.4toMASTER.sql +++ b/DB/version4.2.4toMASTER.sql @@ -1,64 +1,4 @@ -/** 新增已退货数量 **/ -ALTER TABLE li_order_item ADD return_goods_number int DEFAULT 0 COMMENT '退货数量 '; - - --- 促销重构sql -ALTER TABLE li_coupon DROP COLUMN promotion_status; - -ALTER TABLE li_coupon_activity DROP COLUMN promotion_status; -ALTER TABLE li_coupon_activity ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '范围关联的ID'; -ALTER TABLE li_coupon_activity ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; - -ALTER TABLE li_full_discount DROP COLUMN promotion_status; -ALTER TABLE li_full_discount ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_full_discount ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; - -ALTER TABLE li_kanjia_activity_goods DROP COLUMN promotion_status; -ALTER TABLE li_kanjia_activity_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_kanjia_activity_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; -ALTER TABLE li_kanjia_activity_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL; - -ALTER TABLE li_pintuan DROP COLUMN promotion_status; -ALTER TABLE li_pintuan ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_pintuan ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; - -ALTER TABLE li_points_goods DROP COLUMN promotion_status; -ALTER TABLE li_points_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_points_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; -ALTER TABLE li_points_goods ADD `original_price` double(10,2) DEFAULT NULL COMMENT '原价'; -ALTER TABLE li_points_goods ADD `thumbnail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '缩略图'; -ALTER TABLE li_points_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商品编号'; -ALTER TABLE li_points_goods ADD `goods_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '货品名称'; - -ALTER TABLE li_promotion_goods DROP COLUMN promotion_status; -ALTER TABLE li_promotion_goods ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_promotion_goods ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; -ALTER TABLE li_promotion_goods ADD `original_price` double(10,2) DEFAULT NULL COMMENT '原价'; -ALTER TABLE li_promotion_goods ADD `points` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '兑换积分'; -ALTER TABLE li_promotion_goods ADD `goods_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商品编号'; - -ALTER TABLE li_seckill DROP COLUMN promotion_status; -ALTER TABLE li_seckill ADD `scope_id` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '范围关联的ID'; -ALTER TABLE li_seckill ADD `scope_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'PORTION_GOODS' COMMENT '关联范围类型'; - -ALTER TABLE li_full_discount RENAME COLUMN is_coupon TO coupon_flag; -ALTER TABLE li_full_discount RENAME COLUMN is_free_freight TO free_freight_flag; -ALTER TABLE li_full_discount RENAME COLUMN is_full_minus TO full_minus_flag; -ALTER TABLE li_full_discount RENAME COLUMN is_full_rate TO full_rate_flag; -ALTER TABLE li_full_discount RENAME COLUMN is_gift TO gift_flag; -ALTER TABLE li_full_discount RENAME COLUMN is_point TO point_flag; - -ALTER TABLE li_member_coupon RENAME COLUMN is_platform TO platform_flag; - -ALTER TABLE li_goods RENAME COLUMN is_auth TO auth_flag; - -ALTER TABLE li_goods_sku RENAME COLUMN is_promotion TO promotion_flag; -ALTER TABLE li_goods_sku RENAME COLUMN is_auth TO auth_flag; - - --- 增加会员表索引 -ALTER TABLE li_member ADD INDEX query_mobile (`mobile`) COMMENT 'query_member'; --- 会员签到唯一索引 惠券查询索引 -ALTER TABLE li_member_sign ADD INDEX query_create_time (`create_time`) COMMENT 'query_create_time'; -ALTER TABLE li_member_sign ADD INDEX query_member_id (`member_id`) COMMENT 'query_member_id'; -ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day'; \ No newline at end of file +/** 增加签到日期 **/ +ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 '; +ALTER TABLE li_member_sign DROP INDEX uk_member_day; +ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; \ No newline at end of file From cf0101150472ae9f99df2df0bbd20c0bd3135d66 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 31 Mar 2022 16:49:12 +0800 Subject: [PATCH 023/185] =?UTF-8?q?=E6=B3=A8=E9=94=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BE=9B=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../passport/MemberBuyerController.java | 29 ++++++++- .../java/cn/lili/common/enums/ResultCode.java | 1 + .../connect/service/ConnectService.java | 7 +++ .../serviceimpl/ConnectServiceImpl.java | 7 +++ .../modules/member/service/MemberService.java | 31 +++++++++- .../member/serviceimpl/MemberServiceImpl.java | 62 +++++++++++++++++++ 6 files changed, 135 insertions(+), 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 d3b9929e..02dfc48a 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 @@ -125,7 +125,6 @@ public class MemberBuyerController { @ApiOperation(value = "修改密码") @ApiImplicitParams({ - @ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"), @ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query") }) @PostMapping("/resetPassword") @@ -152,6 +151,34 @@ public class MemberBuyerController { return ResultUtil.data(memberService.modifyPass(password, newPassword)); } + @ApiOperation(value = "初始设置密码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newPassword", value = "新密码", required = true, paramType = "query") + }) + @PutMapping("/canInitPassword") + public ResultMessage canInitPassword() { + return ResultUtil.data(memberService.canInitPass()); + } + + @ApiOperation(value = "初始设置密码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newPassword", value = "新密码", required = true, paramType = "query") + }) + @PutMapping("/initPassword") + public ResultMessage initPassword(@NotNull(message = "密码不能为空") @RequestParam String password) { + memberService.initPass(password); + return ResultUtil.success(); + } + + @ApiOperation(value = "注销账号") + @ApiImplicitParams({ + @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query") + }) + @PutMapping("/cancellation") + public ResultMessage cancellation(@NotNull(message = "密码不能为空") @RequestParam String password) { + memberService.cancellation(password); + return ResultUtil.success(); + } @ApiOperation(value = "刷新token") @GetMapping("/refresh/{refreshToken}") diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 021c2b36..1f352b7d 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -40,6 +40,7 @@ public enum ResultCode { FILE_TYPE_NOT_SUPPORT(1010, "不支持上传的文件类型!"), PLATFORM_NOT_SUPPORTED_IM(1006, "平台未开启IM"), STORE_NOT_SUPPORTED_IM(1007, "店铺未开启IM"), + UNINITIALIZED_PASSWORD(1008, "非初始化密码,无法进行初始化设置"), /** * 分类 */ diff --git a/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java b/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java index 6df3b143..9aef44aa 100644 --- a/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java +++ b/framework/src/main/java/cn/lili/modules/connect/service/ConnectService.java @@ -112,4 +112,11 @@ public interface ConnectService extends IService { * @return */ Connect queryConnect(ConnectQueryDTO connectQueryDTO); + + /** + * 根据会员id删除记录 + * + * @param userId 会员id + */ + void deleteByMemberId(String userId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index f7a98a6b..1ea33779 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -245,6 +245,13 @@ public class ConnectServiceImpl extends ServiceImpl impl return this.getOne(queryWrapper); } + @Override + public void deleteByMemberId(String userId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Connect::getUserId, userId); + this.remove(queryWrapper); + } + /** * 会员绑定 绑定微信小程序 *

diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java index d7115916..6824b7cd 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java @@ -25,6 +25,11 @@ import java.util.Map; */ public interface MemberService extends IService { + /** + * 默认密码 + */ + static String DEFAULT_PASSWORD = "111111"; + /** * 获取当前登录的用户信息 * @@ -92,6 +97,29 @@ public interface MemberService extends IService { */ Member modifyPass(String oldPassword, String newPassword); + /** + * 是否可以初始化密码 + * + * @return + */ + boolean canInitPass(); + + /** + * 初始化密码 + * + * @param password 密码 + * @return 操作结果 + */ + void initPass(String password); + + /** + * 注销账号 + * + * @param password 密码 + * @return 操作结果 + */ + void cancellation(String password); + /** * 注册会员 * @@ -209,7 +237,7 @@ public interface MemberService extends IService { /** * 获取指定会员数据 * - * @param columns 指定获取的列 + * @param columns 指定获取的列 * @param memberIds 会员ids * @return 指定会员数据 */ @@ -239,6 +267,7 @@ public interface MemberService extends IService { /** * 获取用户VO + * * @param id 会员id * @return 用户VO */ diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 377b44ff..27e04bbe 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -198,6 +198,7 @@ public class MemberServiceImpl extends ServiceImpl impleme Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(), authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0); registerHandler(member); + member.setPassword(DEFAULT_PASSWORD); //绑定登录方式 loginBindUser(member, authUser.getUuid(), authUser.getSource()); return memberTokenGenerate.createToken(member, false); @@ -283,6 +284,67 @@ public class MemberServiceImpl extends ServiceImpl impleme return member; } + @Override + public boolean canInitPass() { + AuthUser tokenUser = UserContext.getCurrentUser(); + if (tokenUser == null) { + throw new ServiceException(ResultCode.USER_NOT_LOGIN); + } + Member member = this.getById(tokenUser.getId()); + if (member.getPassword().equals(DEFAULT_PASSWORD)) { + return true; + } + return false; + + } + + @Override + public void initPass(String password) { + AuthUser tokenUser = UserContext.getCurrentUser(); + if (tokenUser == null) { + throw new ServiceException(ResultCode.USER_NOT_LOGIN); + } + Member member = this.getById(tokenUser.getId()); + if (member.getPassword().equals(DEFAULT_PASSWORD)) { + //修改会员密码 + LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); + lambdaUpdateWrapper.eq(Member::getId, member.getId()); + lambdaUpdateWrapper.set(Member::getPassword, new BCryptPasswordEncoder().encode(password)); + this.update(lambdaUpdateWrapper); + } + throw new ServiceException(ResultCode.UNINITIALIZED_PASSWORD); + + } + + @Override + public void cancellation(String password) { + + AuthUser tokenUser = UserContext.getCurrentUser(); + if (tokenUser == null) { + throw new ServiceException(ResultCode.USER_NOT_LOGIN); + } + Member member = this.getById(tokenUser.getId()); + if (member.getPassword().equals(new BCryptPasswordEncoder().encode(password))) { + //删除联合登录 + connectService.deleteByMemberId(member.getId()); + //混淆用户信息 + this.confusionMember(member); + } + } + + /** + * 混淆之前的会员信息 + * + * @param member + */ + private void confusionMember(Member member) { + member.setUsername(UuidUtils.getUUID()); + member.setMobile(UuidUtils.getUUID() + member.getMobile()); + member.setNickName("用户已注销"); + member.setDisabled(false); + this.updateById(member); + } + @Override public Token register(String userName, String password, String mobilePhone) { //检测会员信息 From 9d170ecc30f1396bbb5fffbdefb41543950da8ec Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 1 Apr 2022 15:18:35 +0800 Subject: [PATCH 024/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=88=86=E7=B1=BB=E7=BC=93=E5=AD=98key?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java index 99801a9d..6d5a7d8d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java @@ -66,7 +66,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl Date: Fri, 1 Apr 2022 15:21:28 +0800 Subject: [PATCH 025/185] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=BC=83=E7=94=A8?= =?UTF-8?q?=E7=9A=84hutool=E7=9A=84SSLSocketFactoryBuilder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kit/core/http/AbstractHttpDelegate.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/core/http/AbstractHttpDelegate.java b/framework/src/main/java/cn/lili/modules/payment/kit/core/http/AbstractHttpDelegate.java index efad726b..28bf2645 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/core/http/AbstractHttpDelegate.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/core/http/AbstractHttpDelegate.java @@ -1,10 +1,11 @@ package cn.lili.modules.payment.kit.core.http; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.net.SSLContextBuilder; +import cn.hutool.core.net.SSLProtocols; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; -import cn.hutool.http.ssl.SSLSocketFactoryBuilder; import cn.lili.modules.payment.kit.core.PaymentHttpResponse; import javax.net.ssl.KeyManager; @@ -235,12 +236,12 @@ public abstract class AbstractHttpDelegate { try { File file = FileUtil.newFile(filePath); return HttpRequest.post(url) - .setSSLSocketFactory(SSLSocketFactoryBuilder + .setSSLSocketFactory(SSLContextBuilder .create() .setProtocol(protocol) .setKeyManagers(getKeyManager(certPass, certPath, null)) .setSecureRandom(new SecureRandom()) - .build() + .build().getSocketFactory() ) .header("Content-Type", "multipart/form-data;boundary=\"boundary\"") .form("file", file) @@ -263,7 +264,7 @@ public abstract class AbstractHttpDelegate { * @return {@link String} 请求返回的结果 */ public String upload(String url, String data, String certPath, String certPass, String filePath) { - return upload(url, data, certPath, certPass, filePath, SSLSocketFactoryBuilder.TLSv1); + return upload(url, data, certPath, certPass, filePath, SSLProtocols.TLSv1); } /** @@ -279,12 +280,12 @@ public abstract class AbstractHttpDelegate { public String post(String url, String data, String certPath, String certPass, String protocol) { try { return HttpRequest.post(url) - .setSSLSocketFactory(SSLSocketFactoryBuilder + .setSSLSocketFactory(SSLContextBuilder .create() .setProtocol(protocol) .setKeyManagers(getKeyManager(certPass, certPath, null)) .setSecureRandom(new SecureRandom()) - .build() + .build().getSocketFactory() ) .body(data) .execute() @@ -304,7 +305,7 @@ public abstract class AbstractHttpDelegate { * @return {@link String} 请求返回的结果 */ public String post(String url, String data, String certPath, String certPass) { - return post(url, data, certPath, certPass, SSLSocketFactoryBuilder.TLSv1); + return post(url, data, certPath, certPass, SSLProtocols.TLSv1); } /** @@ -320,12 +321,12 @@ public abstract class AbstractHttpDelegate { public String post(String url, String data, InputStream certFile, String certPass, String protocol) { try { return HttpRequest.post(url) - .setSSLSocketFactory(SSLSocketFactoryBuilder + .setSSLSocketFactory(SSLContextBuilder .create() .setProtocol(protocol) .setKeyManagers(getKeyManager(certPass, null, certFile)) .setSecureRandom(new SecureRandom()) - .build() + .build().getSocketFactory() ) .body(data) .execute() @@ -345,7 +346,7 @@ public abstract class AbstractHttpDelegate { * @return {@link String} 请求返回的结果 */ public String post(String url, String data, InputStream certFile, String certPass) { - return post(url, data, certFile, certPass, SSLSocketFactoryBuilder.TLSv1); + return post(url, data, certFile, certPass, SSLProtocols.TLSv1); } /** From f90c6fb27d6bfa58a04c84b44aa42b67035a7685 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Fri, 1 Apr 2022 21:59:44 +0800 Subject: [PATCH 026/185] =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/modules/goods/entity/dos/Goods.java | 4 ++++ .../java/cn/lili/modules/goods/entity/dos/GoodsWords.java | 3 ++- .../main/java/cn/lili/modules/goods/entity/dos/Studio.java | 4 ++++ .../message/entity/enums/NoticeMessageParameterEnum.java | 2 +- .../java/cn/lili/modules/order/order/entity/dos/Order.java | 4 ++++ .../cn/lili/modules/order/order/entity/dos/StoreFlow.java | 4 ++++ .../java/cn/lili/modules/order/order/entity/dos/Trade.java | 3 +++ .../main/java/cn/lili/modules/payment/entity/RefundLog.java | 4 ++++ .../lili/modules/wallet/entity/dos/MemberWithdrawApply.java | 4 ++++ .../java/cn/lili/modules/wechat/entity/dos/WechatMessage.java | 4 ++++ 10 files changed, 34 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index 205672c0..aaf13425 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; +import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsTypeEnum; import cn.lili.mybatis.BaseEntity; @@ -107,6 +108,9 @@ public class Goods extends BaseEntity { @ApiModelProperty(value = "运费模板id") private String templateId; + /** + * @see GoodsAuthEnum + */ @ApiModelProperty(value = "审核状态") private String authFlag; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsWords.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsWords.java index eff94046..d6890ec9 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsWords.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsWords.java @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dos; +import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -41,7 +42,7 @@ public class GoodsWords extends BaseEntity { private String abbreviate; /** - * 类型 + * @see GoodsWordsTypeEnum */ @ApiModelProperty(value = "类型") private String type; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Studio.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Studio.java index b049b84e..b9913804 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Studio.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Studio.java @@ -1,5 +1,6 @@ package cn.lili.modules.goods.entity.dos; +import cn.lili.modules.goods.entity.enums.StudioStatusEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -88,6 +89,9 @@ public class Studio extends BaseEntity { @ApiModelProperty(value = "推荐直播间") private boolean recommend; + /** + * @see StudioStatusEnum + */ @ApiModelProperty(value = "直播间状态") private String status; } diff --git a/framework/src/main/java/cn/lili/modules/message/entity/enums/NoticeMessageParameterEnum.java b/framework/src/main/java/cn/lili/modules/message/entity/enums/NoticeMessageParameterEnum.java index 97f2a085..1e28ee15 100644 --- a/framework/src/main/java/cn/lili/modules/message/entity/enums/NoticeMessageParameterEnum.java +++ b/framework/src/main/java/cn/lili/modules/message/entity/enums/NoticeMessageParameterEnum.java @@ -37,7 +37,7 @@ public enum NoticeMessageParameterEnum { */ CANCEL_REASON("cancel_reason", "取消原因"), /** - * 取消原因 + * 金额 */ PRICE("price", "金额"); diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java index 64e2ddaa..8c012951 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Order.java @@ -12,6 +12,7 @@ import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.*; +import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -78,6 +79,9 @@ public class Order extends BaseEntity { @ApiModelProperty(value = "第三方付款流水号") private String receivableNo; + /** + * @see PaymentMethodEnum + */ @ApiModelProperty(value = "支付方式") private String paymentMethod; diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java index 20ee09c9..9445fc7a 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java @@ -1,6 +1,7 @@ package cn.lili.modules.order.order.entity.dos; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; +import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.mybatis.BaseIdEntity; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; @@ -113,6 +114,9 @@ public class StoreFlow extends BaseIdEntity { @ApiModelProperty(value = "第三方交易流水号") private String transactionId; + /** + * @see PaymentMethodEnum + */ @ApiModelProperty(value = "支付方式名称") private String paymentName; diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java index 9edc785a..ed63df9b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java @@ -35,6 +35,9 @@ public class Trade extends BaseEntity { @ApiModelProperty(value = "买家用户名") private String memberName; + /** + * @see PayStatusEnum + */ @ApiModelProperty(value = "支付方式") private String paymentMethod; diff --git a/framework/src/main/java/cn/lili/modules/payment/entity/RefundLog.java b/framework/src/main/java/cn/lili/modules/payment/entity/RefundLog.java index 8309380c..c6a0663a 100644 --- a/framework/src/main/java/cn/lili/modules/payment/entity/RefundLog.java +++ b/framework/src/main/java/cn/lili/modules/payment/entity/RefundLog.java @@ -1,5 +1,6 @@ package cn.lili.modules.payment.entity; +import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.mybatis.BaseIdEntity; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; @@ -48,6 +49,9 @@ public class RefundLog extends BaseIdEntity { @ApiModelProperty(value = "是否已退款") private Boolean isRefund; + /** + * @see PaymentMethodEnum + */ @ApiModelProperty(value = "退款方式") private String paymentName; diff --git a/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java b/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java index 02aaf1eb..cf598ddf 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java +++ b/framework/src/main/java/cn/lili/modules/wallet/entity/dos/MemberWithdrawApply.java @@ -1,5 +1,6 @@ package cn.lili.modules.wallet.entity.dos; +import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; @@ -28,6 +29,9 @@ public class MemberWithdrawApply extends BaseEntity { @ApiModelProperty(value = "申请提现金额") private Double applyMoney; + /** + * @see WithdrawStatusEnum + */ @ApiModelProperty(value = "提现状态") private String applyStatus; diff --git a/framework/src/main/java/cn/lili/modules/wechat/entity/dos/WechatMessage.java b/framework/src/main/java/cn/lili/modules/wechat/entity/dos/WechatMessage.java index 5753b2e6..6441be30 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/entity/dos/WechatMessage.java +++ b/framework/src/main/java/cn/lili/modules/wechat/entity/dos/WechatMessage.java @@ -1,5 +1,6 @@ package cn.lili.modules.wechat.entity.dos; +import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -34,6 +35,9 @@ public class WechatMessage extends BaseEntity { @ApiModelProperty(value = "是否开启") private Boolean enable = true; + /** + * @see OrderStatusEnum + */ @ApiModelProperty("订单状态") private String orderStatus; From a988dedfbf3245dde795f194e624ffb8753aef56 Mon Sep 17 00:00:00 2001 From: paulGao Date: Sat, 2 Apr 2022 18:42:03 +0800 Subject: [PATCH 027/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=8E=B7=E5=8F=96=E5=9C=B0=E5=9D=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/RegionController.java | 7 ++++++- .../modules/system/service/RegionService.java | 8 ++++++++ .../system/serviceimpl/RegionServiceImpl.java | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/common-api/src/main/java/cn/lili/controller/common/RegionController.java b/common-api/src/main/java/cn/lili/controller/common/RegionController.java index f951f058..9abcfce3 100644 --- a/common-api/src/main/java/cn/lili/controller/common/RegionController.java +++ b/common-api/src/main/java/cn/lili/controller/common/RegionController.java @@ -2,9 +2,9 @@ package cn.lili.controller.common; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.system.service.RegionService; import cn.lili.modules.system.entity.dos.Region; import cn.lili.modules.system.entity.vo.RegionVO; +import cn.lili.modules.system.service.RegionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -38,6 +38,11 @@ public class RegionController { return ResultUtil.data(regionService.getRegion(cityCode,townName)); } + @GetMapping(value = "/name") + @ApiOperation(value = "根据名字获取地区地址id") + public ResultMessage getItemByLastName(String lastName) { + return ResultUtil.data(regionService.getItemByLastName(lastName)); + } @GetMapping(value = "/item/{id}") @ApiImplicitParam(name = "id", value = "地区ID", required = true, dataType = "String", paramType = "path") diff --git a/framework/src/main/java/cn/lili/modules/system/service/RegionService.java b/framework/src/main/java/cn/lili/modules/system/service/RegionService.java index 53261699..3696d7c3 100644 --- a/framework/src/main/java/cn/lili/modules/system/service/RegionService.java +++ b/framework/src/main/java/cn/lili/modules/system/service/RegionService.java @@ -36,6 +36,14 @@ public interface RegionService extends IService { @Cacheable(key = "#id") List getItem(String id); + /** + * 根据最后一级名称获取改所有上级地区id + * + * @param lastName 最后一级名称 + * @return 全部地区id + */ + String getItemByLastName(String lastName); + /** * 获取地址 * diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java index 5b29279d..dfb8863e 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java @@ -61,6 +61,25 @@ public class RegionServiceImpl extends ServiceImpl impleme } } + /** + * 根据最后一级名称获取改所有上级地区id + * + * @param lastName 最后一级名称 + * @return 全部地区id + */ + @Override + public String getItemByLastName(String lastName) { + StringBuilder sql = new StringBuilder(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(Region::getName, lastName); + Region region = this.getOne(lambdaQueryWrapper, false); + if (region != null) { + sql.append(region.getPath()).append(",").append(region.getId()); + return sql.toString().replace(",0,",""); + } + return null; + } + @Override public List getItem(String id) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); From 8e30defa0e8531450e3ff04df7da573d49f6e4ea Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 6 Apr 2022 10:39:51 +0800 Subject: [PATCH 028/185] =?UTF-8?q?=E4=BC=98=E5=8C=96es=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=EF=BC=8C=E5=85=A8=E5=88=86=E8=AF=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=94=B9=E4=B8=BA2=E5=88=86=E8=AF=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 85d669e0..63d53d13 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -562,7 +562,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { */ private List buildKeywordSearch(String keyword) { List filterFunctionBuilders = new ArrayList<>(); - MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.AND); + // operator 为 AND 时 需全部分词匹配。为 OR 时 需配置 minimumShouldMatch(最小分词匹配数)不设置默认为1 + MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch("2"); //分词匹配 filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, ScoreFunctionBuilders.weightFactorFunction(10))); From 40954814114b853a8d02028b535697a9a368f953 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 7 Apr 2022 10:19:19 +0800 Subject: [PATCH 029/185] =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BF=83=E9=94=80?= =?UTF-8?q?=E8=BF=90=E7=AE=97=E6=97=B6=EF=BC=8C=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E7=BC=93=E5=AD=98=EF=BC=8C=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=97=A0=E6=95=88=E6=95=B0=E6=8D=AE=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/impl/CouponRender.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java index f06633e7..9eb7f01e 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java @@ -19,10 +19,7 @@ import cn.lili.modules.promotion.service.MemberCouponService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -62,6 +59,10 @@ public class CouponRender implements CartRenderStep { private void renderCouponRule(TradeDTO tradeDTO) { List memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId()); + memberCouponList = memberCouponList.stream() + .filter(item -> item.getStartTime().before(new Date()) && item.getEndTime().after(new Date())) + .collect(Collectors.toList()); + if (!memberCouponList.isEmpty()) { this.checkMemberExistCoupon(tradeDTO, memberCouponList); } else { From db8796df99f39f6c9334aae221e1789beb029817 Mon Sep 17 00:00:00 2001 From: chopper711 <1814994716@qq.com> Date: Thu, 7 Apr 2022 04:07:23 +0000 Subject: [PATCH 030/185] update README.md. --- README.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b4ebe4b7..a23e42fd 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ ## Lilishop B2B2C商城系统 -##### 开源不易,如有帮助请点Star - - - #### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,进群先看文档后提问) @@ -28,13 +24,13 @@ Lilishop商城系统支持商家入驻,后端基于SpringBoot 研发,前端使用 Vue、uniapp开发, **系统全端全部代码开源** -商城前后端分离,支持分布式部署,支持Docker,各个API独立,并且有独立的消费者。 +前后端分离,支持分布式部署,支持Docker,各个API独立,并且有独立的消费者。 ### 商城 API/消费者 聚合版 api不需要单独部署,只需启动一个jar包就可以正常运转 如有需要,可以点击跳转 https://gitee.com/beijing_hongye_huicheng/lilishop-simplify -### 商城 开发/使用/常见问题 帮助文档 +### 开发/使用/常见问题 帮助文档 https://docs.pickmall.cn @@ -61,7 +57,7 @@ PS:手机验证码为 ‘111111’ ![image-20210511171611793](https://pickmall.cn/assets/imgs/h5-qrcode.png) -### 快速部署本地商城 +### 快速本地部署 [点击跳转](https://docs.pickmall.cn/deploy/%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87.html) @@ -138,11 +134,19 @@ PS:手机验证码为 ‘111111’ ### 版本升级 ``` -商城后续会持续版本升级,修复bug,完善功能,覆盖更多业务场景 o2o/b2b/s2b2b2c/跨境电商 - -后续会考虑推出微服务商城系统/商城中台等 +系统后续会提供多场景解决方案。 +更多架构:微服务、Saas、中台等,都会支持。 支持差价升级商业授权 ``` +### 商业授权 +商业版本与开源版本代码一致,没有区分 + +商业使用需要授权,授权方式可选择联系官网客服,或者qq群联系群主。 + +商业授权模式为永久授权,支持永久升级。 + +商业案例由于涉及部分多层二开关系,如需了解可以咨询销售。 + ### 开源须知 1.仅允许用于个人学习研究使用. @@ -151,7 +155,8 @@ PS:手机验证码为 ‘111111’ 3.软件受国家计算机软件著作权保护(登记号:2021SR0805085)。 -4.限制商用,如果需要商业使用请联系我们。QQ3409056806. +4.限制商用,如果需要商业使用请联系我们。QQ3409056806.或者加入qq群联系群主。 + ### 交流群 From 63b23fbe76026a591da7013408a2c16ac08ac63f Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 7 Apr 2022 16:06:23 +0800 Subject: [PATCH 031/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=9B=B8=E5=90=8C=E5=95=86=E5=93=81=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/serviceimpl/SeckillApplyServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 11665dcb..07572e9c 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -184,6 +184,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl Date: Fri, 8 Apr 2022 16:59:12 +0800 Subject: [PATCH 032/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BC=98=E6=83=A0=E5=88=B8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=A3=80=E6=9F=A5=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MemberCouponService.java | 7 ++++ .../serviceimpl/MemberCouponServiceImpl.java | 33 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java index a19fcd48..0d438b6a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/MemberCouponService.java @@ -125,6 +125,13 @@ public interface MemberCouponService extends IService { */ void cancellation(String memberId, String id); + /** + * 作废无效的会员优惠券 + * + * @return 是否操作成功 + */ + boolean expireInvalidMemberCoupon(String memberId); + /** * 关闭会员优惠券 * diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index d46f606f..9cd0961e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.promotion.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.cache.Cache; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -23,6 +24,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheConfig; @@ -108,7 +110,12 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCoupons(MemberCouponSearchParams param, PageVO pageVo) { QueryWrapper queryWrapper = param.queryWrapper(); - return this.page(PageUtil.initPage(pageVo), queryWrapper); + Page page = this.page(PageUtil.initPage(pageVo), queryWrapper); + if (page.getRecords().stream().anyMatch(i -> i.getEndTime().before(new Date()))) { + this.expireInvalidMemberCoupon(param.getMemberId()); + return this.page(PageUtil.initPage(pageVo), queryWrapper); + } + return page; } /** @@ -119,7 +126,12 @@ public class MemberCouponServiceImpl extends ServiceImpl getMemberCoupons(MemberCouponSearchParams param) { - return this.list(param.queryWrapper()); + List list = this.list(param.queryWrapper()); + if (list.stream().anyMatch(i -> i.getEndTime().before(new Date()))) { + this.expireInvalidMemberCoupon(param.getMemberId()); + return this.list(param.queryWrapper()); + } + return list; } /** @@ -273,6 +285,23 @@ public class MemberCouponServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper() + .eq(CharSequenceUtil.isNotEmpty(memberId), MemberCoupon::getMemberId, memberId) + .eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()) + .le(MemberCoupon::getEndTime, new Date()) + .set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name()); + return this.update(updateWrapper); + } + private void receiverCoupon(String couponId, String memberId, String memberName, Coupon coupon) { this.checkCouponLimit(couponId, memberId); MemberCoupon memberCoupon = new MemberCoupon(coupon); From c0391e3fc100bc6f5585c141e57820f2d0169be8 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Mon, 11 Apr 2022 11:23:02 +0800 Subject: [PATCH 033/185] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=97=B6=E5=88=A0=E9=99=A4=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/wechat/serviceimpl/WechatMessageServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java index 86f9b0fa..448ff57a 100644 --- a/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wechat/serviceimpl/WechatMessageServiceImpl.java @@ -87,14 +87,14 @@ public class WechatMessageServiceImpl extends ServiceImpl { Map params = new HashMap<>(1); params.put("template_id", templateId); String message = WechatMessageUtil.wechatHandler(HttpUtils.doPostWithJson(delMsgTpl + accessToken, params)); log.info("删除模版请求:{},删除模版响应:{}", params, message); }); - } + }*/ //加入数据 List tmpList = initData(); From 81c7a72b9c6c27d4a41cdb66a9a6d2b0750f2d65 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 11 Apr 2022 14:18:37 +0800 Subject: [PATCH 034/185] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E5=9C=A8=E8=B4=AD=E7=89=A9=E8=BD=A6=E4=B8=AD=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=9E=81=E7=AB=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java | 5 +++++ .../cn/lili/modules/order/cart/render/impl/CouponRender.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java index e05113b1..45d9cd87 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/dto/TradeDTO.java @@ -160,4 +160,9 @@ public class TradeDTO implements Serializable { } return skuList; } + + public void removeCoupon() { + this.canUseCoupons = new ArrayList<>(); + this.cantUseCoupons = new ArrayList<>(); + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java index 9eb7f01e..549dbd04 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CouponRender.java @@ -57,8 +57,12 @@ public class CouponRender implements CartRenderStep { * @param tradeDTO 交易dto */ private void renderCouponRule(TradeDTO tradeDTO) { + // 清除之前的优惠券 + tradeDTO.removeCoupon(); + List memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId()); + //获取最新优惠券 memberCouponList = memberCouponList.stream() .filter(item -> item.getStartTime().before(new Date()) && item.getEndTime().after(new Date())) .collect(Collectors.toList()); From 6966376f916d20cde507acd099a231020d36c1f0 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Wed, 13 Apr 2022 11:06:51 +0800 Subject: [PATCH 035/185] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9=E5=8F=8A?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=B1=BB=E5=9E=8B=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/page/service/ArticleService.java | 18 +++++++++++++++- .../page/serviceimpl/ArticleServiceImpl.java | 13 ++++++++++++ .../other/ArticleManagerController.java | 21 +++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java index cd677a0b..9fd53538 100644 --- a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java +++ b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java @@ -53,7 +53,7 @@ public interface ArticleService extends IService

{ Article updateArticle(Article article); /** - * 删除文章 + * 删除文章--id * * @param id */ @@ -87,4 +87,20 @@ public interface ArticleService extends IService
{ */ @CacheEvict(key = "#id") Boolean updateArticleStatus(String id, boolean status); + + /** + * 修改文章--文章类型修改 + * @param article + * @return + */ + @CacheEvict(key = "#article.type") + Article updateArticleType(Article article); + + /** + * 删除文章--类型 + * @param type + * @param id + */ + @CacheEvict(key = "#type") + void delAllByType(String type, String id); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java index 5c942301..312ad9cc 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java @@ -91,4 +91,17 @@ public class ArticleServiceImpl extends ServiceImpl impl article.setOpenStatus(status); return this.updateById(article); } + + @Override + public Article updateArticleType(Article article) { + Article oldArticle = this.getById(article.getId()); + BeanUtil.copyProperties(article, oldArticle); + this.updateById(oldArticle); + return oldArticle; + } + + @Override + public void delAllByType(String type,String id) { + this.removeById(id); + } } \ No newline at end of file diff --git a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java index f9cf79ce..b74da239 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java @@ -60,7 +60,7 @@ public class ArticleManagerController { return ResultUtil.data(article); } - @ApiOperation(value = "修改文章") + @ApiOperation(value = "修改文章--文章id") @ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path") @PutMapping(value = "update/{id}", consumes = "application/json", produces = "application/json") public ResultMessage
update(@RequestBody Article article, @PathVariable("id") String id) { @@ -68,6 +68,23 @@ public class ArticleManagerController { return ResultUtil.data(articleService.updateArticle(article)); } + @ApiOperation(value = "修改文章--文章类型") + @ApiImplicitParam(name = "type", value = "文章类型", required = true, paramType = "path") + @PutMapping(value = "updateArticle/{type}", consumes = "application/json", produces = "application/json") + public ResultMessage
updateArticle(@RequestBody Article article, @PathVariable("type") String type,String id) { + article.setId(id); + article.setType(type); + return ResultUtil.data(articleService.updateArticleType(article)); + } + + @ApiOperation(value = "文章删除-文章类型") + @ApiImplicitParam(name = "type", value = "文章类型", required = true, dataType = "String", paramType = "path") + @DeleteMapping(value = "/delByIds/{type}") + public ResultMessage delAllByType(@PathVariable String type,String id) { + articleService.delAllByType(type,id); + return ResultUtil.success(); + } + @ApiOperation(value = "修改文章状态") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path"), @@ -80,7 +97,7 @@ public class ArticleManagerController { } - @ApiOperation(value = "批量删除") + @ApiOperation(value = "批量删除--id") @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") @DeleteMapping(value = "/delByIds/{id}") public ResultMessage delAllByIds(@PathVariable String id) { From d13b0404fbace4dc493b44235481a634349e0660 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 13 Apr 2022 11:49:23 +0800 Subject: [PATCH 036/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81=E7=A0=81=E5=9C=A8info?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E7=9A=84=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java index 19e999b9..f54982e2 100644 --- a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java @@ -122,7 +122,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { //如果是测试模式 默认验证码 6个1 if (systemSettingProperties.getIsTestModel()) { code = "111111"; + log.info("测试模式 - 接收手机:{},验证码:{}",mobile,code); } else { + log.info("接收手机:{},验证码:{}",mobile,code); //发送短信 this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode); } From ec04c3221fda8635ee9b6ed14640394f653810c9 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Wed, 13 Apr 2022 12:00:40 +0800 Subject: [PATCH 037/185] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/page/service/ArticleService.java | 8 -------- .../modules/page/serviceimpl/ArticleServiceImpl.java | 5 ----- .../controller/other/ArticleManagerController.java | 10 +--------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java index 9fd53538..67e97b56 100644 --- a/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java +++ b/framework/src/main/java/cn/lili/modules/page/service/ArticleService.java @@ -95,12 +95,4 @@ public interface ArticleService extends IService
{ */ @CacheEvict(key = "#article.type") Article updateArticleType(Article article); - - /** - * 删除文章--类型 - * @param type - * @param id - */ - @CacheEvict(key = "#type") - void delAllByType(String type, String id); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java index 312ad9cc..77ddd2f8 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleServiceImpl.java @@ -99,9 +99,4 @@ public class ArticleServiceImpl extends ServiceImpl impl this.updateById(oldArticle); return oldArticle; } - - @Override - public void delAllByType(String type,String id) { - this.removeById(id); - } } \ No newline at end of file diff --git a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java index b74da239..ea8e22ab 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java @@ -77,14 +77,6 @@ public class ArticleManagerController { return ResultUtil.data(articleService.updateArticleType(article)); } - @ApiOperation(value = "文章删除-文章类型") - @ApiImplicitParam(name = "type", value = "文章类型", required = true, dataType = "String", paramType = "path") - @DeleteMapping(value = "/delByIds/{type}") - public ResultMessage delAllByType(@PathVariable String type,String id) { - articleService.delAllByType(type,id); - return ResultUtil.success(); - } - @ApiOperation(value = "修改文章状态") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path"), @@ -97,7 +89,7 @@ public class ArticleManagerController { } - @ApiOperation(value = "批量删除--id") + @ApiOperation(value = "批量删除") @ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path") @DeleteMapping(value = "/delByIds/{id}") public ResultMessage delAllByIds(@PathVariable String id) { From 7270564b10dbb4c441b94d926ea4f21ef85f8253 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 13 Apr 2022 16:58:19 +0800 Subject: [PATCH 038/185] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=A1=BA=E5=BA=8F=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=80=BB=E6=98=AF=E8=BE=93=E5=87=BA=E4=B8=80?= =?UTF-8?q?=E6=AE=B5=E9=94=99=E8=AF=AF=E7=9A=84=E6=97=A5=E5=BF=97=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/order/serviceimpl/OrderServiceImpl.java | 3 +++ .../modules/order/order/serviceimpl/StoreFlowServiceImpl.java | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 24fbc9f8..5593619e 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -62,6 +62,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; @@ -84,6 +85,7 @@ import java.util.stream.Collectors; * @since 2020/11/17 7:38 下午 */ @Service +@Slf4j public class OrderServiceImpl extends ServiceImpl implements OrderService { private static final String ORDER_SN_COLUMN = "order_sn"; @@ -334,6 +336,7 @@ public class OrderServiceImpl extends ServiceImpl implements Order order = this.getBySn(orderSn); //如果订单已支付,就不能再次进行支付 if (order.getPayStatus().equals(PayStatusEnum.PAID.name())) { + log.error("订单[ {} ]检测到重复付款,请处理", orderSn); throw new ServiceException(ResultCode.PAY_DOUBLE_ERROR); } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 3fdf030c..478dd111 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -71,10 +71,6 @@ public class StoreFlowServiceImpl extends ServiceImpl Date: Thu, 14 Apr 2022 09:09:22 +0800 Subject: [PATCH 039/185] remove invalid class --- .../test/promotion/PromotionPriceTest.java | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java diff --git a/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java b/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java deleted file mode 100644 index cfdafeb2..00000000 --- a/manager-api/src/test/java/cn/lili/test/promotion/PromotionPriceTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.lili.test.promotion; - -import cn.lili.modules.promotion.entity.dos.BasePromotions; -import cn.lili.modules.promotion.service.PromotionGoodsService; -import cn.lili.modules.promotion.service.PromotionService; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.util.Map; - -/** - * @author paulG - * @since 2020/11/23 - **/ -@ExtendWith(SpringExtension.class) -@SpringBootTest -class PromotionPriceTest { - - @Autowired - private PromotionService promotionService; - - @Autowired - private PromotionGoodsService promotionGoodsServiceService; - - @Test - void testSeckillPrice() { - Map currentPromotion = promotionService.getCurrentPromotion(); - for (Map.Entry entry : currentPromotion.entrySet()) { - BasePromotions promotion = (BasePromotions) entry.getValue(); - System.out.println(entry.getKey() + "-" + promotion.getId()); - } - Assertions.assertTrue(true); - } - -} From df505e0e1751a9f0367f308b4ecb15a12d5a8bf3 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Fri, 15 Apr 2022 19:05:27 +0800 Subject: [PATCH 040/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95=E9=87=91=E9=A2=9D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/entity/dto/PriceDetailDTO.java | 9 ++- .../order/serviceimpl/OrderServiceImpl.java | 2 +- .../serviceimpl/StoreFlowServiceImpl.java | 43 +++++++++--- .../lili/modules/store/entity/dos/Bill.java | 18 ++--- .../store/serviceimpl/BillServiceImpl.java | 69 +++++++++++++------ 5 files changed, 98 insertions(+), 43 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java index 67872901..edf3cfc9 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java @@ -57,7 +57,8 @@ public class PriceDetailDTO implements Serializable { @ApiModelProperty(value = "平台收取交易佣金比例") private Double platFormCommissionPoint; - @ApiModelProperty(value = "平台收取交易佣金") + + @ApiModelProperty(value = "平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100") private Double platFormCommission; //=========end distribution========== @@ -82,13 +83,15 @@ public class PriceDetailDTO implements Serializable { //=========end update price========== - @ApiModelProperty(value = "流水金额(入账 出帐金额) = goodsPrice + freight - discountPrice - couponPrice + updatePrice") + @ApiModelProperty(value = "流水金额(入账 出帐金额) = " + + "goodsPrice(商品总金额(商品原价)) + freightPrice(配送费) - " + + "discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额)") private Double flowPrice; @ApiModelProperty(value = "结算价格 与 商家/供应商 结算价格(例如积分商品/砍价商品)") private Double settlementPrice; - @ApiModelProperty(value = "最终结算金额 = flowPrice - platFormCommission - distributionCommission") + @ApiModelProperty(value = "最终结算金额 = flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出)") private Double billPrice; /** diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 5593619e..b3b230cc 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -349,7 +349,7 @@ public class OrderServiceImpl extends ServiceImpl implements order.setCanReturn(!PaymentMethodEnum.BANK_TRANSFER.name().equals(order.getPaymentMethod())); this.updateById(order); - //记录订单流水 + //记录店铺订单支付流水 storeFlowService.payOrder(orderSn); //发送订单已付款消息 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 478dd111..8dda9a15 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -1,6 +1,7 @@ package cn.lili.modules.order.order.serviceimpl; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONUtil; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.SnowFlake; @@ -9,6 +10,7 @@ import cn.lili.modules.order.aftersale.entity.dos.AfterSale; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dos.StoreFlow; +import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum; @@ -64,14 +66,16 @@ public class StoreFlowServiceImpl extends ServiceImpl orderItems = orderItemService.getByOrderSn(orderSn); //根据订单编号获取订单数据 Order order = orderService.getBySn(orderSn); - - //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 String orderPromotionType = order.getOrderPromotionType(); //循环子订单记录流水 @@ -92,13 +96,26 @@ public class StoreFlowServiceImpl extends ServiceImpl().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn()) .eq(StoreFlow::getFlowType, FlowTypeEnum.PAY)); + //申请商品退款数量 storeFlow.setNum(afterSale.getNum()); + //分类ID storeFlow.setCategoryId(payStoreFlow.getCategoryId()); - //佣金 + //佣金 = (佣金/订单商品数量)* 售后商品数量 storeFlow.setCommissionPrice(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getCommissionPrice(), payStoreFlow.getNum()), afterSale.getNum())); - //分销佣金 + //分销佣金 =(分销佣金/订单商品数量)* 售后商品数量 storeFlow.setDistributionRebate(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getDistributionRebate(), payStoreFlow.getNum()), afterSale.getNum())); - //流水金额 + //流水金额 = 实际退款金额 storeFlow.setFinalPrice(afterSale.getActualRefundPrice()); - //最终结算金额 + //最终结算金额 =店铺流水金额+店铺单品返现支出金额+平台收取佣金金额 storeFlow.setBillPrice(CurrencyUtil.add(storeFlow.getFinalPrice(), storeFlow.getDistributionRebate(), storeFlow.getCommissionPrice())); - //获取第三方支付流水号 + //退款日志 RefundLog refundLog = refundLogService.queryByAfterSaleSn(afterSale.getSn()); + //第三方流水单号 storeFlow.setTransactionId(refundLog.getReceivableNo()); + //支付方式 storeFlow.setPaymentName(refundLog.getPaymentName()); this.save(storeFlow); } diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dos/Bill.java b/framework/src/main/java/cn/lili/modules/store/entity/dos/Bill.java index 2020ec8c..02d2fe2c 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dos/Bill.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dos/Bill.java @@ -76,14 +76,6 @@ public class Bill extends BaseIdEntity { @ApiModelProperty(value = "支行联行号") private String bankCode; - /** - * 开始算钱啦 - * billPrice=orderPrice-refundPrice - * -commissionPrice+refundCommissionPrice - * -distributionCommission+distributionRefundCommission - * +siteCouponCommission-siteCouponRefundCommission - * +kanjiaSettlementPrice+pointSettlementPrice - */ @ApiModelProperty(value = "结算周期内订单付款总金额") private Double orderPrice; @@ -114,6 +106,16 @@ public class Bill extends BaseIdEntity { @ApiModelProperty(value = "砍价商品结算价格") private Double kanjiaSettlementPrice; + + /** + * 开始算钱啦 + * billPrice(最终结算金额) = + * orderPrice(结算周期内订单付款总金额) - refundPrice(退单金额) + * - commissionPrice(平台收取佣金) + refundCommissionPrice(退单产生退还佣金金额) + * - distributionCommission(分销返现支出) + distributionRefundCommission(分销订单退还,返现佣金返还) + * + siteCouponCommission(平台优惠券补贴) - siteCouponRefundCommission(退货平台优惠券补贴返还) + * + kanjiaSettlementPrice(砍价商品结算价格) + pointSettlementPrice(pointSettlementPrice) + */ @ApiModelProperty(value = "最终结算金额") private Double billPrice; diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index f5eecdb6..5cf4338b 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -68,14 +68,18 @@ public class BillServiceImpl extends ServiceImpl implements Bi StoreDetailVO store = storeDetailService.getStoreDetailVO(storeId); Bill bill = new Bill(); - //结算基础信息 + /** + * @TODO 结算单基础信息 + */ bill.setStartTime(startTime); - bill.setEndTime(DateUtil.yesterday()); + bill.setEndTime(endTime); bill.setBillStatus(BillStatusEnum.OUT.name()); bill.setStoreId(storeId); bill.setStoreName(store.getStoreName()); - //设置结算信息 + /** + * @TODO 结算单基础信息 + */ bill.setBankAccountName(store.getSettlementBankAccountName()); bill.setBankAccountNumber(store.getSettlementBankAccountNum()); bill.setBankCode(store.getSettlementBankJointName()); @@ -84,40 +88,61 @@ public class BillServiceImpl extends ServiceImpl implements Bi //店铺结算单号 bill.setSn(SnowFlake.createStr("B")); - //入账结算信息 - Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper() - .eq("store_id", storeId) - .eq("flow_type", FlowTypeEnum.PAY.name()) - .between("create_time", startTime, endTime)); - double orderPrice = 0D; - if (orderBill != null) { - bill.setOrderPrice(orderBill.getOrderPrice()); - bill.setCommissionPrice(orderBill.getCommissionPrice()); - bill.setDistributionCommission(orderBill.getDistributionCommission()); - bill.setSiteCouponCommission(orderBill.getSiteCouponCommission()); - bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); - bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); - //入账金额=订单金额 - orderPrice = orderBill.getBillPrice(); - } - - //退款结算信息 Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper() .eq("store_id", storeId) .eq("flow_type", FlowTypeEnum.REFUND.name()) .between("create_time", startTime, endTime)); + //店铺退款金额 Double refundPrice = 0D; if (refundBill != null) { + //退单金额 bill.setRefundPrice(refundBill.getRefundPrice()); + //退单产生退还佣金金额 bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice()); + //分销订单退还,返现佣金返还 bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission()); + //退货平台优惠券补贴返还 bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()); + //退款金额=店铺最终退款结算金额 refundPrice = refundBill.getBillPrice(); } - //最终结算金额=入款结算金额-退款结算金额 + + /** + * @TODO 入账结算信息 + */ + Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper() + .eq("store_id", storeId) + .eq("flow_type", FlowTypeEnum.PAY.name()) + .between("create_time", startTime, endTime)); + //店铺入款结算金额 + double orderPrice = 0D; + + if (orderBill != null) { + //结算周期内订单付款总金额 + bill.setOrderPrice(orderBill.getOrderPrice()); + //平台收取佣金 + bill.setCommissionPrice(orderBill.getCommissionPrice()); + //分销返现支出 + bill.setDistributionCommission(orderBill.getDistributionCommission()); + //平台优惠券补贴 + bill.setSiteCouponCommission(orderBill.getSiteCouponCommission()); + //积分商品结算价格 + bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); + //砍价商品结算价格 + bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); + //入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 退单产生退还佣金金额 + 分销订单退还,返现佣金返还+退货平台优惠券补贴返还 + orderPrice = CurrencyUtil.add(orderBill.getBillPrice(), + bill.getSiteCouponCommission(), + bill.getRefundCommissionPrice(), + bill.getDistributionRefundCommission(), + bill.getSiteCouponRefundCommission()); + } + + //最终结算金额=入款结算金额-退款结算金额- Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice); + //店铺最终结算金额=最终结算金额 bill.setBillPrice(finalPrice); //添加结算单 From 37c5ce541bac6e3f18e3dec979dd682ab7734b14 Mon Sep 17 00:00:00 2001 From: paulGao Date: Sun, 17 Apr 2022 21:46:34 +0800 Subject: [PATCH 041/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A5=BC=E5=B1=82?= =?UTF-8?q?=E8=A3=85=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/broadcast/StudioController.java | 4 +- .../modules/goods/service/StudioService.java | 2 +- .../goods/serviceimpl/StudioServiceImpl.java | 22 ++++++++-- .../promotion/service/PromotionService.java | 5 ++- .../serviceimpl/PromotionServiceImpl.java | 40 ++++--------------- .../broadcast/StudioManagerController.java | 2 +- .../promotion/PromotionManagerController.java | 5 ++- .../broadcast/StudioStoreController.java | 2 +- 8 files changed, 38 insertions(+), 44 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/other/broadcast/StudioController.java b/buyer-api/src/main/java/cn/lili/controller/other/broadcast/StudioController.java index d161e5c1..1c03c9e9 100644 --- a/buyer-api/src/main/java/cn/lili/controller/other/broadcast/StudioController.java +++ b/buyer-api/src/main/java/cn/lili/controller/other/broadcast/StudioController.java @@ -3,7 +3,7 @@ package cn.lili.controller.other.broadcast; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.goods.entity.dos.Studio; +import cn.lili.modules.goods.entity.vos.StudioVO; import cn.lili.modules.goods.service.StudioService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; @@ -35,7 +35,7 @@ public class StudioController { @ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query", dataType = "String") }) @GetMapping - public ResultMessage> page(PageVO pageVO, Integer recommend, String status) { + public ResultMessage> page(PageVO pageVO, Integer recommend, String status) { return ResultUtil.data(studioService.studioList(pageVO, recommend, status)); } diff --git a/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java b/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java index 40d273af..906c3696 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java @@ -70,7 +70,7 @@ public interface StudioService extends IService { * @param status 直播间状态 * @return 直播间分页 */ - IPage studioList(PageVO pageVO, Integer recommend, String status); + IPage studioList(PageVO pageVO, Integer recommend, String status); /** * 修改直播间状态 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java index 4aed7636..abda74b1 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java @@ -1,6 +1,7 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.convert.Convert; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -32,12 +33,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -209,15 +213,27 @@ public class StudioServiceImpl extends ServiceImpl impleme } @Override - public IPage studioList(PageVO pageVO, Integer recommend, String status) { + public IPage studioList(PageVO pageVO, Integer recommend, String status) { QueryWrapper queryWrapper = new QueryWrapper() .eq(recommend != null, "recommend", true) - .eq(status != null, "status", status) + .eq(CharSequenceUtil.isNotEmpty(status), "status", status) .orderByDesc("create_time"); if (UserContext.getCurrentUser() != null && UserContext.getCurrentUser().getRole().equals(UserEnums.STORE)) { queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId()); } - return this.page(PageUtil.initPage(pageVO), queryWrapper); + Page page = this.page(PageUtil.initPage(pageVO), queryWrapper); + List records = page.getRecords(); + List studioVOS = new ArrayList<>(); + for (Studio record : records) { + StudioVO studioVO = new StudioVO(); + //获取直播间信息 + BeanUtil.copyProperties(record, studioVO); + //获取直播间商品信息 + studioVO.setCommodityList(commodityMapper.getCommodityByRoomId(studioVO.getRoomId())); + studioVOS.add(studioVO); + } + page.setRecords(studioVOS); + return page; } diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java index 85ad2a41..8f8b5819 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionService.java @@ -1,5 +1,8 @@ package cn.lili.modules.promotion.service; +import cn.lili.modules.promotion.entity.dos.PromotionGoods; + +import java.util.List; import java.util.Map; /** @@ -15,7 +18,7 @@ public interface PromotionService { * * @return 当前促销活动集合 */ - Map getCurrentPromotion(); + Map> getCurrentPromotion(); /** * 根据商品索引获取当前商品索引的所有促销活动信息 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java index f68b0506..b50c79ce 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionServiceImpl.java @@ -2,8 +2,7 @@ package cn.lili.modules.promotion.serviceimpl; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.modules.promotion.entity.dos.*; -import cn.lili.modules.promotion.entity.dto.search.FullDiscountSearchParams; -import cn.lili.modules.promotion.entity.dto.search.PintuanSearchParams; +import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.service.*; @@ -16,6 +15,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 促销业务层实现 @@ -69,37 +69,11 @@ public class PromotionServiceImpl implements PromotionService { * @return 当前促销活动集合 */ @Override - public Map getCurrentPromotion() { - Map resultMap = new HashMap<>(16); - - SeckillSearchParams seckillSearchParams = new SeckillSearchParams(); - seckillSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - //获取当前进行的秒杀活动活动 - List seckillList = seckillService.listFindAll(seckillSearchParams); - if (seckillList != null && !seckillList.isEmpty()) { - for (Seckill seckill : seckillList) { - resultMap.put(PromotionTypeEnum.SECKILL.name(), seckill); - } - } - FullDiscountSearchParams fullDiscountSearchParams = new FullDiscountSearchParams(); - fullDiscountSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - //获取当前进行的满优惠活动 - List fullDiscountList = fullDiscountService.listFindAll(fullDiscountSearchParams); - if (fullDiscountList != null && !fullDiscountList.isEmpty()) { - for (FullDiscount fullDiscount : fullDiscountList) { - resultMap.put(PromotionTypeEnum.FULL_DISCOUNT.name(), fullDiscount); - } - } - PintuanSearchParams pintuanSearchParams = new PintuanSearchParams(); - pintuanSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); - //获取当前进行的拼团活动 - List pintuanList = pintuanService.listFindAll(pintuanSearchParams); - if (pintuanList != null && !pintuanList.isEmpty()) { - for (Pintuan pintuan : pintuanList) { - resultMap.put(PromotionTypeEnum.PINTUAN.name(), pintuan); - } - } - return resultMap; + public Map> getCurrentPromotion() { + PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); + searchParams.setPromotionStatus(PromotionsStatusEnum.START.name()); + List promotionGoods = promotionGoodsService.listFindAll(searchParams); + return promotionGoods.stream().collect(Collectors.groupingBy(PromotionGoods::getPromotionType)); } /** diff --git a/manager-api/src/main/java/cn/lili/controller/other/broadcast/StudioManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/broadcast/StudioManagerController.java index fb514b84..584db8bf 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/broadcast/StudioManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/broadcast/StudioManagerController.java @@ -36,7 +36,7 @@ public class StudioManagerController { @ApiOperation(value = "获取店铺直播间列表") @ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query") @GetMapping - public ResultMessage> page(PageVO pageVO, String status) { + public ResultMessage> page(PageVO pageVO, String status) { return ResultUtil.data(studioService.studioList(pageVO, null, status)); } diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java index 9afbb2b4..a4c9f59d 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/PromotionManagerController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; import java.util.Map; /** @@ -37,8 +38,8 @@ public class PromotionManagerController { @GetMapping("/current") @ApiOperation(value = "获取当前进行中的促销活动") - public ResultMessage> getCurrentPromotion() { - Map currentPromotion = promotionService.getCurrentPromotion(); + public ResultMessage>> getCurrentPromotion() { + Map> currentPromotion = promotionService.getCurrentPromotion(); return ResultUtil.data(currentPromotion); } diff --git a/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java b/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java index 09999f03..efe697e3 100644 --- a/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java @@ -38,7 +38,7 @@ public class StudioStoreController { @ApiOperation(value = "获取店铺直播间列表") @ApiImplicitParam(name = "status", value = "直播间状态", paramType = "query", dataType = "String") @GetMapping - public ResultMessage> page(PageVO pageVO, String status) { + public ResultMessage> page(PageVO pageVO, String status) { return ResultUtil.data(studioService.studioList(pageVO, null, status)); } From 9dc01f6057da85a3829285da0b5c5b6e249626ef Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Mon, 18 Apr 2022 19:09:05 +0800 Subject: [PATCH 042/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95=E7=BB=93=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/serviceimpl/StoreFlowServiceImpl.java | 6 ++++++ .../cn/lili/modules/store/mapper/BillMapper.java | 2 +- .../modules/store/serviceimpl/BillServiceImpl.java | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 8dda9a15..e4707a3f 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -180,6 +180,12 @@ public class StoreFlowServiceImpl extends ServiceImpl { */ @Select("SELECT SUM( final_price ) AS refundPrice,SUM( commission_price ) AS refundCommissionPrice" + ",SUM( distribution_rebate ) AS distributionRefundCommission,SUM( site_coupon_commission ) AS siteCouponRefundCommission" + - ",SUM( bill_price ) AS billPrice FROM li_store_flow ${ew.customSqlSegment}") + ",SUM( final_price ) AS billPrice FROM li_store_flow ${ew.customSqlSegment}") Bill getRefundBill(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index 5cf4338b..d74c4339 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -103,7 +103,7 @@ public class BillServiceImpl extends ServiceImpl implements Bi //分销订单退还,返现佣金返还 bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission()); //退货平台优惠券补贴返还 - bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()); + bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()!=null?refundBill.getSiteCouponRefundCommission():0D); //退款金额=店铺最终退款结算金额 refundPrice = refundBill.getBillPrice(); } @@ -132,16 +132,16 @@ public class BillServiceImpl extends ServiceImpl implements Bi bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); //砍价商品结算价格 bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); - //入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 退单产生退还佣金金额 + 分销订单退还,返现佣金返还+退货平台优惠券补贴返还 + + //入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 分销订单退还,返现佣金返还+退单产生退还佣金金额 orderPrice = CurrencyUtil.add(orderBill.getBillPrice(), bill.getSiteCouponCommission(), - bill.getRefundCommissionPrice(), bill.getDistributionRefundCommission(), - bill.getSiteCouponRefundCommission()); + bill.getRefundCommissionPrice()); } - //最终结算金额=入款结算金额-退款结算金额- - Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice); + //最终结算金额=入款结算金额-退款结算金额-退货平台优惠券补贴返还 + Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice,bill.getSiteCouponRefundCommission()); //店铺最终结算金额=最终结算金额 bill.setBillPrice(finalPrice); From 947a82eac5a8e15b729dd8618b444910f3953c31 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Apr 2022 09:28:26 +0800 Subject: [PATCH 043/185] =?UTF-8?q?=E7=83=AD=E8=AF=8D=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=EF=BC=8C=E7=83=AD=E8=AF=8D=E5=8A=9F=E8=83=BD=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.4toMASTER.sql | 14 +++- .../goods/GoodsBuyerController.java | 6 +- .../hotwords/HotWordsEveryDayTaskExecute.java | 54 +++++++++++++ .../java/cn/lili/common/utils/DateUtil.java | 8 ++ .../serviceimpl/StoreFlowServiceImpl.java | 8 +- .../search/entity/dos/HotWordsHistory.java | 47 +++++++++++ .../entity/dto/HotWordsSearchParams.java | 80 +++++++++++++++++++ .../search/entity/vo/HotWordsHistoryVO.java | 33 ++++++++ .../search/mapper/HotWordsHistoryMapper.java | 32 ++++++++ .../search/service/EsGoodsSearchService.java | 22 ----- .../service/HotWordsHistoryService.java | 41 ++++++++++ .../search/service/HotWordsService.java | 38 +++++++++ .../serviceimpl/EsGoodsSearchServiceImpl.java | 33 +------- .../HotWordsHistoryServiceImpl.java | 73 +++++++++++++++++ .../serviceimpl/HotWordsServiceImpl.java | 68 ++++++++++++++++ .../store/serviceimpl/BillServiceImpl.java | 2 +- .../system/entity/dto/HotWordsSetting.java | 28 +++++++ .../entity/dto/HotWordsSettingItem.java | 41 ++++++++++ .../system/entity/enums/SettingEnum.java | 4 +- .../hotwords/HotWordsManagerController.java | 47 ----------- .../other/HotWordsManagerController.java | 79 ++++++++++++++++++ .../setting/SettingManagerController.java | 4 + 22 files changed, 653 insertions(+), 109 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/search/entity/dos/HotWordsHistory.java create mode 100644 framework/src/main/java/cn/lili/modules/search/entity/dto/HotWordsSearchParams.java create mode 100644 framework/src/main/java/cn/lili/modules/search/entity/vo/HotWordsHistoryVO.java create mode 100644 framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java create mode 100644 framework/src/main/java/cn/lili/modules/search/service/HotWordsHistoryService.java create mode 100644 framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java create mode 100644 framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java create mode 100644 framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java create mode 100644 framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSetting.java create mode 100644 framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSettingItem.java delete mode 100644 manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java create mode 100644 manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java diff --git a/DB/version4.2.4toMASTER.sql b/DB/version4.2.4toMASTER.sql index f8cfb17a..7aad8be2 100644 --- a/DB/version4.2.4toMASTER.sql +++ b/DB/version4.2.4toMASTER.sql @@ -1,4 +1,16 @@ /** 增加签到日期 **/ ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 '; ALTER TABLE li_member_sign DROP INDEX uk_member_day; -ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; \ No newline at end of file +ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; + + +/** 添加历史热词表 **/ +CREATE TABLE `li_hot_words_history` ( + `id` bigint NOT NULL COMMENT 'ID', + `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '创建者', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `delete_flag` bit(1) DEFAULT NULL COMMENT '是否删除', + `update_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '修改者', + `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; \ No newline at end of file diff --git a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java index 92f8838d..fc5a5f0d 100644 --- a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java @@ -14,6 +14,7 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; import cn.lili.modules.search.service.EsGoodsSearchService; +import cn.lili.modules.search.service.HotWordsService; import cn.lili.modules.statistics.aop.PageViewPoint; import cn.lili.modules.statistics.aop.enums.PageViewEnum; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -62,6 +63,9 @@ public class GoodsBuyerController { @Autowired private EsGoodsSearchService goodsSearchService; + @Autowired + private HotWordsService hotWordsService; + @ApiOperation(value = "通过id获取商品信息") @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path", dataType = "Long") @GetMapping(value = "/get/{goodsId}") @@ -117,7 +121,7 @@ public class GoodsBuyerController { @ApiOperation(value = "获取搜索热词") @GetMapping("/hot-words") public ResultMessage> getGoodsHotWords(Integer count) { - List hotWords = goodsSearchService.getHotWords(count); + List hotWords = hotWordsService.getHotWords(count); return ResultUtil.data(hotWords); } diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java index a6e99c32..99f365f9 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java @@ -1,11 +1,24 @@ package cn.lili.timetask.handler.impl.hotwords; +import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; +import cn.lili.common.utils.StringUtils; +import cn.lili.modules.search.entity.dos.HotWordsHistory; +import cn.lili.modules.search.service.HotWordsHistoryService; +import cn.lili.modules.system.entity.dos.Setting; +import cn.lili.modules.system.entity.dto.HotWordsSetting; +import cn.lili.modules.system.entity.dto.HotWordsSettingItem; +import cn.lili.modules.system.entity.enums.SettingEnum; +import cn.lili.modules.system.service.SettingService; import cn.lili.timetask.handler.EveryDayExecute; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.DefaultTypedTuple; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; /** * @author paulG @@ -18,13 +31,54 @@ public class HotWordsEveryDayTaskExecute implements EveryDayExecute { @Autowired private Cache cache; + @Autowired + private HotWordsHistoryService hotWordsHistoryService; + @Autowired + private SettingService settingService; + /** * 执行每日任务 */ @Override public void execute() { + //获取大于0分的热词 + Set tuples = cache.zRangeByScore(CachePrefix.HOT_WORD.getPrefix(), 1, Integer.MAX_VALUE); + //如果任务不为空 + if (!CollectionUtils.isEmpty(tuples)) { + + //因为是第二天统计第一天的数据,所以这里获取昨天凌晨的时间 + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 1); + + //批量保存热词 + List hotWordsHistories = new ArrayList<>(); + for (DefaultTypedTuple tuple : tuples) { + String keywords = (String) tuple.getValue(); + Double score = tuple.getScore(); + hotWordsHistories.add(new HotWordsHistory(calendar.getTime(), keywords, score.intValue())); + } + + hotWordsHistoryService.saveBatch(hotWordsHistories); + } //移除昨日的热搜词 cache.remove(CachePrefix.HOT_WORD.getPrefix()); + + //设置今日默认热词 + Setting setting = settingService.get(SettingEnum.HOT_WORDS.name()); + if (setting == null) { + return; + } + HotWordsSetting hotWordsSetting = JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class); + List hotWordsSettingItems = hotWordsSetting.getHotWordsSettingItems(); + if (hotWordsSettingItems != null && !hotWordsSettingItems.isEmpty()) { + for (HotWordsSettingItem hotWordsSettingItem : hotWordsSettingItems) { + cache.zAdd(CachePrefix.HOT_WORD.getPrefix(), hotWordsSettingItem.getScore(), hotWordsSettingItem.getKeywords()); + } + } } } diff --git a/framework/src/main/java/cn/lili/common/utils/DateUtil.java b/framework/src/main/java/cn/lili/common/utils/DateUtil.java index 34a29c89..11f31484 100644 --- a/framework/src/main/java/cn/lili/common/utils/DateUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/DateUtil.java @@ -28,6 +28,14 @@ public class DateUtil { public static Long getDayOfStart() { return DateUtil.getDateline()/(60*24*60); } + /** + * 当天的开始时间 + * + * @return 今天开始时间 + */ + public static Long getDayOfStart(Date date) { + return date.getTime()/(60*24*60); + } /** * 当天的开始时间 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 478dd111..e13fc1d5 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -149,13 +149,13 @@ public class StoreFlowServiceImpl extends ServiceImpl QueryWrapper queryWrapper() { + //组织查询时间 + QueryWrapper queryWrapper = new QueryWrapper<>(); + StatisticsQueryParam statisticsQueryParam = new StatisticsQueryParam(); + BeanUtils.copyProperties(this, statisticsQueryParam); + Date[] dates = StatisticsDateUtil.getDateArray(statisticsQueryParam); + + //获取当前时间 + Calendar calendar = Calendar.getInstance(); + + + calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + + if (StringUtils.isNotEmpty(keywords)) { + queryWrapper.like("keywords", keywords); + } + queryWrapper.between("create_time", dates[0], dates[1]); + + startTIme = dates[0]; + endTime = dates[1]; + + return queryWrapper; + } + +} diff --git a/framework/src/main/java/cn/lili/modules/search/entity/vo/HotWordsHistoryVO.java b/framework/src/main/java/cn/lili/modules/search/entity/vo/HotWordsHistoryVO.java new file mode 100644 index 00000000..cbbdc0f9 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/entity/vo/HotWordsHistoryVO.java @@ -0,0 +1,33 @@ +package cn.lili.modules.search.entity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.Date; + +/** + * 在线会员 + * + * @author Chopper + * @since 2021-02-21 09:59 + */ +@Data +public class HotWordsHistoryVO { + + /** + * 时间 + */ + private Date createTime; + + /** + * 词 + */ + private String keywords; + + /** + * 分数 + */ + private Integer score; + +} diff --git a/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java b/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java new file mode 100644 index 00000000..31750ae8 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java @@ -0,0 +1,32 @@ +package cn.lili.modules.search.mapper; + +import cn.lili.modules.search.entity.dos.CustomWords; +import cn.lili.modules.search.entity.dos.HotWordsHistory; +import cn.lili.modules.search.entity.vo.HotWordsHistoryVO; +import cn.lili.modules.statistics.entity.vo.OrderStatisticsDataVO; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * 搜索热词历史记录数据处理层 + * + * @author paulG + * @since 2020/10/15 + **/ +public interface HotWordsHistoryMapper extends BaseMapper { + + /** + * 获取订单统计数据 + * + * @param queryWrapper 查询条件 + * @return 订单统计列表 + */ + @Select("SELECT score,keywords,DATE_FORMAT(create_time,'%Y-%m-%d') AS create_time FROM li_hot_words_history " +" ${ew.customSqlSegment}") + List statistics(@Param(Constants.WRAPPER) Wrapper queryWrapper); + +} diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java index 0e50be00..84ac2222 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java @@ -26,28 +26,6 @@ public interface EsGoodsSearchService { */ SearchPage searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo); - /** - * 获取热门关键词 - * - * @param count 热词数量 - * @return 热词集合 - */ - List getHotWords(Integer count); - - /** - * 设置热门关键词 - * - * @param hotWords 热词分数 - */ - void setHotWords(HotWordsDTO hotWords); - - /** - * 删除热门关键词 - * - * @param keywords 热词 - */ - void deleteHotWords(String keywords); - /** * 获取筛选器 * diff --git a/framework/src/main/java/cn/lili/modules/search/service/HotWordsHistoryService.java b/framework/src/main/java/cn/lili/modules/search/service/HotWordsHistoryService.java new file mode 100644 index 00000000..d357b643 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/service/HotWordsHistoryService.java @@ -0,0 +1,41 @@ +package cn.lili.modules.search.service; + +import cn.lili.modules.search.entity.dos.CustomWords; +import cn.lili.modules.search.entity.dos.HotWordsHistory; +import cn.lili.modules.search.entity.dto.HotWordsDTO; +import cn.lili.modules.search.entity.dto.HotWordsSearchParams; +import cn.lili.modules.search.entity.vo.HotWordsHistoryVO; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.poi.ss.formula.functions.T; + +import java.util.Date; +import java.util.List; + +/** + * HotWordsService + * + * @author Chopper + * @version v1.0 + * 2022-04-14 09:35 + */ +public interface HotWordsHistoryService extends IService { + + /** + * 热词统计 + * + * @param hotWordsSearchParams + * @return + */ + List statistics(HotWordsSearchParams hotWordsSearchParams); + + /** + * 根据时间查询 + * + * @param queryTime 查询时间 + * @return + */ + List queryByDay(Date queryTime); +} diff --git a/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java b/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java new file mode 100644 index 00000000..d69c0f27 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java @@ -0,0 +1,38 @@ +package cn.lili.modules.search.service; + +import cn.lili.modules.search.entity.dto.HotWordsDTO; + +import java.util.List; + +/** + * HotWordsService + * + * @author Chopper + * @version v1.0 + * 2022-04-14 09:35 + */ +public interface HotWordsService { + + /** + * 获取热门关键词 + * + * @param count 热词数量 + * @return 热词集合 + */ + List getHotWords(Integer count); + + /** + * 设置热门关键词 + * + * @param hotWords 热词分数 + */ + void setHotWords(HotWordsDTO hotWords); + + /** + * 删除热门关键词 + * + * @param keywords 热词 + */ + void deleteHotWords(String keywords); + +} diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 63d53d13..ac19929b 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -100,38 +100,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { return SearchHitSupport.searchPageFor(search, searchQuery.getPageable()); } - @Override - public List getHotWords(Integer count) { - if (count == null) { - count = 0; - } - List hotWords = new ArrayList<>(); - // redis 排序中,下标从0开始,所以这里需要 -1 处理 - count = count - 1; - Set> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), count); - if (set == null || set.isEmpty()) { - return new ArrayList<>(); - } - for (ZSetOperations.TypedTuple defaultTypedTuple : set) { - hotWords.add(Objects.requireNonNull(defaultTypedTuple.getValue()).toString()); - } - return hotWords; - } - - @Override - public void setHotWords(HotWordsDTO hotWords) { - cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint()); - } - - /** - * 删除热门关键词 - * - * @param keywords 热词 - */ - @Override - public void deleteHotWords(String keywords) { - cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords); - } @Override public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) { @@ -177,6 +145,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { return this.restTemplate.get(id, EsGoodsIndex.class); } + /** * 转换搜索结果为聚合商品展示信息 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java new file mode 100644 index 00000000..e55aee93 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java @@ -0,0 +1,73 @@ +package cn.lili.modules.search.serviceimpl; + +import cn.lili.modules.search.entity.dos.HotWordsHistory; +import cn.lili.modules.search.entity.dto.HotWordsSearchParams; +import cn.lili.modules.search.mapper.HotWordsHistoryMapper; +import cn.lili.modules.search.service.HotWordsHistoryService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 历史热词 + * + * @author paulG + * @since 2020/10/15 + **/ +@Service +public class HotWordsHistoryServiceImpl extends ServiceImpl implements HotWordsHistoryService { + + @Override + public List statistics(HotWordsSearchParams hotWordsSearchParams) { + QueryWrapper queryWrapper = hotWordsSearchParams.queryWrapper(); + + List list = baseMapper.statistics(queryWrapper); + return initData(list, hotWordsSearchParams); + } + + @Override + public List queryByDay(Date queryTime) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("create_time", queryTime); + return list(queryWrapper); + } + + /** + * 历史统计查询 + * + * @param source + * @return + */ + private List initData(List source, HotWordsSearchParams hotWordsSearchParams) { + + //结果集 + List onlineMemberVOS = new ArrayList<>(); + //时间初始化 + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-8:00")); + calendar.setTime(hotWordsSearchParams.getStartTIme()); + //判定是否超出时间 如果结束时间在循环时间之后,则跳出循环 + while (hotWordsSearchParams.getEndTime().after(calendar.getTime())) { + +// //筛选时间相等的查询结果 + Optional first = source.stream().filter(item -> item.getCreateTime().equals(calendar.getTime())).findFirst(); + if (first.isPresent()) { + onlineMemberVOS.add(first.get()); + } else { + onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime())); + } +// for (HotWordsHistory hotWordsHistory : source) { +// System.out.println(hotWordsHistory.getCreateTime().getTime() + "-" + calendar.getTime().getTime()); +// if (hotWordsHistory.getCreateTime().equals(calendar.getTime())) { +// onlineMemberVOS.add(hotWordsHistory); +// } else { +// onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime())); +// } +// } + + calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1); + } + return onlineMemberVOS; + } +} diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java new file mode 100644 index 00000000..26b29ebe --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java @@ -0,0 +1,68 @@ +package cn.lili.modules.search.serviceimpl; + +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; +import cn.lili.modules.search.entity.dto.HotWordsDTO; +import cn.lili.modules.search.mapper.HotWordsHistoryMapper; +import cn.lili.modules.search.service.HotWordsService; +import cn.lili.modules.system.entity.dos.Setting; +import cn.lili.modules.system.entity.enums.SettingEnum; +import cn.lili.modules.system.service.SettingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.ZSetOperations; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +/** + * HotWordsServiceImpl + * + * @author Chopper + * @version v1.0 + * 2022-04-14 09:35 + */ +@Service +public class HotWordsServiceImpl implements HotWordsService { + + /** + * 缓存 + */ + @Autowired + private Cache cache; + @Override + public List getHotWords(Integer count) { + if (count == null) { + count = 0; + } + List hotWords = new ArrayList<>(); + // redis 排序中,下标从0开始,所以这里需要 -1 处理 + count = count - 1; + Set> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), count); + if (set == null || set.isEmpty()) { + return new ArrayList<>(); + } + for (ZSetOperations.TypedTuple defaultTypedTuple : set) { + hotWords.add(Objects.requireNonNull(defaultTypedTuple.getValue()).toString()); + } + return hotWords; + } + + @Override + public void setHotWords(HotWordsDTO hotWords) { + cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint()); + } + + /** + * 删除热门关键词 + * + * @param keywords 热词 + */ + @Override + public void deleteHotWords(String keywords) { + cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords); + } + +} diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index f5eecdb6..8ff1b3dc 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -70,7 +70,7 @@ public class BillServiceImpl extends ServiceImpl implements Bi //结算基础信息 bill.setStartTime(startTime); - bill.setEndTime(DateUtil.yesterday()); + bill.setEndTime(endTime); bill.setBillStatus(BillStatusEnum.OUT.name()); bill.setStoreId(storeId); bill.setStoreName(store.getStoreName()); diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSetting.java new file mode 100644 index 00000000..0b98d43b --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSetting.java @@ -0,0 +1,28 @@ +package cn.lili.modules.system.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 搜索热词 + * + * @author Bulbasaur + * @since 2021/5/16 11:10 下午 + */ +@Data +public class HotWordsSetting implements Serializable { + + //热词1-5,默认分数1-5 + + @ApiModelProperty(value = "热词默认配置") + private List hotWordsSettingItems = new ArrayList<>(); + + + @ApiModelProperty("每日保存数量") + private Integer saveNum; + +} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSettingItem.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSettingItem.java new file mode 100644 index 00000000..41fa826c --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/HotWordsSettingItem.java @@ -0,0 +1,41 @@ +package cn.lili.modules.system.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 积分签到设置 + * + * @author Chopper + * @since 2021-02-26 11:48 + */ +@Data +public class HotWordsSettingItem implements Comparable, Serializable { + + + @ApiModelProperty(value = "热词") + private String keywords; + + + @ApiModelProperty(value = "默认分数") + private Integer score; + + + public Integer getScore() { + if (score == null || score < 0) { + return 0; + } + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + @Override + public int compareTo(HotWordsSettingItem pointSettingItem) { + return pointSettingItem.getScore(); + } +} diff --git a/framework/src/main/java/cn/lili/modules/system/entity/enums/SettingEnum.java b/framework/src/main/java/cn/lili/modules/system/entity/enums/SettingEnum.java index ec6b1e23..55f55c84 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/enums/SettingEnum.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/enums/SettingEnum.java @@ -44,5 +44,7 @@ public enum SettingEnum { //支付宝支付设置 ALIPAY_PAYMENT, //微信支付设置 - WECHAT_PAYMENT; + WECHAT_PAYMENT, + //热词设置 + HOT_WORDS } diff --git a/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java b/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java deleted file mode 100644 index ce4eb8d3..00000000 --- a/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.lili.controller.hotwords; - -import cn.lili.common.enums.ResultUtil; -import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.search.entity.dto.HotWordsDTO; -import cn.lili.modules.search.service.EsGoodsSearchService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -/** - * 管理端,app版本控制器 - * - * @author Chopper - * @since 2018-07-04 21:50:52 - */ -@RestController -@Api(tags = "管理端,系统设置扩展接口") -@RequestMapping("/manager/hotwords/hotwords") -public class HotWordsManagerController { - - @Autowired - private EsGoodsSearchService esGoodsSearchService; - - @ApiOperation(value = "获取热词") - @GetMapping - public ResultMessage getHotWords() { - return ResultUtil.data(esGoodsSearchService.getHotWords(100)); - } - - @ApiOperation(value = "设置热词") - @PostMapping - public ResultMessage paymentForm(@Validated HotWordsDTO hotWords) { - esGoodsSearchService.setHotWords(hotWords); - return ResultUtil.success(); - } - - @ApiOperation(value = "设置热词") - @DeleteMapping("/{words}") - public ResultMessage deleteWords(@PathVariable String words) { - esGoodsSearchService.deleteHotWords(words); - return ResultUtil.success(); - } - -} diff --git a/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java new file mode 100644 index 00000000..79240ea9 --- /dev/null +++ b/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java @@ -0,0 +1,79 @@ +package cn.lili.controller.other; + +import cn.lili.common.enums.ResultUtil; +import cn.lili.common.vo.ResultMessage; +import cn.lili.modules.search.entity.dto.HotWordsDTO; +import cn.lili.modules.search.entity.dto.HotWordsSearchParams; +import cn.lili.modules.search.service.HotWordsHistoryService; +import cn.lili.modules.search.service.HotWordsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.Data; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 管理端,热词管理 + * + * @author Chopper + * @since 2018-07-04 21:50:52 + */ +@RestController +@Api(tags = "管理端,热词管理") +@RequestMapping("/manager/hotwords/hotwords") +public class HotWordsManagerController { + + @Autowired + private HotWordsService hotWordsService; + + + @Autowired + private HotWordsHistoryService hotWordsHistoryService; + + @ApiOperation(value = "获取热词") + @GetMapping + public ResultMessage getHotWords() { + return ResultUtil.data(hotWordsService.getHotWords(100)); + } + + @ApiOperation(value = "设置热词") + @PostMapping + public ResultMessage setHotWords(@Validated HotWordsDTO hotWords) { + hotWordsService.setHotWords(hotWords); + return ResultUtil.success(); + } + + @ApiOperation(value = "删除热词") + @DeleteMapping + public ResultMessage deleteWords(String words) { + hotWordsService.deleteHotWords(words); + return ResultUtil.success(); + } + + @ApiOperation(value = "历史热词") + @GetMapping("/history") + public ResultMessage deleteWords(HistorySearchParams historySearchParams) { + return ResultUtil.data(hotWordsHistoryService.queryByDay(historySearchParams.getDate())); + } + + @ApiOperation(value = "热词统计") + @GetMapping("/statistics") + public ResultMessage deleteWords(HotWordsSearchParams hotWordsSearchParams) { + return ResultUtil.data(hotWordsHistoryService.statistics(hotWordsSearchParams)); + } + + +} + +@Data +class HistorySearchParams { + @DateTimeFormat(pattern = "yyyy-MM-dd") + @NotNull(message = "查询日期不能为空") + private Date date; + +} diff --git a/manager-api/src/main/java/cn/lili/controller/setting/SettingManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/SettingManagerController.java index e0f9c48d..bf85cf9b 100644 --- a/manager-api/src/main/java/cn/lili/controller/setting/SettingManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/SettingManagerController.java @@ -185,6 +185,10 @@ public class SettingManagerController { return setting == null ? ResultUtil.data(new ImSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class)); + case HOT_WORDS: + return setting == null ? + ResultUtil.data(new HotWordsSetting()) : + ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class)); default: throw new ServiceException(ResultCode.SETTING_NOT_TO_SET); } From ce1954e7d354e5cbc2251d1bc6d7d98a28dd3583 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Apr 2022 09:39:33 +0800 Subject: [PATCH 044/185] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E8=80=85=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/hotwords/HotWordsEveryDayTaskExecute.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java index 99f365f9..ecf63d58 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/hotwords/HotWordsEveryDayTaskExecute.java @@ -59,7 +59,7 @@ public class HotWordsEveryDayTaskExecute implements EveryDayExecute { for (DefaultTypedTuple tuple : tuples) { String keywords = (String) tuple.getValue(); Double score = tuple.getScore(); - hotWordsHistories.add(new HotWordsHistory(calendar.getTime(), keywords, score.intValue())); + hotWordsHistories.add(new HotWordsHistory(keywords, score.intValue(), calendar.getTime())); } hotWordsHistoryService.saveBatch(hotWordsHistories); From 89c5c2dd838928dddab10fa5c07524cc64584d82 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Apr 2022 10:18:25 +0800 Subject: [PATCH 045/185] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/entity/vo/EvaluationNumberVO.java | 2 +- .../cn/lili/modules/member/mapper/MemberEvaluationMapper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/entity/vo/EvaluationNumberVO.java b/framework/src/main/java/cn/lili/modules/member/entity/vo/EvaluationNumberVO.java index 92084f43..52d8b772 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/vo/EvaluationNumberVO.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/vo/EvaluationNumberVO.java @@ -12,7 +12,7 @@ import lombok.Data; @Data public class EvaluationNumberVO { - @ApiModelProperty(value = "全部商品") + @ApiModelProperty(value = "全部评价") private Integer all; @ApiModelProperty(value = "好评数量") diff --git a/framework/src/main/java/cn/lili/modules/member/mapper/MemberEvaluationMapper.java b/framework/src/main/java/cn/lili/modules/member/mapper/MemberEvaluationMapper.java index f6b88ce2..3806ea47 100644 --- a/framework/src/main/java/cn/lili/modules/member/mapper/MemberEvaluationMapper.java +++ b/framework/src/main/java/cn/lili/modules/member/mapper/MemberEvaluationMapper.java @@ -38,7 +38,7 @@ public interface MemberEvaluationMapper extends BaseMapper { * @param goodsId 商品ID * @return 会员评价 */ - @Select("select grade,count(1) as num from li_member_evaluation Where goods_id=#{goodsId} and status='OPEN' GROUP BY grade") + @Select("select grade,count(1) as num from li_member_evaluation Where goods_id=#{goodsId} and status='OPEN' and delete_flag = false GROUP BY grade") List> getEvaluationNumber(String goodsId); /** From 0203630d6a315c6bf187fe3f8815d2a6bf345c73 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 20 Apr 2022 09:39:03 +0800 Subject: [PATCH 046/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 32 +++++++++++++++++++ .../event/GeneratorEsGoodsIndexEvent.java | 11 +++++-- .../GeneratorEsGoodsIndexListener.java | 5 ++- .../modules/goods/service/GoodsService.java | 11 +++++++ .../goods/service/GoodsSkuService.java | 9 ++++++ .../goods/serviceimpl/GoodsServiceImpl.java | 23 +++++++++++++ .../serviceimpl/GoodsSkuServiceImpl.java | 30 +++++++++++++++-- .../search/service/EsGoodsIndexService.java | 4 +-- .../serviceimpl/EsGoodsIndexServiceImpl.java | 19 +++++++---- .../cn/lili/rocketmq/tags/GoodsTagsEnum.java | 8 +++++ 10 files changed, 135 insertions(+), 17 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 558b7c30..45c1ea98 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -140,6 +140,14 @@ public class GoodsMessageListener implements RocketMQListener { log.error("生成商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); } break; + case GENERATOR_STORE_GOODS_INDEX: + try { + String storeId = new String(messageExt.getBody()); + this.updateGoodsIndex(storeId); + } catch (Exception e) { + log.error("生成店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + } + break; case UPDATE_GOODS_INDEX_PROMOTIONS: this.updateGoodsIndexPromotions(new String(messageExt.getBody())); break; @@ -220,6 +228,14 @@ public class GoodsMessageListener implements RocketMQListener { List skuIds = JSONUtil.toList(message, String.class); goodsCollectionService.deleteSkuCollection(skuIds); break; + case STORE_GOODS_DELETE: + try { + String storeId = new String(messageExt.getBody()); + goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("storeId", storeId).build()); + } catch (Exception e) { + log.error("删除店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + } + break; //商品评价 case GOODS_COMMENT_COMPLETE: MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class); @@ -308,6 +324,22 @@ public class GoodsMessageListener implements RocketMQListener { goodsIndexService.updateBulkIndex(goodsIndices); } + + /** + * 更新商品索引根据店铺id + * + * @param storeId 店铺id + */ + private void updateGoodsIndex(String storeId) { + //如果商品通过审核&&并且已上架 + GoodsSearchParams searchParams = new GoodsSearchParams(); + searchParams.setStoreId(storeId); + for (Goods goods : this.goodsService.queryListByParams(searchParams)) { + this.updateGoodsIndex(goods); + } + + } + /** * 更新商品索引 * diff --git a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java index ff5da90f..4088b5aa 100644 --- a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java +++ b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java @@ -10,10 +10,15 @@ import org.springframework.context.ApplicationEvent; @Data public class GeneratorEsGoodsIndexEvent extends ApplicationEvent { - private String goodsId; + private static final long serialVersionUID = -6206752641309458207L; - public GeneratorEsGoodsIndexEvent(Object source, String goodsId) { + private String id; + + private String tag; + + public GeneratorEsGoodsIndexEvent(Object source, String tag, String id) { super(source); - this.goodsId = goodsId; + this.tag = tag; + this.id = id; } } diff --git a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java index 7c5b95ba..175e0b13 100644 --- a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java +++ b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java @@ -3,7 +3,6 @@ package cn.lili.modules.goods.listener; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; -import cn.lili.rocketmq.tags.GoodsTagsEnum; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -30,9 +29,9 @@ public class GeneratorEsGoodsIndexListener { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) { - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + esGoodsIndexEvent.getTag(); //发送mq消息 - rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getGoodsId(), RocketmqSendCallbackBuilder.commonCallback()); + rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getId(), RocketmqSendCallbackBuilder.commonCallback()); } } diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index 16ac93e4..d06a4344 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -112,6 +112,17 @@ public interface GoodsService extends IService { */ Boolean updateGoodsMarketAble(List goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason); + + /** + * 更新商品上架状态状态 + * + * @param storeId 店铺ID + * @param goodsStatusEnum 更新的商品状态 + * @param underReason 下架原因 + * @return 更新结果 + */ + Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason); + /** * 更新商品上架状态状态 * 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 40c25077..b723f936 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 @@ -151,6 +151,15 @@ public interface GoodsSkuService extends IService { */ void updateGoodsSkuStatus(Goods goods); + /** + * 更新商品sku状态根据店铺id + * + * @param storeId 店铺id + * @param marketEnable 市场启用状态 + * @param authFlag 审核状态 + */ + void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag); + /** * 发送生成ES商品索引 * 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 ee8fe200..25792d2a 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 @@ -316,6 +316,29 @@ public class GoodsServiceImpl extends ServiceImpl implements return result; } + /** + * 更新商品上架状态状态 + * + * @param storeId 店铺ID + * @param goodsStatusEnum 更新的商品状态 + * @param underReason 下架原因 + * @return 更新结果 + */ + @Override + public Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason) { + boolean result; + + LambdaUpdateWrapper updateWrapper = this.getUpdateWrapperByStoreAuthority(); + updateWrapper.set(Goods::getMarketEnable, goodsStatusEnum.name()); + updateWrapper.set(Goods::getUnderMessage, underReason); + updateWrapper.eq(Goods::getStoreId, storeId); + result = this.update(updateWrapper); + + //修改规格商品 + this.goodsSkuService.updateGoodsSkuStatusByStoreId(storeId, goodsStatusEnum.name(), null); + return result; + } + @Override @Transactional(rollbackFor = Exception.class) public Boolean managerUpdateGoodsMarketAble(List goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) { 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 f7a5932f..d960c34e 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 @@ -325,7 +325,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Transactional(rollbackFor = Exception.class) public void updateGoodsSkuStatus(Goods goods) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(GoodsSku::getGoodsId, goods.getId()); + updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getId()), GoodsSku::getGoodsId, goods.getId()); + updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getStoreId()), GoodsSku::getStoreId, goods.getStoreId()); updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable()); updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag()); updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag()); @@ -342,6 +343,31 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } } + /** + * 更新商品sku状态根据店铺id + * + * @param storeId 店铺id + * @param marketEnable 市场启用状态 + * @param authFlag 审核状态 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(GoodsSku::getStoreId, storeId); + updateWrapper.set(CharSequenceUtil.isNotEmpty(marketEnable), GoodsSku::getMarketEnable, marketEnable); + updateWrapper.set(CharSequenceUtil.isNotEmpty(authFlag), GoodsSku::getAuthFlag, authFlag); + boolean update = this.update(updateWrapper); + if (Boolean.TRUE.equals(update)) { + if (GoodsStatusEnum.UPPER.name().equals(marketEnable)) { + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成店铺商品", GoodsTagsEnum.GENERATOR_STORE_GOODS_INDEX.name(), storeId)); + } else if (GoodsStatusEnum.DOWN.name().equals(marketEnable)) { + cache.vagueDel(CachePrefix.GOODS_SKU.getPrefix()); + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("删除店铺商品", GoodsTagsEnum.STORE_GOODS_DELETE.name(), storeId)); + } + } + } + @Override public List getGoodsSkuByIdFromCache(List ids) { List keys = new ArrayList<>(); @@ -563,7 +589,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { return; } - applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId())); + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品", GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId())); } /** diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index 3adff571..e5a93839 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -71,9 +71,9 @@ public interface EsGoodsIndexService { /** * 删除索引 * - * @param goods 商品索引信息 + * @param queryFields 查询条件 (key 为字段,value为字段值) */ - void deleteIndex(EsGoodsIndex goods); + void deleteIndex(Map queryFields); /** * 删除索引 diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 8ae29f80..ee5f4a76 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -59,7 +59,6 @@ import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; import java.io.IOException; import java.lang.reflect.Field; @@ -287,13 +286,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } + /** + * 删除索引 + * + * @param queryFields 查询条件 + */ @Override - public void deleteIndex(EsGoodsIndex goods) { - if (ObjectUtils.isEmpty(goods)) { - //如果对象为空,则删除全量 - goodsIndexRepository.deleteAll(); + public void deleteIndex(Map queryFields) { + NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder(); + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + for (Map.Entry entry : queryFields.entrySet()) { + boolQueryBuilder.filter(QueryBuilders.termsQuery(entry.getKey(), entry.getValue())); } - goodsIndexRepository.delete(goods); + queryBuilder.withQuery(boolQueryBuilder); + this.restTemplate.delete(queryBuilder.build(), EsGoodsIndex.class); } /** @@ -316,7 +322,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder(); queryBuilder.withQuery(QueryBuilders.termsQuery("id", ids.toArray())); this.restTemplate.delete(queryBuilder.build(), EsGoodsIndex.class); - } @Override diff --git a/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java b/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java index 651e4ce5..e34525de 100644 --- a/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java +++ b/framework/src/main/java/cn/lili/rocketmq/tags/GoodsTagsEnum.java @@ -10,6 +10,10 @@ public enum GoodsTagsEnum { * "生成商品索引" */ GENERATOR_GOODS_INDEX("生成商品索引"), + /** + * "生成店铺商品索引" + */ + GENERATOR_STORE_GOODS_INDEX("生成店铺商品索引"), /** * "更新商品索引" */ @@ -31,6 +35,10 @@ public enum GoodsTagsEnum { * "重置商品索引" */ RESET_GOODS_INDEX("重置商品索引"), + /** + * "删除店铺商品索引" + */ + STORE_GOODS_DELETE("删除店铺商品索引"), /** * "删除商品" */ From 29941310481c9452abbbc5a6b0757fb600cbdd1a Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 21 Apr 2022 10:11:21 +0800 Subject: [PATCH 047/185] =?UTF-8?q?=E5=BD=93=E7=BB=93=E7=AE=97=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E5=8F=AA=E6=9C=89=E4=B8=80=E5=A4=A9=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=BB=93=E7=AE=97=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/store/mapper/StoreDetailMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java b/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java index e2b3fe7b..eed9ade0 100644 --- a/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java +++ b/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java @@ -69,7 +69,8 @@ public interface StoreDetailMapper extends BaseMapper { @Select("SELECT store_id,settlement_day FROM li_store_detail " + "WHERE settlement_cycle LIKE concat(#{day},',%') " + "OR settlement_cycle LIKE concat('%,',#{day},',%') " + - "OR settlement_cycle LIKE concat('%,',#{day})") + "OR settlement_cycle LIKE concat('%,',#{day})"+ + "OR settlement_cycle = #{day}") List getSettlementStore(int day); /** From 1917aa13d511974ec9b8a0d5824fe163ec25dfd3 Mon Sep 17 00:00:00 2001 From: fengtianyangyang Date: Thu, 21 Apr 2022 10:51:12 +0800 Subject: [PATCH 048/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/store/mapper/BillMapper.java | 16 ++++++++-------- .../store/serviceimpl/BillServiceImpl.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/store/mapper/BillMapper.java b/framework/src/main/java/cn/lili/modules/store/mapper/BillMapper.java index c6e1ea90..8d0c4724 100644 --- a/framework/src/main/java/cn/lili/modules/store/mapper/BillMapper.java +++ b/framework/src/main/java/cn/lili/modules/store/mapper/BillMapper.java @@ -35,11 +35,11 @@ public interface BillMapper extends BaseMapper { * @param queryWrapper 查询条件 * @return 结算单 */ - @Select("SELECT SUM( final_price ) AS orderPrice,SUM( commission_price ) AS commissionPrice" + - ",SUM( distribution_rebate ) AS distributionCommission,SUM( site_coupon_commission ) AS siteCouponCommission" + - ",SUM( point_settlement_price ) AS pointSettlementPrice " + - ",SUM( kanjia_settlement_price ) AS kanjiaSettlementPrice " + - ",SUM( bill_price ) AS billPrice " + + @Select("SELECT IFNULL(SUM( final_price ),0) AS orderPrice,IFNULL(SUM( commission_price ),0) AS commissionPrice" + + ",IFNULL(SUM( distribution_rebate ),0) AS distributionCommission,IFNULL(SUM( site_coupon_commission ),0) AS siteCouponCommission" + + ",IFNULL(SUM( point_settlement_price ),0) AS pointSettlementPrice " + + ",IFNULL(SUM( kanjia_settlement_price ),0) AS kanjiaSettlementPrice " + + ",IFNULL(SUM( bill_price ),0) AS billPrice " + "FROM li_store_flow ${ew.customSqlSegment}") Bill getOrderBill(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); @@ -49,8 +49,8 @@ public interface BillMapper extends BaseMapper { * @param queryWrapper 查询条件 * @return 结算单 */ - @Select("SELECT SUM( final_price ) AS refundPrice,SUM( commission_price ) AS refundCommissionPrice" + - ",SUM( distribution_rebate ) AS distributionRefundCommission,SUM( site_coupon_commission ) AS siteCouponRefundCommission" + - ",SUM( final_price ) AS billPrice FROM li_store_flow ${ew.customSqlSegment}") + @Select("SELECT IFNULL(SUM( final_price ),0) AS refundPrice,IFNULL(SUM( commission_price ),0) AS refundCommissionPrice" + + ",IFNULL(SUM( distribution_rebate ),0) AS distributionRefundCommission,IFNULL(SUM( site_coupon_commission ),0) AS siteCouponRefundCommission" + + ",IFNULL(SUM( final_price ),0) AS billPrice FROM li_store_flow ${ew.customSqlSegment}") Bill getRefundBill(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index d74c4339..3b9e2f1d 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -103,7 +103,7 @@ public class BillServiceImpl extends ServiceImpl implements Bi //分销订单退还,返现佣金返还 bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission()); //退货平台优惠券补贴返还 - bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()!=null?refundBill.getSiteCouponRefundCommission():0D); + bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()); //退款金额=店铺最终退款结算金额 refundPrice = refundBill.getBillPrice(); } From 0148868129dcb96e87f79778f437c977438fc8b8 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 21 Apr 2022 15:49:53 +0800 Subject: [PATCH 049/185] =?UTF-8?q?=E5=88=86=E7=B1=BB=E9=80=92=E5=BD=92?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c08865d9..70b29346 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 @@ -335,7 +335,7 @@ public class CategoryServiceImpl extends ServiceImpl i return item.getChildren(); } if (item.getChildren() != null && !item.getChildren().isEmpty()) { - return getChildren(parentId, categoryVOList); + return getChildren(parentId, item.getChildren()); } } return categoryVOList; From 9f965c4e567ee793fcf31478870c3a9cb03a287f Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 21 Apr 2022 16:25:43 +0800 Subject: [PATCH 050/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=96=E6=B6=88=E5=90=8E=E8=B5=A0=E5=93=81=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=B8=8D=E4=BC=9A=E5=8F=96=E6=B6=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82=E4=BC=98=E5=8C=96=E7=83=AD=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/event/impl/FullDiscountExecute.java | 11 +++++++++++ .../java/cn/lili/event/impl/StockUpdateExecute.java | 3 ++- .../search/serviceimpl/EsGoodsSearchServiceImpl.java | 6 +++++- .../hotwords/HotWordsManagerController.java | 9 ++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java index a3507d83..86a08cbb 100644 --- a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java @@ -19,6 +19,7 @@ import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dto.OrderMessage; +import cn.lili.modules.order.order.entity.dto.OrderSearchParams; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.*; import cn.lili.modules.order.order.service.OrderItemService; @@ -96,6 +97,15 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { if (orderMessage.getNewStatus().equals(OrderStatusEnum.PAID)) { log.debug("满减活动,订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()); renderGift(JSONUtil.toBean(cache.getString(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), CartVO.class), orderMessage); + } else if (orderMessage.getNewStatus().equals(OrderStatusEnum.CANCELLED)) { + log.debug("满减活动,取消订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()); + OrderSearchParams searchParams = new OrderSearchParams(); + searchParams.setParentOrderSn(orderMessage.getOrderSn()); + searchParams.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name()); + List orders = orderService.queryListByParams(searchParams); + if (orders != null && !orders.isEmpty()) { + orderService.systemCancel(orders.get(0).getSn(),"主订单取消,赠送订单字段自动取消"); + } } } @@ -190,6 +200,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { BeanUtil.copyProperties(priceDetailDTO, order, "id"); //生成订单参数 order.setSn(SnowFlake.createStr("G")); + order.setParentOrderSn(originOrder.getSn()); order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name()); order.setOrderStatus(OrderStatusEnum.UNPAID.name()); order.setPayStatus(PayStatusEnum.PAID.name()); 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 77806014..e03d38c0 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * 库存扣减,他表示了订单状态是否出库成功 @@ -156,7 +157,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { * @param stocks */ private void checkStocks(List stocks, OrderDetailVO order) { - if (order.getOrderItems().size() == stocks.size()) { + if (!stocks.isEmpty() && order.getOrderItems().size() == stocks.size() && stocks.stream().anyMatch(Objects::nonNull)) { return; } initSkuCache(order.getOrderItems()); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 63d53d13..bafc965d 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -130,7 +130,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { */ @Override public void deleteHotWords(String keywords) { - cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords); + if (CharSequenceUtil.isEmpty(keywords)) { + cache.vagueDel(CachePrefix.HOT_WORD.getPrefix()); + } else { + cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords); + } } @Override diff --git a/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java b/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java index ce4eb8d3..cf7a46d3 100644 --- a/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/hotwords/HotWordsManagerController.java @@ -37,11 +37,18 @@ public class HotWordsManagerController { return ResultUtil.success(); } - @ApiOperation(value = "设置热词") + @ApiOperation(value = "删除热词") @DeleteMapping("/{words}") public ResultMessage deleteWords(@PathVariable String words) { esGoodsSearchService.deleteHotWords(words); return ResultUtil.success(); } + @ApiOperation(value = "删除全部热词") + @DeleteMapping("") + public ResultMessage deleteWordsAll() { + esGoodsSearchService.deleteHotWords(null); + return ResultUtil.success(); + } + } From 4c1ae8c3ccc2a6f07a0d57d31e6c49ed41399615 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 22 Apr 2022 09:11:51 +0800 Subject: [PATCH 051/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=AF=E5=8A=A8=E6=97=B6=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E9=80=A0=E6=88=90es=20client=20must=20not=20be=20null?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/elasticsearch/config/ElasticsearchConfig.java | 6 ------ .../permission/serviceimpl/SystemLogServiceImpl.java | 6 ++---- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 8 +++----- .../search/serviceimpl/EsGoodsSearchServiceImpl.java | 6 ++---- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java index 38b63496..b80da178 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java +++ b/framework/src/main/java/cn/lili/elasticsearch/config/ElasticsearchConfig.java @@ -16,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import javax.annotation.PreDestroy; import java.io.IOException; @@ -69,11 +68,6 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration { return client; } - @Bean("elasticsearchRestTemplate") - public ElasticsearchRestTemplate elasticsearchRestTemplate() { - return new ElasticsearchRestTemplate(this.client); - } - private HttpHost[] getHttpHosts() { List clusterNodes = elasticsearchProperties.getClusterNodes(); HttpHost[] httpHosts = new HttpHost[clusterNodes.size()]; diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java index 7b519465..693794c0 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/SystemLogServiceImpl.java @@ -14,10 +14,9 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; @@ -42,8 +41,7 @@ public class SystemLogServiceImpl implements SystemLogService { * ES */ @Autowired - @Qualifier("elasticsearchRestTemplate") - private ElasticsearchRestTemplate restTemplate; + private ElasticsearchOperations restTemplate; @Override public void saveLog(SystemLogVO systemLogVO) { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index ee5f4a76..c78a96af 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -53,8 +53,7 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.mybatis.spring.MyBatisSystemException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; @@ -116,8 +115,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Autowired - @Qualifier("elasticsearchRestTemplate") - private ElasticsearchRestTemplate restTemplate; + private ElasticsearchOperations restTemplate; @Override public void init() { @@ -504,7 +502,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements /** * 从索引中删除指定促销活动id的促销活动 * - * @param goodsIndex 索引 + * @param goodsIndex 索引 * @param promotionsKey 促销活动key */ private UpdateRequest removePromotionByPromotionKey(EsGoodsIndex goodsIndex, String promotionsKey) { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index bafc965d..d5d252b0 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -36,10 +36,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHitSupport; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchPage; @@ -73,8 +72,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { * ES */ @Autowired - @Qualifier("elasticsearchRestTemplate") - private ElasticsearchRestTemplate restTemplate; + private ElasticsearchOperations restTemplate; @Autowired private EsGoodsIndexService esGoodsIndexService; From 2d574838053b310b1baa91077ee98e8370907239 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Fri, 22 Apr 2022 11:02:23 +0800 Subject: [PATCH 052/185] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E9=80=80=E6=AC=BE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/serviceimpl/StoreFlowServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index e4707a3f..8f888acd 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -78,6 +78,7 @@ public class StoreFlowServiceImpl extends ServiceImpl Date: Fri, 22 Apr 2022 11:10:42 +0800 Subject: [PATCH 053/185] =?UTF-8?q?=E5=94=AE=E5=90=8E=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/aftersale/serviceimpl/AfterSaleServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java index fa73ff32..7c011830 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java @@ -126,8 +126,9 @@ public class AfterSaleServiceImpl extends ServiceImpl Date: Fri, 22 Apr 2022 16:27:13 +0800 Subject: [PATCH 054/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=97=A0=E6=9C=89=E6=95=88=E5=95=86=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E9=80=A0=E6=88=90=E7=A9=BA=E8=AE=A2=E5=8D=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/src/main/java/cn/lili/common/enums/ResultCode.java | 1 + .../lili/modules/order/order/serviceimpl/TradeServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 1f352b7d..76637576 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -177,6 +177,7 @@ public enum ResultCode { MEMBER_ADDRESS_NOT_EXIST(31009, "订单无收货地址,请先配置收货地址"), ORDER_DELIVER_NUM_ERROR(31010, "没有待发货的订单"), ORDER_NOT_SUPPORT_DISTRIBUTION(31011, "购物车中包含不支持配送的商品,请重新选择收货地址,或者重新选择商品"), + ORDER_NOT_EXIST_VALID(31041, "购物车中无有效商品,请检查购物车内商品,或者重新选择商品"), ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"), ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"), diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java index 5d28a5b1..6094598d 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/TradeServiceImpl.java @@ -1 +1 @@ -package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @since 2020/11/17 7:39 下午 */ @Service public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO 购物车视图 */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override @Transactional(rollbackFor = Exception.class) public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO 购物车视图 */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId(), ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO 购物车视图 */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO 购物车视图 */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.endKanjiaActivity(kanjiaId); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @since 2020/11/17 7:39 下午 */ @Service public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO 购物车视图 */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } if (tradeDTO.getCartList().stream().noneMatch(CartVO::getChecked)) { throw new ServiceException(ResultCode.ORDER_NOT_EXIST_VALID); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override @Transactional(rollbackFor = Exception.class) public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO 购物车视图 */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId(), ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO 购物车视图 */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO 购物车视图 */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.endKanjiaActivity(kanjiaId); } } } \ No newline at end of file From 230a8810ef29d7227392ccaac2ac5f8eed928cf0 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Fri, 22 Apr 2022 18:44:32 +0800 Subject: [PATCH 055/185] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=93=81,?= =?UTF-8?q?=E7=A0=8D=E4=BB=B7=E5=95=86=E5=93=81=E7=BB=93=E7=AE=97=E5=8D=95?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 42 ++++++++++++------- .../cart/render/impl/CommissionRender.java | 3 +- .../serviceimpl/PointsGoodsServiceImpl.java | 1 + 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/config/application.yml b/config/application.yml index 703b96ae..ec630a15 100644 --- a/config/application.yml +++ b/config/application.yml @@ -25,11 +25,20 @@ spring: admin: client: url: http://192.168.0.116:8000 + # mongodb + data: + mongodb: + uri: 192.168.0.116:27017 + database: lilishop + username: root + password: lilishop + authentication-database: admin + # replica-set-name: mongoreplset cache: type: redis # Redis redis: - host: 192.168.0.116 + host: 101.43.251.145 port: 6379 password: lilishop lettuce: @@ -60,7 +69,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.0.116:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://101.43.251.145:3306/zhimai1?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop maxActive: 50 @@ -154,6 +163,8 @@ ignored: - /**/*.css - /**/*.png - /**/*.ico + - /buyer/distribution/distribution/** + - /store/distribution/goods/** # Swagger界面内容配置 swagger: @@ -182,6 +193,7 @@ logging: cn.lili: info # org.hibernate: debug # org.springframework: debug + # org.springframework.data.mongodb.core: debug file: # 指定路径 path: logs @@ -211,22 +223,22 @@ lili: #短信模版配置 sms: #登录 - LOGIN: SMS_205755300 + LOGIN: SMS_234157072 #注册 - REGISTER: SMS_205755298 + REGISTER: SMS_234157072 #找回密码 - FIND_USER: SMS_205755301 + FIND_USER: SMS_234157072 #设置密码 - UPDATE_PASSWORD: SMS_205755297 + UPDATE_PASSWORD: SMS_234157072 #支付密码 - WALLET_PASSWORD: SMS_205755301 + WALLET_PASSWORD: SMS_234157072 system: isDemoSite: false isTestModel: true - # 脱敏级别: - # 0:不做脱敏处理 - # 1:管理端用户手机号等信息脱敏 - # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) + # 脱敏级别: + # 0:不做脱敏处理 + # 1:管理端用户手机号等信息脱敏 + # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) sensitiveLevel: 1 statistics: @@ -268,7 +280,7 @@ lili: data: elasticsearch: cluster-name: elasticsearch - cluster-nodes: 192.168.0.116:9200 + cluster-nodes: 101.43.251.145:9200 index: number-of-replicas: 0 number-of-shards: 3 @@ -297,10 +309,8 @@ lili: notice-group: lili_notice_group notice-send-topic: lili_send_notice_topic notice-send-group: lili_send_notice_group - after-sale-topic: lili_after_sale_topic - after-sale-group: lili_after_sale_group rocketmq: - name-server: 192.168.0.116:9876 + name-server: 101.43.251.145:9876 isVIPChannel: false producer: group: lili_group @@ -309,7 +319,7 @@ rocketmq: xxl: job: admin: - addresses: http://192.168.0.116:9001/xxl-job-admin + addresses: http://127.0.0.1:8080/xxl-job-admin executor: appname: xxl-job-executor-lilishop address: diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java index f7e7bf55..8d35dbaf 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CommissionRender.java @@ -4,6 +4,7 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; +import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.goods.service.CategoryService; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; @@ -85,7 +86,7 @@ public class CommissionRender implements CartRenderStep { if (kanjiaPromotions.isPresent()) { JSONObject promotionsObj = JSONUtil.parseObj(kanjiaPromotions.get().getValue()); KanjiaActivityGoods kanjiaActivityGoods = JSONUtil.toBean(promotionsObj, KanjiaActivityGoods.class); - priceDetailDTO.setSettlementPrice(kanjiaActivityGoods.getSettlementPrice()); + priceDetailDTO.setSettlementPrice(CurrencyUtil.add(kanjiaActivityGoods.getSettlementPrice(),priceDetailDTO.getBillPrice())); } } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java index b25d7742..95f37f19 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java @@ -222,6 +222,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl query = MapUtil.builder(new HashMap()).put("id", promotions.getSkuId()).build(); Map update = MapUtil.builder(new HashMap()).put("points", promotions.getPoints()).build(); //修改规格索引,发送mq消息 From 5168d8d08d68ac5c48cda415061f7d52713b07b2 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Fri, 22 Apr 2022 18:45:43 +0800 Subject: [PATCH 056/185] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/config/application.yml b/config/application.yml index ec630a15..703b96ae 100644 --- a/config/application.yml +++ b/config/application.yml @@ -25,20 +25,11 @@ spring: admin: client: url: http://192.168.0.116:8000 - # mongodb - data: - mongodb: - uri: 192.168.0.116:27017 - database: lilishop - username: root - password: lilishop - authentication-database: admin - # replica-set-name: mongoreplset cache: type: redis # Redis redis: - host: 101.43.251.145 + host: 192.168.0.116 port: 6379 password: lilishop lettuce: @@ -69,7 +60,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://101.43.251.145:3306/zhimai1?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://192.168.0.116:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop maxActive: 50 @@ -163,8 +154,6 @@ ignored: - /**/*.css - /**/*.png - /**/*.ico - - /buyer/distribution/distribution/** - - /store/distribution/goods/** # Swagger界面内容配置 swagger: @@ -193,7 +182,6 @@ logging: cn.lili: info # org.hibernate: debug # org.springframework: debug - # org.springframework.data.mongodb.core: debug file: # 指定路径 path: logs @@ -223,22 +211,22 @@ lili: #短信模版配置 sms: #登录 - LOGIN: SMS_234157072 + LOGIN: SMS_205755300 #注册 - REGISTER: SMS_234157072 + REGISTER: SMS_205755298 #找回密码 - FIND_USER: SMS_234157072 + FIND_USER: SMS_205755301 #设置密码 - UPDATE_PASSWORD: SMS_234157072 + UPDATE_PASSWORD: SMS_205755297 #支付密码 - WALLET_PASSWORD: SMS_234157072 + WALLET_PASSWORD: SMS_205755301 system: isDemoSite: false isTestModel: true - # 脱敏级别: - # 0:不做脱敏处理 - # 1:管理端用户手机号等信息脱敏 - # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) + # 脱敏级别: + # 0:不做脱敏处理 + # 1:管理端用户手机号等信息脱敏 + # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) sensitiveLevel: 1 statistics: @@ -280,7 +268,7 @@ lili: data: elasticsearch: cluster-name: elasticsearch - cluster-nodes: 101.43.251.145:9200 + cluster-nodes: 192.168.0.116:9200 index: number-of-replicas: 0 number-of-shards: 3 @@ -309,8 +297,10 @@ lili: notice-group: lili_notice_group notice-send-topic: lili_send_notice_topic notice-send-group: lili_send_notice_group + after-sale-topic: lili_after_sale_topic + after-sale-group: lili_after_sale_group rocketmq: - name-server: 101.43.251.145:9876 + name-server: 192.168.0.116:9876 isVIPChannel: false producer: group: lili_group @@ -319,7 +309,7 @@ rocketmq: xxl: job: admin: - addresses: http://127.0.0.1:8080/xxl-job-admin + addresses: http://192.168.0.116:9001/xxl-job-admin executor: appname: xxl-job-executor-lilishop address: From aa185c8bd2884f72cc60d5a5a40b08df8be84762 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 25 Apr 2022 10:26:51 +0800 Subject: [PATCH 057/185] =?UTF-8?q?=E4=BC=98=E5=8C=96consumer=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=E3=80=82=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=89=B9=E9=87=8F=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/listener/GoodsMessageListener.java | 10 ++++------ .../search/service/EsGoodsIndexService.java | 7 +++++++ .../serviceimpl/EsGoodsIndexServiceImpl.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 45c1ea98..19a1bab4 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -376,20 +376,18 @@ public class GoodsMessageListener implements RocketMQListener { */ private void generatorGoodsIndex(Goods goods, List goodsSkuList) { int skuSource = 100; + List esGoodsIndices = new ArrayList<>(); for (GoodsSku goodsSku : goodsSkuList) { - EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); EsGoodsIndex goodsIndex = this.settingUpGoodsIndexData(goods, goodsSku); goodsIndex.setSkuSource(skuSource--); log.info("goodsSku:{}", goodsSku); - log.info("esGoodsOld:{}", esGoodsOld); //如果商品库存不为0,并且es中有数据 - if (goodsSku.getQuantity() > 0 && esGoodsOld == null) { + if (goodsSku.getQuantity() > 0) { log.info("生成商品索引 {}", goodsIndex); - this.goodsIndexService.addIndex(goodsIndex); - } else if (goodsSku.getQuantity() > 0 && esGoodsOld != null) { - goodsIndexService.updateIndex(goodsIndex); + esGoodsIndices.add(goodsIndex); } } + this.goodsIndexService.addIndex(esGoodsIndices); } private EsGoodsIndex settingUpGoodsIndexData(Goods goods, GoodsSku goodsSku) { diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index e5a93839..aad7893e 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -38,6 +38,13 @@ public interface EsGoodsIndexService { */ void addIndex(EsGoodsIndex goods); + /** + * 添加商品索引 + * + * @param goods 商品索引信息 + */ + void addIndex(List goods); + /** * 更新商品索引 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index c78a96af..0a02ea2a 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -210,6 +210,20 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } + /** + * 添加商品索引 + * + * @param goods 商品索引信息 + */ + @Override + public void addIndex(List goods) { + try { + goodsIndexRepository.saveAll(goods); + } catch (Exception e) { + log.error("批量为商品生成索引异常", e); + } + } + @Override public void updateIndex(EsGoodsIndex goods) { goodsIndexRepository.save(goods); From bb50510ecb970e09d778b59042ca301df198fb07 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 25 Apr 2022 10:31:39 +0800 Subject: [PATCH 058/185] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9D=83=E9=99=90=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/permission/mapper/MenuMapper.java | 2 +- .../permission/serviceimpl/AdminUserServiceImpl.java | 9 --------- .../modules/permission/serviceimpl/MenuServiceImpl.java | 2 +- .../permission/serviceimpl/RoleMenuServiceImpl.java | 8 +------- .../controller/passport/AdminUserManagerController.java | 7 ++----- 5 files changed, 5 insertions(+), 23 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/permission/mapper/MenuMapper.java b/framework/src/main/java/cn/lili/modules/permission/mapper/MenuMapper.java index bd3c7235..049fb70e 100644 --- a/framework/src/main/java/cn/lili/modules/permission/mapper/MenuMapper.java +++ b/framework/src/main/java/cn/lili/modules/permission/mapper/MenuMapper.java @@ -24,7 +24,7 @@ public interface MenuMapper extends BaseMapper { @Select("SELECT menu.* FROM li_menu AS menu WHERE menu.id IN (" + "SELECT rm.menu_id FROM li_role_menu AS rm WHERE rm.role_id IN (" + "SELECT ur.role_id FROM li_user_role AS ur WHERE ur.user_id=#{userId}) OR rm.role_id IN (" + - "SELECT dr.role_id FROM li_department_role AS dr WHERE dr.id=(" + + "SELECT dr.role_id FROM li_department_role AS dr WHERE dr.department_id =(" + "SELECT department_id FROM li_admin_user AS au WHERE au.id = #{userId})))") List findByUserId(String userId); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index a7411f44..53ec3049 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java @@ -141,15 +141,6 @@ public class AdminUserServiceImpl extends ServiceImpl implements Me if (Boolean.TRUE.equals(authUser.getIsSuper())) { return this.tree(); } - List userMenus = this.baseMapper.findByUserId(authUser.getId()); + List userMenus = this.findUserList(authUser.getId()); return this.tree(userMenus); } diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java index 8966c190..86abf44f 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java @@ -47,13 +47,7 @@ public class RoleMenuServiceImpl extends ServiceImpl i @Override public List findAllMenu(String userId) { - String cacheKey = CachePrefix.USER_MENU.getPrefix() + userId; - List menuList = (List) cache.get(cacheKey); - if (menuList == null) { - menuList = menuMapper.getUserRoleMenu(userId); - cache.put(cacheKey, menuList); - } - return menuList; + return menuMapper.getUserRoleMenu(userId); } diff --git a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java index 1be65f27..d93e73e1 100644 --- a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java @@ -88,13 +88,10 @@ public class AdminUserManagerController { @GetMapping(value = "/info") @ApiOperation(value = "获取当前登录用户接口") - public ResultMessage getUserInfo() { + public ResultMessage getUserInfo() { AuthUser tokenUser = UserContext.getCurrentUser(); if (tokenUser != null) { - AdminUserVO adminUser = new AdminUserVO(adminUserService.findByUsername(tokenUser.getUsername())); - if (StringUtils.isNotEmpty(adminUser.getDepartmentId())) { - adminUser.setDepartmentTitle(departmentService.getById(adminUser.getDepartmentId()).getTitle()); - } + AdminUser adminUser = adminUserService.findByUsername(tokenUser.getUsername()); adminUser.setPassword(null); return ResultUtil.data(adminUser); } From b1bdd9b8a5df0b51343a5823defcc8b25571da67 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 25 Apr 2022 17:22:52 +0800 Subject: [PATCH 059/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=B4=A2=E5=BC=95mapping=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/elasticsearch/BaseElasticsearchService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 11a20fab..8421156a 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; /** * @author paulG @@ -343,20 +342,20 @@ public abstract class BaseElasticsearchService { PutMappingRequest request = new PutMappingRequest(index) .source(source, XContentType.JSON); CountDownLatch latch = new CountDownLatch(1); - AtomicReference response = new AtomicReference<>(); client.indices().putMappingAsync( request, RequestOptions.DEFAULT, new ActionListener() { @Override public void onResponse(AcknowledgedResponse r) { - response.set(r); latch.countDown(); + log.info("创建索引mapping成功:{}", r); } @Override public void onFailure(Exception e) { latch.countDown(); + log.error("创建索引mapping失败", e); } }); latch.await(10, TimeUnit.SECONDS); From d0226611d7cb9c2e3f3b99aed760baf29fedd964 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 25 Apr 2022 17:34:24 +0800 Subject: [PATCH 060/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E7=94=9F=E6=88=90=E7=B4=A2=E5=BC=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 0a02ea2a..5338cac3 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -370,6 +370,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements goodsIndexRepository.deleteAll(); for (EsGoodsIndex goodsIndex : goodsIndexList) { try { + log.info("生成商品索引:{}", goodsIndex); addIndex(goodsIndex); resultMap.put(KEY_SUCCESS, resultMap.get(KEY_SUCCESS) + 1); } catch (Exception e) { From 8dc86e048217e2f2e7f894bf3605204a6714d276 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 25 Apr 2022 18:08:06 +0800 Subject: [PATCH 061/185] =?UTF-8?q?=E7=83=AD=E8=AF=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.4toMASTER.sql | 20 ++++--- .../java/cn/lili/common/utils/DateUtil.java | 4 +- .../search/entity/dos/HotWordsHistory.java | 23 +++++--- .../entity/dto/HotWordsSearchParams.java | 3 + .../search/mapper/HotWordsHistoryMapper.java | 2 +- .../search/service/HotWordsService.java | 9 +++ .../HotWordsHistoryServiceImpl.java | 56 ++++++------------- .../serviceimpl/HotWordsServiceImpl.java | 36 ++++++++++-- .../statistics/util/StatisticsDateUtil.java | 26 +++++++++ .../other/HotWordsManagerController.java | 10 +++- 10 files changed, 123 insertions(+), 66 deletions(-) diff --git a/DB/version4.2.4toMASTER.sql b/DB/version4.2.4toMASTER.sql index 7aad8be2..06e0fce2 100644 --- a/DB/version4.2.4toMASTER.sql +++ b/DB/version4.2.4toMASTER.sql @@ -4,13 +4,15 @@ ALTER TABLE li_member_sign DROP INDEX uk_member_day; ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; -/** 添加历史热词表 **/ + +-- ---------------------------- +-- Table structure for li_hot_words_history +-- ---------------------------- +DROP TABLE IF EXISTS `li_hot_words_history`; CREATE TABLE `li_hot_words_history` ( - `id` bigint NOT NULL COMMENT 'ID', - `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '创建者', - `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', - `delete_flag` bit(1) DEFAULT NULL COMMENT '是否删除', - `update_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '修改者', - `update_time` datetime(6) DEFAULT NULL COMMENT '修改时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; \ No newline at end of file + `id` bigint NOT NULL COMMENT 'ID', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `keywords` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '热词', + `score` int DEFAULT NULL COMMENT '热词分数', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; diff --git a/framework/src/main/java/cn/lili/common/utils/DateUtil.java b/framework/src/main/java/cn/lili/common/utils/DateUtil.java index 11f31484..ec6c5ef4 100644 --- a/framework/src/main/java/cn/lili/common/utils/DateUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/DateUtil.java @@ -29,9 +29,9 @@ public class DateUtil { return DateUtil.getDateline()/(60*24*60); } /** - * 当天的开始时间 + * 指定日的开始时间 * - * @return 今天开始时间 + * @return 指定日时间 */ public static Long getDayOfStart(Date date) { return date.getTime()/(60*24*60); diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/HotWordsHistory.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/HotWordsHistory.java index 2fee83e1..a012fc33 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/HotWordsHistory.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/HotWordsHistory.java @@ -1,21 +1,15 @@ package cn.lili.modules.search.entity.dos; -import cn.lili.mybatis.BaseEntity; import cn.lili.mybatis.BaseIdEntity; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.elasticsearch.annotations.DateFormat; -import org.springframework.data.elasticsearch.annotations.Field; -import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.format.annotation.DateTimeFormat; +import java.io.Serializable; import java.util.Date; /** @@ -29,7 +23,7 @@ import java.util.Date; @AllArgsConstructor @NoArgsConstructor @TableName("li_hot_words_history") -public class HotWordsHistory extends BaseIdEntity { +public class HotWordsHistory extends BaseIdEntity implements Comparable, Serializable { /** * 词 @@ -41,7 +35,18 @@ public class HotWordsHistory extends BaseIdEntity { */ private Integer score; + @ApiModelProperty(value = "创建时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern = "yyyy-MM-dd") private Date createTime; + + public HotWordsHistory(String keywords, Integer score) { + this.keywords = keywords; + this.score = score; + } + + @Override + public int compareTo(HotWordsHistory hotWordsHistory) { + return hotWordsHistory.getScore() - this.score; + } } diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dto/HotWordsSearchParams.java b/framework/src/main/java/cn/lili/modules/search/entity/dto/HotWordsSearchParams.java index 930b527b..61cd07c7 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dto/HotWordsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dto/HotWordsSearchParams.java @@ -52,6 +52,9 @@ public class HotWordsSearchParams extends PageVO { private Date endTime; + //搜索热词数量 + private Integer top = 50; + public QueryWrapper queryWrapper() { //组织查询时间 QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java b/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java index 31750ae8..97a1d90c 100644 --- a/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java +++ b/framework/src/main/java/cn/lili/modules/search/mapper/HotWordsHistoryMapper.java @@ -26,7 +26,7 @@ public interface HotWordsHistoryMapper extends BaseMapper { * @param queryWrapper 查询条件 * @return 订单统计列表 */ - @Select("SELECT score,keywords,DATE_FORMAT(create_time,'%Y-%m-%d') AS create_time FROM li_hot_words_history " +" ${ew.customSqlSegment}") + @Select("SELECT sum(score) as score,keywords FROM li_hot_words_history " +" ${ew.customSqlSegment}") List statistics(@Param(Constants.WRAPPER) Wrapper queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java b/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java index d69c0f27..a13c9e7e 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/HotWordsService.java @@ -1,5 +1,6 @@ package cn.lili.modules.search.service; +import cn.lili.modules.search.entity.dos.HotWordsHistory; import cn.lili.modules.search.entity.dto.HotWordsDTO; import java.util.List; @@ -21,6 +22,14 @@ public interface HotWordsService { */ List getHotWords(Integer count); + /** + * 获取热门关键词 + * + * @param count 热词数量 + * @return 热词集合 + */ + List getHotWordsVO(Integer count); + /** * 设置热门关键词 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java index e55aee93..c3091ef7 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsHistoryServiceImpl.java @@ -1,11 +1,16 @@ package cn.lili.modules.search.serviceimpl; +import cn.lili.common.utils.DateUtil; import cn.lili.modules.search.entity.dos.HotWordsHistory; import cn.lili.modules.search.entity.dto.HotWordsSearchParams; import cn.lili.modules.search.mapper.HotWordsHistoryMapper; import cn.lili.modules.search.service.HotWordsHistoryService; +import cn.lili.modules.search.service.HotWordsService; +import cn.lili.modules.statistics.entity.enums.SearchTypeEnum; +import cn.lili.modules.statistics.util.StatisticsDateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @@ -19,55 +24,30 @@ import java.util.*; @Service public class HotWordsHistoryServiceImpl extends ServiceImpl implements HotWordsHistoryService { + @Autowired + private HotWordsService hotWordsService; + @Override public List statistics(HotWordsSearchParams hotWordsSearchParams) { + if (hotWordsSearchParams.getSearchType().equals(SearchTypeEnum.TODAY.name())) { + return hotWordsService.getHotWordsVO(hotWordsSearchParams.getTop()); + } QueryWrapper queryWrapper = hotWordsSearchParams.queryWrapper(); + queryWrapper.groupBy("keywords"); + queryWrapper.orderByDesc("score"); + queryWrapper.last("limit " + hotWordsSearchParams.getTop()); List list = baseMapper.statistics(queryWrapper); - return initData(list, hotWordsSearchParams); + return list; } @Override public List queryByDay(Date queryTime) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.eq("create_time", queryTime); + + Date[] dates = StatisticsDateUtil.getDateArray(queryTime); + queryWrapper.between("create_time", dates[0], dates[1]); return list(queryWrapper); } - /** - * 历史统计查询 - * - * @param source - * @return - */ - private List initData(List source, HotWordsSearchParams hotWordsSearchParams) { - - //结果集 - List onlineMemberVOS = new ArrayList<>(); - //时间初始化 - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-8:00")); - calendar.setTime(hotWordsSearchParams.getStartTIme()); - //判定是否超出时间 如果结束时间在循环时间之后,则跳出循环 - while (hotWordsSearchParams.getEndTime().after(calendar.getTime())) { - -// //筛选时间相等的查询结果 - Optional first = source.stream().filter(item -> item.getCreateTime().equals(calendar.getTime())).findFirst(); - if (first.isPresent()) { - onlineMemberVOS.add(first.get()); - } else { - onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime())); - } -// for (HotWordsHistory hotWordsHistory : source) { -// System.out.println(hotWordsHistory.getCreateTime().getTime() + "-" + calendar.getTime().getTime()); -// if (hotWordsHistory.getCreateTime().equals(calendar.getTime())) { -// onlineMemberVOS.add(hotWordsHistory); -// } else { -// onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime())); -// } -// } - - calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1); - } - return onlineMemberVOS; - } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java index 26b29ebe..d036f96e 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/HotWordsServiceImpl.java @@ -2,20 +2,19 @@ package cn.lili.modules.search.serviceimpl; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; +import cn.lili.modules.search.entity.dos.HotWordsHistory; import cn.lili.modules.search.entity.dto.HotWordsDTO; import cn.lili.modules.search.mapper.HotWordsHistoryMapper; import cn.lili.modules.search.service.HotWordsService; import cn.lili.modules.system.entity.dos.Setting; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; /** * HotWordsServiceImpl @@ -24,6 +23,7 @@ import java.util.Set; * @version v1.0 * 2022-04-14 09:35 */ +@Slf4j @Service public class HotWordsServiceImpl implements HotWordsService { @@ -32,6 +32,7 @@ public class HotWordsServiceImpl implements HotWordsService { */ @Autowired private Cache cache; + @Override public List getHotWords(Integer count) { if (count == null) { @@ -50,6 +51,33 @@ public class HotWordsServiceImpl implements HotWordsService { return hotWords; } + @Override + public List getHotWordsVO(Integer count) { + if (count == null) { + count = 50; + } + List hotWords = new ArrayList<>(); + // redis 排序中,下标从0开始,所以这里需要 -1 处理 + count = count - 1; + Set> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), count); + if (set == null || set.isEmpty()) { + return new ArrayList<>(); + } + for (ZSetOperations.TypedTuple defaultTypedTuple : set) { + try { + hotWords.add(new HotWordsHistory(defaultTypedTuple.getValue().toString(), + defaultTypedTuple.getScore().intValue())); + } catch (Exception e) { + log.error("读取热词错误", e); + } + + } + + + Collections.sort(hotWords); + return hotWords; + } + @Override public void setHotWords(HotWordsDTO hotWords) { cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint()); diff --git a/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java b/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java index 8161765d..d97b1b82 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java +++ b/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java @@ -121,4 +121,30 @@ public class StatisticsDateUtil { } } + + /** + * 根据一个日期,获取这一天的开始时间和结束时间 + * + * @param queryDate + * @return + */ + public static Date[] getDateArray(Date queryDate) { + + Date[] dateArray = new Date[2]; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(queryDate); + //时间归到今天凌晨0点 + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + dateArray[0] = calendar.getTime(); + + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1); + calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) - 1); + + dateArray[1] = calendar.getTime(); + return dateArray; + } + } diff --git a/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java index 79240ea9..a8b5f01a 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/HotWordsManagerController.java @@ -2,6 +2,7 @@ package cn.lili.controller.other; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; +import cn.lili.modules.search.entity.dos.HotWordsHistory; import cn.lili.modules.search.entity.dto.HotWordsDTO; import cn.lili.modules.search.entity.dto.HotWordsSearchParams; import cn.lili.modules.search.service.HotWordsHistoryService; @@ -15,7 +16,10 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.constraints.NotNull; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; +import java.util.List; /** * 管理端,热词管理 @@ -58,7 +62,9 @@ public class HotWordsManagerController { @ApiOperation(value = "历史热词") @GetMapping("/history") public ResultMessage deleteWords(HistorySearchParams historySearchParams) { - return ResultUtil.data(hotWordsHistoryService.queryByDay(historySearchParams.getDate())); + List hotWordsHistoryList = hotWordsHistoryService.queryByDay(historySearchParams.getDate()); + Collections.sort(hotWordsHistoryList); + return ResultUtil.data(hotWordsHistoryList); } @ApiOperation(value = "热词统计") @@ -66,8 +72,6 @@ public class HotWordsManagerController { public ResultMessage deleteWords(HotWordsSearchParams hotWordsSearchParams) { return ResultUtil.data(hotWordsHistoryService.statistics(hotWordsSearchParams)); } - - } @Data From cbd201c43b175d95a85360aec4797cfe13d68593 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 25 Apr 2022 18:58:01 +0800 Subject: [PATCH 062/185] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/serviceimpl/EsGoodsSearchServiceImpl.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index ac19929b..179c8f6c 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -36,10 +36,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHitSupport; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchPage; @@ -73,8 +72,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { * ES */ @Autowired - @Qualifier("elasticsearchRestTemplate") - private ElasticsearchRestTemplate restTemplate; + private ElasticsearchOperations restTemplate; @Autowired private EsGoodsIndexService esGoodsIndexService; @@ -145,7 +143,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { return this.restTemplate.get(id, EsGoodsIndex.class); } - /** * 转换搜索结果为聚合商品展示信息 * From 0e0a8b039db6f5187d0bb366e264bb65773ac8a0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 26 Apr 2022 09:33:54 +0800 Subject: [PATCH 063/185] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9D=83=E9=99=90=E4=B8=8D=E5=86=8D=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E6=B0=B8=E4=B9=85=E7=BC=93=E5=AD=98=EF=BC=8C=E8=80=8C=E6=98=AF?= =?UTF-8?q?=E6=94=BE=E5=9C=A8=E4=B8=B4=E6=97=B6=E7=BC=93=E5=AD=98=EF=BC=88?= =?UTF-8?q?5=E5=88=86=E9=92=9F=EF=BC=89=EF=BC=8C=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=A2=91=E7=8E=87=E8=BE=83=E4=BD=8E=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E5=8A=A0=E4=B8=8A=E6=B6=89=E5=8F=8A=E7=9A=84=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E5=A4=AA=E5=A4=8D=E6=9D=82=EF=BC=8C=E6=89=80=E4=BB=A5?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=BA=86=E4=B9=8B=E5=89=8D=E5=AF=B9=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=9A=84=E6=B0=B8=E4=B9=85=E7=BC=93=E5=AD=98=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=A8=A1=E7=B3=8A=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=BC=93=E5=AD=98=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/cache/CachePrefix.java | 7 +++---- .../permission/serviceimpl/MenuServiceImpl.java | 9 +++++---- .../serviceimpl/RoleMenuServiceImpl.java | 9 +++------ .../modules/system/token/ManagerTokenGenerate.java | 14 -------------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/framework/src/main/java/cn/lili/cache/CachePrefix.java b/framework/src/main/java/cn/lili/cache/CachePrefix.java index 27740abe..43423d64 100644 --- a/framework/src/main/java/cn/lili/cache/CachePrefix.java +++ b/framework/src/main/java/cn/lili/cache/CachePrefix.java @@ -471,10 +471,9 @@ public enum CachePrefix { STORE_CATEGORY, /** * 用户菜单 - */ - MENU_USER_ID, - /** - * 用户菜单 + *

+ * 这个缓存并非永久缓存,而是300秒缓存,也就是说修改用户关联的部门,关联的角色, + * 部门关联的角色,角色关联的菜单等等,最多需要5分钟才能生效 */ USER_MENU, /** diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java index 464aba61..9557ceae 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java @@ -7,6 +7,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; 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.SearchVO; import cn.lili.modules.permission.entity.dos.Menu; import cn.lili.modules.permission.entity.dos.RoleMenu; @@ -66,11 +67,12 @@ public class MenuServiceImpl extends ServiceImpl implements Me @Override public List

findUserList(String userId) { - String cacheKey = CachePrefix.MENU_USER_ID.getPrefix() + userId; + String cacheKey = CachePrefix.USER_MENU.getPrefix(UserEnums.MANAGER) + userId; List menuList = cache.get(cacheKey); if (menuList == null) { menuList = this.baseMapper.findByUserId(userId); - cache.put(cacheKey, menuList); + //每5分钟重新确认用户权限 + cache.put(cacheKey, menuList, 300L); } return menuList; } @@ -84,8 +86,7 @@ public class MenuServiceImpl extends ServiceImpl implements Me @Override public boolean saveOrUpdateMenu(Menu menu) { if (CharSequenceUtil.isNotEmpty(menu.getId())) { - cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix()); - cache.vagueDel(CachePrefix.USER_MENU.getPrefix()); + } return this.saveOrUpdate(menu); } diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java index 86abf44f..0d2a22dc 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java @@ -59,8 +59,7 @@ public class RoleMenuServiceImpl extends ServiceImpl i this.deleteRoleMenu(roleId); //重新保存角色菜单关系 this.saveBatch(roleMenus); - cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix()); - cache.vagueDel(CachePrefix.USER_MENU.getPrefix()); + } catch (Exception e) { log.error("修改用户权限错误", e); } @@ -72,8 +71,7 @@ public class RoleMenuServiceImpl extends ServiceImpl i QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("role_id", roleId); this.remove(queryWrapper); - cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix()); - cache.vagueDel(CachePrefix.USER_MENU.getPrefix()); + } @Override @@ -82,7 +80,6 @@ public class RoleMenuServiceImpl extends ServiceImpl i QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("role_id", roleId); this.remove(queryWrapper); - cache.vagueDel(CachePrefix.MENU_USER_ID.getPrefix()); - cache.vagueDel(CachePrefix.USER_MENU.getPrefix()); + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java index ec13d030..10a38764 100644 --- a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java @@ -1,8 +1,6 @@ package cn.lili.modules.system.token; import cn.hutool.core.text.CharSequenceUtil; -import cn.lili.cache.Cache; -import cn.lili.cache.CachePrefix; import cn.lili.common.security.AuthUser; import cn.lili.common.security.enums.PermissionEnum; import cn.lili.common.security.enums.UserEnums; @@ -11,7 +9,6 @@ import cn.lili.common.security.token.TokenUtil; import cn.lili.common.security.token.base.AbstractTokenGenerate; import cn.lili.modules.permission.entity.dos.AdminUser; import cn.lili.modules.permission.entity.vo.UserMenuVO; -import cn.lili.modules.permission.service.RoleMenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -32,21 +29,10 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { @Autowired private TokenUtil tokenUtil; - @Autowired - private RoleMenuService roleMenuService; - @Autowired - private Cache cache; - @Override public Token createToken(AdminUser adminUser, Boolean longTerm) { AuthUser authUser = new AuthUser(adminUser.getUsername(), adminUser.getId(), adminUser.getAvatar(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper()); - - - List userMenuVOList = roleMenuService.findAllMenu(authUser.getId()); - //缓存权限列表 - cache.put(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId(), this.permissionList(userMenuVOList)); - return tokenUtil.createToken(adminUser.getUsername(), authUser, longTerm, UserEnums.MANAGER); } From b2a8578f436a07f65f9bc79ad717f31e296de113 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 26 Apr 2022 11:36:28 +0800 Subject: [PATCH 064/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=9C=BA=E5=88=B6=E3=80=82=EF=BC=88=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E4=BD=9C=E7=94=A8=E4=BA=8Ees=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=A0=E9=99=A4=E6=97=B6=EF=BC=8C=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=9A=84=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 19 ++++--- .../common/aop/annotation/RetryOperation.java | 25 ++++++++++ .../common/aop/interceptor/RetryAspect.java | 50 +++++++++++++++++++ .../lili/common/exception/RetryException.java | 21 ++++++++ .../serviceimpl/EsGoodsIndexServiceImpl.java | 43 +++++++++------- 5 files changed, 132 insertions(+), 26 deletions(-) create mode 100644 framework/src/main/java/cn/lili/common/aop/annotation/RetryOperation.java create mode 100644 framework/src/main/java/cn/lili/common/aop/interceptor/RetryAspect.java create mode 100644 framework/src/main/java/cn/lili/common/exception/RetryException.java diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 19a1bab4..7e9b9aa3 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -6,6 +6,8 @@ import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ClassLoaderUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.lili.common.aop.annotation.RetryOperation; +import cn.lili.common.exception.RetryException; import cn.lili.event.GoodsCommentCompleteEvent; import cn.lili.modules.distribution.entity.dos.DistributionGoods; import cn.lili.modules.distribution.entity.dto.DistributionGoodsSearchParams; @@ -121,6 +123,7 @@ public class GoodsMessageListener implements RocketMQListener { private PromotionGoodsService promotionGoodsService; @Override + @RetryOperation public void onMessage(MessageExt messageExt) { switch (GoodsTagsEnum.valueOf(messageExt.getTags())) { @@ -137,7 +140,7 @@ public class GoodsMessageListener implements RocketMQListener { Goods goods = this.goodsService.getById(goodsId); updateGoodsIndex(goods); } catch (Exception e) { - log.error("生成商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("生成商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; case GENERATOR_STORE_GOODS_INDEX: @@ -145,7 +148,7 @@ public class GoodsMessageListener implements RocketMQListener { String storeId = new String(messageExt.getBody()); this.updateGoodsIndex(storeId); } catch (Exception e) { - log.error("生成店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("生成店铺商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; case UPDATE_GOODS_INDEX_PROMOTIONS: @@ -171,7 +174,7 @@ public class GoodsMessageListener implements RocketMQListener { List goodsList = goodsService.queryListByParams(searchParams); this.updateGoodsIndex(goodsList); } catch (Exception e) { - log.error("更新商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("更新商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; case UPDATE_GOODS_INDEX_FIELD: @@ -184,7 +187,7 @@ public class GoodsMessageListener implements RocketMQListener { Map updateFields = updateIndexFields.get("updateFields", Map.class); goodsIndexService.updateIndex(queryFields, updateFields); } catch (Exception e) { - log.error("更新商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("更新商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; case RESET_GOODS_INDEX: @@ -193,7 +196,7 @@ public class GoodsMessageListener implements RocketMQListener { List goodsIndices = JSONUtil.toList(goodsIdsJsonStr, EsGoodsIndex.class); goodsIndexService.updateBulkIndex(goodsIndices); } catch (Exception e) { - log.error("重置商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("重置商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; //审核商品 @@ -219,7 +222,7 @@ public class GoodsMessageListener implements RocketMQListener { } } catch (Exception e) { - log.error("删除商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; //规格删除 @@ -232,8 +235,10 @@ public class GoodsMessageListener implements RocketMQListener { try { String storeId = new String(messageExt.getBody()); goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("storeId", storeId).build()); + } catch (RetryException re) { + throw re; } catch (Exception e) { - log.error("删除店铺商品索引事件执行异常,商品信息 {}", new String(messageExt.getBody())); + log.error("删除店铺商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } break; //商品评价 diff --git a/framework/src/main/java/cn/lili/common/aop/annotation/RetryOperation.java b/framework/src/main/java/cn/lili/common/aop/annotation/RetryOperation.java new file mode 100644 index 00000000..d12ab403 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/aop/annotation/RetryOperation.java @@ -0,0 +1,25 @@ +package cn.lili.common.aop.annotation; + +import java.lang.annotation.*; + +/** + * 异常重试注解 + * + * @author paulG + * @since 2022/4/26 + **/ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface RetryOperation { + /** + * 重试次数 + */ + int retryCount() default 3; + + /** + * 重试间隔 + */ + int waitSeconds() default 10; +} diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/RetryAspect.java b/framework/src/main/java/cn/lili/common/aop/interceptor/RetryAspect.java new file mode 100644 index 00000000..bc9173b6 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/RetryAspect.java @@ -0,0 +1,50 @@ +package cn.lili.common.aop.interceptor; + +import cn.lili.common.aop.annotation.RetryOperation; +import cn.lili.common.exception.RetryException; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +/** + * @author paulG + * @since 2022/4/26 + **/ +@Aspect +@Component +@Slf4j +public class RetryAspect { + + + @Around(value = "@annotation(retryOperation)") + public Object retryOperation(ProceedingJoinPoint joinPoint, RetryOperation retryOperation) throws Throwable { + + Object response = null; + int retryCount = retryOperation.retryCount(); + int waitSeconds = retryOperation.waitSeconds(); + boolean successful = false; + + do { + try { + response = joinPoint.proceed(); + successful = true; + } catch (RetryException ex) { + log.info("Operation failed, retries remaining: {}", retryCount); + retryCount--; + if (retryCount < 0) { + successful = true; + log.error(ex.getMessage()); + } + if (waitSeconds > 0 && !successful) { + log.info("Waiting for {} second(s) before next retry", waitSeconds); + Thread.sleep(waitSeconds * 1000L); + } + } + } while (!successful); + + return response; + } + +} diff --git a/framework/src/main/java/cn/lili/common/exception/RetryException.java b/framework/src/main/java/cn/lili/common/exception/RetryException.java new file mode 100644 index 00000000..97ccb522 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/exception/RetryException.java @@ -0,0 +1,21 @@ +package cn.lili.common.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 如需异常重试,则抛出此异常 + * + * @author paulG + * @since 2022/4/26 + **/ +@EqualsAndHashCode(callSuper = true) +@Data +public class RetryException extends RuntimeException { + + private static final long serialVersionUID = 7886918292771470846L; + + public RetryException(String message) { + super(message); + } +} diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 5338cac3..f8958231 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -12,6 +12,7 @@ import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.RetryException; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.elasticsearch.BaseElasticsearchService; @@ -39,7 +40,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.assertj.core.util.IterableUtil; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.update.UpdateRequest; @@ -48,6 +48,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; @@ -268,7 +269,15 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements script.append("ctx._source.").append(entry.getKey()).append("=").append("'").append(entry.getValue()).append("'").append(";"); } update.setScript(new Script(script.toString())); - client.updateByQueryAsync(update, RequestOptions.DEFAULT, this.actionListener()); + update.setConflicts("proceed"); + try { + BulkByScrollResponse bulkByScrollResponse = client.updateByQuery(update, RequestOptions.DEFAULT); + if (bulkByScrollResponse.getVersionConflicts() > 0) { + throw new RetryException("更新商品索引失败,es内容版本冲突"); + } + } catch (IOException e) { + log.error("更新商品索引异常", e); + } } /** @@ -305,13 +314,23 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements */ @Override public void deleteIndex(Map queryFields) { - NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); for (Map.Entry entry : queryFields.entrySet()) { boolQueryBuilder.filter(QueryBuilders.termsQuery(entry.getKey(), entry.getValue())); } - queryBuilder.withQuery(boolQueryBuilder); - this.restTemplate.delete(queryBuilder.build(), EsGoodsIndex.class); + + DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(); + deleteByQueryRequest.setQuery(boolQueryBuilder); + deleteByQueryRequest.indices(getIndexName()); + deleteByQueryRequest.setConflicts("proceed"); + try { + BulkByScrollResponse bulkByScrollResponse = client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT); + if (bulkByScrollResponse.getVersionConflicts() > 0) { + throw new RetryException("删除索引失败,es内容版本冲突"); + } + } catch (IOException e) { + log.error("删除索引异常", e); + } } /** @@ -792,18 +811,4 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap)); return index; } - - private ActionListener actionListener() { - return new ActionListener() { - @Override - public void onResponse(BulkByScrollResponse bulkByScrollResponse) { - log.info("UpdateByQueryResponse: {}", bulkByScrollResponse); - } - - @Override - public void onFailure(Exception e) { - log.error("UpdateByQueryRequestFailure: ", e); - } - }; - } } From 27112e35b3160bc8235dffca295b914ae69fd954 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 26 Apr 2022 11:37:48 +0800 Subject: [PATCH 065/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E4=B8=8D=E8=83=BD=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=E3=80=82=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86=E7=AB=AF?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=8A=E4=B8=8B=E6=9E=B6=E6=97=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=B8=85=E7=A9=BAgoods=E7=BC=93=E5=AD=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java | 3 +++ .../modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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 25792d2a..70fa8277 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 @@ -363,6 +363,9 @@ public class GoodsServiceImpl extends ServiceImpl implements queryWrapper.in(Goods::getId, goodsIds); List goodsList = this.list(queryWrapper); for (Goods goods : goodsList) { + if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { + cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); + } goodsSkuService.updateGoodsSkuStatus(goods); } if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index d5d252b0..bee4efee 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -88,7 +88,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { if (!exists) { esGoodsIndexService.init(); } - if (CharSequenceUtil.isNotEmpty(searchDTO.getKeyword())) { + if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword())) { cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword()); } NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo); From 16fdb28141c8faa87b12e784559d8411ed29df37 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 26 Apr 2022 14:16:39 +0800 Subject: [PATCH 066/185] =?UTF-8?q?=E5=A4=9A=E4=BF=AE=E6=94=B9=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/token/ManagerTokenGenerate.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java index 10a38764..ec13d030 100644 --- a/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/system/token/ManagerTokenGenerate.java @@ -1,6 +1,8 @@ package cn.lili.modules.system.token; import cn.hutool.core.text.CharSequenceUtil; +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; import cn.lili.common.security.AuthUser; import cn.lili.common.security.enums.PermissionEnum; import cn.lili.common.security.enums.UserEnums; @@ -9,6 +11,7 @@ import cn.lili.common.security.token.TokenUtil; import cn.lili.common.security.token.base.AbstractTokenGenerate; import cn.lili.modules.permission.entity.dos.AdminUser; import cn.lili.modules.permission.entity.vo.UserMenuVO; +import cn.lili.modules.permission.service.RoleMenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,10 +32,21 @@ public class ManagerTokenGenerate extends AbstractTokenGenerate { @Autowired private TokenUtil tokenUtil; + @Autowired + private RoleMenuService roleMenuService; + @Autowired + private Cache cache; + @Override public Token createToken(AdminUser adminUser, Boolean longTerm) { AuthUser authUser = new AuthUser(adminUser.getUsername(), adminUser.getId(), adminUser.getAvatar(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper()); + + + List userMenuVOList = roleMenuService.findAllMenu(authUser.getId()); + //缓存权限列表 + cache.put(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId(), this.permissionList(userMenuVOList)); + return tokenUtil.createToken(adminUser.getUsername(), authUser, longTerm, UserEnums.MANAGER); } From 66e62725717d738452ec203c888dab5cf789abef Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 27 Apr 2022 18:15:11 +0800 Subject: [PATCH 067/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84es=E5=95=86=E5=93=81=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E7=BB=93=E6=9E=84=E3=80=82=E8=A7=A3=E5=86=B3=E5=88=9D?= =?UTF-8?q?=E6=AC=A1=E5=90=AF=E5=8A=A8=E6=97=B6=EF=BC=8C=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common-api/src/main/resources/application.yml | 1 + .../cn/lili/modules/search/entity/dos/EsGoodsAttribute.java | 4 ++-- .../java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common-api/src/main/resources/application.yml b/common-api/src/main/resources/application.yml index a914b499..f139f9bd 100644 --- a/common-api/src/main/resources/application.yml +++ b/common-api/src/main/resources/application.yml @@ -121,6 +121,7 @@ ignored: - /source/** - /common/common/slider/** - /common/common/sms/** + - /common/common/logo - /druid/** - /swagger-ui.html - /doc.html diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsAttribute.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsAttribute.java index bbfad035..434f3a09 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsAttribute.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsAttribute.java @@ -33,7 +33,7 @@ public class EsGoodsAttribute implements Serializable { /** * 属性名称 */ - @Field(type = FieldType.Text) + @Field(type = FieldType.Text, fielddata = true) private String name; /** @@ -45,7 +45,7 @@ public class EsGoodsAttribute implements Serializable { /** * 属性值 */ - @Field(type = FieldType.Text) + @Field(type = FieldType.Text, fielddata = true) private String value; diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index b4cdf3fd..73f01614 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -256,9 +256,11 @@ public class EsGoodsIndex implements Serializable { * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum */ @ApiModelProperty(value = "商品类型", required = true) + @Field(type = FieldType.Text) private String goodsType; @ApiModelProperty(value = "商品sku基础分数", required = true) + @Field(type = FieldType.Integer) private Integer skuSource; /** From f4a7d8ea92eca4b3d9493aa684589ae4a49bbc6e Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 5 May 2022 11:57:05 +0800 Subject: [PATCH 068/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=B2=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=8F=90=E4=BA=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aop/interceptor/PreventDuplicateSubmissionsInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java index 263cf18f..cb098b51 100644 --- a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java @@ -38,7 +38,7 @@ public class PreventDuplicateSubmissionsInterceptor { try { Long count = cache.incr(getParams(), preventDuplicateSubmissions.expire()); //如果超过1或者设置的参数,则表示重复提交了 - if (count.intValue() >= preventDuplicateSubmissions.expire()) { + if (count.intValue() >= 1) { throw new ServiceException(ResultCode.LIMIT_ERROR); } } From 840637c0d07b32e4ec115d20e98a5c227b4a27ee Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 5 May 2022 17:58:13 +0800 Subject: [PATCH 069/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=8A=B6=E6=80=81=E6=97=B6=EF=BC=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=BC=93=E5=AD=98=E7=9A=84=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reventDuplicateSubmissionsInterceptor.java | 15 ++++--- .../goods/serviceimpl/GoodsServiceImpl.java | 39 +++++++++++-------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java index cb098b51..77a3a66b 100644 --- a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java @@ -1,13 +1,5 @@ package cn.lili.common.aop.interceptor; -/** - * 防重复提交业务 - * - * @author Chopper - * @version v1.0 - * 2022-01-25 09:20 - */ - import cn.lili.cache.Cache; import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; import cn.lili.common.enums.ResultCode; @@ -23,6 +15,13 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +/** + * 防重复提交业务 + * + * @author Chopper + * @version v1.0 + * 2022-01-25 09:20 + */ @Aspect @Component @Slf4j 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 70fa8277..0655f583 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 @@ -306,13 +306,7 @@ public class GoodsServiceImpl extends ServiceImpl implements LambdaQueryWrapper queryWrapper = this.getQueryWrapperByStoreAuthority(); queryWrapper.in(Goods::getId, goodsIds); List goodsList = this.list(queryWrapper); - for (Goods goods : goodsList) { - goodsSkuService.updateGoodsSkuStatus(goods); - } - - if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { - this.deleteEsGoods(goodsIds); - } + this.updateGoodsStatus(goodsIds, goodsStatusEnum, goodsList); return result; } @@ -362,15 +356,7 @@ public class GoodsServiceImpl extends ServiceImpl implements LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(Goods::getId, goodsIds); List goodsList = this.list(queryWrapper); - for (Goods goods : goodsList) { - if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { - cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); - } - goodsSkuService.updateGoodsSkuStatus(goods); - } - if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { - this.deleteEsGoods(goodsIds); - } + this.updateGoodsStatus(goodsIds, goodsStatusEnum, goodsList); return result; } @@ -391,6 +377,7 @@ public class GoodsServiceImpl extends ServiceImpl implements for (Goods goods : goodsList) { //修改SKU状态 goodsSkuService.updateGoodsSkuStatus(goods); + cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); } this.deleteEsGoods(goodsIds); @@ -479,6 +466,26 @@ public class GoodsServiceImpl extends ServiceImpl implements } + /** + * 更新商品状态 + * + * @param goodsIds 商品ID + * @param goodsStatusEnum 商品状态 + * @param goodsList 商品列表 + */ + private void updateGoodsStatus(List goodsIds, GoodsStatusEnum goodsStatusEnum, List goodsList) { + for (Goods goods : goodsList) { + if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { + cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); + } + goodsSkuService.updateGoodsSkuStatus(goods); + } + + if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { + this.deleteEsGoods(goodsIds); + } + } + /** * 发送删除es索引的信息 * From fd92d93289e29899d31cc4512497281ff53601f1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 6 May 2022 15:50:20 +0800 Subject: [PATCH 070/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B8=85=E7=A9=BA=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index ccf3e7d8..b271f7c0 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -542,7 +542,7 @@ public class CartServiceImpl implements CartService { } //构建交易 Trade trade = tradeBuilder.createTrade(tradeDTO); - this.cleanChecked(tradeDTO); + this.cleanChecked(this.readDTO(cartTypeEnum)); return trade; } From a375feabfca0d88be9cb62062d59b93fcef365ac Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 6 May 2022 15:51:13 +0800 Subject: [PATCH 071/185] =?UTF-8?q?=E5=94=AE=E5=90=8E=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=94=AE=E5=90=8E=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A2=AB=E5=A4=9A=E4=B8=AA=E5=9C=B0=E6=96=B9=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=E4=BC=98=E5=8C=96=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=90=8E=E5=8F=AA=E6=9C=89=E4=B8=80=E4=B8=AA=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/event/impl/PaymentExecute.java | 70 +++++++------------ .../cn/lili/modules/payment/kit/Payment.java | 12 +--- .../modules/payment/kit/RefundSupport.java | 26 ------- .../kit/plugin/alipay/AliPayPlugin.java | 25 ------- .../kit/plugin/wallet/WalletPlugin.java | 17 +---- .../kit/plugin/wechat/WechatPlugin.java | 6 -- 6 files changed, 28 insertions(+), 128 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java b/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java index 6889c867..058ff793 100644 --- a/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java @@ -5,6 +5,7 @@ import cn.lili.common.utils.SpringContextUtil; import cn.lili.event.OrderStatusChangeEvent; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dto.OrderMessage; +import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.payment.entity.RefundLog; @@ -33,52 +34,33 @@ public class PaymentExecute implements OrderStatusChangeEvent { @Override public void orderChange(OrderMessage orderMessage) { - switch (orderMessage.getNewStatus()) { - case CANCELLED: - Order order = orderService.getBySn(orderMessage.getOrderSn()); + if (orderMessage.getNewStatus() == OrderStatusEnum.CANCELLED) { + Order order = orderService.getBySn(orderMessage.getOrderSn()); - //如果未付款,则不去要退回相关代码执行 - if (order.getPayStatus().equals(PayStatusEnum.UNPAID.name())) { - return; - } - PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(order.getPaymentMethod()); - //进行退款操作 - switch (paymentMethodEnum) { - case WALLET: - case ALIPAY: - case WECHAT: - //获取支付方式 - Payment payment = - (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); + //如果未付款,则不去要退回相关代码执行 + if (order.getPayStatus().equals(PayStatusEnum.UNPAID.name())) { + return; + } + PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(order.getPaymentMethod()); - RefundLog refundLog = RefundLog.builder() - .isRefund(false) - .totalAmount(order.getFlowPrice()) - .payPrice(order.getFlowPrice()) - .memberId(order.getMemberId()) - .paymentName(order.getPaymentMethod()) - .afterSaleNo("订单取消") - .orderSn(order.getSn()) - .paymentReceivableNo(order.getReceivableNo()) - .outOrderNo("AF" + SnowFlake.getIdStr()) - .outOrderNo("AF" + SnowFlake.getIdStr()) - .refundReason("订单取消") - .build(); - payment.cancel(refundLog); - break; - case BANK_TRANSFER: - break; - default: - log.error("订单支付执行异常,订单编号:{}", orderMessage.getOrderSn()); - break; - } - break; - default: - break; + //获取支付方式 + Payment payment = + (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); + + RefundLog refundLog = RefundLog.builder() + .isRefund(false) + .totalAmount(order.getFlowPrice()) + .payPrice(order.getFlowPrice()) + .memberId(order.getMemberId()) + .paymentName(order.getPaymentMethod()) + .afterSaleNo("订单取消") + .orderSn(order.getSn()) + .paymentReceivableNo(order.getReceivableNo()) + .outOrderNo("AF" + SnowFlake.getIdStr()) + .outOrderNo("AF" + SnowFlake.getIdStr()) + .refundReason("订单取消") + .build(); + payment.refund(refundLog); } - - } - - } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java b/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java index 4046dc1a..f67c2619 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/Payment.java @@ -83,17 +83,6 @@ public interface Payment { throw new ServiceException(ResultCode.PAY_ERROR); } - - /** - * 取消支付订单 - * - * @param refundLog 支付参数 - */ - default void cancel(RefundLog refundLog) { - throw new ServiceException(ResultCode.PAY_ERROR); - } - - /** * 回调 * @@ -131,6 +120,7 @@ public interface Payment { default String callbackUrl(String api, PaymentMethodEnum paymentMethodEnum) { return api + "/buyer/payment/cashier/callback/" + paymentMethodEnum.name(); } + /** * 支付异步通知地址 * diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/RefundSupport.java b/framework/src/main/java/cn/lili/modules/payment/kit/RefundSupport.java index e8b75859..3e3d059e 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/RefundSupport.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/RefundSupport.java @@ -75,7 +75,6 @@ public class RefundSupport { * * @return void * @Author ftyy - * @Description //TODO * @Date 17:33 2021/11/18 * @Param [afterSale] **/ @@ -89,31 +88,6 @@ public class RefundSupport { orderItemService.updateById(orderItem); } - /** - * 订单取消 - * - * @param afterSale - */ - public void cancel(AfterSale afterSale) { - - Order order = orderService.getBySn(afterSale.getOrderSn()); - RefundLog refundLog = RefundLog.builder() - .isRefund(false) - .totalAmount(afterSale.getActualRefundPrice()) - .payPrice(afterSale.getActualRefundPrice()) - .memberId(afterSale.getMemberId()) - .paymentName(order.getPaymentMethod()) - .afterSaleNo(afterSale.getSn()) - .paymentReceivableNo(order.getReceivableNo()) - .outOrderNo("AF" + SnowFlake.getIdStr()) - .orderSn(afterSale.getOrderSn()) - .refundReason(afterSale.getReason()) - .build(); - PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.paymentNameOf(order.getPaymentMethod()); - Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); - payment.refund(refundLog); - } - /** * 退款通知 diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java index b4a8a094..9641d751 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java @@ -211,31 +211,6 @@ public class AliPayPlugin implements Payment { } - @Override - public void cancel(RefundLog refundLog) { - AlipayTradeCancelModel model = new AlipayTradeCancelModel(); - //这里取支付回调时返回的流水 - if (StringUtils.isNotEmpty(refundLog.getPaymentReceivableNo())) { - model.setTradeNo(refundLog.getPaymentReceivableNo()); - } else { - log.error("退款时,支付参数为空导致异常:{}", refundLog); - throw new ServiceException(ResultCode.ALIPAY_PARAMS_EXCEPTION); - } - try { - //与阿里进行交互 - AlipayTradeCancelResponse alipayTradeCancelResponse = AliPayApi.tradeCancelToResponse(model); - if (alipayTradeCancelResponse.isSuccess()) { - refundLog.setIsRefund(true); - refundLog.setReceivableNo(refundLog.getOutOrderNo()); - } else { - refundLog.setErrorMessage(String.format("错误码:%s,错误原因:%s", alipayTradeCancelResponse.getSubCode(), alipayTradeCancelResponse.getSubMsg())); - } - refundLogService.save(refundLog); - } catch (Exception e) { - log.error("支付宝退款异常", e); - } - } - @Override public void refundNotify(HttpServletRequest request) { //不需要实现 diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java index 9a2d1edc..434085db 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wallet/WalletPlugin.java @@ -96,21 +96,6 @@ public class WalletPlugin implements Payment { return ResultUtil.success(ResultCode.PAY_SUCCESS); } - @Override - public void cancel(RefundLog refundLog) { - - try { - memberWalletService.increase(new MemberWalletUpdateDTO(refundLog.getTotalAmount(), - refundLog.getMemberId(), - "取消[" + refundLog.getOrderSn() + "]订单,退还金额[" + refundLog.getTotalAmount() + "]", - DepositServiceTypeEnum.WALLET_REFUND.name())); - refundLog.setIsRefund(true); - refundLogService.save(refundLog); - } catch (Exception e) { - log.error("订单取消错误", e); - } - } - /** * 保存支付日志 * @@ -134,7 +119,7 @@ public class WalletPlugin implements Payment { try { memberWalletService.increase(new MemberWalletUpdateDTO(refundLog.getTotalAmount(), refundLog.getMemberId(), - "售后[" + refundLog.getAfterSaleNo() + "]审批,退还金额[" + refundLog.getTotalAmount() + "]", + "订单[" + refundLog.getOrderSn() + "],售后单[" + refundLog.getAfterSaleNo() + "],退还金额[" + refundLog.getTotalAmount() + "]", DepositServiceTypeEnum.WALLET_REFUND.name())); refundLog.setIsRefund(true); refundLogService.save(refundLog); diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index a32e8572..5eaf7b60 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -554,12 +554,6 @@ public class WechatPlugin implements Payment { } - @Override - public void cancel(RefundLog refundLog) { - this.refund(refundLog); - } - - @Override public void refundNotify(HttpServletRequest request) { String timestamp = request.getHeader("Wechatpay-Timestamp"); From 4705c2595a22d4ab9fce58cffd8f55cc7bddcc9a Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Fri, 6 May 2022 16:16:34 +0800 Subject: [PATCH 072/185] =?UTF-8?q?=E8=BF=BD=E8=B8=AA=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=A2=9E=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E5=90=8E=E5=9B=9B=E4=BD=8D=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aftersale/serviceimpl/AfterSaleServiceImpl.java | 4 ++-- .../order/order/serviceimpl/OrderServiceImpl.java | 3 ++- .../payment/kit/plugin/wechat/WechatPlugin.java | 2 +- .../modules/system/service/LogisticsService.java | 3 ++- .../system/serviceimpl/LogisticsServiceImpl.java | 12 ++++++++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java index 7c011830..768a6e94 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java @@ -269,8 +269,8 @@ public class AfterSaleServiceImpl extends ServiceImpl implements //获取订单信息 Order order = this.getBySn(orderSn); //获取踪迹信息 - return logisticsService.getLogistic(order.getLogisticsCode(), order.getLogisticsNo()); + String str=order.getConsigneeMobile(); + return logisticsService.getLogistic(order.getLogisticsCode(), order.getLogisticsNo(), str.substring(str.length()-4)); } @Override diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index 5eaf7b60..3ba64830 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -293,7 +293,7 @@ public class WechatPlugin implements Payment { Map map = WxPayKit.appPrepayIdCreateSign(appid, setting.getMchId(), prepayId, - setting.getApiclient_key(), SignType.HMACSHA256); + setting.getApiclient_key(), SignType.MD5); log.info("唤起支付参数:{}", map); return ResultUtil.data(map); diff --git a/framework/src/main/java/cn/lili/modules/system/service/LogisticsService.java b/framework/src/main/java/cn/lili/modules/system/service/LogisticsService.java index b3f1c16e..5cdf8698 100644 --- a/framework/src/main/java/cn/lili/modules/system/service/LogisticsService.java +++ b/framework/src/main/java/cn/lili/modules/system/service/LogisticsService.java @@ -19,9 +19,10 @@ public interface LogisticsService extends IService { * * @param logisticsId 物流公司ID * @param logisticsNo 单号 + * @param customerName 手机号后四位 * @return */ - Traces getLogistic(String logisticsId, String logisticsNo); + Traces getLogistic(String logisticsId, String logisticsNo, String customerName); /** * 获取已开启的物流公司列表 diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java index e7b40f61..2e750ac3 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java @@ -43,9 +43,9 @@ public class LogisticsServiceImpl extends ServiceImpl params = new HashMap<>(8); params.put("RequestData", urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", EBusinessID); From 0a631a7c938f5ff9a138dbcd8a50b8fbbe3b8f91 Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Sat, 7 May 2022 21:24:51 +0800 Subject: [PATCH 073/185] =?UTF-8?q?requestData=E5=A4=9A=E4=BA=86=E4=B8=AA?= =?UTF-8?q?=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/system/serviceimpl/LogisticsServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java index 2e750ac3..6dd2cbac 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java @@ -90,7 +90,7 @@ public class LogisticsServiceImpl extends ServiceImpl params = new HashMap<>(8); params.put("RequestData", urlEncoder(requestData, "UTF-8")); From 038eda1562cd6a40d6324458efde39712c1ddf23 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 10 May 2022 14:38:57 +0800 Subject: [PATCH 074/185] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E4=BA=91maven=E5=9C=B0=E5=9D=80=E3=80=82=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BE=9D=E8=B5=96=E5=88=B0=E6=9C=80=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/pom.xml | 7 +++++++ pom.xml | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/framework/pom.xml b/framework/pom.xml index d4c011bb..6919e763 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -123,6 +123,7 @@ mysql mysql-connector-java + 8.0.29 @@ -134,6 +135,12 @@ org.redisson redisson ${redisson} + + + slf4j-api + org.slf4j + + diff --git a/pom.xml b/pom.xml index 9e83ebb2..53b79e7e 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 4.6.0 3.14.0 2.0.9 - 2.2.1 + 2.2.2 0.11.2 4.0.0 1.2.8 @@ -46,13 +46,13 @@ 4.7.2 4.7.2 2.0.9 - 2.6.2 + 2.6.6 1.21 5.1.0 5.1.0 - 7.0.1 - 3.4.1 - 1.7.35 + 7.1.1 + 3.5.0 + 1.7.36 3.2.3 1.9 4.3 @@ -110,7 +110,7 @@ central aliyun maven - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/repository/public default From 850b124da3dca53b6f073af758357762d98d8691 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 11 May 2022 17:49:44 +0800 Subject: [PATCH 075/185] =?UTF-8?q?=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E4=B8=8A=E4=B8=80=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/statistics/OnlineMemberStatistics.java | 12 +++++++++--- .../modules/statistics/entity/vo/OnlineMemberVO.java | 7 +++++++ .../serviceimpl/PlatformViewServiceImpl.java | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java index e2aee5e3..8cffcd84 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** @@ -54,8 +55,13 @@ public class OnlineMemberStatistics implements EveryHourExecute { calendar.set(Calendar.MILLISECOND, 0); Calendar finalCalendar = calendar; + + AtomicReference lastNum = new AtomicReference<>(1); onlineMemberVOS = onlineMemberVOS.stream() - .filter(onlineMemberVO -> onlineMemberVO.getDate().after(finalCalendar.getTime())) + .filter(onlineMemberVO -> { + lastNum.set(onlineMemberVO.getNum()); + return onlineMemberVO.getDate().after(finalCalendar.getTime()); + }) .collect(Collectors.toList()); //计入新数据 @@ -63,7 +69,7 @@ public class OnlineMemberStatistics implements EveryHourExecute { calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - onlineMemberVOS.add(new OnlineMemberVO(calendar.getTime(), cache.keys(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + "*").size())); + onlineMemberVOS.add(new OnlineMemberVO(calendar.getTime(), cache.keys(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + "*").size(), lastNum.get())); //写入缓存 cache.put(CachePrefix.ONLINE_MEMBER.getPrefix(), onlineMemberVOS); @@ -95,7 +101,7 @@ public class OnlineMemberStatistics implements EveryHourExecute { onlineMemberVOS = onlineMemberVOS.stream() .filter(onlineMemberVO -> onlineMemberVO.getDate().after(calendar.getTime())) .collect(Collectors.toList()); - onlineMemberVOS.add(new OnlineMemberVO(time, num)); + onlineMemberVOS.add(new OnlineMemberVO(time, num, num)); //写入缓存 cache.put(CachePrefix.ONLINE_MEMBER.getPrefix(), onlineMemberVOS); diff --git a/framework/src/main/java/cn/lili/modules/statistics/entity/vo/OnlineMemberVO.java b/framework/src/main/java/cn/lili/modules/statistics/entity/vo/OnlineMemberVO.java index fc66d9da..bd20847b 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/entity/vo/OnlineMemberVO.java +++ b/framework/src/main/java/cn/lili/modules/statistics/entity/vo/OnlineMemberVO.java @@ -3,6 +3,7 @@ package cn.lili.modules.statistics.entity.vo; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.Date; @@ -14,6 +15,7 @@ import java.util.Date; */ @Data @AllArgsConstructor +@NoArgsConstructor public class OnlineMemberVO { /** @@ -27,4 +29,9 @@ public class OnlineMemberVO { */ private Integer num; + /** + * 上一周期在线会员人数 + */ + private Integer lastNum; + } diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java index 9b0e69c7..f1263659 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java @@ -142,7 +142,7 @@ public class PlatformViewServiceImpl extends ServiceImpl Date: Wed, 11 May 2022 19:20:35 +0800 Subject: [PATCH 076/185] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95-=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BC=98=E6=83=A0=E5=88=B8=E8=A1=A5=E8=B4=B4=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/StoreFlowServiceImpl.java | 29 ++++++------ .../store/serviceimpl/BillServiceImpl.java | 44 +++++++------------ 2 files changed, 30 insertions(+), 43 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 8f888acd..3a1e6c8b 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -76,16 +76,18 @@ public class StoreFlowServiceImpl extends ServiceImpl orderItems = orderItemService.getByOrderSn(orderSn); //根据订单编号获取订单数据 Order order = orderService.getBySn(orderSn); + //如果查询到多条支付记录,打印日志 + if (order.getPayStatus().equals(PayStatusEnum.PAID.name())) { + log.error("订单[{}]检测到重复付款,请处理", orderSn); + } + //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 String orderPromotionType = order.getOrderPromotionType(); - //循环子订单记录流水 for (OrderItem item : orderItems) { StoreFlow storeFlow = new StoreFlow(); BeanUtil.copyProperties(item, storeFlow); - //去掉orderitem的时间。 - storeFlow.setCreateTime(null); //入账 storeFlow.setId(SnowFlake.getIdStr()); storeFlow.setFlowType(FlowTypeEnum.PAY.name()); @@ -100,28 +102,24 @@ public class StoreFlowServiceImpl extends ServiceImpl implements Bi bill.setSn(SnowFlake.createStr("B")); //退款结算信息 - Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper() - .eq("store_id", storeId) - .eq("flow_type", FlowTypeEnum.REFUND.name()) - .between("create_time", startTime, endTime)); + Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper().eq("store_id", storeId).eq("flow_type", FlowTypeEnum.REFUND.name()).between("create_time", startTime, endTime)); //店铺退款金额 Double refundPrice = 0D; if (refundBill != null) { //退单金额 - bill.setRefundPrice(refundBill.getRefundPrice()); + bill.setRefundPrice(refundBill.getRefundPrice() != null ? refundBill.getRefundPrice() : 0D); //退单产生退还佣金金额 - bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice()); + bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice() != null ? refundBill.getRefundCommissionPrice() : 0D); //分销订单退还,返现佣金返还 - bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission()); + bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission() != null ? refundBill.getRefundCommissionPrice() : 0D); //退货平台优惠券补贴返还 - bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission()); + bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission() != null ? refundBill.getSiteCouponRefundCommission() : 0D); //退款金额=店铺最终退款结算金额 - refundPrice = refundBill.getBillPrice(); + refundPrice = refundBill.getBillPrice() != null ? refundBill.getBillPrice() : 0D; } /** * @TODO 入账结算信息 */ - Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper() - .eq("store_id", storeId) - .eq("flow_type", FlowTypeEnum.PAY.name()) - .between("create_time", startTime, endTime)); + Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper().eq("store_id", storeId).eq("flow_type", FlowTypeEnum.PAY.name()).between("create_time", startTime, endTime)); //店铺入款结算金额 double orderPrice = 0D; if (orderBill != null) { //结算周期内订单付款总金额 - bill.setOrderPrice(orderBill.getOrderPrice()); + bill.setOrderPrice(orderBill.getOrderPrice() != null ? orderBill.getOrderPrice() : 0D); //平台收取佣金 - bill.setCommissionPrice(orderBill.getCommissionPrice()); + bill.setCommissionPrice(orderBill.getCommissionPrice() != null ? orderBill.getCommissionPrice() : 0D); //分销返现支出 - bill.setDistributionCommission(orderBill.getDistributionCommission()); + bill.setDistributionCommission(orderBill.getDistributionCommission() != null ? orderBill.getDistributionCommission() : 0D); //平台优惠券补贴 - bill.setSiteCouponCommission(orderBill.getSiteCouponCommission()); + bill.setSiteCouponCommission(orderBill.getSiteCouponCommission() != null ? orderBill.getSiteCouponCommission() : 0D); //积分商品结算价格 - bill.setPointSettlementPrice(orderBill.getPointSettlementPrice()); + bill.setPointSettlementPrice(orderBill.getPointSettlementPrice() != null ? orderBill.getPointSettlementPrice() : 0D); //砍价商品结算价格 - bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice()); + bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice() != null ? orderBill.getKanjiaSettlementPrice() : 0D); //入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 分销订单退还,返现佣金返还+退单产生退还佣金金额 - orderPrice = CurrencyUtil.add(orderBill.getBillPrice(), - bill.getSiteCouponCommission(), - bill.getDistributionRefundCommission(), - bill.getRefundCommissionPrice()); + orderPrice = CurrencyUtil.add(orderBill.getBillPrice() == null ? 0 : orderBill.getBillPrice(), bill.getSiteCouponCommission() == null ? 0 : bill.getSiteCouponCommission(), bill.getDistributionRefundCommission() == null ? 0 : bill.getDistributionRefundCommission(), bill.getRefundCommissionPrice() == null ? 0 : bill.getRefundCommissionPrice()); } - //最终结算金额=入款结算金额-退款结算金额-退货平台优惠券补贴返还 - Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice,bill.getSiteCouponRefundCommission()); + Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice, bill.getSiteCouponRefundCommission() == null ? 0 : bill.getSiteCouponRefundCommission()); //店铺最终结算金额=最终结算金额 bill.setBillPrice(finalPrice); @@ -276,9 +266,7 @@ public class BillServiceImpl extends ServiceImpl implements Bi writer.setColumnWidth(12, 20); - List storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO( - StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build() - ); + List storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build()); writer.write(storeFlowRefundDownloadVOList, true); ServletOutputStream out = null; From b49b0290f80d58896b5cd3c2d5493ebefa9ba04b Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Thu, 12 May 2022 15:30:53 +0800 Subject: [PATCH 077/185] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=A4=9A=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/StoreFlowServiceImpl.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 3a1e6c8b..dfe3e1af 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -76,18 +76,16 @@ public class StoreFlowServiceImpl extends ServiceImpl orderItems = orderItemService.getByOrderSn(orderSn); //根据订单编号获取订单数据 Order order = orderService.getBySn(orderSn); - //如果查询到多条支付记录,打印日志 - if (order.getPayStatus().equals(PayStatusEnum.PAID.name())) { - log.error("订单[{}]检测到重复付款,请处理", orderSn); - } - //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 String orderPromotionType = order.getOrderPromotionType(); + //循环子订单记录流水 for (OrderItem item : orderItems) { StoreFlow storeFlow = new StoreFlow(); BeanUtil.copyProperties(item, storeFlow); + //去掉orderitem的时间。 + storeFlow.setCreateTime(null); //入账 storeFlow.setId(SnowFlake.getIdStr()); storeFlow.setFlowType(FlowTypeEnum.PAY.name()); @@ -102,24 +100,28 @@ public class StoreFlowServiceImpl extends ServiceImpl Date: Fri, 13 May 2022 09:01:06 +0800 Subject: [PATCH 078/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9sku?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A6=82=E5=AD=98=E5=9C=A8sku=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 d960c34e..e156c8a8 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 @@ -162,7 +162,13 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } else { newSkuList = new ArrayList<>(); for (Map map : skuList) { - GoodsSku sku = new GoodsSku(); + GoodsSku sku = null; + if (map.get("id") != null) { + sku = this.getGoodsSkuByIdFromCache(map.get("id").toString()); + } + if (sku == null || map.get("id") == null) { + sku = new GoodsSku(); + } //设置商品信息 goodsInfo(sku, goods); //设置商品规格信息 From 0629ce51af127ad75ce69b174624ef435bb96e24 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 13 May 2022 09:19:21 +0800 Subject: [PATCH 079/185] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=E7=BB=99?= =?UTF-8?q?=E4=BA=880?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/statistics/OnlineMemberStatistics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java index 8cffcd84..92b6b23f 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java @@ -56,7 +56,7 @@ public class OnlineMemberStatistics implements EveryHourExecute { Calendar finalCalendar = calendar; - AtomicReference lastNum = new AtomicReference<>(1); + AtomicReference lastNum = new AtomicReference<>(0); onlineMemberVOS = onlineMemberVOS.stream() .filter(onlineMemberVO -> { lastNum.set(onlineMemberVO.getNum()); From ccdcb1d0f60150a047e59894267dae3179634a3d Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 13 May 2022 11:03:26 +0800 Subject: [PATCH 080/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9sku?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A6=82=E5=AD=98=E5=9C=A8sku=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/service/GoodsGalleryService.java | 7 +++++++ .../goods/serviceimpl/GoodsGalleryServiceImpl.java | 10 ++++++++++ .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 5 ++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsGalleryService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsGalleryService.java index 501e22f1..65592834 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsGalleryService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsGalleryService.java @@ -36,4 +36,11 @@ public interface GoodsGalleryService extends IService { */ List goodsGalleryList(String goodsId); + /** + * 根据商品 id删除商品相册缩略图 + * + * @param goodsId 商品ID + */ + void removeByGoodsId(String goodsId); + } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index 5e4577d7..a6493be4 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java @@ -75,4 +75,14 @@ public class GoodsGalleryServiceImpl extends ServiceImpl().eq("goods_id", goodsId)); } + + /** + * 根据商品 id删除商品相册缩略图 + * + * @param goodsId 商品ID + */ + @Override + public void removeByGoodsId(String goodsId) { + this.baseMapper.delete(new UpdateWrapper().eq("goods_id", goodsId)); + } } \ 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 e156c8a8..53211c3d 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 @@ -149,10 +149,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i oldSkuIds.add(goodsSkuVO.getId()); cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId())); } - goodsIndexService.deleteIndexByIds(oldSkuIds); this.removeByIds(oldSkuIds); //删除sku相册 - goodsGalleryService.removeByIds(oldSkuIds); + goodsGalleryService.removeByGoodsId(goods.getId()); // 添加商品sku newSkuList = this.addGoodsSku(skuList, goods); @@ -633,7 +632,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i skus.add(goodsSku); cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); } - this.saveBatch(skus); + this.saveOrUpdateBatch(skus); return skus; } From 57cf3b94e087dfd72c26a2b6b3c7a59468b4b730 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 13 May 2022 11:19:02 +0800 Subject: [PATCH 081/185] =?UTF-8?q?=E8=B6=B3=E8=BF=B9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/FootprintController.java | 3 +- .../member/mapper/FootprintMapper.java | 11 ------ .../member/service/FootprintService.java | 3 +- .../serviceimpl/FootprintServiceImpl.java | 36 +++++++++++++------ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/member/FootprintController.java b/buyer-api/src/main/java/cn/lili/controller/member/FootprintController.java index 256603f9..e5de7c6b 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/FootprintController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/FootprintController.java @@ -5,6 +5,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.member.service.FootprintService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -34,7 +35,7 @@ public class FootprintController { @ApiOperation(value = "分页获取") @GetMapping - public ResultMessage> getByPage(PageVO page) { + public ResultMessage> getByPage(PageVO page) { return ResultUtil.data(footprintService.footPrintPage(page)); } diff --git a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java index 6638d618..f65c731b 100644 --- a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java +++ b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java @@ -18,17 +18,6 @@ import java.util.List; * @since 2020-02-25 14:10:16 */ public interface FootprintMapper extends BaseMapper { - - /** - * 获取用户足迹的SkuId分页 - * - * @param page 分页 - * @param queryWrapper 查询条件 - * @return 用户足迹的SkuId分页 - */ - @Select("select sku_id from li_foot_print ${ew.customSqlSegment} ") - List footprintSkuIdList(IPage page, @Param(Constants.WRAPPER) Wrapper queryWrapper); - /** * 删除超过100条后的记录 * diff --git a/framework/src/main/java/cn/lili/modules/member/service/FootprintService.java b/framework/src/main/java/cn/lili/modules/member/service/FootprintService.java index fc5d8ca3..3005ce96 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/FootprintService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/FootprintService.java @@ -3,6 +3,7 @@ package cn.lili.modules.member.service; import cn.lili.common.vo.PageVO; import cn.lili.modules.member.entity.dos.FootPrint; import cn.lili.modules.search.entity.dos.EsGoodsIndex; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -44,7 +45,7 @@ public interface FootprintService extends IService { * @param pageVO 分页 * @return 会员浏览历史列表 */ - List footPrintPage(PageVO pageVO); + IPage footPrintPage(PageVO pageVO); /** * 获取当前会员的浏览记录数量 diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java index 0fea8a25..d5b315b8 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java @@ -9,7 +9,9 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,6 +21,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 会员浏览历史业务层实现 @@ -29,9 +32,7 @@ import java.util.Objects; @Service public class FootprintServiceImpl extends ServiceImpl implements FootprintService { - /** - * es商品业务层 - */ + @Autowired private EsGoodsSearchService esGoodsSearchService; @@ -74,20 +75,35 @@ public class FootprintServiceImpl extends ServiceImpl footPrintPage(PageVO pageVO) { + public IPage footPrintPage(PageVO pageVO) { LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId()); lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false); - lambdaQueryWrapper.orderByDesc(FootPrint::getUpdateTime); - List skuIdList = this.baseMapper.footprintSkuIdList(PageUtil.initPage(pageVO), lambdaQueryWrapper); - if (!skuIdList.isEmpty()) { - List list = esGoodsSearchService.getEsGoodsBySkuIds(skuIdList); + lambdaQueryWrapper.orderByDesc(FootPrint::getCreateTime); + IPage footPrintPages = this.page(PageUtil.initPage(pageVO), lambdaQueryWrapper); + + + //定义结果 + IPage esGoodsIndexIPage = new Page(); + + if (footPrintPages.getRecords() == null || footPrintPages.getRecords().isEmpty()) { + return esGoodsIndexIPage; + } else { + List list = esGoodsSearchService.getEsGoodsBySkuIds( + footPrintPages.getRecords().stream().map(item -> { + return item.getSkuId(); + }).collect(Collectors.toList())); //去除为空的商品数据 list.removeIf(Objects::isNull); - return list; + + esGoodsIndexIPage.setPages(footPrintPages.getPages()); + esGoodsIndexIPage.setRecords(list); + esGoodsIndexIPage.setTotal(footPrintPages.getTotal()); + esGoodsIndexIPage.setSize(footPrintPages.getSize()); + esGoodsIndexIPage.setCurrent(footPrintPages.getCurrent()); + return esGoodsIndexIPage; } - return Collections.emptyList(); } @Override From 81f48d9c92f6573f0e8b9be6b936abee5c203ff8 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 13 May 2022 11:45:30 +0800 Subject: [PATCH 082/185] =?UTF-8?q?=E5=AF=B9=E4=B8=8A=E4=B8=80=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E7=9A=84=E5=8F=82=E6=95=B0=E8=B5=8B=E5=80=BC=E5=81=9A?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/statistics/OnlineMemberStatistics.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java index 92b6b23f..1afdac4c 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java @@ -59,7 +59,9 @@ public class OnlineMemberStatistics implements EveryHourExecute { AtomicReference lastNum = new AtomicReference<>(0); onlineMemberVOS = onlineMemberVOS.stream() .filter(onlineMemberVO -> { - lastNum.set(onlineMemberVO.getNum()); + if (onlineMemberVO.getDate().before(finalCalendar.getTime())) { + lastNum.set(onlineMemberVO.getNum()); + } return onlineMemberVO.getDate().after(finalCalendar.getTime()); }) .collect(Collectors.toList()); From 3dcff0b682325a93b0936762f7b85b526952d56c Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 13 May 2022 17:42:36 +0800 Subject: [PATCH 083/185] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E4=BA=BA=E6=95=B0?= =?UTF-8?q?=E6=B5=81=E9=87=8F=E5=B1=95=E7=A4=BA=E5=B0=91=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/statistics/serviceimpl/PlatformViewServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java index f1263659..5d824068 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewServiceImpl.java @@ -131,7 +131,7 @@ public class PlatformViewServiceImpl extends ServiceImpl Date: Fri, 13 May 2022 18:18:46 +0800 Subject: [PATCH 084/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=EF=BC=8C=E5=88=86=E6=89=B9?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsIndexServiceImpl.java | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index f8958231..6c4626d2 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.search.serviceimpl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.thread.ThreadUtil; @@ -37,6 +38,8 @@ import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.assertj.core.util.IterableUtil; @@ -137,34 +140,46 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements ThreadUtil.execAsync(() -> { try { - List esGoodsIndices = new ArrayList<>(); LambdaQueryWrapper goodsQueryWrapper = new LambdaQueryWrapper<>(); goodsQueryWrapper.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name()); goodsQueryWrapper.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()); goodsQueryWrapper.eq(Goods::getDeleteFlag, false); - for (Goods goods : goodsService.list(goodsQueryWrapper)) { - LambdaQueryWrapper skuQueryWrapper = new LambdaQueryWrapper<>(); - skuQueryWrapper.eq(GoodsSku::getGoodsId, goods.getId()); - skuQueryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); - skuQueryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); - skuQueryWrapper.eq(GoodsSku::getDeleteFlag, false); - - List goodsSkuList = goodsSkuService.list(skuQueryWrapper); - int skuSource = 100; - for (GoodsSku goodsSku : goodsSkuList) { - EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku, goods); - esGoodsIndex.setSkuSource(skuSource--); - esGoodsIndices.add(esGoodsIndex); - //库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量 - cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); + for (int i = 1; ; i++) { + List esGoodsIndices = new ArrayList<>(); + IPage page = new Page<>(i, 1000); + IPage goodsIPage = goodsService.page(page, goodsQueryWrapper); + if (goodsIPage == null || CollUtil.isEmpty(goodsIPage.getRecords())) { + break; } - + for (Goods goods : goodsIPage.getRecords()) { + LambdaQueryWrapper skuQueryWrapper = new LambdaQueryWrapper<>(); + skuQueryWrapper.eq(GoodsSku::getGoodsId, goods.getId()); + skuQueryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); + skuQueryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); + skuQueryWrapper.eq(GoodsSku::getDeleteFlag, false); + for (int j = 1; ; j++) { + IPage skuPage = new Page<>(j, 100); + IPage skuIPage = goodsSkuService.page(skuPage, skuQueryWrapper); + if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) { + break; + } + int skuSource = 100; + for (GoodsSku goodsSku : skuIPage.getRecords()) { + EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku, goods); + esGoodsIndex.setSkuSource(skuSource--); + esGoodsIndices.add(esGoodsIndex); + //库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量 + cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); + } + } + } + this.initIndex(esGoodsIndices); } + //初始化商品索引 - this.initIndex(esGoodsIndices); } catch (Exception e) { log.error("商品索引生成异常:", e); //如果出现异常,则将进行中的任务标识取消掉,打印日志 From a540e424605f1e935b1aa1cf617769b669c8e2dc Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Wed, 18 May 2022 14:35:34 +0800 Subject: [PATCH 085/185] siteController --- .../controller/common/SiteController.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 common-api/src/main/java/cn/lili/controller/common/SiteController.java diff --git a/common-api/src/main/java/cn/lili/controller/common/SiteController.java b/common-api/src/main/java/cn/lili/controller/common/SiteController.java new file mode 100644 index 00000000..70b32328 --- /dev/null +++ b/common-api/src/main/java/cn/lili/controller/common/SiteController.java @@ -0,0 +1,33 @@ +package cn.lili.controller.common; + +import cn.lili.common.enums.ResultUtil; +import cn.lili.common.vo.ResultMessage; +import cn.lili.modules.system.entity.enums.SettingEnum; +import cn.lili.modules.system.service.SettingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 滑块验证码接口 + * + * @author Chopper + * @since 2020/11/26 15:41 + */ +@Slf4j +@RestController +@RequestMapping("/common/common/site") +@Api(tags = "系统基础接口") +public class SiteController { + + @Autowired + private SettingService settingService; + + @ApiOperation(value = "获取系统基础信息") + @GetMapping + public ResultMessage getFileList() { + return ResultUtil.data(settingService.get(SettingEnum.BASE_SETTING.name())); + } +} From 87e13b36772cb64a575f65ba21894ae63376c0cb Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 18 May 2022 15:15:22 +0800 Subject: [PATCH 086/185] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kit/plugin/wechat/model/UnifiedOrderModel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java index 25d5a3ca..1266aab7 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java @@ -1,5 +1,6 @@ package cn.lili.modules.payment.kit.plugin.wechat.model; +import cn.lili.common.utils.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -42,6 +43,7 @@ public class UnifiedOrderModel { * 商品描述 */ private String description; + /** * 商户订单号 */ @@ -82,6 +84,15 @@ public class UnifiedOrderModel { * 场景信息 */ private SceneInfo scene_info; + + + public String getDescription() { + if (!StringUtils.isEmpty(description) && description.length() > 30) { + return description.substring(30); + } + return description; + } + } From e3626a094def34f15214af9f1dde614f336b2731 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 18 May 2022 16:48:03 +0800 Subject: [PATCH 087/185] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E8=BF=9B=E8=A1=8C=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/payment/kit/params/dto/CashierParam.java | 4 ++++ .../kit/plugin/wechat/model/UnifiedOrderModel.java | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java index 577cd13c..b28d7950 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java @@ -47,6 +47,10 @@ public class CashierParam { if (StringUtils.isEmpty(detail)) { return "清单详细"; } + //对参数长度进行限制 + if (!StringUtils.isEmpty(detail) && detail.length() > 30) { + detail = detail.substring(30); + } return StringUtils.filterSpecialChart(detail); } } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java index 1266aab7..52aeff50 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/UnifiedOrderModel.java @@ -1,5 +1,6 @@ package cn.lili.modules.payment.kit.plugin.wechat.model; +import cn.hutool.json.JSONUtil; import cn.lili.common.utils.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -85,14 +86,6 @@ public class UnifiedOrderModel { */ private SceneInfo scene_info; - - public String getDescription() { - if (!StringUtils.isEmpty(description) && description.length() > 30) { - return description.substring(30); - } - return description; - } - } From d25f17782b4d3e940851579c31d3622582f4da35 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 18 May 2022 21:35:17 +0800 Subject: [PATCH 088/185] =?UTF-8?q?=E8=A7=84=E8=8C=83=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/payment/kit/params/dto/CashierParam.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java index b28d7950..b7b5b096 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java @@ -18,6 +18,8 @@ import java.util.List; @ToString public class CashierParam { + static Long MAX_DETAIL_LENGTH = 30L; + @ApiModelProperty(value = "价格") private Double price; @@ -48,7 +50,7 @@ public class CashierParam { return "清单详细"; } //对参数长度进行限制 - if (!StringUtils.isEmpty(detail) && detail.length() > 30) { + if (!StringUtils.isEmpty(detail) && detail.length() > MAX_DETAIL_LENGTH) { detail = detail.substring(30); } return StringUtils.filterSpecialChart(detail); From f5718b4062febc22db1c03eb0a97c952b0f8bbe6 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 18 May 2022 22:00:42 +0800 Subject: [PATCH 089/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9sku?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A6=82=E5=AD=98=E5=9C=A8sku=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 53211c3d..00cbe0b0 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 @@ -179,7 +179,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i this.clearCache(sku.getId()); } } - this.updateBatchById(newSkuList); + this.saveOrUpdateBatch(newSkuList); } this.updateStock(newSkuList); if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) { From b19e4043cde187b5fd08be3d62a56a7247867e6a Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 18 May 2022 22:38:13 +0800 Subject: [PATCH 090/185] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/utils/StringUtils.java | 14 ++++++++++++++ .../payment/kit/params/dto/CashierParam.java | 6 +----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/utils/StringUtils.java b/framework/src/main/java/cn/lili/common/utils/StringUtils.java index f3ae80e1..bf9df5b6 100644 --- a/framework/src/main/java/cn/lili/common/utils/StringUtils.java +++ b/framework/src/main/java/cn/lili/common/utils/StringUtils.java @@ -147,6 +147,20 @@ public class StringUtils extends StrUtil { return str.concat(appendStr); } + /** + * 切割字符串 + * + * @param str 字符串 + * @param length 长度 + * @return 处理后的字符串 + */ + public static String sub(String str, Integer length) { + if (str.length() < length) { + return str; + } + return str.substring(0, length); + } + /** * 过滤特殊字符串 * diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java index b7b5b096..4bdfcbe5 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java @@ -49,10 +49,6 @@ public class CashierParam { if (StringUtils.isEmpty(detail)) { return "清单详细"; } - //对参数长度进行限制 - if (!StringUtils.isEmpty(detail) && detail.length() > MAX_DETAIL_LENGTH) { - detail = detail.substring(30); - } - return StringUtils.filterSpecialChart(detail); + return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30)); } } From 7fccbc2aa2ec12fe6bf180b1fec5f366408bdfc8 Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Thu, 19 May 2022 15:23:44 +0800 Subject: [PATCH 091/185] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=96=87=E7=AB=A0=E6=8E=A5=E5=8F=A3=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/controller/other/ArticleManagerController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java index ea8e22ab..d9372124 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ArticleManagerController.java @@ -42,6 +42,14 @@ public class ArticleManagerController { return ResultUtil.data(articleService.getById(id)); } + @ApiOperation(value = "根据类型查看文章") + @ApiImplicitParam(name = "type", value = "文章类型", required = true, dataType = "String", paramType = "path") + @GetMapping(value = "/type/{type}") + public ResultMessage
getByType(@PathVariable String type) { + + return ResultUtil.data(articleService.customGetByType(type)); + } + @ApiOperation(value = "分页获取") @ApiImplicitParams({ @ApiImplicitParam(name = "categoryId", value = "文章分类ID", paramType = "query"), From f2b327c811ad14ad170dd1ba3b353adb277adcb2 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 19 May 2022 17:34:55 +0800 Subject: [PATCH 092/185] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81sku=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E3=80=82mysql=20replace=20into(=E5=85=88=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=EF=BC=8C=E5=A6=82=E5=AD=98=E5=9C=A8=E5=88=99=E5=88=A0?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E6=96=B0=E5=A2=9E=E3=80=82=E5=A6=82=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=96=B0=E5=A2=9E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/mapper/GoodsSkuMapper.java | 76 +++++++++++++++++++ .../goods/service/GoodsSkuService.java | 2 + .../serviceimpl/GoodsSkuServiceImpl.java | 21 ++++- 3 files changed, 97 insertions(+), 2 deletions(-) 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 62f65589..db3e0a58 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,8 @@ package cn.lili.modules.goods.mapper; import cn.lili.modules.goods.entity.dos.GoodsSku; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -23,4 +25,78 @@ public interface GoodsSkuMapper extends BaseMapper { @Select("SELECT id FROM li_goods_sku WHERE goods_id = #{goodsId}") List getGoodsSkuIdByGoodsId(String goodsId); + + @Insert("replace into li_goods_sku (\n" + + "\tid,\n" + + "\tgoods_id,\n" + + "\tspecs,\n" + + "\tsimple_specs,\n" + + "\tfreight_template_id,\n" + + "\tgoods_name,\n" + + "\tsn,\n" + + "\tbrand_id,\n" + + "\tcategory_path,\n" + + "\tgoods_unit,\n" + + "\tselling_point,\n" + + "\tweight,\n" + + "\tmarket_enable,\n" + + "\tintro,\n" + + "\tprice,\n" + + "\tcost,\n" + + "\tquantity,\n" + + "\tgrade,\n" + + "\tthumbnail,\n" + + "\tsmall,\n" + + "\tstore_category_path,\n" + + "\tstore_id,\n" + + "\tstore_name,\n" + + "\tauth_flag,\n" + + "\tself_operated,\n" + + "\tmobile_intro,\n" + + "\trecommend,\n" + + "\tsales_model,\n" + + "\tgoods_type,\n" + + "\tcreate_by,\n" + + "\tcreate_time,\n" + + "\tupdate_time,\n" + + "\tdelete_flag \n" + + ")\n" + + " VALUES\n" + + "(\n" + + "\t#{goodsSku.id},\n" + + "\t#{goodsSku.goodsId},\n" + + "\t#{goodsSku.specs},\n" + + "\t#{goodsSku.simpleSpecs},\n" + + "\t#{goodsSku.freightTemplateId},\n" + + "\t#{goodsSku.goodsName},\n" + + "\t#{goodsSku.sn},\n" + + "\t#{goodsSku.brandId},\n" + + "\t#{goodsSku.categoryPath},\n" + + "\t#{goodsSku.goodsUnit},\n" + + "\t#{goodsSku.sellingPoint},\n" + + "\t#{goodsSku.weight},\n" + + "\t#{goodsSku.marketEnable},\n" + + "\t#{goodsSku.intro},\n" + + "\t#{goodsSku.price},\n" + + "\t#{goodsSku.cost},\n" + + "\t#{goodsSku.quantity},\n" + + "\t#{goodsSku.grade},\n" + + "\t#{goodsSku.thumbnail},\n" + + "\t#{goodsSku.small},\n" + + "\t#{goodsSku.storeCategoryPath},\n" + + "\t#{goodsSku.storeId},\n" + + "\t#{goodsSku.storeName},\n" + + "\t#{goodsSku.authFlag},\n" + + "\t#{goodsSku.selfOperated},\n" + + "\t#{goodsSku.mobileIntro},\n" + + "\t#{goodsSku.recommend},\n" + + "\t#{goodsSku.salesModel},\n" + + "\t#{goodsSku.goodsType},\n" + + "\t#{goodsSku.createBy},\n" + + "\t#{goodsSku.createTime},\n" + + "\t#{goodsSku.updateTime},\n" + + "\t#{goodsSku.deleteFlag}\n" + + ")") + int replaceGoodsSku(@Param("goodsSku") GoodsSku goodsSku); + } \ 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 b723f936..4babd511 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 @@ -211,4 +211,6 @@ public interface GoodsSkuService extends IService { * @return 全部skuId的集合 */ List getSkuIdsByGoodsId(String goodsId); + + boolean deleteAndInsertGoodsSkus(List goodsSkus); } \ 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 00cbe0b0..4957ec16 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 @@ -13,6 +13,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; +import cn.lili.common.utils.SnowFlake; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; @@ -149,9 +150,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl i oldSkuIds.add(goodsSkuVO.getId()); cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId())); } - this.removeByIds(oldSkuIds); + + this.remove(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); //删除sku相册 goodsGalleryService.removeByGoodsId(goods.getId()); + getGoodsListByGoodsId(goods.getId()); // 添加商品sku newSkuList = this.addGoodsSku(skuList, goods); @@ -179,6 +182,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i this.clearCache(sku.getId()); } } + this.remove(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); this.saveOrUpdateBatch(newSkuList); } this.updateStock(newSkuList); @@ -393,7 +397,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override public List getGoodsListByGoodsId(String goodsId) { - List list = this.list(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goodsId)); + List list = this.list(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goodsId).orderByAsc(GoodsSku::getGoodsName)); return this.getGoodsSkuVOList(list); } @@ -597,6 +601,19 @@ public class GoodsSkuServiceImpl extends ServiceImpl i applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品", GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId())); } + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deleteAndInsertGoodsSkus(List goodsSkus) { + int count = 0; + for (GoodsSku skus : goodsSkus) { + if (CharSequenceUtil.isEmpty(skus.getId())) { + skus.setId(SnowFlake.getIdStr()); + } + count = this.baseMapper.replaceGoodsSku(skus); + } + return count > 0; + } + /** * 修改库存 * From e9fdec6bb0872d0b57313e129200a56f011a9bbd Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 25 May 2022 11:22:53 +0800 Subject: [PATCH 093/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=A7=84=E6=A0=BC=E6=97=B6=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=A7=84=E6=A0=BC=E5=90=8E=E3=80=82es=E4=B8=AD?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=A0=E9=99=A4=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/listener/GoodsMessageListener.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 7e9b9aa3..ab19413d 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -138,7 +138,7 @@ public class GoodsMessageListener implements RocketMQListener { String goodsId = new String(messageExt.getBody()); log.info("生成索引: {}", goodsId); Goods goods = this.goodsService.getById(goodsId); - updateGoodsIndex(goods); + this.updateGoodsIndex(goods); } catch (Exception e) { log.error("生成商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } @@ -214,10 +214,7 @@ public class GoodsMessageListener implements RocketMQListener { if (goodsById != null) { this.deleteGoods(goodsById); this.updateGoodsNum(goodsById); - List skuIdsByGoodsId = this.goodsSkuService.getSkuIdsByGoodsId(goodsId); - if (skuIdsByGoodsId != null && !skuIdsByGoodsId.isEmpty()) { - this.goodsIndexService.deleteIndexByIds(skuIdsByGoodsId); - } + goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); } } @@ -392,6 +389,7 @@ public class GoodsMessageListener implements RocketMQListener { esGoodsIndices.add(goodsIndex); } } + this.goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goods.getId()).build()); this.goodsIndexService.addIndex(esGoodsIndices); } From 90671729eab4d13cd8b4216dbbaca0a0e3141504 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 25 May 2022 17:41:31 +0800 Subject: [PATCH 094/185] =?UTF-8?q?=E4=B8=8A=E4=B8=80=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/impl/statistics/OnlineMemberStatistics.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java index 1afdac4c..db9797b0 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/statistics/OnlineMemberStatistics.java @@ -59,7 +59,8 @@ public class OnlineMemberStatistics implements EveryHourExecute { AtomicReference lastNum = new AtomicReference<>(0); onlineMemberVOS = onlineMemberVOS.stream() .filter(onlineMemberVO -> { - if (onlineMemberVO.getDate().before(finalCalendar.getTime())) { + //如果为过滤参数,则记录为过期参数,则为统一时段上一周期的在线人数 + if (!onlineMemberVO.getDate().after(finalCalendar.getTime())) { lastNum.set(onlineMemberVO.getNum()); } return onlineMemberVO.getDate().after(finalCalendar.getTime()); From 431ff0464459f1ec90ec493cf8a894857b8099c3 Mon Sep 17 00:00:00 2001 From: xiaochangbai <704566072@qq.com> Date: Thu, 26 May 2022 16:24:39 +0800 Subject: [PATCH 095/185] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E5=BB=B6=E8=BF=9F=E6=B6=88=E6=81=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java index abda74b1..3e4aff1c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java @@ -121,7 +121,7 @@ public class StudioServiceImpl extends ServiceImpl impleme rocketmqCustomProperties.getPromotionTopic()); //直播间结束 - broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.START.name()); + broadcastMessage = new BroadcastMessage(studio.getId(), StudioStatusEnum.END.name()); this.timeTrigger.edit( TimeExecuteConstant.BROADCAST_EXECUTOR, broadcastMessage, From acb9e78a368c2bf1b310a463d23fbdeba51fb8d2 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 27 May 2022 16:32:00 +0800 Subject: [PATCH 096/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=89=B9=E5=8F=91=E9=94=80=E5=94=AE=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=95=86=E5=93=81sku=E7=9A=84=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DB/version4.2.4toMASTER.sql | 48 +++- .../java/cn/lili/common/enums/ResultCode.java | 4 + .../modules/goods/entity/dos/DraftGoods.java | 4 +- .../lili/modules/goods/entity/dos/Goods.java | 8 +- .../modules/goods/entity/dos/GoodsSku.java | 37 +++ .../modules/goods/entity/dos/Wholesale.java | 30 +++ .../goods/entity/dto/GoodsOperationDTO.java | 20 +- .../goods/entity/dto/GoodsSearchParams.java | 9 + .../goods/entity/dto/WholesaleDTO.java | 16 ++ .../entity/enums/GoodsSalesModeEnum.java | 9 +- .../modules/goods/entity/vos/GoodsVO.java | 6 + .../modules/goods/mapper/WholesaleMapper.java | 11 + .../modules/goods/render/GoodsSkuRender.java | 19 ++ .../goods/service/GoodsSkuService.java | 18 +- .../goods/service/WholesaleService.java | 28 ++ .../goods/serviceimpl/GoodsServiceImpl.java | 20 +- .../serviceimpl/GoodsSkuServiceImpl.java | 246 ++++-------------- .../serviceimpl/WholesaleServiceImpl.java | 64 +++++ .../modules/goods/sku/GoodsSkuBuilder.java | 114 ++++++++ .../goods/sku/render/SalesModelRender.java | 23 ++ .../impl/WholesaleSaleModelRenderImpl.java | 76 ++++++ .../cart/render/impl/CheckDataRender.java | 34 +++ .../order/cart/service/CartServiceImpl.java | 33 ++- .../search/entity/dos/EsGoodsIndex.java | 1 + 24 files changed, 642 insertions(+), 236 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/mapper/WholesaleMapper.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/sku/render/SalesModelRender.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java diff --git a/DB/version4.2.4toMASTER.sql b/DB/version4.2.4toMASTER.sql index 06e0fce2..c243f814 100644 --- a/DB/version4.2.4toMASTER.sql +++ b/DB/version4.2.4toMASTER.sql @@ -1,7 +1,10 @@ /** 增加签到日期 **/ -ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 '; -ALTER TABLE li_member_sign DROP INDEX uk_member_day; -ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; +ALTER TABLE li_member_sign + ADD day int DEFAULT NULL COMMENT '签到日 '; +ALTER TABLE li_member_sign + DROP INDEX uk_member_day; +ALTER TABLE li_member_sign + add unique uk_member_day (member_id, day) COMMENT 'uk_member_day'; @@ -9,10 +12,35 @@ ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk -- Table structure for li_hot_words_history -- ---------------------------- DROP TABLE IF EXISTS `li_hot_words_history`; -CREATE TABLE `li_hot_words_history` ( - `id` bigint NOT NULL COMMENT 'ID', - `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', - `keywords` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '热词', - `score` int DEFAULT NULL COMMENT '热词分数', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_bin; +CREATE TABLE `li_hot_words_history` +( + `id` bigint NOT NULL COMMENT 'ID', + `create_time` datetime(6) DEFAULT NULL COMMENT '创建时间', + `keywords` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT '热词', + `score` int DEFAULT NULL COMMENT '热词分数', + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb3 COLLATE = utf8_bin COMMENT '热词历史表'; + +-- ---------------------------- +-- Records of li_hot_words_history +-- ---------------------------- + +-- ---------------------------- +-- Table structure for li_wholesale +-- ---------------------------- +DROP TABLE IF EXISTS `li_wholesale`; +CREATE TABLE `li_wholesale` +( + `id` bigint NOT NULL, + `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `create_time` datetime(6) DEFAULT NULL, + `delete_flag` bit(1) DEFAULT NULL, + `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + `update_time` datetime(6) DEFAULT NULL, + `price` decimal(10, 2) DEFAULT NULL COMMENT '价格', + `goods_id` bigint DEFAULT NULL COMMENT '商品id', + `sku_id` bigint DEFAULT NULL COMMENT '商品skuId', + `num` int DEFAULT NULL COMMENT '起购量', + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '批发规则表'; + diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 76637576..e6fa993c 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -76,6 +76,10 @@ public enum ResultCode { GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), MUST_HAVE_GOODS_SKU(11012, "规格必须要有一个!"), + MUST_HAVE_SALES_MODEL(11022, "销售模式为批发时必须要有批发规则!"), + + HAVE_INVALID_SALES_MODEL(11023, "批发规则存在小于等于0的无效数据!"), + GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"), PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"), VIRTUAL_GOODS_NOT_NEED_TEMP(11015, "虚拟商品无需选择配送模板"), diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java index 03652d78..da2dbed2 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java @@ -12,7 +12,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Max; @@ -114,6 +113,9 @@ public class DraftGoods extends BaseEntity { @ApiModelProperty(value = "是否为推荐商品") private boolean recommend; + /** + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum + */ @ApiModelProperty(value = "销售模式") private String salesModel; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index aaf13425..7a079046 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -8,6 +8,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; +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 cn.lili.mybatis.BaseEntity; @@ -133,6 +134,9 @@ public class Goods extends BaseEntity { @ApiModelProperty(value = "是否为推荐商品", required = true) private Boolean recommend; + /** + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum + */ @ApiModelProperty(value = "销售模式", required = true) private String salesModel; @@ -179,10 +183,10 @@ public class Goods extends BaseEntity { if (!sku.containsKey("sn") || sku.get("sn") == null) { throw new ServiceException(ResultCode.GOODS_SKU_SN_ERROR); } - if (!sku.containsKey("price") || StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) { + if ((!sku.containsKey("price") || StringUtil.isEmpty(sku.get("price").toString()) || Convert.toDouble(sku.get("price")) <= 0) && !goodsOperationDTO.getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())) { throw new ServiceException(ResultCode.GOODS_SKU_PRICE_ERROR); } - if (!sku.containsKey("cost") || StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) { + if ((!sku.containsKey("cost") || StringUtil.isEmpty(sku.get("cost").toString()) || Convert.toDouble(sku.get("cost")) <= 0) && !goodsOperationDTO.getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())) { throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); } //虚拟商品没有重量字段 diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java index 767fd0bb..ebe97e91 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Max; @@ -24,6 +25,7 @@ import java.util.Date; @Data @TableName("li_goods_sku") @ApiModel(value = "商品sku对象") +@NoArgsConstructor public class GoodsSku extends BaseEntity { private static final long serialVersionUID = 4865908658161118934L; @@ -150,6 +152,9 @@ public class GoodsSku extends BaseEntity { @ApiModelProperty(value = "是否为推荐商品", required = true) private Boolean recommend; + /** + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum + */ @ApiModelProperty(value = "销售模式", required = true) private String salesModel; /** @@ -173,4 +178,36 @@ public class GoodsSku extends BaseEntity { return super.getUpdateTime(); } } + + /** + * 设置规格商品的基本商品信息 + * + * @param goods 基本商品信息 + */ + public GoodsSku(Goods goods) { + //商品基本信息 + this.goodsId = goods.getId(); + this.goodsName = goods.getGoodsName(); + this.goodsType = goods.getGoodsType(); + + this.selfOperated = goods.getSelfOperated(); + this.sellingPoint = goods.getSellingPoint(); + this.categoryPath = goods.getCategoryPath(); + this.brandId = goods.getBrandId(); + this.marketEnable = goods.getMarketEnable(); + this.intro = goods.getIntro(); + this.mobileIntro = goods.getMobileIntro(); + this.goodsUnit = goods.getGoodsUnit(); + this.grade = 100D; + //商品状态 + this.authFlag = goods.getAuthFlag(); + this.salesModel = goods.getSalesModel(); + //卖家信息 + this.storeId = goods.getStoreId(); + this.storeName = goods.getStoreName(); + this.storeCategoryPath = goods.getStoreCategoryPath(); + this.freightTemplateId = goods.getTemplateId(); + this.recommend = goods.getRecommend(); + } + } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java new file mode 100644 index 00000000..1838d006 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Wholesale.java @@ -0,0 +1,30 @@ +package cn.lili.modules.goods.entity.dos; + +import cn.lili.mybatis.BaseIdEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author paulG + * @since 2022/5/20 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("li_wholesale") +@ApiModel(value = "批发商品") +public class Wholesale extends BaseIdEntity { + + private static final long serialVersionUID = -6389806138583086068L; + + @ApiModelProperty(value = "商品ID") + private String goodsId; + @ApiModelProperty(value = "SkuID") + private String skuId; + @ApiModelProperty(value = "数量") + private Integer num; + @ApiModelProperty(value = "金额") + private Double price; +} 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 497bc349..6981372e 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 @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; /** - * 商品编辑DTO + * 商品操作DTO * * @author pikachu * @since 2020-02-24 19:27:20 @@ -77,13 +77,12 @@ public class GoodsOperationDTO implements Serializable { @Min(value = 0, message = "运费模板值不正确") private String templateId; - @ApiModelProperty(value = "sku列表") - @Valid - private List> skuList; - @ApiModelProperty(value = "卖点") private String sellingPoint; + /** + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum + */ @ApiModelProperty(value = "销售模式", required = true) private String salesModel; @@ -112,6 +111,17 @@ public class GoodsOperationDTO implements Serializable { @ApiModelProperty(value = "商品视频") private String goodsVideo; + + @ApiModelProperty(value = "sku列表") + @Valid + private List> skuList; + + /** + * 批发商品规则 + */ + @ApiModelProperty(value = "批发商品规则") + private List wholesaleList; + public String getGoodsName() { //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤,影响很大。 // 业务中,全局代码中只有商品名称不能拥有英文逗号,是由于商品名称存在一个数据库联合查询,结果要根据逗号分组 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 db523f1d..679c03d8 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 @@ -77,6 +77,12 @@ public class GoodsSearchParams extends PageVO { @ApiModelProperty(value = "商品类型") private String goodsType; + /** + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum + */ + @ApiModelProperty(value = "销售模式", required = true) + private String salesModel; + public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); if (CharSequenceUtil.isNotEmpty(goodsId)) { @@ -121,6 +127,9 @@ public class GoodsSearchParams extends PageVO { if (CharSequenceUtil.isNotEmpty(goodsType)) { queryWrapper.eq("goods_type", goodsType); } + if (CharSequenceUtil.isNotEmpty(salesModel)) { + queryWrapper.eq("sales_model", salesModel); + } queryWrapper.eq("delete_flag", false); this.betweenWrapper(queryWrapper); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java new file mode 100644 index 00000000..31cbd0bb --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/WholesaleDTO.java @@ -0,0 +1,16 @@ +package cn.lili.modules.goods.entity.dto; + +import cn.lili.modules.goods.entity.dos.Wholesale; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author paulG + * @since 2022/5/25 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +public class WholesaleDTO extends Wholesale { + private static final long serialVersionUID = 853297561151783335L; + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java b/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java index 2cabe2c7..b6d03aa5 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java @@ -1,19 +1,14 @@ package cn.lili.modules.goods.entity.enums; /** - * 商品审核 + * 销售模式 * * @author pikachu * @since 2020-02-26 23:24:13 */ public enum GoodsSalesModeEnum { - /** - * 需要审核 并且待审核 - */ + RETAIL("零售"), - /** - * 审核通过 - */ WHOLESALE("批发"); private final String description; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java index 804940a3..bf62838f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsVO.java @@ -1,9 +1,11 @@ package cn.lili.modules.goods.entity.vos; import cn.lili.modules.goods.entity.dos.Goods; +import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @@ -14,6 +16,7 @@ import java.util.List; * @since 2020-02-26 23:24:13 */ @Data +@EqualsAndHashCode(callSuper = true) public class GoodsVO extends Goods { private static final long serialVersionUID = 6377623919990713567L; @@ -29,4 +32,7 @@ public class GoodsVO extends Goods { @ApiModelProperty(value = "sku列表") private List skuList; + + @ApiModelProperty(value = "批发商品消费规则列表") + private List wholesaleList; } diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/WholesaleMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/WholesaleMapper.java new file mode 100644 index 00000000..372d4d43 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/mapper/WholesaleMapper.java @@ -0,0 +1,11 @@ +package cn.lili.modules.goods.mapper; + +import cn.lili.modules.goods.entity.dos.Wholesale; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @author paulG + * @since 2022/5/24 + **/ +public interface WholesaleMapper extends BaseMapper { +} diff --git a/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java b/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java new file mode 100644 index 00000000..61bfe273 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java @@ -0,0 +1,19 @@ +package cn.lili.modules.goods.render; + +import cn.lili.modules.goods.entity.dos.GoodsSku; + +import java.util.List; +import java.util.Map; + +/** + * 商品sku渲染器 + * + * @author paulG + * @since 2022/5/20 + **/ +public interface GoodsSkuRender { + + + GoodsSku render(List> skuList); + +} 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 4babd511..a1462bca 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 @@ -3,6 +3,7 @@ package cn.lili.modules.goods.service; import cn.lili.cache.CachePrefix; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; @@ -43,19 +44,18 @@ public interface GoodsSkuService extends IService { /** * 添加商品sku * - * @param skuList sku列表 - * @param goods 商品信息 + * @param goods 商品信息 + * @param goodsOperationDTO 商品操作信息 */ - void add(List> skuList, Goods goods); + void add(Goods goods, GoodsOperationDTO goodsOperationDTO); /** * 更新商品sku * - * @param skuList sku列表 - * @param goods 商品信息 - * @param regeneratorSkuFlag 是否是否重新生成sku + * @param goods 商品信息 + * @param goodsOperationDTO 商品操作信息 */ - void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag); + void update(Goods goods, GoodsOperationDTO goodsOperationDTO); /** * 更新商品sku @@ -154,9 +154,9 @@ public interface GoodsSkuService extends IService { /** * 更新商品sku状态根据店铺id * - * @param storeId 店铺id + * @param storeId 店铺id * @param marketEnable 市场启用状态 - * @param authFlag 审核状态 + * @param authFlag 审核状态 */ void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag); diff --git a/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java b/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java new file mode 100644 index 00000000..37346af0 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/service/WholesaleService.java @@ -0,0 +1,28 @@ +package cn.lili.modules.goods.service; + +import cn.lili.modules.goods.entity.dos.Wholesale; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * @author paulG + * @since 2022/5/24 + **/ +public interface WholesaleService extends IService { + + + List findByGoodsId(String goodsId); + + Boolean removeByGoodsId(String goodsId); + + /** + * 匹配批发规则 + * + * @param goodsId 商品规则 + * @param num 数量 + * @return 批发规则 + */ + Wholesale match(String goodsId, Integer num); + +} 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 0655f583..fbbbf6a3 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 @@ -1,5 +1,6 @@ package cn.lili.modules.goods.serviceimpl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.json.JSONUtil; @@ -14,6 +15,7 @@ import cn.lili.common.security.enums.UserEnums; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsGallery; +import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; @@ -22,10 +24,7 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; 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.CategoryService; -import cn.lili.modules.goods.service.GoodsGalleryService; -import cn.lili.modules.goods.service.GoodsService; -import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.*; import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.service.MemberEvaluationService; @@ -110,6 +109,9 @@ public class GoodsServiceImpl extends ServiceImpl implements @Autowired private FreightTemplateService freightTemplateService; + @Autowired + private WholesaleService wholesaleService; + @Autowired private Cache cache; @@ -168,7 +170,7 @@ public class GoodsServiceImpl extends ServiceImpl implements //添加商品 this.save(goods); //添加商品sku信息 - this.goodsSkuService.add(goodsOperationDTO.getSkuList(), goods); + this.goodsSkuService.add(goods, goodsOperationDTO); //添加相册 if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId()); @@ -192,7 +194,7 @@ public class GoodsServiceImpl extends ServiceImpl implements //修改商品 this.updateById(goods); //修改商品sku信息 - this.goodsSkuService.update(goodsOperationDTO.getSkuList(), goods, goodsOperationDTO.getRegeneratorSkuFlag()); + this.goodsSkuService.update(goods, goodsOperationDTO); //添加相册 if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId()); @@ -247,6 +249,12 @@ public class GoodsServiceImpl extends ServiceImpl implements if (CharSequenceUtil.isNotEmpty(goods.getParams())) { goodsVO.setGoodsParamsDTOList(JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class)); } + + List wholesaleList = wholesaleService.findByGoodsId(goodsId); + if (CollUtil.isNotEmpty(wholesaleList)) { + goodsVO.setWholesaleList(wholesaleList); + } + cache.put(CachePrefix.GOODS.getPrefix() + goodsId, goodsVO); return goodsVO; } 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 4957ec16..1f19526a 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 @@ -1,6 +1,5 @@ package cn.lili.modules.goods.serviceimpl; -import cn.hutool.core.convert.Convert; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; @@ -16,6 +15,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.SnowFlake; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; @@ -26,10 +26,9 @@ import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.entity.vos.SpecValueVO; import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; import cn.lili.modules.goods.mapper.GoodsSkuMapper; -import cn.lili.modules.goods.service.CategoryService; -import cn.lili.modules.goods.service.GoodsGalleryService; -import cn.lili.modules.goods.service.GoodsService; -import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.*; +import cn.lili.modules.goods.sku.GoodsSkuBuilder; +import cn.lili.modules.goods.sku.render.SalesModelRender; import cn.lili.modules.member.entity.dos.FootPrint; import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; @@ -38,7 +37,6 @@ import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.CouponGetEnum; import cn.lili.modules.promotion.service.PromotionGoodsService; -import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.utils.EsIndexUtil; @@ -114,35 +112,42 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Autowired private ApplicationEventPublisher applicationEventPublisher; + @Autowired + private WholesaleService wholesaleService; + + @Autowired + private List salesModelRenders; + @Override @Transactional(rollbackFor = Exception.class) - public void add(List> skuList, Goods goods) { - // 检查是否需要生成索引 - List newSkuList; - //如果有规格 - if (skuList != null && !skuList.isEmpty()) { - // 添加商品sku - newSkuList = this.addGoodsSku(skuList, goods); - } else { + public void add(Goods goods, GoodsOperationDTO goodsOperationDTO) { + // 是否存在规格 + if (goodsOperationDTO.getSkuList() == null || goodsOperationDTO.getSkuList().isEmpty()) { throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU); } + // 检查是否需要生成索引 + List goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO); + renderGoodsSkuList(goodsSkus, goodsOperationDTO); - this.updateStock(newSkuList); - if (!newSkuList.isEmpty()) { - generateEs(goods); + if (!goodsSkus.isEmpty()) { + this.saveOrUpdateBatch(goodsSkus); + this.updateStock(goodsSkus); + this.generateEs(goods); } } @Override @Transactional(rollbackFor = Exception.class) - public void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag) { + public void update(Goods goods, GoodsOperationDTO goodsOperationDTO) { // 是否存在规格 - if (skuList == null || skuList.isEmpty()) { + if (goodsOperationDTO.getSkuList() == null || goodsOperationDTO.getSkuList().isEmpty()) { throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU); } - List newSkuList; + List skuList; //删除旧的sku信息 - if (Boolean.TRUE.equals(regeneratorSkuFlag)) { + if (Boolean.TRUE.equals(goodsOperationDTO.getRegeneratorSkuFlag())) { + skuList = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO); + renderGoodsSkuList(skuList, goodsOperationDTO); List goodsListByGoodsId = getGoodsListByGoodsId(goods.getId()); List oldSkuIds = new ArrayList<>(); //删除旧索引 @@ -154,40 +159,34 @@ public class GoodsSkuServiceImpl extends ServiceImpl i this.remove(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); //删除sku相册 goodsGalleryService.removeByGoodsId(goods.getId()); - getGoodsListByGoodsId(goods.getId()); - // 添加商品sku - newSkuList = this.addGoodsSku(skuList, goods); //发送mq消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.SKU_DELETE.name(); rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(oldSkuIds), RocketmqSendCallbackBuilder.commonCallback()); } else { - newSkuList = new ArrayList<>(); - for (Map map : skuList) { + skuList = new ArrayList<>(); + for (Map map : goodsOperationDTO.getSkuList()) { GoodsSku sku = null; if (map.get("id") != null) { - sku = this.getGoodsSkuByIdFromCache(map.get("id").toString()); + sku = GoodsSkuBuilder.build(this.getGoodsSkuByIdFromCache(map.get("id").toString()), map, goodsOperationDTO); } if (sku == null || map.get("id") == null) { - sku = new GoodsSku(); + sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); } - //设置商品信息 - goodsInfo(sku, goods); - //设置商品规格信息 - skuInfo(sku, goods, map, null); - newSkuList.add(sku); + renderGoodsSku(sku, goodsOperationDTO); + skuList.add(sku); //如果商品状态值不对,则es索引移除 if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())) { goodsIndexService.deleteIndexById(sku.getId()); this.clearCache(sku.getId()); } } - this.remove(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); - this.saveOrUpdateBatch(newSkuList); } - this.updateStock(newSkuList); - if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) { - generateEs(goods); + if (!skuList.isEmpty()) { + this.remove(new LambdaQueryWrapper().eq(GoodsSku::getGoodsId, goods.getId())); + this.saveOrUpdateBatch(skuList); + this.updateStock(skuList); + this.generateEs(goods); } } @@ -257,9 +256,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } //商品下架||商品未审核通过||商品删除,则提示:商品已下架 - if (GoodsStatusEnum.DOWN.name().equals(goodsVO.getMarketEnable()) - || !GoodsAuthEnum.PASS.name().equals(goodsVO.getAuthFlag()) - || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { + if (GoodsStatusEnum.DOWN.name().equals(goodsVO.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goodsVO.getAuthFlag()) || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } @@ -278,13 +275,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl i promotionMap = promotionMap.entrySet().stream().parallel().filter(i -> { JSONObject jsonObject = JSONUtil.parseObj(i.getValue()); // 过滤活动赠送优惠券和无效时间的活动 - return (jsonObject.get("getType") == null || jsonObject.get("getType", String.class).equals(CouponGetEnum.FREE.name())) && - (jsonObject.get("startTime") != null && jsonObject.get("startTime", Date.class).getTime() <= System.currentTimeMillis()) && - (jsonObject.get("endTime") == null || jsonObject.get("endTime", Date.class).getTime() >= System.currentTimeMillis()); + return (jsonObject.get("getType") == null || jsonObject.get("getType", String.class).equals(CouponGetEnum.FREE.name())) && (jsonObject.get("startTime") != null && jsonObject.get("startTime", Date.class).getTime() <= System.currentTimeMillis()) && (jsonObject.get("endTime") == null || jsonObject.get("endTime", Date.class).getTime() >= System.currentTimeMillis()); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - Optional> containsPromotion = promotionMap.entrySet().stream().filter(i -> - i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + Optional> containsPromotion = promotionMap.entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); if (containsPromotion.isPresent()) { JSONObject jsonObject = JSONUtil.parseObj(containsPromotion.get().getValue()); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); @@ -305,6 +299,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //获取分类 String[] split = goodsSkuDetail.getCategoryPath().split(","); + map.put("wholesaleList", wholesaleService.findByGoodsId(goodsSkuDetail.getGoodsId())); map.put("categoryName", categoryService.getCategoryNameByIds(Arrays.asList(split))); //获取规格信息 @@ -347,7 +342,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku); } if (!goodsSkus.isEmpty()) { - generateEs(goods); + this.generateEs(goods); } } } @@ -565,10 +560,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //修改规格索引,发送mq消息 - Map updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap( - MapUtil.builder(new HashMap()).put("id", goodsSku.getId()).build(), - MapUtil.builder(new HashMap()).put("commentNum", goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum) - .put("grade", grade).build()); + Map updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap(MapUtil.builder(new HashMap()).put("id", goodsSku.getId()).build(), MapUtil.builder(new HashMap()).put("commentNum", goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum).put("grade", grade).build()); String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name(); rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(updateIndexFieldsMap), RocketmqSendCallbackBuilder.commonCallback()); @@ -632,153 +624,25 @@ public class GoodsSkuServiceImpl extends ServiceImpl i /** - * 增加sku集合 + * 批量渲染商品sku * - * @param skuList sku列表 - * @param goods 商品信息 + * @param goodsSkuList sku集合 + * @param goodsOperationDTO 商品操作DTO */ - List addGoodsSku(List> skuList, Goods goods) { - List skus = new ArrayList<>(); - for (Map skuVO : skuList) { - Map resultMap = this.add(skuVO, goods); - GoodsSku goodsSku = (GoodsSku) resultMap.get("goodsSku"); - if (goods.getSelfOperated() != null) { - goodsSku.setSelfOperated(goods.getSelfOperated()); - } - goodsSku.setGoodsType(goods.getGoodsType()); - skus.add(goodsSku); - cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); - } - this.saveOrUpdateBatch(skus); - return skus; + void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO) { + // 商品销售模式渲染器 + salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO)); } /** - * 添加商品规格 + * 渲染商品sku * - * @param map 规格属性 - * @param goods 商品 - * @return 规格商品 + * @param goodsSku sku + * @param goodsOperationDTO 商品操作DTO */ - private Map add(Map map, Goods goods) { - Map resultMap = new HashMap<>(2); - GoodsSku sku = new GoodsSku(); - - //商品索引 - EsGoodsIndex esGoodsIndex = new EsGoodsIndex(); - - //设置商品信息 - goodsInfo(sku, goods); - //设置商品规格信息 - skuInfo(sku, goods, map, esGoodsIndex); - - esGoodsIndex.setGoodsSku(sku); - resultMap.put("goodsSku", sku); - resultMap.put("goodsIndex", esGoodsIndex); - return resultMap; - } - - /** - * 设置规格商品的商品信息 - * - * @param sku 规格 - * @param goods 商品 - */ - private void goodsInfo(GoodsSku sku, Goods goods) { - //商品基本信息 - sku.setGoodsId(goods.getId()); - - sku.setSellingPoint(goods.getSellingPoint()); - sku.setCategoryPath(goods.getCategoryPath()); - sku.setBrandId(goods.getBrandId()); - sku.setMarketEnable(goods.getMarketEnable()); - sku.setIntro(goods.getIntro()); - sku.setMobileIntro(goods.getMobileIntro()); - sku.setGoodsUnit(goods.getGoodsUnit()); - sku.setGrade(100D); - //商品状态 - sku.setAuthFlag(goods.getAuthFlag()); - sku.setSalesModel(goods.getSalesModel()); - //卖家信息 - sku.setStoreId(goods.getStoreId()); - sku.setStoreName(goods.getStoreName()); - sku.setStoreCategoryPath(goods.getStoreCategoryPath()); - sku.setFreightTemplateId(goods.getTemplateId()); - sku.setRecommend(goods.getRecommend()); - } - - /** - * 设置商品规格信息 - * - * @param sku 规格商品 - * @param goods 商品 - * @param map 规格信息 - * @param esGoodsIndex 商品索引 - */ - private void skuInfo(GoodsSku sku, Goods goods, Map map, EsGoodsIndex esGoodsIndex) { - - //规格简短信息 - StringBuilder simpleSpecs = new StringBuilder(); - //商品名称 - StringBuilder goodsName = new StringBuilder(goods.getGoodsName()); - //规格商品缩略图 - String thumbnail = ""; - String small = ""; - //规格值 - Map specMap = new HashMap<>(16); - //商品属性 - List attributes = new ArrayList<>(); - - //获取规格信息 - for (Map.Entry spec : map.entrySet()) { - //保存规格信息 - if (("id").equals(spec.getKey()) || ("sn").equals(spec.getKey()) || ("cost").equals(spec.getKey()) - || ("price").equals(spec.getKey()) || ("quantity").equals(spec.getKey()) - || ("weight").equals(spec.getKey())) { - continue; - } else { - specMap.put(spec.getKey(), spec.getValue()); - if (("images").equals(spec.getKey())) { - //设置规格商品缩略图 - List> images = (List>) spec.getValue(); - if (images == null || images.isEmpty()) { - continue; - } - //设置规格商品缩略图 - //如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前 - if (CharSequenceUtil.isNotEmpty(spec.getValue().toString())) { - thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); - small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); - } - } else { - if (spec.getValue() != null) { - //设置商品名称 - goodsName.append(" ").append(spec.getValue()); - //规格简短信息 - simpleSpecs.append(" ").append(spec.getValue()); - } - } - } - } - //设置规格信息 - sku.setGoodsName(goodsName.toString()); - sku.setThumbnail(thumbnail); - sku.setSmall(small); - - //规格信息 - sku.setId(Convert.toStr(map.get("id"), "")); - sku.setSn(Convert.toStr(map.get("sn"))); - sku.setWeight(Convert.toDouble(map.get("weight"), 0D)); - sku.setPrice(Convert.toDouble(map.get("price"), 0D)); - sku.setCost(Convert.toDouble(map.get("cost"), 0D)); - sku.setQuantity(Convert.toInt(map.get("quantity"), 0)); - sku.setSpecs(JSONUtil.toJsonStr(specMap)); - sku.setSimpleSpecs(simpleSpecs.toString()); - - if (esGoodsIndex != null) { - //商品索引 - esGoodsIndex.setAttrList(attributes); - } + void renderGoodsSku(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { + // 商品销售模式渲染器 + salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO)); } /** diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java new file mode 100644 index 00000000..ad759acb --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java @@ -0,0 +1,64 @@ +package cn.lili.modules.goods.serviceimpl; + +import cn.hutool.core.collection.CollUtil; +import cn.lili.cache.Cache; +import cn.lili.modules.goods.entity.dos.Wholesale; +import cn.lili.modules.goods.mapper.WholesaleMapper; +import cn.lili.modules.goods.service.WholesaleService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author paulG + * @since 2022/5/24 + **/ +@Service +@CacheConfig(cacheNames = "{wholesale}_") +public class WholesaleServiceImpl extends ServiceImpl implements WholesaleService { + + @Autowired + private Cache> cache; + + @Override + @Cacheable(key = "#goodsId") + public List findByGoodsId(String goodsId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Wholesale::getGoodsId, goodsId); + return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList()); + } + + @Override + @CacheEvict(key = "#goodsId") + public Boolean removeByGoodsId(String goodsId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Wholesale::getGoodsId, goodsId); + return this.remove(queryWrapper); + } + + @Override + public Wholesale match(String goodsId, Integer num) { + List wholesaleList = cache.get("{wholesale}_" + goodsId); + if (wholesaleList == null) { + wholesaleList = this.findByGoodsId(goodsId); + cache.put("{wholesale}_" + goodsId, wholesaleList); + } + List matchList = wholesaleList.stream() + .filter(wholesale -> wholesale.getNum() <= num) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(matchList)) { + return matchList.get(matchList.size() - 1); + } else if (CollUtil.isNotEmpty(wholesaleList) && CollUtil.isEmpty(matchList)) { + return wholesaleList.get(0); + } + return null; + } +} diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java new file mode 100644 index 00000000..63d83980 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java @@ -0,0 +1,114 @@ +package cn.lili.modules.goods.sku; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.json.JSONUtil; +import cn.lili.modules.goods.entity.dos.Goods; +import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * @author paulG + * @since 2022/5/20 + **/ +@Component +public class GoodsSkuBuilder { + + + private static final String IMAGES_KEY = "images"; + + + /** + * 构建商品sku + * + * @param goods 商品 + * @param skuInfo sku信息列表 + * @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空) + * @return 商品sku + */ + public static GoodsSku build(Goods goods, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { + GoodsSku goodsSku = new GoodsSku(goods); + builderSingle(goodsSku, skuInfo, goodsOperationDTO); + return goodsSku; + } + + /** + * 批量构建商品sku + * + * @param goods 商品 + * @param goodsOperationDTO 商品操作信息 + * @return 商品sku + */ + public static List buildBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) { + return builderBatch(goods, goodsOperationDTO); + } + + /** + * 从已有的商品sku中构建商品sku + * + * @param goodsSku 原商品sku + * @param skuInfo sku信息列表 + * @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空) + * @return 商品sku + */ + public static GoodsSku build(GoodsSku goodsSku, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { + builderSingle(goodsSku, skuInfo, goodsOperationDTO); + return goodsSku; + } + + private static void builderSingle(GoodsSku goodsSku, Map skuInfo, GoodsOperationDTO goodsOperationDTO) { + Assert.notNull(goodsSku, "goodsSku不能为空"); + Assert.notEmpty(skuInfo, "skuInfo不能为空"); + //规格简短信息 + StringBuilder simpleSpecs = new StringBuilder(); + //商品名称 + StringBuilder goodsName = new StringBuilder(goodsOperationDTO.getGoodsName()); + //规格值 + Map specMap = new HashMap<>(16); + + // 原始规格项 + String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", IMAGES_KEY}; + //获取规格信息 + for (Map.Entry spec : skuInfo.entrySet()) { + //保存新增规格信息 + if (!CollUtil.contains(Arrays.asList(ignoreOriginKeys), spec.getKey()) && spec.getValue() != null) { + specMap.put(spec.getKey(), spec.getValue()); + //设置商品名称 + goodsName.append(" ").append(spec.getValue()); + //规格简短信息 + simpleSpecs.append(" ").append(spec.getValue()); + } + } + //设置规格信息 + goodsSku.setGoodsName(goodsName.toString()); + + + //规格信息 + goodsSku.setId(Convert.toStr(skuInfo.get("id"), "")); + goodsSku.setSn(Convert.toStr(skuInfo.get("sn"))); + goodsSku.setWeight(Convert.toDouble(skuInfo.get("weight"), 0D)); + goodsSku.setPrice(Convert.toDouble(skuInfo.get("price"), 0D)); + goodsSku.setCost(Convert.toDouble(skuInfo.get("cost"), 0D)); + goodsSku.setQuantity(Convert.toInt(skuInfo.get("quantity"), 0)); + goodsSku.setSpecs(JSONUtil.toJsonStr(specMap)); + goodsSku.setSimpleSpecs(simpleSpecs.toString()); + } + + private static List builderBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) { + Assert.notEmpty(goodsOperationDTO.getSkuList(), "goodsOperationDTO.getSkuList()不能为空"); + Assert.notNull(goods, "goods不能为空"); + List goodsSkus = new ArrayList<>(); + for (Map skuInfo : goodsOperationDTO.getSkuList()) { + GoodsSku goodsSku = new GoodsSku(goods); + builderSingle(goodsSku, skuInfo, goodsOperationDTO); + goodsSkus.add(goodsSku); + } + return goodsSkus; + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/SalesModelRender.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/SalesModelRender.java new file mode 100644 index 00000000..cc1f4591 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/SalesModelRender.java @@ -0,0 +1,23 @@ +package cn.lili.modules.goods.sku.render; + +import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; + +import java.util.List; + +/** + * 根据商品销售模型渲染商品sku + * + * @author paulG + * @since 2022/5/20 + **/ +public interface SalesModelRender { + + + String getSalesMode(); + + void renderSingle(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO); + + void renderBatch(List goodsSkus, GoodsOperationDTO goodsOperationDTO); + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java new file mode 100644 index 00000000..ea18054e --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java @@ -0,0 +1,76 @@ +package cn.lili.modules.goods.sku.render.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; +import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.Wholesale; +import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; +import cn.lili.modules.goods.entity.dto.WholesaleDTO; +import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; +import cn.lili.modules.goods.service.WholesaleService; +import cn.lili.modules.goods.sku.render.SalesModelRender; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author paulG + * @since 2022/5/24 + **/ +@Component +public class WholesaleSaleModelRenderImpl implements SalesModelRender { + /** + * 批发商品 + */ + @Autowired + private WholesaleService wholesaleService; + + + @Override + @Transactional(rollbackFor = Exception.class) + public void renderSingle(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { + Assert.notEmpty(goodsOperationDTO.getWholesaleList(), "批发规则不能为空"); + this.checkWholesaleList(goodsOperationDTO.getWholesaleList()); + List collect = goodsOperationDTO.getWholesaleList().stream().sorted(Comparator.comparing(Wholesale::getPrice)).collect(Collectors.toList()); + wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + wholesaleService.saveOrUpdateBatch(collect); + goodsSku.setPrice(collect.get(0).getPrice()); + goodsSku.setCost(collect.get(0).getPrice()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void renderBatch(List goodsSkus, GoodsOperationDTO goodsOperationDTO) { + Assert.notEmpty(goodsOperationDTO.getWholesaleList(), "批发规则不能为空"); + this.checkWholesaleList(goodsOperationDTO.getWholesaleList()); + List collect = goodsOperationDTO.getWholesaleList().stream().sorted(Comparator.comparing(Wholesale::getPrice)).collect(Collectors.toList()); + for (GoodsSku skus : goodsSkus) { + skus.setPrice(collect.get(0).getPrice()); + skus.setCost(collect.get(0).getPrice()); + } + wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + wholesaleService.saveOrUpdateBatch(collect); + } + + private void checkWholesaleList(List wholesaleList) { + if (CollUtil.isEmpty(wholesaleList)) { + throw new ServiceException(ResultCode.MUST_HAVE_SALES_MODEL); + } + for (WholesaleDTO wholesaleDTO : wholesaleList) { + if (wholesaleDTO.getPrice() == null || wholesaleDTO.getPrice() <= 0 || wholesaleDTO.getNum() == null || wholesaleDTO.getNum() <= 0) { + throw new ServiceException(ResultCode.HAVE_INVALID_SALES_MODEL); + } + } + } + + @Override + public String getSalesMode() { + return GoodsSalesModeEnum.WHOLESALE.name(); + } +} diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 58ca809d..7d6eb9fa 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.cart.render.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; @@ -7,10 +8,14 @@ import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.context.UserContext; +import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; +import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.WholesaleService; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.TradeDTO; @@ -55,6 +60,9 @@ public class CheckDataRender implements CartRenderStep { @Autowired private MemberService memberService; + @Autowired + private WholesaleService wholesaleService; + @Override public RenderStepEnums step() { @@ -69,6 +77,7 @@ public class CheckDataRender implements CartRenderStep { //校验商品有效性 checkData(tradeDTO); + preSaleModel(tradeDTO); //店铺分组数据初始化 groupStore(tradeDTO); @@ -212,4 +221,29 @@ public class CheckDataRender implements CartRenderStep { } + + /** + * 商品销售模式特殊处理 + * + * @param tradeDTO 交易信息 + */ + private void preSaleModel(TradeDTO tradeDTO) { + // 寻找同goods下销售模式为批发的商品 + Map> goodsGroup = tradeDTO.getSkuList().stream().filter(i -> i.getGoodsSku().getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())).collect(Collectors.groupingBy(i -> i.getGoodsSku().getGoodsId())); + if (CollUtil.isNotEmpty(goodsGroup)) { + goodsGroup.forEach((k, v) -> { + // 获取购买总数 + int sum = v.stream().mapToInt(CartSkuVO::getNum).sum(); + // 匹配符合的批发规则 + Wholesale match = wholesaleService.match(k, sum); + if (match != null) { + v.forEach(i -> { + // 将符合规则的商品设置批发价格 + i.setPurchasePrice(match.getPrice()); + i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); + }); + } + }); + } + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index b271f7c0..f23459df 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.cart.service; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; @@ -11,11 +12,14 @@ import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; +import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.WholesaleService; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.service.MemberAddressService; @@ -124,6 +128,9 @@ public class CartServiceImpl implements CartService { @Autowired private PromotionGoodsService promotionGoodsService; + @Autowired + private WholesaleService wholesaleService; + @Override public void add(String skuId, Integer num, String cartType, Boolean cover) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); @@ -193,6 +200,7 @@ public class CartServiceImpl implements CartService { cartSkuVOS.add(cartSkuVO); } + this.checkGoodsSaleModel(dataSku, tradeDTO.getSkuList()); tradeDTO.setCartTypeEnum(cartTypeEnum); //如购物车发生更改,则重置优惠券 tradeDTO.setStoreCoupons(null); @@ -554,12 +562,9 @@ public class CartServiceImpl implements CartService { goodsIndex = goodsIndexService.getResetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); } if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) { - if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || - (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) - && CartTypeEnum.PINTUAN.name().equals(cartType))) { + if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) && CartTypeEnum.PINTUAN.name().equals(cartType))) { - Optional> containsPromotion = goodsIndex.getPromotionMap().entrySet().stream().filter(i -> - i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + Optional> containsPromotion = goodsIndex.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); if (containsPromotion.isPresent()) { JSONObject promotionsObj = JSONUtil.parseObj(containsPromotion.get().getValue()); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); @@ -709,6 +714,24 @@ public class CartServiceImpl implements CartService { } } + + private void checkGoodsSaleModel(GoodsSku dataSku, List cartSkuVOS) { + if (dataSku.getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())) { + int numSum = 0; + List sameGoodsIdSkuList = cartSkuVOS.stream().filter(i -> i.getGoodsSku().getGoodsId().equals(dataSku.getGoodsId())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(sameGoodsIdSkuList)) { + numSum += sameGoodsIdSkuList.stream().mapToInt(CartSkuVO::getNum).sum(); + } + Wholesale match = wholesaleService.match(dataSku.getGoodsId(), numSum); + if (match != null) { + sameGoodsIdSkuList.forEach(i -> { + i.setPurchasePrice(match.getPrice()); + i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); + }); + } + } + } + /** * 校验拼团信息 * diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 73f01614..71ba03c0 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -215,6 +215,7 @@ public class EsGoodsIndex implements Serializable { /** * 销售模式 + * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum */ @Field(type = FieldType.Text) @ApiModelProperty("销售模式") From c0337afbaa1b5b0e97d7bc081e9b7cc6883c1337 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 27 May 2022 16:32:39 +0800 Subject: [PATCH 097/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E5=8D=87=E7=BA=A7hutool=E5=92=8Clombok=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/entity/dos/StudioCommodity.java | 4 ++++ .../cn/lili/modules/permission/entity/dos/Department.java | 5 ++++- .../lili/modules/promotion/entity/vos/PromotionSkuVO.java | 6 +++++- .../permission/DepartmentManagerController.java | 8 ++++---- pom.xml | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/StudioCommodity.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/StudioCommodity.java index 1b6e90d7..061dac65 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/StudioCommodity.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/StudioCommodity.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -15,11 +16,14 @@ import lombok.NoArgsConstructor; * @since 2021/5/18 5:42 下午 */ @Data +@EqualsAndHashCode(callSuper = true) @ApiModel(value = "直播间商品") @TableName("li_studio_commodity") @NoArgsConstructor public class StudioCommodity extends BaseIdEntity { + private static final long serialVersionUID = 8383627725577840261L; + @ApiModelProperty(value = "房间ID") private Integer roomId; diff --git a/framework/src/main/java/cn/lili/modules/permission/entity/dos/Department.java b/framework/src/main/java/cn/lili/modules/permission/entity/dos/Department.java index aa8d7348..854db81f 100644 --- a/framework/src/main/java/cn/lili/modules/permission/entity/dos/Department.java +++ b/framework/src/main/java/cn/lili/modules/permission/entity/dos/Department.java @@ -5,8 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; -import java.math.BigDecimal; +import javax.validation.constraints.NotNull; /** @@ -18,11 +19,13 @@ import java.math.BigDecimal; @Data @TableName("li_department") @ApiModel(value = "部门") +@EqualsAndHashCode(callSuper = true) public class Department extends BaseEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "部门名称") + @NotNull(message = "部门名称不能为空") private String title; @ApiModelProperty(value = "父id") diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java index 57c54dad..24b3558d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java @@ -5,6 +5,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + /** * 促销skuVO * @@ -15,7 +17,9 @@ import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor -public class PromotionSkuVO { +public class PromotionSkuVO implements Serializable { + + private static final long serialVersionUID = -8587010496940375179L; /** * 促销类型 diff --git a/manager-api/src/main/java/cn/lili/controller/permission/DepartmentManagerController.java b/manager-api/src/main/java/cn/lili/controller/permission/DepartmentManagerController.java index 724b6c97..86087a74 100644 --- a/manager-api/src/main/java/cn/lili/controller/permission/DepartmentManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/permission/DepartmentManagerController.java @@ -1,15 +1,16 @@ package cn.lili.controller.permission; import cn.lili.common.enums.ResultUtil; -import cn.lili.mybatis.util.PageUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.SearchVO; import cn.lili.modules.permission.entity.dos.Department; import cn.lili.modules.permission.entity.vo.DepartmentVO; import cn.lili.modules.permission.service.DepartmentService; +import cn.lili.mybatis.util.PageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -45,15 +46,14 @@ public class DepartmentManagerController { @PostMapping @ApiOperation(value = "新增部门") - public ResultMessage save(Department department) { + public ResultMessage save(@Validated Department department) { departmentService.save(department); return ResultUtil.data(department); } @PutMapping("/{id}") @ApiOperation(value = "更新部门") - public ResultMessage update(@PathVariable String id, Department department) { - departmentService.updateById(department); + public ResultMessage update(@PathVariable String id, @Validated Department department) { departmentService.updateById(department); return ResultUtil.data(department); } diff --git a/pom.xml b/pom.xml index 53b79e7e..a9d92a59 100644 --- a/pom.xml +++ b/pom.xml @@ -26,11 +26,11 @@ 1 4.22.32.ALL 3.5.1 - 5.7.20 + 5.8.0 2.0.3.RELEASE 3.0.4 2.9.10 - 1.18.22 + 1.18.24 3.15.6 4.5.18 3.11.1 From 17c7552f7faa84e1a73458e080142073ef0b4dad Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 30 May 2022 10:39:12 +0800 Subject: [PATCH 098/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=89=B9=E5=8F=91=E9=94=80=E5=94=AE=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=95=86=E5=93=81sku=E7=9A=84=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/GoodsSkuServiceImpl.java | 18 ++++++++++++++++++ .../serviceimpl/WholesaleServiceImpl.java | 1 + .../modules/goods/sku/GoodsSkuBuilder.java | 12 +++++++----- .../cart/render/impl/CheckDataRender.java | 12 +++++++++--- 4 files changed, 35 insertions(+), 8 deletions(-) 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 1f19526a..509ec070 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 @@ -632,6 +632,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i void renderGoodsSkuList(List goodsSkuList, GoodsOperationDTO goodsOperationDTO) { // 商品销售模式渲染器 salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO)); + for (GoodsSku goodsSku : goodsSkuList) { + this.renderImages(goodsSku); + } } /** @@ -643,6 +646,21 @@ public class GoodsSkuServiceImpl extends ServiceImpl i void renderGoodsSku(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { // 商品销售模式渲染器 salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO)); + this.renderImages(goodsSku); + } + + /** + * 渲染sku图片 + * + * @param goodsSku + */ + void renderImages(GoodsSku goodsSku) { + JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); + List> images = jsonObject.get("images", List.class); + if (images != null && !images.isEmpty()) { + goodsSku.setThumbnail(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail()); + goodsSku.setSmall(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall()); + } } /** diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java index ad759acb..d8c2b98c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/WholesaleServiceImpl.java @@ -41,6 +41,7 @@ public class WholesaleServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Wholesale::getGoodsId, goodsId); + cache.remove("{wholesale}_" + goodsId); return this.remove(queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java index 63d83980..cc86a43f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/GoodsSkuBuilder.java @@ -71,16 +71,18 @@ public class GoodsSkuBuilder { Map specMap = new HashMap<>(16); // 原始规格项 - String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", IMAGES_KEY}; + String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"}; //获取规格信息 for (Map.Entry spec : skuInfo.entrySet()) { //保存新增规格信息 if (!CollUtil.contains(Arrays.asList(ignoreOriginKeys), spec.getKey()) && spec.getValue() != null) { specMap.put(spec.getKey(), spec.getValue()); - //设置商品名称 - goodsName.append(" ").append(spec.getValue()); - //规格简短信息 - simpleSpecs.append(" ").append(spec.getValue()); + if (!spec.getKey().equals(IMAGES_KEY)) { + //设置商品名称 + goodsName.append(" ").append(spec.getValue()); + //规格简短信息 + simpleSpecs.append(" ").append(spec.getValue()); + } } } //设置规格信息 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 7d6eb9fa..1430263b 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -233,14 +233,20 @@ public class CheckDataRender implements CartRenderStep { if (CollUtil.isNotEmpty(goodsGroup)) { goodsGroup.forEach((k, v) -> { // 获取购买总数 - int sum = v.stream().mapToInt(CartSkuVO::getNum).sum(); + int sum = v.stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).mapToInt(CartSkuVO::getNum).sum(); + int fSum = v.stream().filter(i -> Boolean.FALSE.equals(i.getChecked())).mapToInt(CartSkuVO::getNum).sum(); // 匹配符合的批发规则 Wholesale match = wholesaleService.match(k, sum); if (match != null) { v.forEach(i -> { // 将符合规则的商品设置批发价格 - i.setPurchasePrice(match.getPrice()); - i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); + if (Boolean.TRUE.equals(i.getChecked())) { + i.setPurchasePrice(match.getPrice()); + i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); + } else { + i.setPurchasePrice(wholesaleService.match(k, fSum).getPrice()); + i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); + } }); } }); From 1ecd32027ea4fce6bd3247098c3f06caaad2f881 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 31 May 2022 14:37:18 +0800 Subject: [PATCH 099/185] =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=97=B6,=E6=B8=85=E9=99=A4=E7=BC=93=E5=AD=98;=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/service/CategoryService.java | 6 ------ .../modules/goods/serviceimpl/CategoryServiceImpl.java | 9 +++++++++ .../order/order/serviceimpl/OrderServiceImpl.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) 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 86888589..1941fe40 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 @@ -4,9 +4,6 @@ package cn.lili.modules.goods.service; import cn.lili.modules.goods.entity.dos.Category; import cn.lili.modules.goods.entity.vos.CategoryVO; import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; import java.util.List; @@ -16,7 +13,6 @@ import java.util.List; * @author pikachu * @since 2020-03-02 16:44:56 */ -@CacheConfig(cacheNames = "{category}") public interface CategoryService extends IService { @@ -35,7 +31,6 @@ public interface CategoryService extends IService { * @param id * @return */ - @Cacheable(key = "#id") Category getCategoryById(String id); /** @@ -99,7 +94,6 @@ public interface CategoryService extends IService { * @param category 商品分类信息 * @return 修改结果 */ - @CacheEvict(key = "#category.id") void updateCategory(Category category); /** 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 70b29346..c262f9ff 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 @@ -19,6 +19,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -36,6 +39,7 @@ import java.util.stream.Collectors; * @since 2020-02-23 15:18:56 */ @Service +@CacheConfig(cacheNames = "{CATEGORY}") public class CategoryServiceImpl extends ServiceImpl implements CategoryService { private static final String DELETE_FLAG_COLUMN = "delete_flag"; @@ -60,6 +64,7 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override + @Cacheable(key = "#id") public Category getCategoryById(String id) { return this.getById(id); } @@ -216,6 +221,7 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override + @CacheEvict(key = "#category.id") @Transactional(rollbackFor = Exception.class) public void updateCategory(Category category) { //判断分类佣金是否正确 @@ -242,6 +248,7 @@ public class CategoryServiceImpl extends ServiceImpl i @Override + @CacheEvict(key = "#id") @Transactional(rollbackFor = Exception.class) public void delete(String id) { this.removeById(id); @@ -253,6 +260,7 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override + @CacheEvict(key = "#categoryId") @Transactional(rollbackFor = Exception.class) public void updateCategoryStatus(String categoryId, Boolean enableOperations) { //禁用子分类 @@ -346,5 +354,6 @@ public class CategoryServiceImpl extends ServiceImpl i */ private void removeCache() { cache.remove(CachePrefix.CATEGORY.getPrefix()); + cache.remove(CachePrefix.CATEGORY_ARRAY.getPrefix()); } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index c44e9de5..b6211c3c 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -709,6 +709,7 @@ public class OrderServiceImpl extends ServiceImpl implements * @return 是否成功 */ @Override + @Transactional(rollbackFor = Exception.class) public boolean checkFictitiousOrder(String pintuanId, Integer requiredNum, Boolean fictitious) { Map> collect = this.queryListByPromotion(pintuanId) .stream().collect(Collectors.groupingBy(Order::getParentOrderSn)); @@ -813,7 +814,6 @@ public class OrderServiceImpl extends ServiceImpl implements //如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下) PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage(); //开团结束时间 -// long startTime = DateUtil.offsetHour(new Date(), 1).getTime(); long startTime = DateUtil.offsetMinute(new Date(), 2).getTime(); pintuanOrderMessage.setOrderSn(parentOrderSn); pintuanOrderMessage.setPintuanId(pintuanId); From a3c4e72902f103129679486fb6f5e67c8f49f0dd Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 31 May 2022 16:33:10 +0800 Subject: [PATCH 100/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=89=B9=E5=8F=91=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PreventDuplicateSubmissionsInterceptor.java | 4 ++-- .../sku/render/impl/WholesaleSaleModelRenderImpl.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java index 77a3a66b..8f6decfe 100644 --- a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java @@ -36,8 +36,8 @@ public class PreventDuplicateSubmissionsInterceptor { try { Long count = cache.incr(getParams(), preventDuplicateSubmissions.expire()); - //如果超过1或者设置的参数,则表示重复提交了 - if (count.intValue() >= 1) { + //如果超过2或者设置的参数,则表示重复提交了 + if (count.intValue() >= 2) { throw new ServiceException(ResultCode.LIMIT_ERROR); } } diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java index ea18054e..a63660cb 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java @@ -2,6 +2,7 @@ package cn.lili.modules.goods.sku.render.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -38,7 +39,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { Assert.notEmpty(goodsOperationDTO.getWholesaleList(), "批发规则不能为空"); this.checkWholesaleList(goodsOperationDTO.getWholesaleList()); List collect = goodsOperationDTO.getWholesaleList().stream().sorted(Comparator.comparing(Wholesale::getPrice)).collect(Collectors.toList()); - wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + if (CharSequenceUtil.isNotEmpty(goodsOperationDTO.getGoodsId())) { + wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + } wholesaleService.saveOrUpdateBatch(collect); goodsSku.setPrice(collect.get(0).getPrice()); goodsSku.setCost(collect.get(0).getPrice()); @@ -54,7 +57,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { skus.setPrice(collect.get(0).getPrice()); skus.setCost(collect.get(0).getPrice()); } - wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + if (CharSequenceUtil.isNotEmpty(goodsOperationDTO.getGoodsId())) { + wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); + } wholesaleService.saveOrUpdateBatch(collect); } From 1a6ec578de64b4fd1cdc06a6ef604463690eb492 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 31 May 2022 17:01:01 +0800 Subject: [PATCH 101/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=E9=BB=98=E8=AE=A4=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=AD=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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 509ec070..f80087ae 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 @@ -167,12 +167,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i skuList = new ArrayList<>(); for (Map map : goodsOperationDTO.getSkuList()) { GoodsSku sku = null; - if (map.get("id") != null) { - sku = GoodsSkuBuilder.build(this.getGoodsSkuByIdFromCache(map.get("id").toString()), map, goodsOperationDTO); - } - if (sku == null || map.get("id") == null) { - sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); - } + sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); renderGoodsSku(sku, goodsOperationDTO); skuList.add(sku); //如果商品状态值不对,则es索引移除 From 400a06d2ac576740ba10d36b1ac6ffb411cb5cd7 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 31 May 2022 17:23:21 +0800 Subject: [PATCH 102/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=EF=BC=8C=E6=89=B9=E5=8F=91=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=A7=84=E5=88=99=E6=B2=A1=E6=9C=89=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WholesaleSaleModelRenderImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java index a63660cb..93337ce0 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java @@ -37,11 +37,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { @Transactional(rollbackFor = Exception.class) public void renderSingle(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { Assert.notEmpty(goodsOperationDTO.getWholesaleList(), "批发规则不能为空"); - this.checkWholesaleList(goodsOperationDTO.getWholesaleList()); + this.checkWholesaleList(goodsOperationDTO.getWholesaleList(), goodsSku); List collect = goodsOperationDTO.getWholesaleList().stream().sorted(Comparator.comparing(Wholesale::getPrice)).collect(Collectors.toList()); - if (CharSequenceUtil.isNotEmpty(goodsOperationDTO.getGoodsId())) { - wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); - } + wholesaleService.removeByGoodsId(goodsSku.getGoodsId()); wholesaleService.saveOrUpdateBatch(collect); goodsSku.setPrice(collect.get(0).getPrice()); goodsSku.setCost(collect.get(0).getPrice()); @@ -51,19 +49,17 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { @Transactional(rollbackFor = Exception.class) public void renderBatch(List goodsSkus, GoodsOperationDTO goodsOperationDTO) { Assert.notEmpty(goodsOperationDTO.getWholesaleList(), "批发规则不能为空"); - this.checkWholesaleList(goodsOperationDTO.getWholesaleList()); + this.checkWholesaleList(goodsOperationDTO.getWholesaleList(), goodsSkus.get(0)); List collect = goodsOperationDTO.getWholesaleList().stream().sorted(Comparator.comparing(Wholesale::getPrice)).collect(Collectors.toList()); for (GoodsSku skus : goodsSkus) { skus.setPrice(collect.get(0).getPrice()); skus.setCost(collect.get(0).getPrice()); } - if (CharSequenceUtil.isNotEmpty(goodsOperationDTO.getGoodsId())) { - wholesaleService.removeByGoodsId(goodsOperationDTO.getGoodsId()); - } + wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId()); wholesaleService.saveOrUpdateBatch(collect); } - private void checkWholesaleList(List wholesaleList) { + private void checkWholesaleList(List wholesaleList, GoodsSku goodsSku) { if (CollUtil.isEmpty(wholesaleList)) { throw new ServiceException(ResultCode.MUST_HAVE_SALES_MODEL); } @@ -71,6 +67,10 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { if (wholesaleDTO.getPrice() == null || wholesaleDTO.getPrice() <= 0 || wholesaleDTO.getNum() == null || wholesaleDTO.getNum() <= 0) { throw new ServiceException(ResultCode.HAVE_INVALID_SALES_MODEL); } + if (CharSequenceUtil.isEmpty(wholesaleDTO.getGoodsId())) { + wholesaleDTO.setGoodsId(goodsSku.getGoodsId()); + } + } } From 23c742c4c6d545be4236a25a8bba46df0413f030 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 1 Jun 2022 15:23:21 +0800 Subject: [PATCH 103/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8F=98=E6=9B=B4=E6=97=B6=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=95=86=E5=93=81=E7=BC=93=E5=AD=98=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/GoodsServiceImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 fbbbf6a3..dd509616 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 @@ -278,6 +278,7 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override @Transactional(rollbackFor = Exception.class) public boolean auditGoods(List goodsIds, GoodsAuthEnum goodsAuthEnum) { + List goodsCacheKeys = new ArrayList<>(); boolean result = false; for (String goodsId : goodsIds) { Goods goods = this.checkExist(goodsId); @@ -285,12 +286,13 @@ public class GoodsServiceImpl extends ServiceImpl implements result = this.updateById(goods); goodsSkuService.updateGoodsSkuStatus(goods); //删除之前的缓存 - cache.remove(CachePrefix.GOODS.getPrefix() + goodsId); + goodsCacheKeys.add(CachePrefix.GOODS.getPrefix() + goodsId); //商品审核消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_AUDIT.name(); //发送mq消息 rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goods), RocketmqSendCallbackBuilder.commonCallback()); } + cache.multiDel(goodsCacheKeys); return result; } @@ -382,14 +384,15 @@ public class GoodsServiceImpl extends ServiceImpl implements LambdaQueryWrapper queryWrapper = this.getQueryWrapperByStoreAuthority(); queryWrapper.in(Goods::getId, goodsIds); List goodsList = this.list(queryWrapper); + List goodsCacheKeys = new ArrayList<>(); for (Goods goods : goodsList) { //修改SKU状态 goodsSkuService.updateGoodsSkuStatus(goods); - cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); + goodsCacheKeys.add(CachePrefix.GOODS.getPrefix() + goods.getId()); } - + //删除缓存 + cache.multiDel(goodsCacheKeys); this.deleteEsGoods(goodsIds); - return true; } @@ -482,12 +485,12 @@ public class GoodsServiceImpl extends ServiceImpl implements * @param goodsList 商品列表 */ private void updateGoodsStatus(List goodsIds, GoodsStatusEnum goodsStatusEnum, List goodsList) { + List goodsCacheKeys = new ArrayList<>(); for (Goods goods : goodsList) { - if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { - cache.remove(CachePrefix.GOODS.getPrefix() + goods.getId()); - } + goodsCacheKeys.add(CachePrefix.GOODS.getPrefix() + goods.getId()); goodsSkuService.updateGoodsSkuStatus(goods); } + cache.multiDel(goodsCacheKeys); if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) { this.deleteEsGoods(goodsIds); From 486bebe6d2ade36095ed6c50f96ad9543116ede6 Mon Sep 17 00:00:00 2001 From: xiaochangbai <704566072@qq.com> Date: Wed, 1 Jun 2022 18:03:30 +0800 Subject: [PATCH 104/185] =?UTF-8?q?feat:=E6=99=BA=E8=83=BD=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=8E=A8=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/entity/dto/EsGoodsSearchDTO.java | 3 ++ .../serviceimpl/EsGoodsSearchServiceImpl.java | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java index 564d0ecd..2f0759d6 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java @@ -44,4 +44,7 @@ public class EsGoodsSearchDTO { @ApiModelProperty(hidden = true) private Map> notShowCol = new HashMap<>(); + @ApiModelProperty("当前商品skuId,根据当前浏览的商品信息来给用户推荐可能喜欢的商品") + private String currentGoodsId; + } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 620d3bd8..e77d5bce 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -363,6 +363,9 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { //对查询条件进行处理 this.commonSearch(filterBuilder, searchDTO); + //智能推荐 + this.recommended(filterBuilder,searchDTO); + //未上架的商品不显示 filterBuilder.must(QueryBuilders.matchQuery("marketEnable", GoodsStatusEnum.UPPER.name())); //待审核和审核不通过的商品不显示 @@ -401,6 +404,36 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { return nativeSearchQueryBuilder; } + /** + * 商品推荐 + * @param filterBuilder + * @param searchDTO + */ + private void recommended(BoolQueryBuilder filterBuilder, EsGoodsSearchDTO searchDTO) { + EsGoodsIndex currentGoodsIndice = null; + if(CharSequenceUtil.isNotEmpty(searchDTO.getCurrentGoodsId())){ + //查询当前商品的信息 + NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder(); + NativeSearchQuery build = searchQueryBuilder.build(); + build.setIds(Arrays.asList(searchDTO.getCurrentGoodsId())); + List esGoodsIndices = restTemplate.multiGet(build, EsGoodsIndex.class, restTemplate.getIndexCoordinatesFor(EsGoodsIndex.class)); + if(esGoodsIndices==null || esGoodsIndices.size()<1){ + return; + } + currentGoodsIndice = esGoodsIndices.get(0); + } + //推荐相同分类的商品 + String categoryPath = currentGoodsIndice.getCategoryPath(); + if(CharSequenceUtil.isNotEmpty(categoryPath)){ + //匹配二级分类 + String substring = categoryPath.substring(0, categoryPath.lastIndexOf(",")); + filterBuilder.must(QueryBuilders.wildcardQuery("categoryPath",substring+"*")); + } + + //排除当前商品 + filterBuilder.mustNot(QueryBuilders.matchQuery("id",searchDTO.getCurrentGoodsId())); + } + /** * 查询属性处理 * From ccb57411a2f0ae224aafd87daa67bcf8467ea4ac Mon Sep 17 00:00:00 2001 From: xiaochangbai <704566072@qq.com> Date: Wed, 1 Jun 2022 21:27:51 +0800 Subject: [PATCH 105/185] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsSearchServiceImpl.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index e77d5bce..e91bd477 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -410,28 +410,28 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { * @param searchDTO */ private void recommended(BoolQueryBuilder filterBuilder, EsGoodsSearchDTO searchDTO) { - EsGoodsIndex currentGoodsIndice = null; - if(CharSequenceUtil.isNotEmpty(searchDTO.getCurrentGoodsId())){ - //查询当前商品的信息 - NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder(); - NativeSearchQuery build = searchQueryBuilder.build(); - build.setIds(Arrays.asList(searchDTO.getCurrentGoodsId())); - List esGoodsIndices = restTemplate.multiGet(build, EsGoodsIndex.class, restTemplate.getIndexCoordinatesFor(EsGoodsIndex.class)); - if(esGoodsIndices==null || esGoodsIndices.size()<1){ - return; - } - currentGoodsIndice = esGoodsIndices.get(0); + + String currentGoodsId = searchDTO.getCurrentGoodsId(); + if(CharSequenceUtil.isEmpty(currentGoodsId)) { + return; } - //推荐相同分类的商品 - String categoryPath = currentGoodsIndice.getCategoryPath(); + + //排除当前商品 + filterBuilder.mustNot(QueryBuilders.matchQuery("id",currentGoodsId)); + + //查询当前浏览商品的索引信息 + EsGoodsIndex esGoodsIndex = restTemplate.get(currentGoodsId, EsGoodsIndex.class); + if(esGoodsIndex==null) { + return; + } + //推荐与当前浏览商品相同一个二级分类下的商品 + String categoryPath = esGoodsIndex.getCategoryPath(); if(CharSequenceUtil.isNotEmpty(categoryPath)){ //匹配二级分类 String substring = categoryPath.substring(0, categoryPath.lastIndexOf(",")); filterBuilder.must(QueryBuilders.wildcardQuery("categoryPath",substring+"*")); } - //排除当前商品 - filterBuilder.mustNot(QueryBuilders.matchQuery("id",searchDTO.getCurrentGoodsId())); } /** From d4a13c8a82300c2bf24dfac577ff89bdb424254e Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 2 Jun 2022 09:16:30 +0800 Subject: [PATCH 106/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=95=B0=E9=87=8F=EF=BC=8C=E5=BA=97=E9=93=BA=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE2=E5=B0=8F=E6=97=B6=E3=80=82=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 23 --------- .../handler/impl/store/StoreExecute.java | 49 +++++++++++++++++++ .../StoreRatingExecute.java | 2 +- .../main/java/cn/lili/cache/CachePrefix.java | 4 ++ .../goods/service/GoodsSkuService.java | 14 ++++++ .../goods/serviceimpl/GoodsServiceImpl.java | 12 +++++ .../serviceimpl/GoodsSkuServiceImpl.java | 12 +++++ .../modules/store/service/StoreService.java | 3 +- .../serviceimpl/StoreDetailServiceImpl.java | 12 ++++- .../store/serviceimpl/StoreServiceImpl.java | 6 +-- 10 files changed, 107 insertions(+), 30 deletions(-) create mode 100644 consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreExecute.java rename consumer/src/main/java/cn/lili/timetask/handler/impl/{storerating => store}/StoreRatingExecute.java (97%) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index ab19413d..f8f8a35e 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -60,11 +60,6 @@ public class GoodsMessageListener implements RocketMQListener { */ @Autowired private EsGoodsIndexService goodsIndexService; - /** - * 店铺 - */ - @Autowired - private StoreService storeService; /** * 商品 */ @@ -202,7 +197,6 @@ public class GoodsMessageListener implements RocketMQListener { //审核商品 case GOODS_AUDIT: Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class); - updateGoodsNum(goods); updateGoodsIndex(goods); break; //删除商品 @@ -213,7 +207,6 @@ public class GoodsMessageListener implements RocketMQListener { Goods goodsById = this.goodsService.getById(goodsId); if (goodsById != null) { this.deleteGoods(goodsById); - this.updateGoodsNum(goodsById); goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); } } @@ -458,22 +451,6 @@ public class GoodsMessageListener implements RocketMQListener { distributionGoodsService.removeById(distributionGoods.getId()); } } - - /** - * 修改商品数量 - * - * @param goods 信息体 - */ - private void updateGoodsNum(Goods goods) { - try { - //更新店铺商品数量 - assert goods != null; - storeService.updateStoreGoodsNum(goods.getStoreId()); - } catch (Exception e) { - log.error("修改商品数量错误"); - } - } - /** * 商品购买完成 * 1.更新商品购买数量 diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreExecute.java new file mode 100644 index 00000000..283a1552 --- /dev/null +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreExecute.java @@ -0,0 +1,49 @@ +package cn.lili.timetask.handler.impl.store; + +import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.store.entity.dos.Store; +import cn.lili.modules.store.entity.enums.StoreStatusEnum; +import cn.lili.modules.store.service.StoreService; +import cn.lili.timetask.handler.EveryDayExecute; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 店铺信息更新 + * + * @author Chopper + * @since 2021/3/15 5:30 下午 + */ +@Component +@Slf4j +public class StoreExecute implements EveryDayExecute { + /** + * 店铺 + */ + @Autowired + private StoreService storeService; + + @Autowired + private GoodsSkuService goodsSkuService; + + @Override + public void execute() { + //获取所有开启的店铺 + List storeList = storeService.list(new LambdaQueryWrapper().eq(Store::getStoreDisable, StoreStatusEnum.OPEN.name())); + + for (Store store : storeList) { + try { + Long num = goodsSkuService.countSkuNum(store.getId()); + storeService.updateStoreGoodsNum(store.getId(), num); + } catch (Exception e) { + log.error("店铺id为{},更新商品数量失败", store.getId(), e); + } + } + + + } +} diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/storerating/StoreRatingExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreRatingExecute.java similarity index 97% rename from consumer/src/main/java/cn/lili/timetask/handler/impl/storerating/StoreRatingExecute.java rename to consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreRatingExecute.java index 90ba815e..269ab947 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/storerating/StoreRatingExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/store/StoreRatingExecute.java @@ -1,4 +1,4 @@ -package cn.lili.timetask.handler.impl.storerating; +package cn.lili.timetask.handler.impl.store; import cn.lili.common.enums.SwitchEnum; import cn.lili.modules.member.entity.dos.MemberEvaluation; diff --git a/framework/src/main/java/cn/lili/cache/CachePrefix.java b/framework/src/main/java/cn/lili/cache/CachePrefix.java index 43423d64..52592ba6 100644 --- a/framework/src/main/java/cn/lili/cache/CachePrefix.java +++ b/framework/src/main/java/cn/lili/cache/CachePrefix.java @@ -465,6 +465,10 @@ public enum CachePrefix { */ INIT_INDEX_FLAG, + /** + * 店铺 + */ + STORE, /** * 店铺分类 */ 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 a1462bca..0fc10b04 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 @@ -212,5 +212,19 @@ public interface GoodsSkuService extends IService { */ List getSkuIdsByGoodsId(String goodsId); + /** + * 删除并且新增sku,即覆盖之前信息 + * + * @param goodsSkus + * @return + */ boolean deleteAndInsertGoodsSkus(List goodsSkus); + + /** + * 统计sku总数 + * + * @param storeId + * @return + */ + Long countSkuNum(String storeId); } \ No newline at end of file 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 fbbbf6a3..7d7fa570 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 @@ -469,11 +469,23 @@ public class GoodsServiceImpl extends ServiceImpl implements return this.count( new LambdaQueryWrapper() .eq(Goods::getStoreId, storeId) + .eq(Goods::getDeleteFlag, Boolean.FALSE) .eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name()) .eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name())); } + + /** + * 更新店铺商品数量 + * + * @param storeId 信息体 + */ + void updateGoodsNum(String storeId) { + Long num = goodsSkuService.countSkuNum(storeId); + storeService.updateStoreGoodsNum(storeId, num); + } + /** * 更新商品状态 * 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 f80087ae..72e32930 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 @@ -601,6 +601,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return count > 0; } + @Override + public Long countSkuNum(String storeId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + queryWrapper + .eq(GoodsSku::getStoreId, storeId) + .eq(GoodsSku::getDeleteFlag, Boolean.FALSE) + .eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()) + .eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); + return this.count(queryWrapper); + } + /** * 修改库存 * diff --git a/framework/src/main/java/cn/lili/modules/store/service/StoreService.java b/framework/src/main/java/cn/lili/modules/store/service/StoreService.java index 95632b0d..28693e53 100644 --- a/framework/src/main/java/cn/lili/modules/store/service/StoreService.java +++ b/framework/src/main/java/cn/lili/modules/store/service/StoreService.java @@ -106,8 +106,9 @@ public interface StoreService extends IService { * 更新店铺商品数量 * * @param storeId 店铺ID + * @param num 商品数量 */ - void updateStoreGoodsNum(String storeId); + void updateStoreGoodsNum(String storeId, Long num); /** * 更新店铺收藏数量 diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java index 50ff1703..c932f659 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreDetailServiceImpl.java @@ -3,6 +3,8 @@ package cn.lili.modules.store.serviceimpl; import cn.hutool.core.date.DateTime; import cn.hutool.core.map.MapUtil; import cn.hutool.json.JSONUtil; +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; @@ -64,9 +66,17 @@ public class StoreDetailServiceImpl extends ServiceImpl implements } @Override - public void updateStoreGoodsNum(String storeId) { - //获取店铺已上架已审核通过商品数量 - long goodsNum = goodsService.countStoreGoodsNum(storeId); + public void updateStoreGoodsNum(String storeId, Long num) { //修改店铺商品数量 this.update(new LambdaUpdateWrapper() - .set(Store::getGoodsNum, goodsNum) + .set(Store::getGoodsNum, num) .eq(Store::getId, storeId)); } From 234b8ab31c3b942c932ac0375eb7c9a1932fa6f1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 2 Jun 2022 10:31:24 +0800 Subject: [PATCH 107/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=97=B6=E5=BD=93=E5=89=8D=E5=95=86=E5=93=81=E4=BF=83=E9=94=80?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=8A=B6=E6=80=81=E7=9A=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=88=E4=BF=AE=E5=A4=8D=E6=89=8B=E5=8A=A8=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=88=96=E4=B8=8B=E6=9E=B6=E4=BF=83=E9=94=80=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E4=BF=83=E9=94=80=E4=BB=B7=E6=A0=BC=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/cart/entity/vo/CartSkuVO.java | 4 ++ .../cart/render/impl/CheckDataRender.java | 17 ++++++ .../order/cart/service/CartServiceImpl.java | 38 +----------- .../service/PromotionGoodsService.java | 17 +++++- .../PromotionGoodsServiceImpl.java | 58 +++++++++++++++++-- .../promotion/tools/PromotionCacheKeys.java | 39 ------------- 6 files changed, 88 insertions(+), 85 deletions(-) delete mode 100644 framework/src/main/java/cn/lili/modules/promotion/tools/PromotionCacheKeys.java diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index 59f2e7ea..30608258 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -117,4 +117,8 @@ public class CartSkuVO extends CartBase implements Serializable { public Map getPromotionMap() { return PromotionTools.filterInvalidPromotionsMap(this.promotionMap); } + + public Map getNotFilterPromotionMap() { + return this.promotionMap; + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 1430263b..8cb02a48 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -31,6 +31,7 @@ import cn.lili.modules.promotion.entity.dos.Coupon; import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.PointsGoods; import cn.lili.modules.promotion.entity.vos.CouponVO; +import cn.lili.modules.promotion.service.PromotionGoodsService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -63,6 +64,11 @@ public class CheckDataRender implements CartRenderStep { @Autowired private WholesaleService wholesaleService; + /** + * 商品索引 + */ + @Autowired + private PromotionGoodsService promotionGoodsService; @Override public RenderStepEnums step() { @@ -127,6 +133,17 @@ public class CheckDataRender implements CartRenderStep { //设置失效消息 cartSkuVO.setErrorMessage("商品库存不足,现有库存数量[" + dataSku.getQuantity() + "]"); } + //如果存在商品促销活动,则判定商品促销状态 + if (CollUtil.isNotEmpty(cartSkuVO.getNotFilterPromotionMap()) || Boolean.TRUE.equals(cartSkuVO.getGoodsSku().getPromotionFlag())) { + //获取当前最新的促销信息 + cartSkuVO.setPromotionMap(this.promotionGoodsService.getCurrentGoodsPromotion(cartSkuVO.getGoodsSku(), tradeDTO.getCartTypeEnum().name())); + //设定商品价格 + Double goodsPrice = cartSkuVO.getGoodsSku().getPromotionFlag() != null && cartSkuVO.getGoodsSku().getPromotionFlag() ? cartSkuVO.getGoodsSku().getPromotionPrice() : cartSkuVO.getGoodsSku().getPrice(); + cartSkuVO.setPurchasePrice(goodsPrice); + cartSkuVO.setUtilPrice(goodsPrice); + cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); + } + } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index f23459df..0712ddca 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -16,7 +16,6 @@ import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; -import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.WholesaleService; @@ -36,10 +35,8 @@ import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.vo.ReceiptVO; import cn.lili.modules.promotion.entity.dos.KanjiaActivity; import cn.lili.modules.promotion.entity.dos.MemberCoupon; -import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; -import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; @@ -139,7 +136,7 @@ public class CartServiceImpl implements CartService { } CartTypeEnum cartTypeEnum = getCartType(cartType); GoodsSku dataSku = checkGoods(skuId); - Map promotionMap = this.getCurrentGoodsPromotion(dataSku, cartType); + Map promotionMap = promotionGoodsService.getCurrentGoodsPromotion(dataSku, cartType); try { //购物车方式购买需要保存之前的选择,其他方式购买,则直接抹除掉之前的记录 @@ -554,39 +551,6 @@ public class CartServiceImpl implements CartService { return trade; } - private Map getCurrentGoodsPromotion(GoodsSku dataSku, String cartType) { - Map promotionMap; - EsGoodsIndex goodsIndex = goodsIndexService.findById(dataSku.getId()); - if (goodsIndex == null) { - GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId()); - goodsIndex = goodsIndexService.getResetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); - } - if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) { - if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) && CartTypeEnum.PINTUAN.name().equals(cartType))) { - - Optional> containsPromotion = goodsIndex.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); - if (containsPromotion.isPresent()) { - JSONObject promotionsObj = JSONUtil.parseObj(containsPromotion.get().getValue()); - PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); - searchParams.setSkuId(dataSku.getId()); - searchParams.setPromotionId(promotionsObj.get("id").toString()); - PromotionGoods promotionsGoods = promotionGoodsService.getPromotionsGoods(searchParams); - if (promotionsGoods != null && promotionsGoods.getPrice() != null) { - dataSku.setPromotionFlag(true); - dataSku.setPromotionPrice(promotionsGoods.getPrice()); - } else { - dataSku.setPromotionFlag(false); - dataSku.setPromotionPrice(null); - } - } - } - promotionMap = goodsIndex.getPromotionMap(); - } else { - promotionMap = null; - } - return promotionMap; - } - /** * 获取购物车类型 diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java index 58a80e00..4aac7c38 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java @@ -3,6 +3,7 @@ package cn.lili.modules.promotion.service; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; +import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import java.util.Date; import java.util.List; +import java.util.Map; /** * 促销商品业务层 @@ -35,7 +37,7 @@ public interface PromotionGoodsService extends IService { /** * 获取某sku所有有效活动 * - * @param skuId 商品skuId + * @param skuId 商品skuId * @param storeIds 店铺id * @return 促销商品集合 */ @@ -70,7 +72,7 @@ public interface PromotionGoodsService extends IService { /** * 获取当前有效时间特定促销类型的促销商品信息 * - * @param skuId skuId + * @param skuId skuId * @param promotionTypes 特定促销类型 * @return 促销商品信息 */ @@ -79,7 +81,7 @@ public interface PromotionGoodsService extends IService { /** * 获取当前有效时间特定促销类型的促销商品价格 * - * @param skuId skuId + * @param skuId skuId * @param promotionTypes 特定促销类型 * @return 促销商品价格 */ @@ -154,4 +156,13 @@ public interface PromotionGoodsService extends IService { */ void deletePromotionGoods(PromotionGoodsSearchParams searchParams); + /** + * 获取当前商品促销信息 + * + * @param dataSku 商品sku信息 + * @param cartType 购物车类型 + * @return 当前商品促销信息 + */ + Map getCurrentGoodsPromotion(GoodsSku dataSku, String cartType); + } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index cc2a993f..98852a25 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -2,10 +2,15 @@ package cn.lili.modules.promotion.serviceimpl; import cn.hutool.core.convert.Convert; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.vos.GoodsVO; +import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.SeckillApply; import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; @@ -16,6 +21,8 @@ import cn.lili.modules.promotion.mapper.PromotionGoodsMapper; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.tools.PromotionTools; +import cn.lili.modules.search.entity.dos.EsGoodsIndex; +import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -27,10 +34,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 促销商品业务层实现 @@ -59,6 +63,12 @@ public class PromotionGoodsServiceImpl extends ServiceImpl findSkuValidPromotion(String skuId, String storeIds) { @@ -267,8 +277,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl promotionIds) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .in(PromotionGoods::getPromotionId, promotionIds); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().in(PromotionGoods::getPromotionId, promotionIds); this.remove(queryWrapper); } @@ -282,4 +291,41 @@ public class PromotionGoodsServiceImpl extends ServiceImpl getCurrentGoodsPromotion(GoodsSku dataSku, String cartType) { + Map promotionMap; + EsGoodsIndex goodsIndex = goodsIndexService.findById(dataSku.getId()); + if (goodsIndex == null) { + GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId()); + goodsIndex = goodsIndexService.getResetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList()); + } + if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) { + if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) || (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name())) && CartTypeEnum.PINTUAN.name().equals(cartType))) { + Optional> containsPromotion = goodsIndex.getPromotionMap().entrySet().stream().filter(i -> i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst(); + containsPromotion.ifPresent(stringObjectEntry -> this.setGoodsPromotionInfo(dataSku, stringObjectEntry)); + } + promotionMap = goodsIndex.getPromotionMap(); + } else { + promotionMap = null; + dataSku.setPromotionFlag(false); + dataSku.setPromotionPrice(null); + } + return promotionMap; + } + + private void setGoodsPromotionInfo(GoodsSku dataSku, Map.Entry promotionInfo) { + JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo); + PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); + searchParams.setSkuId(dataSku.getId()); + searchParams.setPromotionId(promotionsObj.get("id").toString()); + PromotionGoods promotionsGoods = this.getPromotionsGoods(searchParams); + if (promotionsGoods != null && promotionsGoods.getPrice() != null) { + dataSku.setPromotionFlag(true); + dataSku.setPromotionPrice(promotionsGoods.getPrice()); + } else { + dataSku.setPromotionFlag(false); + dataSku.setPromotionPrice(null); + } + } + } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionCacheKeys.java b/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionCacheKeys.java deleted file mode 100644 index 6281f779..00000000 --- a/framework/src/main/java/cn/lili/modules/promotion/tools/PromotionCacheKeys.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.lili.modules.promotion.tools; - -import cn.lili.cache.CachePrefix; - -/** - * 满额活动缓存Key - * @author paulG - * @since 2020/10/12 - **/ -public class PromotionCacheKeys { - - /** - * 读取满优惠redis key - * @param activityId 活动ID - * @return 满优惠redis key - */ - public static String getFullDiscountKey(String activityId){ - return CachePrefix.STORE_ID_FULL_DISCOUNT + "::" + activityId; - } - - /** - * 读取满优惠redis key - * @param id id - * @return 满优惠redis key - */ - public static String getPromotionGoodsKey(String id){ - return CachePrefix.PROMOTION_GOODS + "::" + id; - } - - /** - * 读取秒杀活动redis key - * @param timeStr 时间字符串(格式为 yyyyMMdd) - * @return 满优惠redis key - */ - public static String getSeckillTimelineKey(String timeStr){ - return CachePrefix.STORE_ID_SECKILL + "::" + timeStr; - } - -} From c4d879a0ad37ef4c07b38c4c34e97ebadb384f38 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 2 Jun 2022 16:50:26 +0800 Subject: [PATCH 108/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=95=86=E5=93=81=E6=97=B6=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/event/impl/StockUpdateExecute.java | 1 + .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 10 +++------- 2 files changed, 4 insertions(+), 7 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 e03d38c0..ceee4a1a 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -358,6 +358,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId())); GoodsSku goodsSku = new GoodsSku(); goodsSku.setId(orderItem.getSkuId()); + goodsSku.setGoodsId(orderItem.getGoodsId()); goodsSkus.add(goodsSku); } //批量获取商品库存 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 72e32930..aa6bc4c4 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 @@ -506,18 +506,14 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public void updateGoodsStuck(List goodsSkus) { - //商品id集合 hashset 去重复 - Set goodsIds = new HashSet<>(); - for (GoodsSku sku : goodsSkus) { - goodsIds.add(sku.getGoodsId()); - } + Map> groupByGoodsIds = goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId)); //获取相关的sku集合 LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(GoodsSku::getGoodsId, goodsIds); + lambdaQueryWrapper.in(GoodsSku::getGoodsId, groupByGoodsIds.keySet()); List goodsSkuList = this.list(lambdaQueryWrapper); //统计每个商品的库存 - for (String goodsId : goodsIds) { + for (String goodsId : groupByGoodsIds.keySet()) { //库存 Integer quantity = 0; for (GoodsSku goodsSku : goodsSkuList) { From 65a4bb77788149b5c814424ad403af99bcb0097b Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 6 Jun 2022 10:12:09 +0800 Subject: [PATCH 109/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=8F=91=E7=94=9F=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF=E6=97=B6=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/entity/vo/OrderItemVO.java | 34 +++++++++++-- .../order/order/entity/vo/OrderSimpleVO.java | 50 ++++++++++++++----- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderItemVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderItemVO.java index 6d091159..5ab18dcf 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderItemVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderItemVO.java @@ -5,6 +5,7 @@ import cn.lili.modules.order.order.entity.enums.OrderComplaintStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.NoArgsConstructor; /** * 子订单VO @@ -13,6 +14,7 @@ import lombok.Data; * @since 2020-08-17 20:28 */ @Data +@NoArgsConstructor public class OrderItemVO { @ApiModelProperty(value = "编号") @@ -55,17 +57,39 @@ public class OrderItemVO { private String commentStatus; - public OrderItemVO(String sn, String goodsId, String skuId, String num, String image, String name, String afterSaleStatus, String complainStatus, String commentStatus, Double goodsPrice) { + public void setSn(String sn) { this.sn = sn; - this.goodsId = goodsId; + } + + public void setSkuId(String skuId) { this.skuId = skuId; + } + + public void setNum(String num) { this.num = num; + } + + public void setImage(String image) { this.image = image; + } + + public void setName(String name) { this.name = name; - this.afterSaleStatus = afterSaleStatus; - this.complainStatus = complainStatus; - this.commentStatus = commentStatus; + } + + public void setGoodsPrice(Double goodsPrice) { this.goodsPrice = goodsPrice; } + public void setAfterSaleStatus(String afterSaleStatus) { + this.afterSaleStatus = afterSaleStatus; + } + + public void setComplainStatus(String complainStatus) { + this.complainStatus = complainStatus; + } + + public void setCommentStatus(String commentStatus) { + this.commentStatus = commentStatus; + } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java index f44efa3d..4f58fb0c 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java @@ -1,7 +1,7 @@ package cn.lili.modules.order.order.entity.vo; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ClientTypeEnum; -import cn.lili.common.utils.StringUtils; import cn.lili.modules.order.order.entity.enums.*; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; @@ -135,28 +135,54 @@ public class OrderSimpleVO { private String deliverStatus; public List getOrderItems() { - if (StringUtils.isEmpty(groupGoodsId)) { + if (CharSequenceUtil.isEmpty(groupGoodsId)) { return new ArrayList<>(); } List orderItemVOS = new ArrayList<>(); - String[] orderItemsSn = groupOrderItemsSn.split(","); + + String[] goodsId = groupGoodsId.split(","); - String[] skuId = groupSkuId.split(","); - String[] num = groupNum.split(","); - String[] image = groupImages.split(","); - String[] name = groupName.split(","); - String[] afterSaleStatus = groupAfterSaleStatus.split(","); - String[] complainStatus = groupComplainStatus.split(","); - String[] commentStatus = groupCommentStatus.split(","); - String[] goodsPrice = groupGoodsPrice.split(","); for (int i = 0; i < goodsId.length; i++) { - orderItemVOS.add(new OrderItemVO(orderItemsSn[i], goodsId[i], skuId[i], num[i], image[i], name[i], afterSaleStatus[i], complainStatus[i], commentStatus[i], Double.parseDouble(goodsPrice[i]))); + orderItemVOS.add(this.getOrderItemVO(i)); } return orderItemVOS; } + private OrderItemVO getOrderItemVO(int i) { + OrderItemVO orderItemVO = new OrderItemVO(); + orderItemVO.setGoodsId(groupGoodsId.split(",")[i]); + if (CharSequenceUtil.isNotEmpty(groupOrderItemsSn)) { + orderItemVO.setSn(groupOrderItemsSn.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupSkuId)) { + orderItemVO.setSkuId(groupSkuId.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupName)) { + orderItemVO.setName(groupName.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupNum) && groupNum.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setNum(groupNum.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupImages) && groupImages.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setImage(groupImages.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupAfterSaleStatus) && groupAfterSaleStatus.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setAfterSaleStatus(groupAfterSaleStatus.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupComplainStatus) && groupComplainStatus.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setComplainStatus(groupComplainStatus.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupCommentStatus) && groupCommentStatus.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setCommentStatus(groupCommentStatus.split(",")[i]); + } + if (CharSequenceUtil.isNotEmpty(groupGoodsPrice) && groupGoodsPrice.split(",").length == groupGoodsId.split(",").length) { + orderItemVO.setGoodsPrice(Double.parseDouble(groupGoodsPrice.split(",")[i])); + } + return orderItemVO; + } + /** * 初始化自身状态 */ From ee3f8a92616b4e1e16954a59794a90f00728b8ac Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 6 Jun 2022 15:24:52 +0800 Subject: [PATCH 110/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=B8=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E8=8E=B7=E5=8F=96=E7=9A=84=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8D=E8=83=BD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 3 +++ .../cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 0712ddca..7b44ed78 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -604,6 +604,9 @@ public class CartServiceImpl implements CartService { cartPrice = CurrencyUtil.add(cartPrice, CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); skuPrice.put(cartSkuVO.getGoodsSku().getId(), CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); } + } else { + cartPrice = CurrencyUtil.add(cartPrice, CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); + skuPrice.put(cartSkuVO.getGoodsSku().getId(), CurrencyUtil.mul(cartSkuVO.getGoodsSku().getPrice(), cartSkuVO.getNum())); } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java index 4f58fb0c..711ffd92 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/OrderSimpleVO.java @@ -2,7 +2,6 @@ package cn.lili.modules.order.order.entity.vo; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ClientTypeEnum; -import cn.lili.modules.order.order.entity.enums.*; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; From a22ccbdda5e23d1a59686816149fa705b48a745a Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 7 Jun 2022 09:35:58 +0800 Subject: [PATCH 111/185] =?UTF-8?q?=E5=85=BC=E5=AE=B9MINIO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/buyer/test/cart/FileTest.java | 4 +- .../controller/common/UploadController.java | 7 +- framework/pom.xml | 7 + .../modules/file/entity/enums/OssEnum.java | 17 ++ ...FileManagerPlugin.java => FilePlugin.java} | 11 +- .../file/plugin/FilePluginFactory.java | 59 +++++++ ...eManagerPlugin.java => AliFilePlugin.java} | 62 ++----- .../file/plugin/impl/MinioFilePlugin.java | 165 ++++++++++++++++++ .../file/serviceimpl/FileServiceImpl.java | 9 +- .../modules/system/entity/dto/OssSetting.java | 38 ++++ pom.xml | 1 + 11 files changed, 320 insertions(+), 60 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/file/entity/enums/OssEnum.java rename framework/src/main/java/cn/lili/modules/file/plugin/{FileManagerPlugin.java => FilePlugin.java} (77%) create mode 100644 framework/src/main/java/cn/lili/modules/file/plugin/FilePluginFactory.java rename framework/src/main/java/cn/lili/modules/file/plugin/impl/{AliFileManagerPlugin.java => AliFilePlugin.java} (72%) create mode 100644 framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java diff --git a/buyer-api/src/test/java/cn/lili/buyer/test/cart/FileTest.java b/buyer-api/src/test/java/cn/lili/buyer/test/cart/FileTest.java index 1ccf3cff..b7907bca 100644 --- a/buyer-api/src/test/java/cn/lili/buyer/test/cart/FileTest.java +++ b/buyer-api/src/test/java/cn/lili/buyer/test/cart/FileTest.java @@ -1,7 +1,7 @@ package cn.lili.buyer.test.cart; -import cn.lili.modules.file.plugin.FileManagerPlugin; +import cn.lili.modules.file.plugin.FilePlugin; import cn.lili.modules.goods.entity.dos.Brand; import cn.lili.modules.goods.service.BrandService; import com.xkcoding.http.util.StringUtil; @@ -27,7 +27,7 @@ class FileTest { @Autowired - private FileManagerPlugin fileManagerPlugin; + private FilePlugin fileManagerPlugin; @Autowired private BrandService brandService; diff --git a/common-api/src/main/java/cn/lili/controller/common/UploadController.java b/common-api/src/main/java/cn/lili/controller/common/UploadController.java index 25001d07..d97fa40c 100644 --- a/common-api/src/main/java/cn/lili/controller/common/UploadController.java +++ b/common-api/src/main/java/cn/lili/controller/common/UploadController.java @@ -12,7 +12,8 @@ import cn.lili.common.utils.Base64DecodeMultipartFile; import cn.lili.common.utils.CommonUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.file.entity.File; -import cn.lili.modules.file.plugin.FileManagerPlugin; +import cn.lili.modules.file.plugin.FilePlugin; +import cn.lili.modules.file.plugin.FilePluginFactory; import cn.lili.modules.file.service.FileService; import cn.lili.modules.system.entity.dos.Setting; import cn.lili.modules.system.entity.enums.SettingEnum; @@ -47,7 +48,7 @@ public class UploadController { @Autowired private SettingService settingService; @Autowired - private FileManagerPlugin fileManagerPlugin; + private FilePluginFactory filePluginFactory; @Autowired private Cache cache; @@ -86,7 +87,7 @@ public class UploadController { try { InputStream inputStream = file.getInputStream(); //上传至第三方云服务或服务器 - result = fileManagerPlugin.inputStreamUpload(inputStream, fileKey); + result = filePluginFactory.filePlugin().inputStreamUpload(inputStream, fileKey); //保存数据信息至数据库 newFile.setName(file.getOriginalFilename()); newFile.setFileSize(file.getSize()); diff --git a/framework/pom.xml b/framework/pom.xml index 6919e763..5974c103 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -420,6 +420,13 @@ + + io.minio + minio + ${minio.version} + + + diff --git a/framework/src/main/java/cn/lili/modules/file/entity/enums/OssEnum.java b/framework/src/main/java/cn/lili/modules/file/entity/enums/OssEnum.java new file mode 100644 index 00000000..748faeca --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/file/entity/enums/OssEnum.java @@ -0,0 +1,17 @@ +package cn.lili.modules.file.entity.enums; + +import com.aliyun.oss.OSS; + +/** + * OssEnum + * + * @author Chopper + * @version v1.0 + * 2022-06-06 11:23 + */ +public enum OssEnum { + /** + * + */ + ALI_OSS, MINIO; +} diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/FileManagerPlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/FilePlugin.java similarity index 77% rename from framework/src/main/java/cn/lili/modules/file/plugin/FileManagerPlugin.java rename to framework/src/main/java/cn/lili/modules/file/plugin/FilePlugin.java index bd279d05..2f6fa799 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/FileManagerPlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/FilePlugin.java @@ -1,16 +1,23 @@ package cn.lili.modules.file.plugin; +import cn.lili.modules.file.entity.enums.OssEnum; + import java.io.InputStream; import java.util.List; /** - * 文件管理插件 + * 文件插件接口 * * @author Chopper */ -public interface FileManagerPlugin { +public interface FilePlugin { + /** + * 插件名称 + */ + OssEnum pluginName(); + /** * 文件路径上传 * diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/FilePluginFactory.java b/framework/src/main/java/cn/lili/modules/file/plugin/FilePluginFactory.java new file mode 100644 index 00000000..63e4da08 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/file/plugin/FilePluginFactory.java @@ -0,0 +1,59 @@ +package cn.lili.modules.file.plugin; + +import cn.hutool.json.JSONUtil; +import cn.lili.common.exception.ServiceException; +import cn.lili.modules.file.entity.enums.OssEnum; +import cn.lili.modules.file.plugin.impl.AliFilePlugin; +import cn.lili.modules.file.plugin.impl.MinioFilePlugin; +import cn.lili.modules.system.entity.dos.Setting; +import cn.lili.modules.system.entity.dto.OssSetting; +import cn.lili.modules.system.entity.enums.SettingEnum; +import cn.lili.modules.system.service.SettingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 文件服务抽象工厂 直接返回操作类 + * + * @author Chopper + * @version v1.0 + * 2022-06-06 11:35 + */ +@Component +public class FilePluginFactory { + + + @Autowired + private SettingService settingService; + + + /** + * 获取oss client + * + * @return + */ + public FilePlugin filePlugin() { + + OssSetting ossSetting = null; + try { + Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); + + ossSetting = JSONUtil.toBean(setting.getSettingValue(), OssSetting.class); + + + switch (OssEnum.valueOf(ossSetting.getType())) { + + case MINIO: + return new MinioFilePlugin(ossSetting); + case ALI_OSS: + return new AliFilePlugin(ossSetting); + default: + throw new ServiceException(); + } + } catch (Exception e) { + throw new ServiceException(); + } + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFilePlugin.java similarity index 72% rename from framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java rename to framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFilePlugin.java index 4ddbf899..e195a2a0 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFilePlugin.java @@ -1,23 +1,17 @@ package cn.lili.modules.file.plugin.impl; -import cn.hutool.core.util.StrUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.modules.file.plugin.FileManagerPlugin; -import cn.lili.modules.system.entity.dos.Setting; +import cn.lili.modules.file.entity.enums.OssEnum; +import cn.lili.modules.file.plugin.FilePlugin; import cn.lili.modules.system.entity.dto.OssSetting; -import cn.lili.modules.system.entity.enums.SettingEnum; -import cn.lili.modules.system.service.SettingService; import com.aliyun.oss.ClientException; import com.aliyun.oss.OSS; import com.aliyun.oss.OSSClientBuilder; import com.aliyun.oss.OSSException; import com.aliyun.oss.model.DeleteObjectsRequest; import com.aliyun.oss.model.ObjectMetadata; -import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import java.io.File; import java.io.InputStream; @@ -29,28 +23,19 @@ import java.util.List; * @author Chopper */ -@Component @Slf4j -public class AliFileManagerPlugin implements FileManagerPlugin { +public class AliFilePlugin implements FilePlugin { - @Autowired - private SettingService settingService; + private OssSetting ossSetting; - /** - * 下一个初始化配置参数的时间 - * 这里为了防止多次调用redis,减少与redis的交互时间 - */ - private static Long nextInitSetting; + public AliFilePlugin(OssSetting ossSetting) { + this.ossSetting = ossSetting; + } - /** - * 暂时设定3分账请求一次设置 - */ - private static final Long INTERVAL = 60 * 3 * 1000L; - - /** - * 静态设置,最快三分钟更新一次 - */ - private static OssSetting ossSetting; + @Override + public OssEnum pluginName() { + return OssEnum.ALI_OSS; + } /** * 获取oss client @@ -58,32 +43,12 @@ public class AliFileManagerPlugin implements FileManagerPlugin { * @return */ private OSS getOssClient() { - OssSetting ossSetting = getSetting(); - return new OSSClientBuilder().build( ossSetting.getEndPoint(), ossSetting.getAccessKeyId(), ossSetting.getAccessKeySecret()); } - /** - * 获取配置 - * - * @return - */ - private OssSetting getSetting() { - //如果没有配置,或者没有下次刷新时间,或者下次刷新时间小于当前时间,则从redis 更新一次 - if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) { - Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); - if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { - throw new ServiceException(ResultCode.OSS_NOT_EXIST); - } - nextInitSetting = System.currentTimeMillis() + INTERVAL; - ossSetting = new Gson().fromJson(setting.getSettingValue(), OssSetting.class); - return ossSetting; - } - return ossSetting; - } /** * 获取配置前缀 @@ -91,7 +56,6 @@ public class AliFileManagerPlugin implements FileManagerPlugin { * @return */ private String getUrlPrefix() { - OssSetting ossSetting = getSetting(); return "https://" + ossSetting.getBucketName() + "." + ossSetting.getEndPoint() + "/"; } @@ -130,7 +94,7 @@ public class AliFileManagerPlugin implements FileManagerPlugin { try { ObjectMetadata meta = new ObjectMetadata(); meta.setContentType("image/jpg"); - ossClient.putObject(getSetting().getBucketName(), key, inputStream, meta); + ossClient.putObject(ossSetting.getBucketName(), key, inputStream, meta); } catch (OSSException oe) { log.error("Caught an OSSException, which means your request made it to OSS, " + "but was rejected with an error response for some reason."); @@ -161,7 +125,7 @@ public class AliFileManagerPlugin implements FileManagerPlugin { try { ossClient.deleteObjects( - new DeleteObjectsRequest(getSetting().getBucketName()).withKeys(key)); + new DeleteObjectsRequest(ossSetting.getBucketName()).withKeys(key)); } catch (OSSException oe) { log.error("Caught an OSSException, which means your request made it to OSS, " + "but was rejected with an error response for some reason."); diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java new file mode 100644 index 00000000..67471641 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java @@ -0,0 +1,165 @@ +package cn.lili.modules.file.plugin.impl; + +import cn.lili.modules.file.entity.enums.OssEnum; +import cn.lili.modules.file.plugin.FilePlugin; +import cn.lili.modules.system.entity.dto.OssSetting; +import io.minio.*; +import io.minio.errors.ErrorResponseException; +import io.minio.messages.DeleteObject; +import lombok.extern.slf4j.Slf4j; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * MINIO文件插件 + * + * @author liushuai(liushuai711 @ gmail.com) + * @version v4.0 + * @Description: + * @since 2022/6/6 17:45 + */ +@Slf4j +public class MinioFilePlugin implements FilePlugin { + + private OssSetting ossSetting; + + public MinioFilePlugin(OssSetting ossSetting) { + this.ossSetting = ossSetting; + } + + /** + * 桶占位符 + */ + private static final String BUCKET_PARAM = "${bucket}"; + /** + * bucket权限-只读 + */ + private static final String READ_ONLY = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetBucketLocation\",\"s3:ListBucket\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetObject\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "/*\"]}]}"; + /** + * bucket权限-只读 + */ + private static final String WRITE_ONLY = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetBucketLocation\",\"s3:ListBucketMultipartUploads\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:AbortMultipartUpload\",\"s3:DeleteObject\",\"s3:ListMultipartUploadParts\",\"s3:PutObject\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "/*\"]}]}"; + /** + * bucket权限-读写 + */ + private static final String READ_WRITE = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetBucketLocation\",\"s3:ListBucket\",\"s3:ListBucketMultipartUploads\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:DeleteObject\",\"s3:GetObject\",\"s3:ListMultipartUploadParts\",\"s3:PutObject\",\"s3:AbortMultipartUpload\"],\"Resource\":[\"arn:aws:s3:::" + BUCKET_PARAM + "/*\"]}]}"; + + + private MinioClient minioClient; + + + @Override + public OssEnum pluginName() { + return OssEnum.MINIO; + } + + @Override + public String pathUpload(String filePath, String key) { + try { + return this.inputStreamUpload(new FileInputStream(filePath), key); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return null; + } + + @Override + public String inputStreamUpload(InputStream inputStream, String key) { + String bucket = ""; + try { + MinioClient client = getOssClient(); + bucket = ossSetting.getM_bucketName(); + PutObjectArgs putObjectArgs = PutObjectArgs.builder() + .bucket(bucket).stream(inputStream, inputStream.available(), 5 * 1024 * 1024) + .object(key) + .contentType("image/png") + .build(); + client.putObject(putObjectArgs); + } catch (ErrorResponseException e) { + e.printStackTrace(); + return null; + } catch (Exception e) { + log.error("上传失败2,", e); + return null; + } + //拼接出可访问的url地址 + return ossSetting.getM_endpoint() + "/" + bucket + "/" + key; + } + + + @Override + public void deleteFile(List key) { + if (key == null || key.isEmpty()) { + return; + } + MinioClient ossClient = getOssClient(); + List objectList = key.stream().map(DeleteObject::new).collect(Collectors.toList()); + ossClient.removeObjects(RemoveObjectsArgs.builder().objects(objectList).build()); + } + + + /** + * 获取oss client + * + * @return + */ + private MinioClient getOssClient() { + if (minioClient != null) { + return this.minioClient; + } + synchronized (this) { + if (minioClient == null) { + //创建客户端 + this.minioClient = MinioClient.builder() + .endpoint(ossSetting.getM_endpoint()) + .credentials(ossSetting.getM_accessKey(), ossSetting.getM_secretKey()) + .build(); + try { + //查看对应的bucket是否已经存在,不存在则创建 + if (!minioClient.bucketExists(BucketExistsArgs.builder().bucket(ossSetting.getM_bucketName()).build())) { + //创建bucket + MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(ossSetting.getM_bucketName()).build(); + this.minioClient.makeBucket(makeBucketArgs); + setBucketPolicy(this.minioClient, ossSetting.getM_bucketName(), "read-write"); + log.info("创建minio桶成功{}", ossSetting.getM_bucketName()); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("创建[{}]bucket失败", ossSetting.getM_bucketName()); + } + } + } + return minioClient; + } + + + /** + * 更新桶权限策略 + * + * @param bucket 桶 + * @param policy 权限 + */ + public static void setBucketPolicy(MinioClient client, String bucket, String policy) throws Exception { + switch (policy) { + case "read-only": + client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).config(READ_ONLY.replace(BUCKET_PARAM, bucket)).build()); + break; + case "write-only": + client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).config(WRITE_ONLY.replace(BUCKET_PARAM, bucket)).build()); + break; + case "read-write": + client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).region("public").config(READ_WRITE.replace(BUCKET_PARAM, bucket)).build()); + break; + case "none": + default: + break; + } + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java b/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java index 4d68c0f5..bc830cce 100644 --- a/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/file/serviceimpl/FileServiceImpl.java @@ -9,7 +9,8 @@ import cn.lili.common.vo.SearchVO; import cn.lili.modules.file.entity.File; import cn.lili.modules.file.entity.dto.FileOwnerDTO; import cn.lili.modules.file.mapper.FileMapper; -import cn.lili.modules.file.plugin.FileManagerPlugin; +import cn.lili.modules.file.plugin.FilePlugin; +import cn.lili.modules.file.plugin.FilePluginFactory; import cn.lili.modules.file.service.FileService; import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -31,7 +32,7 @@ import java.util.List; public class FileServiceImpl extends ServiceImpl implements FileService { @Autowired - private FileManagerPlugin fileManagerPlugin; + private FilePluginFactory filePluginFactory; @Override public void batchDelete(List ids) { @@ -42,7 +43,7 @@ public class FileServiceImpl extends ServiceImpl implements Fi List files = this.list(queryWrapper); List keys = new ArrayList<>(); files.forEach(item -> keys.add(item.getFileKey())); - fileManagerPlugin.deleteFile(keys); + filePluginFactory.filePlugin().deleteFile(keys); this.remove(queryWrapper); } @@ -68,7 +69,7 @@ public class FileServiceImpl extends ServiceImpl implements Fi List files = this.list(queryWrapper); List keys = new ArrayList<>(); files.forEach(item -> keys.add(item.getFileKey())); - fileManagerPlugin.deleteFile(keys); + filePluginFactory.filePlugin().deleteFile(keys); this.remove(queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java index 80c5fd07..fd71d3b3 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java @@ -1,5 +1,7 @@ package cn.lili.modules.system.entity.dto; +import cn.lili.common.utils.StringUtils; +import cn.lili.modules.file.entity.enums.OssEnum; import lombok.Data; import java.io.Serializable; @@ -15,6 +17,12 @@ import java.io.Serializable; public class OssSetting implements Serializable { private static final long serialVersionUID = 2975271656230801861L; + + /** + * oss类型 + */ + private String type; + /** * 域名 */ @@ -35,4 +43,34 @@ public class OssSetting implements Serializable { * 密钥 */ private String accessKeySecret = ""; + + + /** + * minio服务地址 + */ + private String m_endpoint; + + /** + * minio用户名 + */ + private String m_accessKey; + + /** + * minio密码 + */ + private String m_secretKey; + + /** + * minio bucket名称 + */ + private String m_bucketName; + + + public String getType() { + //默认给阿里云oss存储类型 + if (StringUtils.isEmpty(type)) { + return OssEnum.ALI_OSS.name(); + } + return type; + } } diff --git a/pom.xml b/pom.xml index a9d92a59..99b15f0a 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ 1.2.2 2.3.1 20211018.2 + 8.0.3 From 7b9f4be98cf585d0a1e3138da756f7c399b3c44c Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 7 Jun 2022 12:16:08 +0800 Subject: [PATCH 112/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/tools/PromotionTools.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 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 125bde42..44aa15e9 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 @@ -164,13 +164,16 @@ public class PromotionTools { } //移除无效促销活动 return map.entrySet().stream().filter(i -> { - JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); - BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); - if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { - return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + if (i != null) { + JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); + BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); + if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + } } + return true; - }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions())); } } From 8f3ca8c28d401ec0f2d0d1acad7048a27eb9aec5 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 7 Jun 2022 12:30:29 +0800 Subject: [PATCH 113/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/promotion/tools/PromotionTools.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 44aa15e9..b0aa1544 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 @@ -1,5 +1,6 @@ package cn.lili.modules.promotion.tools; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.CharSequenceUtil; @@ -159,7 +160,7 @@ public class PromotionTools { } public static Map filterInvalidPromotionsMap(Map map) { - if (map == null) { + if (CollUtil.isEmpty(map)) { return new HashMap<>(); } //移除无效促销活动 @@ -173,7 +174,7 @@ public class PromotionTools { } return true; - }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions())); + }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions(), (oldValue, newValue) -> newValue)); } } From 9ece357e39cc63738589d3bd3333f6f3651fb7e0 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 7 Jun 2022 15:07:14 +0800 Subject: [PATCH 114/185] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF=E5=BC=82=E5=B8=B8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/tools/PromotionTools.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 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 b0aa1544..851faef4 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 @@ -13,6 +13,7 @@ import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; import java.util.*; import java.util.function.Consumer; @@ -25,6 +26,7 @@ import java.util.stream.Collectors; * @author paulG * @since 2020/8/18 **/ +@Slf4j public class PromotionTools { public static final String START_TIME_COLUMN = "start_time"; @@ -163,18 +165,23 @@ public class PromotionTools { if (CollUtil.isEmpty(map)) { return new HashMap<>(); } - //移除无效促销活动 - return map.entrySet().stream().filter(i -> { - if (i != null) { - JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); - BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); - if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { - return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + try { + //移除无效促销活动 + return map.entrySet().stream().filter(i -> { + if (i != null) { + JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); + BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); + if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); + } } - } - return true; - }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions(), (oldValue, newValue) -> newValue)); + return true; + }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions(), (oldValue, newValue) -> newValue)); + } catch (Exception e) { + log.error("过滤无效促销活动出现异常。异常促销信息:{},异常信息:{} ", map, e); + return new HashMap<>(); + } } } From 5f6bae6fa9019b5a1a550e1386b95407dc6f6b4b Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 7 Jun 2022 15:18:07 +0800 Subject: [PATCH 115/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/tools/PromotionTools.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 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 851faef4..8266a6b0 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 @@ -167,17 +167,14 @@ public class PromotionTools { } try { //移除无效促销活动 - return map.entrySet().stream().filter(i -> { - if (i != null) { - JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); - BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); - if (basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { - return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); - } + return map.entrySet().stream().filter(Objects::nonNull).filter(i -> { + JSONObject promotionsObj = JSONUtil.parseObj(i.getValue()); + BasePromotions basePromotions = promotionsObj.toBean(BasePromotions.class); + if (basePromotions != null && basePromotions.getStartTime() != null && basePromotions.getEndTime() != null) { + return basePromotions.getStartTime().getTime() <= System.currentTimeMillis() && basePromotions.getEndTime().getTime() >= System.currentTimeMillis(); } - - return true; - }).collect(Collectors.toMap(stringObjectEntry -> stringObjectEntry != null ? stringObjectEntry.getKey() : null, stringObjectEntry1 -> stringObjectEntry1 != null ? stringObjectEntry1.getValue() : new BasePromotions(), (oldValue, newValue) -> newValue)); + return i.getValue() != null; + }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> newValue)); } catch (Exception e) { log.error("过滤无效促销活动出现异常。异常促销信息:{},异常信息:{} ", map, e); return new HashMap<>(); From f32c7a7253ec19d4ee0cb4c60713571d2a9e2602 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 7 Jun 2022 18:30:21 +0800 Subject: [PATCH 116/185] =?UTF-8?q?=E8=BF=90=E8=B4=B9=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E8=B0=83=E6=95=B4=20=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E8=BF=90=E8=B4=B9=E6=A8=A1=E7=89=88=E7=9A=84=E5=95=86=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E9=87=87=E7=94=A8=E7=B4=AF=E5=8A=A0=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=EF=BC=8C=E8=B5=B7=E9=80=81=E8=B4=B9/=E8=99=9A=E4=BB=B6?= =?UTF-8?q?=EF=BC=88=E9=87=8D=EF=BC=89=E8=B4=B9=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cart/render/impl/SkuFreightRender.java | 119 ++++++++++++++---- 1 file changed, 98 insertions(+), 21 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index d0b0e672..e7e7cc31 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -11,11 +11,15 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO; import cn.lili.modules.store.entity.enums.FreightTemplateEnum; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import cn.lili.modules.store.service.FreightTemplateService; +import org.apache.xmlbeans.impl.store.Cur; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * sku 运费计算 @@ -43,31 +47,35 @@ public class SkuFreightRender implements CartRenderStep { if (memberAddress == null) { return; } - //循环渲染购物车商品运费价格 - forSku: - for (CartSkuVO cartSkuVO : cartSkuVOS) { - //获取sku运费模版 - String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId(); - //免运费则跳出运费计算 - if (Boolean.TRUE.equals(cartSkuVO.getIsFreeFreight()) || freightTemplateId == null) { - continue; - } + //运费分组信息 + Map> freightGroups = freightTemplateGrouping(cartSkuVOS); + + //循环运费模版 + for (String freightTemplateId : freightGroups.keySet()) { + + //商品id列表 + List skuIds = freightGroups.get(freightTemplateId); + + //当前购物车商品列表 + List currentCartSkus = cartSkuVOS.stream().filter(item -> skuIds.contains(item.getGoodsSku().getId())).collect(Collectors.toList()); + //寻找对应对商品运费计算模版 FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId); if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) { - //店铺支付运费则跳过 + //店铺模版免运费则跳过 if (freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())) { break; } + + //运费模版 FreightTemplateChild freightTemplateChild = null; - //获取市级别id + //获取市级别id匹配运费模版 String addressId = memberAddress.getConsigneeAddressIdPath().split(",")[1]; - //获取匹配的收货地址 for (FreightTemplateChild templateChild : freightTemplate.getFreightTemplateChildList()) { - //如果当前模版包含,则返回 + //模版匹配判定 if (templateChild.getAreaId().contains(addressId)) { freightTemplateChild = templateChild; break; @@ -78,28 +86,97 @@ public class SkuFreightRender implements CartRenderStep { if (tradeDTO.getNotSupportFreight() == null) { tradeDTO.setNotSupportFreight(new ArrayList<>()); } - tradeDTO.getNotSupportFreight().add(cartSkuVO); - continue forSku; + tradeDTO.getNotSupportFreight().addAll(currentCartSkus); + continue; } //物流规则模型创立 FreightTemplateChildDTO freightTemplateChildDTO = new FreightTemplateChildDTO(freightTemplateChild); - + //模型写入运费模版设置的计费方式 freightTemplateChildDTO.setPricingMethod(freightTemplate.getPricingMethod()); - //要计算的基数 数量/重量 - Double count = (freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name())) ? - cartSkuVO.getNum() : - cartSkuVO.getGoodsSku().getWeight() * cartSkuVO.getNum(); + //计算运费总数 + Double count = currentCartSkus.stream().mapToDouble(item -> + // 根据计费规则 累加计费基数 + freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name()) ? + item.getNum() : + CurrencyUtil.mul(item.getNum(), item.getGoodsSku().getWeight()) + ).sum(); //计算运费 Double countFreight = countFreight(count, freightTemplateChildDTO); + //写入SKU运费 - cartSkuVO.getPriceDetailDTO().setFreightPrice(countFreight); + resetFreightPrice(FreightTemplateEnum.valueOf(freightTemplateChildDTO.getPricingMethod()), count, countFreight, currentCartSkus); } } } + + /** + * sku运费写入 + * + * @param freightTemplateEnum 运费计算模式 + * @param count 计费基数总数 + * @param countFreight 总运费 + * @param cartSkuVOS 与运费相关的购物车商品 + */ + private void resetFreightPrice(FreightTemplateEnum freightTemplateEnum, Double count, Double countFreight, List cartSkuVOS) { + + //剩余运费 默认等于总运费 + Double surplusFreightPrice = countFreight; + + //当前下标 + int index = 1; + for (CartSkuVO cartSkuVO : cartSkuVOS) { + //如果是最后一个 则将剩余运费直接赋值 + //PS: 循环中避免百分比累加不等于100%,所以最后一个运费不以比例计算,直接将剩余运费赋值 + if (index == cartSkuVOS.size()) { + cartSkuVO.getPriceDetailDTO().setFreightPrice(surplusFreightPrice); + break; + } + + Double freightPrice = freightTemplateEnum == FreightTemplateEnum.NUM ? + CurrencyUtil.mul(countFreight, CurrencyUtil.div(cartSkuVO.getNum(), count)) : + CurrencyUtil.mul(countFreight, + CurrencyUtil.div(CurrencyUtil.mul(cartSkuVO.getNum(), cartSkuVO.getGoodsSku().getWeight()), count)); + + //剩余运费=总运费-当前循环的商品运费 + surplusFreightPrice = CurrencyUtil.sub(surplusFreightPrice, freightPrice); + + cartSkuVO.getPriceDetailDTO().setFreightPrice(freightPrice); + index++; + } + } + + /** + * 运费模版分组 + * + * @param cartSkuVOS 购物车商品 + * @return map<运费模版id , List < skuid>> + */ + private Map> freightTemplateGrouping(List cartSkuVOS) { + Map> map = new HashMap<>(); + //循环渲染购物车商品运费价格 + for (CartSkuVO cartSkuVO : cartSkuVOS) { + ////免运费判定 + String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId(); + if (Boolean.TRUE.equals(cartSkuVO.getIsFreeFreight()) || freightTemplateId == null) { + continue; + } + //包含 则value值中写入sku标识,否则直接写入新的对象,key为模版id,value为new arraylist + if (map.containsKey(freightTemplateId)) { + map.get(freightTemplateId).add(cartSkuVO.getGoodsSku().getId()); + } else { + List skuIdsList = new ArrayList<>(); + skuIdsList.add(cartSkuVO.getGoodsSku().getId()); + map.put(freightTemplateId, skuIdsList); + } + } + return map; + } + + /** * 计算运费 * From fb45fee42663bf5aae9be60ff1e4c534ab8a7be2 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Tue, 7 Jun 2022 18:41:31 +0800 Subject: [PATCH 117/185] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=A2=84=E5=AD=98=E6=AC=BE=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E4=B8=BA0=E6=97=A0=E6=B3=95=E5=AE=A1=E6=A0=B8=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/order/entity/dos/StoreFlow.java | 4 ++-- .../modules/wallet/serviceimpl/MemberWalletServiceImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java index 9445fc7a..0f9a9ab7 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java @@ -93,10 +93,10 @@ public class StoreFlow extends BaseIdEntity { @ApiModelProperty(value = "平台优惠券 使用金额") private Double siteCouponPrice; - @ApiModelProperty(value = "站点优惠券佣金比例") + @ApiModelProperty(value = "站点优惠券补贴比例") private Double siteCouponPoint; - @ApiModelProperty(value = "站点优惠券佣金") + @ApiModelProperty(value = "站点优惠券补贴金额") private Double siteCouponCommission; @ApiModelProperty(value = "单品分销返现支出") diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java index 87766492..d411481d 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java @@ -168,8 +168,8 @@ public class MemberWalletServiceImpl extends ServiceImpl CurrencyUtil.sub(memberWallet.getMemberWallet(), memberWalletUpdateDTO.getMoney())) { - throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT); + if (0 > CurrencyUtil.sub(memberWallet.getMemberFrozenWallet(), memberWalletUpdateDTO.getMoney())) { + throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT); } memberWallet.setMemberFrozenWallet(CurrencyUtil.sub(memberWallet.getMemberFrozenWallet(), memberWalletUpdateDTO.getMoney())); this.updateById(memberWallet); From 6ce2b65d895624aebc62f216119fac8bef5a2d54 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 8 Jun 2022 16:15:14 +0800 Subject: [PATCH 118/185] =?UTF-8?q?=E9=80=82=E9=85=8D=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=9A=84sql=EF=BC=8C=E5=B0=86=E5=B9=B3=E5=8F=B0id=E6=94=B9?= =?UTF-8?q?=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/promotion/entity/dos/BasePromotions.java | 2 +- .../java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java | 2 +- .../java/cn/lili/modules/promotion/tools/PromotionTools.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java index f3366dde..5867af4a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/BasePromotions.java @@ -29,7 +29,7 @@ public class BasePromotions extends BaseEntity { @ApiModelProperty(value = "商家名称,如果是平台,这个值为 platform") private String storeName; - @ApiModelProperty(value = "商家id,如果是平台,这个值为 platform") + @ApiModelProperty(value = "商家id,如果是平台,这个值为 0") private String storeId; @NotEmpty(message = "活动名称不能为空") diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java index 6eeff349..11c30b9a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/MemberCoupon.java @@ -36,7 +36,7 @@ public class MemberCoupon extends BaseEntity { @ApiModelProperty(value = "从哪个模版领取的优惠券") private String couponId; - @ApiModelProperty(value = "商家id,如果是平台发送,这个值为 platform") + @ApiModelProperty(value = "商家id,如果是平台发送,这个值为 0") private String storeId; @ApiModelProperty(value = "商家名称,如果是平台,这个值为 platform") 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 8266a6b0..9148080e 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 @@ -31,7 +31,7 @@ public class PromotionTools { public static final String START_TIME_COLUMN = "start_time"; public static final String END_TIME_COLUMN = "end_time"; - public static final String PLATFORM_ID = "platform"; + public static final String PLATFORM_ID = "0"; public static final String PLATFORM_NAME = "platform"; /** From 8426294a0fcf6e049f72ac13e23187b62913b221 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 8 Jun 2022 16:35:44 +0800 Subject: [PATCH 119/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=AD=98=E5=9C=A8=E6=9D=A1=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BC=A0=E9=80=92=E9=A1=BA=E5=BA=8F=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/serviceimpl/MemberServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 27e04bbe..415a1d85 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -681,7 +681,7 @@ public class MemberServiceImpl extends ServiceImpl impleme */ private void checkMember(String userName, String mobilePhone) { //判断手机号是否存在 - if (findMember(userName, mobilePhone) > 0) { + if (findMember(mobilePhone, userName) > 0) { throw new ServiceException(ResultCode.USER_EXIST); } } From 478ba2048a50ddd316a2020b6f1efaff589fe46a Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 9 Jun 2022 09:13:13 +0800 Subject: [PATCH 120/185] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=80=A7=E5=88=A4=E5=AE=9A=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=95=86=E5=93=81=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=AF=94=E8=BE=83=E6=94=B9=E4=B8=BA=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E6=AF=94=E8=BE=83=EF=BC=88?= =?UTF-8?q?=E5=9B=A0=E4=BF=AE=E6=94=B9=E4=BA=86=E5=95=86=E5=93=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=80=BB=E8=BE=91=EF=BC=8C=E6=AF=8F=E6=AC=A1=E9=83=BD?= =?UTF-8?q?=E6=98=AF=E5=88=A0=E9=99=A4=E5=90=8E=E6=96=B0=E5=A2=9E=EF=BC=8C?= =?UTF-8?q?=E6=89=80=E4=BB=A5=E6=97=A0=E5=95=86=E5=93=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/goods/entity/dos/GoodsSku.java | 6 +++--- .../modules/order/cart/render/impl/CheckDataRender.java | 2 +- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 2 +- framework/src/main/java/cn/lili/mybatis/BaseEntity.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java index ebe97e91..0c89fdc1 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java @@ -171,11 +171,11 @@ public class GoodsSku extends BaseEntity { } @Override - public Date getUpdateTime() { - if (super.getUpdateTime() == null) { + public Date getCreateTime() { + if (super.getCreateTime() == null) { return new Date(1593571928); } else { - return super.getUpdateTime(); + return super.getCreateTime(); } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 8cb02a48..5b5fb2a7 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -107,7 +107,7 @@ public class CheckDataRender implements CartRenderStep { //缓存中的商品信息 GoodsSku dataSku = goodsSkuService.getGoodsSkuByIdFromCache(cartSkuVO.getGoodsSku().getId()); //商品有效性判定 - if (dataSku == null || dataSku.getUpdateTime().before(cartSkuVO.getGoodsSku().getUpdateTime())) { + if (dataSku == null || dataSku.getCreateTime().after(cartSkuVO.getGoodsSku().getCreateTime())) { //设置购物车未选中 cartSkuVO.setChecked(false); //设置购物车此sku商品已失效 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 7b44ed78..3a45ded2 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -150,7 +150,7 @@ public class CartServiceImpl implements CartService { //购物车中已经存在,更新数量 - if (cartSkuVO != null && dataSku.getUpdateTime().equals(cartSkuVO.getGoodsSku().getUpdateTime())) { + if (cartSkuVO != null && dataSku.getCreateTime().equals(cartSkuVO.getGoodsSku().getCreateTime())) { //如果覆盖购物车中商品数量 if (Boolean.TRUE.equals(cover)) { diff --git a/framework/src/main/java/cn/lili/mybatis/BaseEntity.java b/framework/src/main/java/cn/lili/mybatis/BaseEntity.java index ab73d591..126c6cbc 100644 --- a/framework/src/main/java/cn/lili/mybatis/BaseEntity.java +++ b/framework/src/main/java/cn/lili/mybatis/BaseEntity.java @@ -64,7 +64,7 @@ public abstract class BaseEntity implements Serializable { @LastModifiedDate @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField(fill = FieldFill.UPDATE) + @TableField(fill = FieldFill.INSERT_UPDATE) @ApiModelProperty(value = "更新时间", hidden = true) @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis") private Date updateTime; From 5e6a56e193280f2b5978792710df498efa1f3a3e Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 9 Jun 2022 09:15:57 +0800 Subject: [PATCH 121/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=AA=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/StoreGoodsLabelServiceImpl.java | 2 +- .../modules/order/cart/render/impl/SkuFreightRender.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java index 6d5a7d8d..6d5f9a0e 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java @@ -56,7 +56,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl storeGoodsLabelVOChildList = new ArrayList<>(); list.stream() - .filter(label -> label.getParentId().equals(storeGoodsLabel.getId())) + .filter(label -> label.getParentId() != null && label.getParentId().equals(storeGoodsLabel.getId())) .forEach(storeGoodsLabelChild -> storeGoodsLabelVOChildList.add(new StoreGoodsLabelVO(storeGoodsLabelChild.getId(), storeGoodsLabelChild.getLabelName(), storeGoodsLabelChild.getLevel(), storeGoodsLabelChild.getSortOrder()))); storeGoodsLabelVO.setChildren(storeGoodsLabelVOChildList); storeGoodsLabelVOList.add(storeGoodsLabelVO); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index e7e7cc31..799c62b8 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -11,7 +11,6 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO; import cn.lili.modules.store.entity.enums.FreightTemplateEnum; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import cn.lili.modules.store.service.FreightTemplateService; -import org.apache.xmlbeans.impl.store.Cur; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -51,16 +50,16 @@ public class SkuFreightRender implements CartRenderStep { Map> freightGroups = freightTemplateGrouping(cartSkuVOS); //循环运费模版 - for (String freightTemplateId : freightGroups.keySet()) { + for (Map.Entry> freightTemplateGroup : freightGroups.entrySet()) { //商品id列表 - List skuIds = freightGroups.get(freightTemplateId); + List skuIds = freightTemplateGroup.getValue(); //当前购物车商品列表 List currentCartSkus = cartSkuVOS.stream().filter(item -> skuIds.contains(item.getGoodsSku().getId())).collect(Collectors.toList()); //寻找对应对商品运费计算模版 - FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId); + FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateGroup.getKey()); if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) { @@ -99,7 +98,7 @@ public class SkuFreightRender implements CartRenderStep { Double count = currentCartSkus.stream().mapToDouble(item -> // 根据计费规则 累加计费基数 freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name()) ? - item.getNum() : + item.getNum().doubleValue() : CurrencyUtil.mul(item.getNum(), item.getGoodsSku().getWeight()) ).sum(); From d14763d52c25fb0c17c2aba0267668afd5c339b3 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 9 Jun 2022 15:32:24 +0800 Subject: [PATCH 122/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0buyer=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E6=A3=80=E6=B5=8Bes=E7=B4=A2=E5=BC=95=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=88=99=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/init/EsGoodsIndexInitRunner.java | 30 +++++++++++++++++++ .../lili/cache/config/redis/RedisConfig.java | 2 +- .../BaseElasticsearchService.java | 2 +- .../search/entity/dos/EsGoodsIndex.java | 2 +- .../search/service/EsGoodsIndexService.java | 8 ++++- .../serviceimpl/EsGoodsIndexServiceImpl.java | 19 ++++++++++++ .../serviceimpl/EsGoodsSearchServiceImpl.java | 23 +++++--------- 7 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 buyer-api/src/main/java/cn/lili/init/EsGoodsIndexInitRunner.java diff --git a/buyer-api/src/main/java/cn/lili/init/EsGoodsIndexInitRunner.java b/buyer-api/src/main/java/cn/lili/init/EsGoodsIndexInitRunner.java new file mode 100644 index 00000000..8b3e9952 --- /dev/null +++ b/buyer-api/src/main/java/cn/lili/init/EsGoodsIndexInitRunner.java @@ -0,0 +1,30 @@ +package cn.lili.init; + +import cn.lili.modules.search.service.EsGoodsIndexService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +/** + * @author paulG + * @since 2022/6/9 + **/ +@Component +@Slf4j +public class EsGoodsIndexInitRunner implements ApplicationRunner { + + @Autowired + private EsGoodsIndexService esGoodsIndexService; + + + @Override + public void run(ApplicationArguments args) { + try { + esGoodsIndexService.initIndex(); + } catch (Exception e) { + log.error("检测ES商品索引失败", e); + } + } +} diff --git a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java index 659c1ece..0551f26b 100644 --- a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java +++ b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java @@ -115,7 +115,6 @@ public class RedisConfig extends CachingConfigurerSupport { @Bean(destroyMethod = "shutdown") public RedissonClient redisson() { Config config = new Config(); - if (redisProperties.getSentinel() != null && !redisProperties.getSentinel().getNodes().isEmpty()) { // 哨兵模式 SentinelServersConfig sentinelServersConfig = config.useSentinelServers(); @@ -145,6 +144,7 @@ public class RedisConfig extends CachingConfigurerSupport { if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) { singleServerConfig.setPassword(redisProperties.getPassword()); } + singleServerConfig.setPingConnectionInterval(1000); } return Redisson.create(config); diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index 8421156a..fec64277 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -123,7 +123,7 @@ public abstract class BaseElasticsearchService { " \"type\": \"keyword\"\n" + " },\n" + " \"type\": {\n" + - " \"type\": \"long\"\n" + + " \"type\": \"integer\"\n" + " },\n" + " \"value\": {\n" + " \"type\": \"keyword\"\n" + diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 71ba03c0..9687f832 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -277,7 +277,7 @@ public class EsGoodsIndex implements Serializable { * @see PromotionTypeEnum * value 为 促销活动实体信息 */ - @Field(type = FieldType.Nested) + @Field(type = FieldType.Text) @ApiModelProperty("商品促销活动集合JSON,key 为 促销活动类型,value 为 促销活动实体信息 ") private String promotionMapJson; diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index aad7893e..ffb8d56a 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -20,7 +20,7 @@ import java.util.Map; public interface EsGoodsIndexService { /** - * 全局索引初始化 + * 全局索引数据初始化 */ void init(); @@ -31,6 +31,12 @@ public interface EsGoodsIndexService { */ Map getProgress(); + + /** + * 全局索引初始化 + */ + void initIndex(); + /** * 添加商品索引 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 6c4626d2..063de202 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -200,6 +200,25 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements return map; } + @Override + public void initIndex() { + //索引名称拼接 + String indexName = this.getIndexName(); + + //索引初始化,因为mapping结构问题: + //但是如果索引已经自动生成过,这里就不会创建索引,设置mapping,所以这里决定在初始化索引的同时,将已有索引删除,重新创建 + + boolean indexExist = this.indexExist(indexName); + log.info("检测 {} 索引结构是否存在:{}", indexName, indexExist); + if (!indexExist) { + + log.info("初始化索引结构 {}", indexName); + //如果索引不存在,则创建索引 + createIndexRequest(indexName); + } + + } + @Override public void addIndex(EsGoodsIndex goods) { try { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index e91bd477..3b9d18cc 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -11,10 +11,8 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; -import cn.lili.modules.search.entity.dto.HotWordsDTO; import cn.lili.modules.search.entity.dto.ParamOptions; import cn.lili.modules.search.entity.dto.SelectorOptions; -import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; import com.alibaba.druid.util.StringUtils; import lombok.extern.slf4j.Slf4j; @@ -44,7 +42,6 @@ import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; -import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Service; import java.util.*; @@ -73,9 +70,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { */ @Autowired private ElasticsearchOperations restTemplate; - - @Autowired - private EsGoodsIndexService esGoodsIndexService; /** * 缓存 */ @@ -84,10 +78,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { @Override public SearchPage searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo) { - boolean exists = restTemplate.indexOps(EsGoodsIndex.class).exists(); - if (!exists) { - esGoodsIndexService.init(); - } if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword())) { cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword()); } @@ -364,7 +354,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { this.commonSearch(filterBuilder, searchDTO); //智能推荐 - this.recommended(filterBuilder,searchDTO); + this.recommended(filterBuilder, searchDTO); //未上架的商品不显示 filterBuilder.must(QueryBuilders.matchQuery("marketEnable", GoodsStatusEnum.UPPER.name())); @@ -406,30 +396,31 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { /** * 商品推荐 + * * @param filterBuilder * @param searchDTO */ private void recommended(BoolQueryBuilder filterBuilder, EsGoodsSearchDTO searchDTO) { String currentGoodsId = searchDTO.getCurrentGoodsId(); - if(CharSequenceUtil.isEmpty(currentGoodsId)) { + if (CharSequenceUtil.isEmpty(currentGoodsId)) { return; } //排除当前商品 - filterBuilder.mustNot(QueryBuilders.matchQuery("id",currentGoodsId)); + filterBuilder.mustNot(QueryBuilders.matchQuery("id", currentGoodsId)); //查询当前浏览商品的索引信息 EsGoodsIndex esGoodsIndex = restTemplate.get(currentGoodsId, EsGoodsIndex.class); - if(esGoodsIndex==null) { + if (esGoodsIndex == null) { return; } //推荐与当前浏览商品相同一个二级分类下的商品 String categoryPath = esGoodsIndex.getCategoryPath(); - if(CharSequenceUtil.isNotEmpty(categoryPath)){ + if (CharSequenceUtil.isNotEmpty(categoryPath)) { //匹配二级分类 String substring = categoryPath.substring(0, categoryPath.lastIndexOf(",")); - filterBuilder.must(QueryBuilders.wildcardQuery("categoryPath",substring+"*")); + filterBuilder.must(QueryBuilders.wildcardQuery("categoryPath", substring + "*")); } } From 4316fa8953c3f05a890c08992aa5e916a8d491e1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 9 Jun 2022 16:43:16 +0800 Subject: [PATCH 123/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BC=96=E8=BE=91=E5=95=86=E5=93=81=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=8E=9F=E5=95=86=E5=93=81=E7=9A=84=E9=94=80?= =?UTF-8?q?=E9=87=8F=E3=80=81=E5=A5=BD=E8=AF=84=E7=8E=87=E5=92=8C=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/GoodsSkuServiceImpl.java | 32 ++++++++++++++++--- .../search/entity/dos/EsGoodsIndex.java | 5 +-- .../serviceimpl/EsGoodsIndexServiceImpl.java | 3 +- 3 files changed, 32 insertions(+), 8 deletions(-) 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 aa6bc4c4..c4072466 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 @@ -14,6 +14,7 @@ import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.SnowFlake; import cn.lili.modules.goods.entity.dos.Goods; +import cn.lili.modules.goods.entity.dos.GoodsGallery; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; @@ -166,8 +167,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } else { skuList = new ArrayList<>(); for (Map map : goodsOperationDTO.getSkuList()) { - GoodsSku sku = null; - sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); + GoodsSku sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO); renderGoodsSku(sku, goodsOperationDTO); skuList.add(sku); //如果商品状态值不对,则es索引移除 @@ -636,6 +636,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i // 商品销售模式渲染器 salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO)); for (GoodsSku goodsSku : goodsSkuList) { + extendOldSkuValue(goodsSku); this.renderImages(goodsSku); } } @@ -647,22 +648,43 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goodsOperationDTO 商品操作DTO */ void renderGoodsSku(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { + extendOldSkuValue(goodsSku); // 商品销售模式渲染器 salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO)); this.renderImages(goodsSku); } + /** + * 将原sku的一些不会直接传递的值放到新的sku中 + * + * @param goodsSku 商品sku + */ + private void extendOldSkuValue(GoodsSku goodsSku) { + if (CharSequenceUtil.isNotEmpty(goodsSku.getGoodsId())) { + GoodsSku oldSku = this.getGoodsSkuByIdFromCache(goodsSku.getId()); + if (oldSku != null) { + goodsSku.setCommentNum(oldSku.getCommentNum()); + goodsSku.setViewCount(oldSku.getViewCount()); + goodsSku.setBuyCount(oldSku.getBuyCount()); + goodsSku.setGrade(oldSku.getGrade()); + } + } + } + /** * 渲染sku图片 * - * @param goodsSku + * @param goodsSku sku */ void renderImages(GoodsSku goodsSku) { JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); List> images = jsonObject.get("images", List.class); if (images != null && !images.isEmpty()) { - goodsSku.setThumbnail(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail()); - goodsSku.setSmall(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall()); + GoodsGallery goodsGallery = goodsGalleryService.getGoodsGallery(images.get(0).get("url")); + goodsSku.setBig(goodsGallery.getOriginal()); + goodsSku.setOriginal(goodsGallery.getOriginal()); + goodsSku.setThumbnail(goodsGallery.getThumbnail()); + goodsSku.setSmall(goodsGallery.getSmall()); } } diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java index 9687f832..743b5dd5 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java @@ -28,7 +28,7 @@ import java.util.Map; * @author paulG **/ @Data -@Document(indexName = "#{@elasticsearchProperties.indexPrefix}_" + EsSuffix.GOODS_INDEX_NAME) +@Document(indexName = "#{@elasticsearchProperties.indexPrefix}_" + EsSuffix.GOODS_INDEX_NAME, createIndex = false) @ToString @NoArgsConstructor @Accessors(chain = true) @@ -215,6 +215,7 @@ public class EsGoodsIndex implements Serializable { /** * 销售模式 + * * @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum */ @Field(type = FieldType.Text) @@ -316,7 +317,7 @@ public class EsGoodsIndex implements Serializable { /** * 参数索引增加 * - * @param sku 商品sku信息 + * @param sku 商品sku信息 * @param goodsParamDTOS 商品参数信息 */ public EsGoodsIndex(GoodsSku sku, List goodsParamDTOS) { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 063de202..2c999f64 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -66,6 +66,7 @@ import org.springframework.stereotype.Service; import java.io.IOException; import java.lang.reflect.Field; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -127,7 +128,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements Boolean flag = (Boolean) cache.get(CachePrefix.INIT_INDEX_FLAG.getPrefix()); //为空则默认写入没有任务 if (flag == null) { - cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false); + cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false, 10L, TimeUnit.MINUTES); } //有正在初始化的任务,则提示异常 if (Boolean.TRUE.equals(flag)) { From b7b278f2966ae03d3923a0221f5929e162c0acd8 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 10 Jun 2022 18:42:56 +0800 Subject: [PATCH 124/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/render/GoodsSkuRender.java | 19 ------------------- .../goods/service/GoodsSkuService.java | 6 +++--- pom.xml | 1 - 3 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java diff --git a/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java b/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java deleted file mode 100644 index 61bfe273..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/render/GoodsSkuRender.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.lili.modules.goods.render; - -import cn.lili.modules.goods.entity.dos.GoodsSku; - -import java.util.List; -import java.util.Map; - -/** - * 商品sku渲染器 - * - * @author paulG - * @since 2022/5/20 - **/ -public interface GoodsSkuRender { - - - GoodsSku render(List> skuList); - -} 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 0fc10b04..031fac67 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 @@ -215,7 +215,7 @@ public interface GoodsSkuService extends IService { /** * 删除并且新增sku,即覆盖之前信息 * - * @param goodsSkus + * @param goodsSkus 商品sku集合 * @return */ boolean deleteAndInsertGoodsSkus(List goodsSkus); @@ -223,8 +223,8 @@ public interface GoodsSkuService extends IService { /** * 统计sku总数 * - * @param storeId - * @return + * @param storeId 店铺id + * @return sku总数 */ Long countSkuNum(String storeId); } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 99b15f0a..966ba0c3 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,6 @@ ${docker-registry}/${project.artifactId}:${revision}.${images-version} java ["java", "-jar", "/${project.build.finalName}.jar"] - true / From e9a0c293f8a19329558ee5acf7e71ecb7d76c07b Mon Sep 17 00:00:00 2001 From: chopper711 <1814994716@qq.com> Date: Mon, 13 Jun 2022 06:53:48 +0000 Subject: [PATCH 125/185] update README.md. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a23e42fd..800a2b13 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ ## Lilishop B2B2C商城系统 -#### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,进群先看文档后提问) +#### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,其他问题先看文档后提问) ##### 交流 qq 1群 961316482(已满) Lilishop交流群点击快捷加群 -##### 交流 qq 2群 875294241 +##### 交流 qq 2群 875294241(最后63名额) Lilishop交流群2群点击快捷加群 +##### 交流 qq 3群 263785057(2022-06-13建立) + +Lilishop交流群3群 + + ##### 体验 公众号/小程序/APP 体验,扫描二维码 ![image-20210511171611793](https://pickmall.cn/assets/imgs/h5-qrcode.png) From c161206832866e835d6c178a37551d440310bc1e Mon Sep 17 00:00:00 2001 From: chopper711 <1814994716@qq.com> Date: Mon, 13 Jun 2022 06:54:12 +0000 Subject: [PATCH 126/185] update README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 800a2b13..3ea8ed39 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ##### 交流 qq 3群 263785057(2022-06-13建立) -Lilishop交流群3群 +Lilishop交流群3群点击快捷加群 ##### 体验 公众号/小程序/APP 体验,扫描二维码 From 056f040317446ebd5dbc29b72ae8e558ecb38a37 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 13 Jun 2022 18:50:09 +0800 Subject: [PATCH 127/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E7=94=9F=E6=88=90=EF=BC=8C=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseElasticsearchService.java | 1 + .../modules/goods/entity/dto/GoodsSkuDTO.java | 25 ++++ .../modules/goods/entity/vos/GoodsSkuVO.java | 2 + .../modules/goods/mapper/GoodsSkuMapper.java | 15 +++ .../goods/service/GoodsSkuService.java | 12 ++ .../serviceimpl/GoodsSkuServiceImpl.java | 8 ++ .../search/service/EsGoodsIndexService.java | 5 +- .../serviceimpl/EsGoodsIndexServiceImpl.java | 124 ++++++++++-------- .../serviceimpl/EsGoodsSearchServiceImpl.java | 7 +- .../other/ElasticsearchController.java | 2 +- .../cn/lili/test/elasticsearch/EsTest.java | 14 +- 11 files changed, 151 insertions(+), 64 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index fec64277..c1d956be 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -85,6 +85,7 @@ public abstract class BaseElasticsearchService { */ protected void createIndexRequest(String index) { try { + deleteIndexRequest(index); CreateIndexRequest request = new CreateIndexRequest(index); //Settings for this index request.settings(Settings.builder() diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java new file mode 100644 index 00000000..a93db09f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java @@ -0,0 +1,25 @@ +package cn.lili.modules.goods.entity.dto; + +import cn.lili.modules.goods.entity.dos.GoodsSku; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * @author paulG + * @since 2022/6/13 + **/ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +public class GoodsSkuDTO extends GoodsSku { + + private static final long serialVersionUID = 6600436187015048097L; + + @ApiModelProperty(value = "商品参数json") + private String params; + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsSkuVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsSkuVO.java index 32f3a030..4721a4c9 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/GoodsSkuVO.java @@ -5,6 +5,7 @@ import cn.lili.modules.goods.entity.dos.GoodsSku; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.List; @@ -16,6 +17,7 @@ import java.util.List; * @since 2020-02-26 23:24:13 */ @Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor public class GoodsSkuVO extends GoodsSku { 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 db3e0a58..e17f6d41 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 @@ -1,7 +1,11 @@ package cn.lili.modules.goods.mapper; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -99,4 +103,15 @@ public interface GoodsSkuMapper extends BaseMapper { ")") int replaceGoodsSku(@Param("goodsSku") GoodsSku goodsSku); + + /** + * 分页查询商品skuDTO + * + * @param page 分页 + * @param queryWrapper 查询条件 + * @return 售后VO分页 + */ + @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); + } \ 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 031fac67..754a5edf 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 @@ -5,9 +5,12 @@ import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; +import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -136,6 +139,15 @@ public interface GoodsSkuService extends IService { */ IPage getGoodsSkuByPage(GoodsSearchParams searchParams); + + /** + * 分页查询商品sku信息 + * + * @param searchParams 查询参数 + * @return 商品sku信息 + */ + IPage getGoodsSkuDTOByPage(Page page, Wrapper queryWrapper); + /** * 列表查询商品sku信息 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index c4072466..c4d89278 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 @@ -18,6 +18,7 @@ import cn.lili.modules.goods.entity.dos.GoodsGallery; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsSearchParams; +import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; @@ -44,9 +45,11 @@ import cn.lili.modules.search.utils.EsIndexUtil; import cn.lili.mybatis.util.PageUtil; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; @@ -448,6 +451,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return this.page(PageUtil.initPage(searchParams), searchParams.queryWrapper()); } + @Override + public IPage getGoodsSkuDTOByPage(Page page, Wrapper queryWrapper) { + return this.baseMapper.queryByParams(page, queryWrapper); + } + /** * 列表查询商品sku信息 * diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index ffb8d56a..199e7e79 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -29,7 +29,7 @@ public interface EsGoodsIndexService { * * @return */ - Map getProgress(); + Map getProgress(); /** @@ -106,8 +106,9 @@ public interface EsGoodsIndexService { * 初始化商品索引 * * @param goodsIndexList 商品索引列表 + * @param regeneratorIndex 是否重新生成索引 */ - void initIndex(List goodsIndexList); + void initIndex(List goodsIndexList, boolean regeneratorIndex); /** * 更新商品索引的促销信息 diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 2c999f64..773e603d 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -21,6 +21,7 @@ import cn.lili.elasticsearch.EsSuffix; import cn.lili.elasticsearch.config.ElasticsearchProperties; import cn.lili.modules.goods.entity.dos.*; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; @@ -38,6 +39,7 @@ import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; @@ -83,6 +85,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements private final Map fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class); + + private final String KEY_SUCCESS = "success"; + private final String KEY_FAIL = "fail"; + private final String KEY_PROCESSED = "processed"; + @Autowired private ElasticsearchProperties elasticsearchProperties; @Autowired @@ -128,7 +135,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements Boolean flag = (Boolean) cache.get(CachePrefix.INIT_INDEX_FLAG.getPrefix()); //为空则默认写入没有任务 if (flag == null) { - cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false, 10L, TimeUnit.MINUTES); + cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false); } //有正在初始化的任务,则提示异常 if (Boolean.TRUE.equals(flag)) { @@ -137,48 +144,58 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //初始化标识 cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), null); - cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), true); + cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), true, 10L, TimeUnit.MINUTES); + ThreadUtil.execAsync(() -> { try { - LambdaQueryWrapper goodsQueryWrapper = new LambdaQueryWrapper<>(); - goodsQueryWrapper.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name()); - goodsQueryWrapper.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()); - goodsQueryWrapper.eq(Goods::getDeleteFlag, false); + QueryWrapper skuQueryWrapper = new QueryWrapper<>(); + skuQueryWrapper.eq("gs.auth_flag", GoodsAuthEnum.PASS.name()); + skuQueryWrapper.eq("gs.market_enable", GoodsStatusEnum.UPPER.name()); + skuQueryWrapper.eq("gs.delete_flag", false); + + + Map resultMap = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); + + if (CollUtil.isEmpty(resultMap)) { + QueryWrapper skuCountQueryWrapper = new QueryWrapper<>(); + skuCountQueryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name()); + skuCountQueryWrapper.eq("market_enable", GoodsStatusEnum.UPPER.name()); + skuCountQueryWrapper.eq("delete_flag", false); + resultMap = new HashMap<>(); + resultMap.put(KEY_SUCCESS, 0L); + resultMap.put(KEY_FAIL, 0L); + resultMap.put(KEY_PROCESSED, 0L); + resultMap.put("total", this.goodsSkuService.count(skuCountQueryWrapper)); + cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), resultMap); + } for (int i = 1; ; i++) { List esGoodsIndices = new ArrayList<>(); - IPage page = new Page<>(i, 1000); - IPage goodsIPage = goodsService.page(page, goodsQueryWrapper); - if (goodsIPage == null || CollUtil.isEmpty(goodsIPage.getRecords())) { + Page skuPage = new Page<>(i, 100); + IPage skuIPage = goodsSkuService.getGoodsSkuDTOByPage(skuPage, skuQueryWrapper); + if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) { break; } - for (Goods goods : goodsIPage.getRecords()) { - LambdaQueryWrapper skuQueryWrapper = new LambdaQueryWrapper<>(); - skuQueryWrapper.eq(GoodsSku::getGoodsId, goods.getId()); - skuQueryWrapper.eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()); - skuQueryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name()); - skuQueryWrapper.eq(GoodsSku::getDeleteFlag, false); - for (int j = 1; ; j++) { - IPage skuPage = new Page<>(j, 100); - IPage skuIPage = goodsSkuService.page(skuPage, skuQueryWrapper); - if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) { - break; - } - int skuSource = 100; - for (GoodsSku goodsSku : skuIPage.getRecords()) { - EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku, goods); - esGoodsIndex.setSkuSource(skuSource--); - esGoodsIndices.add(esGoodsIndex); - //库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量 - cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); - } + for (GoodsSkuDTO goodsSku : skuIPage.getRecords()) { + int skuSource = 100; + EsGoodsIndex esGoodsIndex = wrapperEsGoodsIndex(goodsSku); + long count = esGoodsIndices.stream().filter(j -> j.getGoodsId().equals(esGoodsIndex.getGoodsId())).count(); + if (count >= 1) { + skuSource -= count; } + esGoodsIndex.setSkuSource(skuSource); + esGoodsIndices.add(esGoodsIndex); + //库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量 + cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); } - this.initIndex(esGoodsIndices); + + //批量插入索引,如果为第一次则删除原索引并创建新索引 + this.initIndex(esGoodsIndices, i == 1); } + cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false); //初始化商品索引 } catch (Exception e) { @@ -188,16 +205,17 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false); } }); + } @Override - public Map getProgress() { - Map map = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); + public Map getProgress() { + Map map = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); if (map == null) { return Collections.emptyMap(); } Boolean flag = (Boolean) cache.get(CachePrefix.INIT_INDEX_FLAG.getPrefix()); - map.put("flag", Boolean.TRUE.equals(flag) ? 1 : 0); + map.put("flag", Boolean.TRUE.equals(flag) ? 1L : 0L); return map; } @@ -391,7 +409,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } @Override - public void initIndex(List goodsIndexList) { + public void initIndex(List goodsIndexList, boolean regeneratorIndex) { if (goodsIndexList == null || goodsIndexList.isEmpty()) { //初始化标识 cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), null); @@ -405,27 +423,18 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //但是如果索引已经自动生成过,这里就不会创建索引,设置mapping,所以这里决定在初始化索引的同时,将已有索引删除,重新创建 //如果索引存在,则删除,重新生成。 这里应该有更优解。 - if (this.indexExist(indexName)) { - deleteIndexRequest(indexName); + boolean indexExist = this.indexExist(indexName); + if (regeneratorIndex || !indexExist) { + //如果索引不存在,则创建索引 + createIndexRequest(indexName); } - //如果索引不存在,则创建索引 - createIndexRequest(indexName); - Map resultMap = new HashMap<>(16); - final String KEY_SUCCESS = "success"; - final String KEY_FAIL = "fail"; - final String KEY_PROCESSED = "processed"; - resultMap.put("total", goodsIndexList.size()); - resultMap.put(KEY_SUCCESS, 0); - resultMap.put(KEY_FAIL, 0); - resultMap.put(KEY_PROCESSED, 0); - cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), resultMap); + Map resultMap = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); if (!goodsIndexList.isEmpty()) { - goodsIndexRepository.deleteAll(); for (EsGoodsIndex goodsIndex : goodsIndexList) { try { log.info("生成商品索引:{}", goodsIndex); - addIndex(goodsIndex); + this.addIndex(goodsIndex); resultMap.put(KEY_SUCCESS, resultMap.get(KEY_SUCCESS) + 1); } catch (Exception e) { log.error("商品{}生成索引错误!", goodsIndex); @@ -436,7 +445,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } cache.put(CachePrefix.INIT_INDEX_PROCESS.getPrefix(), resultMap); - cache.put(CachePrefix.INIT_INDEX_FLAG.getPrefix(), false); } @Override @@ -813,30 +821,30 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements return elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME; } - private EsGoodsIndex wrapperEsGoodsIndex(GoodsSku goodsSku, Goods goods) { + private EsGoodsIndex wrapperEsGoodsIndex(GoodsSkuDTO goodsSku) { EsGoodsIndex index = new EsGoodsIndex(goodsSku); //商品参数索引 - if (goods.getParams() != null && !goods.getParams().isEmpty()) { - List goodsParamDTOS = JSONUtil.toList(goods.getParams(), GoodsParamsDTO.class); + if (CharSequenceUtil.isNotEmpty(goodsSku.getParams())) { + List goodsParamDTOS = JSONUtil.toList(goodsSku.getParams(), GoodsParamsDTO.class); index = new EsGoodsIndex(goodsSku, goodsParamDTOS); } //商品分类索引 - if (goods.getCategoryPath() != null) { - List categories = categoryService.listByIdsOrderByLevel(Arrays.asList(goods.getCategoryPath().split(","))); + if (goodsSku.getCategoryPath() != null) { + List categories = categoryService.listByIdsOrderByLevel(Arrays.asList(goodsSku.getCategoryPath().split(","))); if (!categories.isEmpty()) { index.setCategoryNamePath(ArrayUtil.join(categories.stream().map(Category::getName).toArray(), ",")); } } //商品品牌索引 - Brand brand = brandService.getById(goods.getBrandId()); + Brand brand = brandService.getById(goodsSku.getBrandId()); if (brand != null) { index.setBrandName(brand.getName()); index.setBrandUrl(brand.getLogo()); } //店铺分类索引 - if (goods.getStoreCategoryPath() != null && CharSequenceUtil.isNotEmpty(goods.getStoreCategoryPath())) { - List storeGoodsLabels = storeGoodsLabelService.listByStoreIds(Arrays.asList(goods.getStoreCategoryPath().split(","))); + if (goodsSku.getStoreCategoryPath() != null && CharSequenceUtil.isNotEmpty(goodsSku.getStoreCategoryPath())) { + List storeGoodsLabels = storeGoodsLabelService.listByStoreIds(Arrays.asList(goodsSku.getStoreCategoryPath().split(","))); if (!storeGoodsLabels.isEmpty()) { index.setStoreCategoryNamePath(ArrayUtil.join(storeGoodsLabels.stream().map(StoreGoodsLabel::getLabelName).toArray(), ",")); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 3b9d18cc..fd25cf2b 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -365,9 +365,12 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { //关键字检索 if (CharSequenceUtil.isEmpty(searchDTO.getKeyword())) { List filterFunctionBuilders = new ArrayList<>(); - GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 100, 10).setWeight(10); + GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(2); FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchAllQuery(), skuNoScore); filterFunctionBuilders.add(skuNoBuilder); + FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(3); + FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchAllQuery(), buyCountScore); + filterFunctionBuilders.add(buyCountBuilder); FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()]; filterFunctionBuilders.toArray(builders); FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders) @@ -561,7 +564,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + keyword + "*"), ScoreMode.None), ScoreFunctionBuilders.weightFactorFunction(8))); - GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 100, 10).setWeight(7); + GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(7); FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, skuNoScore); filterFunctionBuilders.add(skuNoBuilder); diff --git a/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java b/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java index 2ecb8cdd..89d878b3 100644 --- a/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java +++ b/manager-api/src/main/java/cn/lili/controller/other/ElasticsearchController.java @@ -33,7 +33,7 @@ public class ElasticsearchController { } @GetMapping("/progress") - public ResultMessage> getProgress() { + public ResultMessage> getProgress() { return ResultUtil.data(esGoodsIndexService.getProgress()); } } diff --git a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java index 3ecf49f3..762bcbdb 100644 --- a/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java +++ b/manager-api/src/test/java/cn/lili/test/elasticsearch/EsTest.java @@ -3,9 +3,11 @@ package cn.lili.test.elasticsearch; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.common.vo.PageVO; +import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; +import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; @@ -47,6 +49,9 @@ class EsTest { @Autowired private GoodsSkuService goodsSkuService; + @Autowired + private GoodsService goodsService; + @Autowired private Cache cache; @@ -63,6 +68,13 @@ class EsTest { // System.out.println(HtmlUtil.filter("+ADw-script+AD4-alert(document.cookie)+ADw-/script+AD4-")); // Date dt1 = new Date(2021, 12, 10); // Date dt2 = new Date(2021, 12, 14); + for (int i = 0; i < 1000; i++) { + + Goods goods = new Goods(); + goods.setGoodsName("测试商品" + i); +// goods.setAuthFlag(); + } + // } @@ -132,7 +144,7 @@ class EsTest { esGoodsIndices.add(index); cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); } - esGoodsIndexService.initIndex(esGoodsIndices); + esGoodsIndexService.initIndex(esGoodsIndices, true); Assertions.assertTrue(true); } From 049a759cda1ed6536c01a58465d375823e0e6d8b Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 14 Jun 2022 15:36:29 +0800 Subject: [PATCH 128/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=A1=E6=81=AF=E5=90=8E=EF=BC=8C=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/store/serviceimpl/StoreServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index c8f85805..90db9136 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -2,6 +2,8 @@ package cn.lili.modules.store.serviceimpl; import cn.hutool.core.date.DateTime; import cn.hutool.core.text.CharSequenceUtil; +import cn.lili.cache.Cache; +import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.security.AuthUser; @@ -60,6 +62,10 @@ public class StoreServiceImpl extends ServiceImpl implements @Autowired private StoreDetailService storeDetailService; + + @Autowired + private Cache cache; + @Override public IPage findByConditionPage(StoreSearchParams storeSearchParams, PageVO page) { return this.baseMapper.getStoreList(PageUtil.initPage(page), storeSearchParams.queryWrapper()); @@ -145,6 +151,7 @@ public class StoreServiceImpl extends ServiceImpl implements storeDetailService.updateStoreGoodsInfo(store); } } + cache.remove(CachePrefix.STORE.getPrefix() + storeEditDTO.getStoreId()); return store; } From 1edd3441bc39cdd3eca8b7a42d27181be8aff066 Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Wed, 15 Jun 2022 18:09:55 +0800 Subject: [PATCH 129/185] =?UTF-8?q?=E7=94=B5=E5=AD=90=E9=9D=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 98852a25..42067203 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -314,6 +314,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl promotionInfo) { + System.out.println(promotionInfo); JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); searchParams.setSkuId(dataSku.getId()); From 9f83b40be4207e047ad4d891d13d7db867ede2f9 Mon Sep 17 00:00:00 2001 From: caihongcheng <1501738723@qq.com> Date: Wed, 15 Jun 2022 18:21:06 +0800 Subject: [PATCH 130/185] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 42067203..98852a25 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -314,7 +314,6 @@ public class PromotionGoodsServiceImpl extends ServiceImpl promotionInfo) { - System.out.println(promotionInfo); JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); searchParams.setSkuId(dataSku.getId()); From 7bb06e7fdc88368dd47a0006d31b5454277bc9c1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 16 Jun 2022 10:21:41 +0800 Subject: [PATCH 131/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java | 1 + .../promotion/serviceimpl/PromotionGoodsServiceImpl.java | 2 +- .../cn/lili/controller/permission/MenuManagerController.java | 1 - .../main/java/cn/lili/security/ManagerAuthenticationFilter.java | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java index 9557ceae..8e062fd4 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/MenuServiceImpl.java @@ -88,6 +88,7 @@ public class MenuServiceImpl extends ServiceImpl implements Me if (CharSequenceUtil.isNotEmpty(menu.getId())) { } + cache.vagueDel(CachePrefix.USER_MENU.getPrefix(UserEnums.MANAGER)); return this.saveOrUpdate(menu); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 98852a25..1eda7644 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -314,7 +314,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl promotionInfo) { - JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo); + JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo.getValue()); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); searchParams.setSkuId(dataSku.getId()); searchParams.setPromotionId(promotionsObj.get("id").toString()); diff --git a/manager-api/src/main/java/cn/lili/controller/permission/MenuManagerController.java b/manager-api/src/main/java/cn/lili/controller/permission/MenuManagerController.java index 6c7c478b..73e3b1cf 100644 --- a/manager-api/src/main/java/cn/lili/controller/permission/MenuManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/permission/MenuManagerController.java @@ -53,7 +53,6 @@ public class MenuManagerController { @ApiImplicitParam(name = "id", value = "菜单ID", required = true, paramType = "path", dataType = "String") @ApiOperation(value = "编辑") @PutMapping(value = "/{id}") - @DemoSite public ResultMessage edit(@PathVariable String id, Menu menu) { menu.setId(id); diff --git a/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java b/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java index 27a1586f..ddd981cb 100755 --- a/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java +++ b/manager-api/src/main/java/cn/lili/security/ManagerAuthenticationFilter.java @@ -84,7 +84,7 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter { //如果不是超级管理员, 则鉴权 - if (!authUser.getIsSuper()) { + if (Boolean.FALSE.equals(authUser.getIsSuper())) { //获取缓存中的权限 Map> permission = (Map>) cache.get(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId()); From cf1e6fc283535bebe2bc18d840a44b914d51d63d Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 16 Jun 2022 16:40:28 +0800 Subject: [PATCH 132/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=B9=E5=8F=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=8D=E8=83=BD=E5=8F=82=E5=8A=A0=E4=BF=83?= =?UTF-8?q?=E9=94=80=E6=B4=BB=E5=8A=A8=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/enums/ResultCode.java | 1 + .../order/cart/service/CartServiceImpl.java | 2 +- .../PromotionGoodsServiceImpl.java | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index e6fa993c..e871846b 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -253,6 +253,7 @@ public enum ResultCode { */ PROMOTION_GOODS_NOT_EXIT(40000, "当前促销商品不存在!"), PROMOTION_GOODS_QUANTITY_NOT_EXIT(40020, "当前促销商品库存不足!"), + PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE(40050, "批发商品无法参加促销"), PROMOTION_SAME_ACTIVE_EXIST(40001, "活动时间内已存在同类活动,请选择关闭、删除当前时段的活动"), PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"), PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"), diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 3a45ded2..298f58c1 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -419,7 +419,7 @@ public class CartServiceImpl implements CartService { cartSkuVO.setNum(num); } - if (cartSkuVO.getNum() > 99) { + if (!GoodsSalesModeEnum.WHOLESALE.name().equals(cartSkuVO.getGoodsSku().getSalesModel()) && cartSkuVO.getNum() > 99) { cartSkuVO.setNum(99); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 1eda7644..cb3c1d37 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -5,8 +5,11 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.PromotionTypeEnum; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; @@ -313,6 +316,40 @@ public class PromotionGoodsServiceImpl extends ServiceImpl entityList) { + for (PromotionGoods promotionGoods : entityList) { + this.checkGoodsSku(promotionGoods.getSkuId()); + } + return super.saveBatch(entityList); + } + + @Override + public boolean saveOrUpdateBatch(Collection entityList) { + for (PromotionGoods promotionGoods : entityList) { + this.checkGoodsSku(promotionGoods.getSkuId()); + } + return super.saveOrUpdateBatch(entityList); + } + + /** + * 检查是否为不能参加促销活动的商品 + * + * @param skuId 商品skuId + */ + private void checkGoodsSku(String skuId) { + GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(skuId); + if (goodsSku != null && GoodsSalesModeEnum.WHOLESALE.name().equals(goodsSku.getSalesModel())) { + throw new ServiceException(ResultCode.PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE, goodsSku.getGoodsName()); + } + } + private void setGoodsPromotionInfo(GoodsSku dataSku, Map.Entry promotionInfo) { JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo.getValue()); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); From 61c77e0047304bfca31a29279e1163d399e3790d Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 16 Jun 2022 16:46:09 +0800 Subject: [PATCH 133/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E5=8F=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E4=B9=B0=E6=95=B0=E9=87=8F=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 298f58c1..f6a3fe26 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -419,7 +419,7 @@ public class CartServiceImpl implements CartService { cartSkuVO.setNum(num); } - if (!GoodsSalesModeEnum.WHOLESALE.name().equals(cartSkuVO.getGoodsSku().getSalesModel()) && cartSkuVO.getNum() > 99) { + if (cartSkuVO.getGoodsSku() != null && !GoodsSalesModeEnum.WHOLESALE.name().equals(cartSkuVO.getGoodsSku().getSalesModel()) && cartSkuVO.getNum() > 99) { cartSkuVO.setNum(99); } } From d704e2eb55bedad83e067b13263199a69facd56e Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 17 Jun 2022 11:20:22 +0800 Subject: [PATCH 134/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=97=B6no=20such=20index=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elasticsearch/BaseElasticsearchService.java | 1 - .../lili/modules/goods/service/GoodsSkuService.java | 3 ++- .../member/serviceimpl/FootprintServiceImpl.java | 7 ++----- .../payment/kit/params/dto/CashierParam.java | 5 +++-- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 13 +++++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index c1d956be..fec64277 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -85,7 +85,6 @@ public abstract class BaseElasticsearchService { */ protected void createIndexRequest(String index) { try { - deleteIndexRequest(index); CreateIndexRequest request = new CreateIndexRequest(index); //Settings for this index request.settings(Settings.builder() 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 754a5edf..8a322a79 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 @@ -143,7 +143,8 @@ public interface GoodsSkuService extends IService { /** * 分页查询商品sku信息 * - * @param searchParams 查询参数 + * @param page 分页参数 + * @param queryWrapper 查询参数 * @return 商品sku信息 */ IPage getGoodsSkuDTOByPage(Page page, Wrapper queryWrapper); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java index d5b315b8..41e4b815 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java @@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; @@ -85,15 +84,13 @@ public class FootprintServiceImpl extends ServiceImpl esGoodsIndexIPage = new Page(); + IPage esGoodsIndexIPage = new Page<>(); if (footPrintPages.getRecords() == null || footPrintPages.getRecords().isEmpty()) { return esGoodsIndexIPage; } else { List list = esGoodsSearchService.getEsGoodsBySkuIds( - footPrintPages.getRecords().stream().map(item -> { - return item.getSkuId(); - }).collect(Collectors.toList())); + footPrintPages.getRecords().stream().map(FootPrint::getSkuId).collect(Collectors.toList())); //去除为空的商品数据 list.removeIf(Objects::isNull); diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java index 4bdfcbe5..75bf50d2 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java @@ -1,5 +1,6 @@ package cn.lili.modules.payment.kit.params.dto; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.utils.StringUtils; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,7 +19,7 @@ import java.util.List; @ToString public class CashierParam { - static Long MAX_DETAIL_LENGTH = 30L; + static final Long MAX_DETAIL_LENGTH = 30L; @ApiModelProperty(value = "价格") private Double price; @@ -46,7 +47,7 @@ public class CashierParam { private Double walletValue; public String getDetail() { - if (StringUtils.isEmpty(detail)) { + if (CharSequenceUtil.isEmpty(detail)) { return "清单详细"; } return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30)); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 773e603d..ae81c85d 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -86,9 +86,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements private final Map fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class); - private final String KEY_SUCCESS = "success"; - private final String KEY_FAIL = "fail"; - private final String KEY_PROCESSED = "processed"; + private static final String KEY_SUCCESS = "success"; + private static final String KEY_FAIL = "fail"; + private static final String KEY_PROCESSED = "processed"; @Autowired private ElasticsearchProperties elasticsearchProperties; @@ -105,8 +105,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Autowired private GoodsSkuService goodsSkuService; @Autowired - private GoodsService goodsService; - @Autowired private BrandService brandService; @Autowired @@ -425,8 +423,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //如果索引存在,则删除,重新生成。 这里应该有更优解。 boolean indexExist = this.indexExist(indexName); if (regeneratorIndex || !indexExist) { + if (indexExist) { + this.deleteIndexRequest(indexName); + } //如果索引不存在,则创建索引 - createIndexRequest(indexName); + this.createIndexRequest(indexName); } Map resultMap = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); From 6d09bd498779edb02d014f376921544222d6efc6 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 17 Jun 2022 15:40:52 +0800 Subject: [PATCH 135/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/order/cart/entity/vo/CartSkuVO.java | 2 ++ .../search/serviceimpl/EsGoodsSearchServiceImpl.java | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index 30608258..1dcffeeb 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -6,6 +6,7 @@ import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.promotion.tools.PromotionTools; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; @@ -19,6 +20,7 @@ import java.util.Map; */ @Data @NoArgsConstructor +@EqualsAndHashCode(callSuper = true) public class CartSkuVO extends CartBase implements Serializable { diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index fd25cf2b..20646ebb 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -56,6 +56,9 @@ import java.util.*; @Service public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { + // 最小分词匹配数 + private static final String MINIMUM_SHOULD_MATCH = "1"; + private static final String ATTR_PATH = "attrList"; private static final String ATTR_VALUE = "attrList.value"; private static final String ATTR_NAME = "attrList.name"; @@ -540,7 +543,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()]; filterFunctionBuilders.toArray(builders); - FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders) + FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch(MINIMUM_SHOULD_MATCH), builders) .scoreMode(FunctionScoreQuery.ScoreMode.SUM) .setMinScore(2); //聚合搜索则将结果放入过滤条件 @@ -556,7 +559,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { private List buildKeywordSearch(String keyword) { List filterFunctionBuilders = new ArrayList<>(); // operator 为 AND 时 需全部分词匹配。为 OR 时 需配置 minimumShouldMatch(最小分词匹配数)不设置默认为1 - MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch("2"); + MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch(MINIMUM_SHOULD_MATCH); //分词匹配 filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, ScoreFunctionBuilders.weightFactorFunction(10))); @@ -564,11 +567,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + keyword + "*"), ScoreMode.None), ScoreFunctionBuilders.weightFactorFunction(8))); - GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(7); + GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(2); FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, skuNoScore); filterFunctionBuilders.add(skuNoBuilder); - FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(6); + FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(3); FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, buyCountScore); filterFunctionBuilders.add(buyCountBuilder); return filterFunctionBuilders; From e17e3474cac4df19b5bc727e251c7a7051154779 Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 17 Jun 2022 19:08:08 +0800 Subject: [PATCH 136/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsSearchServiceImpl.java | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 20646ebb..37cd3373 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -25,7 +25,6 @@ import org.elasticsearch.index.query.Operator; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.functionscore.FieldValueFactorFunctionBuilder; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; -import org.elasticsearch.index.query.functionscore.GaussDecayFunctionBuilder; import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; import org.elasticsearch.search.aggregations.*; import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested; @@ -57,7 +56,7 @@ import java.util.*; public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { // 最小分词匹配数 - private static final String MINIMUM_SHOULD_MATCH = "1"; + private static final String MINIMUM_SHOULD_MATCH = "2"; private static final String ATTR_PATH = "attrList"; private static final String ATTR_VALUE = "attrList.value"; @@ -367,16 +366,10 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { //关键字检索 if (CharSequenceUtil.isEmpty(searchDTO.getKeyword())) { - List filterFunctionBuilders = new ArrayList<>(); - GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(2); - FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchAllQuery(), skuNoScore); - filterFunctionBuilders.add(skuNoBuilder); - FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(3); - FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchAllQuery(), buyCountScore); - filterFunctionBuilders.add(buyCountBuilder); + List filterFunctionBuilders = this.buildFunctionSearch(); FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()]; filterFunctionBuilders.toArray(builders); - FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders) + FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(QueryBuilders.matchAllQuery(), builders) .scoreMode(FunctionScoreQuery.ScoreMode.SUM) .setMinScore(2); //聚合搜索则将结果放入过滤条件 @@ -532,18 +525,16 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { * @param keyword 关键字 */ private void keywordSearch(BoolQueryBuilder filterBuilder, String keyword) { - List filterFunctionBuilders = new ArrayList<>(); - if (keyword.contains(" ")) { - for (String s : keyword.split(" ")) { - filterFunctionBuilders.addAll(this.buildKeywordSearch(s)); - } - } else { - filterFunctionBuilders = this.buildKeywordSearch(keyword); - } + + List filterFunctionBuilders = this.buildFunctionSearch(); + + //分词匹配 + // operator 为 AND 时 需全部分词匹配。为 OR 时 需配置 minimumShouldMatch(最小分词匹配数)不设置默认为1 + MatchQueryBuilder goodsNameMatchQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch(MINIMUM_SHOULD_MATCH); FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()]; filterFunctionBuilders.toArray(builders); - FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch(MINIMUM_SHOULD_MATCH), builders) + FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(goodsNameMatchQuery, builders) .scoreMode(FunctionScoreQuery.ScoreMode.SUM) .setMinScore(2); //聚合搜索则将结果放入过滤条件 @@ -553,26 +544,20 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { /** * 构造关键字查询 * - * @param keyword 关键字 * @return 构造查询的集合 */ - private List buildKeywordSearch(String keyword) { + private List buildFunctionSearch() { List filterFunctionBuilders = new ArrayList<>(); - // operator 为 AND 时 需全部分词匹配。为 OR 时 需配置 minimumShouldMatch(最小分词匹配数)不设置默认为1 - MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch(MINIMUM_SHOULD_MATCH); - //分词匹配 - filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, - ScoreFunctionBuilders.weightFactorFunction(10))); - //属性匹配 - filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + keyword + "*"), ScoreMode.None), - ScoreFunctionBuilders.weightFactorFunction(8))); - GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 50, 10, 50).setWeight(2); - FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, skuNoScore); +// GaussDecayFunctionBuilder skuNoScore = ScoreFunctionBuilders.gaussDecayFunction("skuSource", 100, 10).setWeight(2); +// FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(skuNoScore); +// filterFunctionBuilders.add(skuNoBuilder); + FieldValueFactorFunctionBuilder skuNoScore = ScoreFunctionBuilders.fieldValueFactorFunction("skuSource").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(3); + FunctionScoreQueryBuilder.FilterFunctionBuilder skuNoBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(skuNoScore); filterFunctionBuilders.add(skuNoBuilder); FieldValueFactorFunctionBuilder buyCountScore = ScoreFunctionBuilders.fieldValueFactorFunction("buyCount").modifier(FieldValueFactorFunction.Modifier.LOG1P).setWeight(3); - FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, buyCountScore); + FunctionScoreQueryBuilder.FilterFunctionBuilder buyCountBuilder = new FunctionScoreQueryBuilder.FilterFunctionBuilder(buyCountScore); filterFunctionBuilders.add(buyCountBuilder); return filterFunctionBuilders; } From 8894e5482fb4af41b75ceb78e5b28a5c171414fb Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 20 Jun 2022 11:06:20 +0800 Subject: [PATCH 137/185] =?UTF-8?q?minio=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=94=99=E8=AF=AFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java index 67471641..d7f992d7 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java @@ -99,7 +99,7 @@ public class MinioFilePlugin implements FilePlugin { } MinioClient ossClient = getOssClient(); List objectList = key.stream().map(DeleteObject::new).collect(Collectors.toList()); - ossClient.removeObjects(RemoveObjectsArgs.builder().objects(objectList).build()); + ossClient.removeObjects(RemoveObjectsArgs.builder().objects(objectList).bucket(ossSetting.getM_bucketName()).build()); } From ea1b91af2a95754b3f596c03c2db99e46328301d Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 20 Jun 2022 12:01:32 +0800 Subject: [PATCH 138/185] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=84=8F=E4=B9=89=E4=B8=8D=E6=98=8E=E7=A1=AE=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E8=A1=A5=E5=85=85=E5=A4=87=E6=B3=A8=E3=80=82=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E4=B8=80=E8=A1=8C=E6=97=A0=E6=95=88=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/event/impl/PaymentExecute.java | 1 - .../lili/modules/payment/serviceimpl/PaymentServiceImpl.java | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java b/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java index 058ff793..deb3fa65 100644 --- a/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/PaymentExecute.java @@ -57,7 +57,6 @@ public class PaymentExecute implements OrderStatusChangeEvent { .orderSn(order.getSn()) .paymentReceivableNo(order.getReceivableNo()) .outOrderNo("AF" + SnowFlake.getIdStr()) - .outOrderNo("AF" + SnowFlake.getIdStr()) .refundReason("订单取消") .build(); payment.refund(refundLog); diff --git a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java index 06b6d70a..97b69d8b 100644 --- a/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/payment/serviceimpl/PaymentServiceImpl.java @@ -28,9 +28,12 @@ public class PaymentServiceImpl implements PaymentService { @Override public void success(PaymentSuccessParams paymentSuccessParams) { + //支付状态 boolean paymentResult = cashierSupport.paymentResult(paymentSuccessParams.getPayParam()); + + //已支付则返回 if (paymentResult) { - log.warn("订单支付状态后,调用支付成功接口,流水号:{}", paymentSuccessParams.getReceivableNo()); + log.warn("收银台重复收款,流水号:{}", paymentSuccessParams.getReceivableNo()); return; } From cb52fca2a4e807e06d1b28859049e0b3d8e765e6 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 14:44:58 +0800 Subject: [PATCH 139/185] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=82=E9=BB=98=E8=AE=A4=E6=8B=BC=E5=9B=A2?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?24=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/cache/config/redis/RedisConfig.java | 17 ++++++-------- .../serviceimpl/ConnectServiceImpl.java | 23 +++++++++++-------- .../entity/dto/ManagerMemberEditDTO.java | 3 ++- .../order/serviceimpl/OrderServiceImpl.java | 4 ++-- .../serviceimpl/PintuanServiceImpl.java | 2 +- .../promotion/tools/PromotionTools.java | 8 ++----- .../search/entity/dos/CustomWords.java | 2 ++ .../search/service/EsGoodsSearchService.java | 1 - .../serviceimpl/EsGoodsSearchServiceImpl.java | 5 ++-- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java index 0551f26b..8af75596 100644 --- a/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java +++ b/framework/src/main/java/cn/lili/cache/config/redis/RedisConfig.java @@ -11,7 +11,6 @@ import org.redisson.config.ClusterServersConfig; import org.redisson.config.Config; import org.redisson.config.SentinelServersConfig; import org.redisson.config.SingleServerConfig; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -56,13 +55,11 @@ import java.util.Map; public class RedisConfig extends CachingConfigurerSupport { + private static final String REDIS_PREFIX = "redis://"; + @Value("${lili.cache.timeout:7200}") private Integer timeout; - @Autowired - private RedisProperties redisProperties; - - /** * 当有多个管理器的时候,必须使用该注解在一个管理器上注释:表示该管理器为默认的管理器 * @@ -101,7 +98,7 @@ public class RedisConfig extends CachingConfigurerSupport { public RedisTemplate redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { RedisTemplate template = new RedisTemplate<>(); //使用fastjson序列化 - FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class); + FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); //value值的序列化采用fastJsonRedisSerializer template.setValueSerializer(fastJsonRedisSerializer); template.setHashValueSerializer(fastJsonRedisSerializer); @@ -113,7 +110,7 @@ public class RedisConfig extends CachingConfigurerSupport { } @Bean(destroyMethod = "shutdown") - public RedissonClient redisson() { + public RedissonClient redisson(RedisProperties redisProperties) { Config config = new Config(); if (redisProperties.getSentinel() != null && !redisProperties.getSentinel().getNodes().isEmpty()) { // 哨兵模式 @@ -121,7 +118,7 @@ public class RedisConfig extends CachingConfigurerSupport { sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster()); List sentinelAddress = new ArrayList<>(); for (String node : redisProperties.getCluster().getNodes()) { - sentinelAddress.add("redis://" + node); + sentinelAddress.add(REDIS_PREFIX + node); } sentinelServersConfig.setSentinelAddresses(sentinelAddress); if (CharSequenceUtil.isNotEmpty(redisProperties.getSentinel().getPassword())) { @@ -132,7 +129,7 @@ public class RedisConfig extends CachingConfigurerSupport { ClusterServersConfig clusterServersConfig = config.useClusterServers(); List clusterNodes = new ArrayList<>(); for (String node : redisProperties.getCluster().getNodes()) { - clusterNodes.add("redis://" + node); + clusterNodes.add(REDIS_PREFIX + node); } clusterServersConfig.setNodeAddresses(clusterNodes); if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) { @@ -140,7 +137,7 @@ public class RedisConfig extends CachingConfigurerSupport { } } else { SingleServerConfig singleServerConfig = config.useSingleServer(); - singleServerConfig.setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort()); + singleServerConfig.setAddress(REDIS_PREFIX + redisProperties.getHost() + ":" + redisProperties.getPort()); if (CharSequenceUtil.isNotEmpty(redisProperties.getPassword())) { singleServerConfig.setPassword(redisProperties.getPassword()); } diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index 1ea33779..e910a6c7 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -89,6 +89,7 @@ public class ConnectServiceImpl extends ServiceImpl impl } return memberTokenGenerate.createToken(member, longTerm); } catch (NoPermissionException e) { + log.error("联合登陆失败:", e); throw e; } } @@ -121,7 +122,7 @@ public class ConnectServiceImpl extends ServiceImpl impl @Override public void bind(String unionId, String type) { - AuthUser authUser = UserContext.getCurrentUser(); + AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser()); Connect connect = new Connect(authUser.getId(), unionId, type); this.save(connect); } @@ -160,6 +161,7 @@ public class ConnectServiceImpl extends ServiceImpl impl @Override + @Transactional public Token miniProgramAutoLogin(WechatMPLoginParams params) { Object cacheData = cache.get(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid()); @@ -186,8 +188,8 @@ public class ConnectServiceImpl extends ServiceImpl impl /** * 通过微信返回等code 获取openid 等信息 * - * @param code - * @return + * @param code 微信code + * @return 微信返回的信息 */ public JSONObject getConnect(String code) { WechatConnectSettingItem setting = getWechatMPSetting(); @@ -208,11 +210,12 @@ public class ConnectServiceImpl extends ServiceImpl impl * @param params 微信小程序自动登录参数 * @param openId 微信openid * @param unionId 微信unionid - * @return + * @return token */ @Transactional(rollbackFor = Exception.class) public Token phoneMpBindAndLogin(String sessionKey, WechatMPLoginParams params, String openId, String unionId) { - String encryptedData = params.getEncryptedData(), iv = params.getIv(); + String encryptedData = params.getEncryptedData(); + String iv = params.getIv(); JSONObject userInfo = this.getUserInfo(encryptedData, sessionKey, iv); log.info("联合登陆返回:{}", userInfo.toString()); String phone = (String) userInfo.get("purePhoneNumber"); @@ -259,9 +262,9 @@ public class ConnectServiceImpl extends ServiceImpl impl * 这样,微信小程序注册之后,其他app 公众号页面,都可以实现绑定自动登录功能 *

* - * @param openId - * @param unionId - * @param member + * @param openId 微信openid + * @param unionId 微信unionid + * @param member 会员 */ private void bindMpMember(String openId, String unionId, Member member) { @@ -272,7 +275,7 @@ public class ConnectServiceImpl extends ServiceImpl impl lambdaQueryWrapper.eq(Connect::getUnionId, unionId); lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT.name()); List connects = this.list(lambdaQueryWrapper); - if (connects.size() == 0) { + if (connects.isEmpty()) { Connect connect = new Connect(); connect.setUnionId(unionId); connect.setUserId(member.getId()); @@ -281,7 +284,7 @@ public class ConnectServiceImpl extends ServiceImpl impl } }//如果openid 不为空 则为账号绑定openid if (CharSequenceUtil.isNotEmpty(openId)) { - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(Connect::getUnionId, openId); lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name()); List connects = this.list(lambdaQueryWrapper); diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java index 8818ad4a..c61792aa 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java @@ -24,6 +24,7 @@ public class ManagerMemberEditDTO { @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) @NotNull(message = "会员用户名不能为空") private String id; + @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) @NotNull(message = "会员用户名不能为空") private String username; @@ -48,7 +49,7 @@ public class ManagerMemberEditDTO { private Integer sex; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @DateTimeFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "会员生日") private Date birthday; diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index b6211c3c..ca00f595 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -811,10 +811,10 @@ public class OrderServiceImpl extends ServiceImpl implements List list = this.getPintuanOrder(pintuanId, parentOrderSn); int count = list.size(); if (count == 1) { - //如果为开团订单,则发布一个一小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下) + //如果为开团订单,则发布一个24小时的延时任务,时间到达后,如果未成团则自动结束(未开启虚拟成团的情况下) PintuanOrderMessage pintuanOrderMessage = new PintuanOrderMessage(); //开团结束时间 - long startTime = DateUtil.offsetMinute(new Date(), 2).getTime(); + long startTime = DateUtil.offsetHour(new Date(), 24).getTime(); pintuanOrderMessage.setOrderSn(parentOrderSn); pintuanOrderMessage.setPintuanId(pintuanId); TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR, 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 4edd344a..6750104b 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 @@ -299,7 +299,7 @@ public class PintuanServiceImpl extends AbstractPromotionsServiceImpl Date: Wed, 22 Jun 2022 15:05:25 +0800 Subject: [PATCH 140/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=9C=89=E5=8F=82=E5=8A=A0=E5=95=86=E5=93=81=E7=9A=84=E4=BF=83?= =?UTF-8?q?=E9=94=80=E6=B4=BB=E5=8A=A8=E7=9A=84=E6=97=B6=E9=97=B4=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=8E=9F=E5=8F=82=E4=B8=8E=E6=B4=BB=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=9A=84=E6=97=B6=E9=97=B4=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/promotion/tools/PromotionTools.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 02eb5703..1eb51582 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 @@ -133,6 +133,13 @@ public class PromotionTools { promotionGoods.setStoreName(promotion.getStoreName()); } promotionGoods.setTitle(promotion.getPromotionName()); + // 如果是秒杀活动保留原时间 + if (promotionGoods.getStartTime() == null || !PromotionTypeEnum.SECKILL.equals(promotionTypeEnum)) { + promotionGoods.setStartTime(promotion.getStartTime()); + } + if (promotionGoods.getStartTime() == null || !PromotionTypeEnum.SECKILL.equals(promotionTypeEnum)) { + promotionGoods.setEndTime(promotion.getEndTime()); + } promotionGoods.setStartTime(promotion.getStartTime()); promotionGoods.setEndTime(promotion.getEndTime()); promotionGoods.setPromotionType(promotionTypeEnum.name()); From 96697e11fd848334f206ba72872172252b4179bc Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 17:31:26 +0800 Subject: [PATCH 141/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=8F=91=E9=80=81mq?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E4=B8=BA=E8=AE=A2=E5=8D=95=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E5=8F=91=E9=80=81mq=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=8F=90=E4=BA=A4=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/TransactionCommitSendMQEvent.java | 32 +++++++++++++++ .../TransactionCommitSendMQListener.java | 38 +++++++++++++++++ .../event/GeneratorEsGoodsIndexEvent.java | 24 ----------- .../GeneratorEsGoodsIndexListener.java | 37 ----------------- .../serviceimpl/GoodsSkuServiceImpl.java | 8 ++-- .../order/serviceimpl/OrderServiceImpl.java | 17 +++++--- .../UpdateEsGoodsIndexPromotionsEvent.java | 19 --------- .../UpdateEsGoodsIndexPromotionsListener.java | 41 ------------------- .../AbstractPromotionsServiceImpl.java | 17 ++------ 9 files changed, 90 insertions(+), 143 deletions(-) create mode 100644 framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java create mode 100644 framework/src/main/java/cn/lili/common/listener/TransactionCommitSendMQListener.java delete mode 100644 framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java delete mode 100644 framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java delete mode 100644 framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java delete mode 100644 framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java diff --git a/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java b/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java new file mode 100644 index 00000000..9f16c1e4 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java @@ -0,0 +1,32 @@ +package cn.lili.common.event; + +import lombok.Getter; +import org.springframework.context.ApplicationEvent; + +/** + * 事务提交后发生mq事件 + * + * @author paulG + * @since 2022/1/19 + **/ +public class TransactionCommitSendMQEvent extends ApplicationEvent { + + private static final long serialVersionUID = 5885956821347953071L; + + + @Getter + private final String topic; + + @Getter + private final String tag; + + @Getter + private final String message; + + public TransactionCommitSendMQEvent(Object source, String topic, String tag, String message) { + super(source); + this.topic = topic; + this.tag = tag; + this.message = message; + } +} diff --git a/framework/src/main/java/cn/lili/common/listener/TransactionCommitSendMQListener.java b/framework/src/main/java/cn/lili/common/listener/TransactionCommitSendMQListener.java new file mode 100644 index 00000000..c709df75 --- /dev/null +++ b/framework/src/main/java/cn/lili/common/listener/TransactionCommitSendMQListener.java @@ -0,0 +1,38 @@ +package cn.lili.common.listener; + +import cn.lili.common.event.TransactionCommitSendMQEvent; +import cn.lili.rocketmq.RocketmqSendCallbackBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +/** + * 事务提交监听器 + * + * @author paulG + * @since 2022/1/19 + **/ +@Component +@Slf4j +public class TransactionCommitSendMQListener { + + /** + * rocketMq + */ + @Autowired + private RocketMQTemplate rocketMQTemplate; + + + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + public void send(TransactionCommitSendMQEvent event) { + log.info("事务提交,发送mq信息!{}", event); + String destination = event.getTopic() + ":" + event.getTag(); + //发送订单变更mq消息 + rocketMQTemplate.asyncSend(destination, event.getMessage(), RocketmqSendCallbackBuilder.commonCallback()); + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java deleted file mode 100644 index 4088b5aa..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.lili.modules.goods.event; - -import lombok.Data; -import org.springframework.context.ApplicationEvent; - -/** - * @author paulG - * @since 2022/1/19 - **/ -@Data -public class GeneratorEsGoodsIndexEvent extends ApplicationEvent { - - private static final long serialVersionUID = -6206752641309458207L; - - private String id; - - private String tag; - - public GeneratorEsGoodsIndexEvent(Object source, String tag, String id) { - super(source); - this.tag = tag; - this.id = id; - } -} diff --git a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java deleted file mode 100644 index 175e0b13..00000000 --- a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.lili.modules.goods.listener; - -import cn.lili.common.properties.RocketmqCustomProperties; -import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; -import org.apache.rocketmq.spring.core.RocketMQTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; - -/** - * @author paulG - * @since 2022/1/19 - **/ -@Component -public class GeneratorEsGoodsIndexListener { - - /** - * rocketMq - */ - @Autowired - private RocketMQTemplate rocketMQTemplate; - /** - * rocketMq配置 - */ - @Autowired - private RocketmqCustomProperties rocketmqCustomProperties; - - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) - public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) { - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + esGoodsIndexEvent.getTag(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getId(), RocketmqSendCallbackBuilder.commonCallback()); - } - -} 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 c4d89278..94bec3dc 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 @@ -9,6 +9,7 @@ import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; +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; @@ -26,7 +27,6 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.entity.vos.SpecValueVO; -import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent; import cn.lili.modules.goods.mapper.GoodsSkuMapper; import cn.lili.modules.goods.service.*; import cn.lili.modules.goods.sku.GoodsSkuBuilder; @@ -362,10 +362,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl i boolean update = this.update(updateWrapper); if (Boolean.TRUE.equals(update)) { if (GoodsStatusEnum.UPPER.name().equals(marketEnable)) { - applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成店铺商品", GoodsTagsEnum.GENERATOR_STORE_GOODS_INDEX.name(), storeId)); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("生成店铺商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GENERATOR_STORE_GOODS_INDEX.name(), storeId)); } else if (GoodsStatusEnum.DOWN.name().equals(marketEnable)) { cache.vagueDel(CachePrefix.GOODS_SKU.getPrefix()); - applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("删除店铺商品", GoodsTagsEnum.STORE_GOODS_DELETE.name(), storeId)); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("删除店铺商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.STORE_GOODS_DELETE.name(), storeId)); } } } @@ -589,7 +589,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { return; } - applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品", GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId())); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("生成商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId())); } @Override diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index ca00f595..fab02420 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -10,6 +10,7 @@ import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.ResultCode; +import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.OperationalJudgment; @@ -66,6 +67,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.util.CellRangeAddressList; 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; import org.springframework.web.multipart.MultipartFile; @@ -144,6 +146,10 @@ public class OrderServiceImpl extends ServiceImpl implements @Autowired private TradeService tradeService; + + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + @Override @Transactional(rollbackFor = Exception.class) public void intoDB(TradeDTO tradeDTO) { @@ -445,12 +451,13 @@ public class OrderServiceImpl extends ServiceImpl implements //获取订单信息 Order order = this.getBySn(orderSn); //获取踪迹信息 - String str=order.getConsigneeMobile(); - return logisticsService.getLogistic(order.getLogisticsCode(), order.getLogisticsNo(), str.substring(str.length()-4)); + String str = order.getConsigneeMobile(); + return logisticsService.getLogistic(order.getLogisticsCode(), order.getLogisticsNo(), str.substring(str.length() - 4)); } @Override @OrderLogPoint(description = "'订单['+#orderSn+']核销,核销码['+#verificationCode+']'", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public Order take(String orderSn, String verificationCode) { //获取订单信息 @@ -534,10 +541,9 @@ public class OrderServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void sendUpdateStatusMessage(OrderMessage orderMessage) { - String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.STATUS_CHANGE.name(); - //发送订单变更mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(orderMessage), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("发送订单变更mq消息", rocketmqCustomProperties.getOrderTopic(), OrderTagsEnum.STATUS_CHANGE.name(), JSONUtil.toJsonStr(orderMessage))); } @Override @@ -621,6 +627,7 @@ public class OrderServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void batchDeliver(MultipartFile files) { InputStream inputStream; diff --git a/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java b/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java deleted file mode 100644 index 94442bf7..00000000 --- a/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.lili.modules.promotion.event; - -import lombok.Data; -import org.springframework.context.ApplicationEvent; - -/** - * @author paulG - * @since 2022/1/19 - **/ -@Data -public class UpdateEsGoodsIndexPromotionsEvent extends ApplicationEvent { - - private String promotionsJsonStr; - - public UpdateEsGoodsIndexPromotionsEvent(Object source, String promotionsJsonStr) { - super(source); - this.promotionsJsonStr = promotionsJsonStr; - } -} diff --git a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java deleted file mode 100644 index 00417c5f..00000000 --- a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.lili.modules.promotion.listener; - -import cn.lili.common.properties.RocketmqCustomProperties; -import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; -import cn.lili.rocketmq.tags.GoodsTagsEnum; -import org.apache.rocketmq.spring.core.RocketMQTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; - -/** - * @author paulG - * @since 2022/1/19 - **/ -@Component -public class UpdateEsGoodsIndexPromotionsListener { - - /** - * rocketMq - */ - @Autowired - private RocketMQTemplate rocketMQTemplate; - /** - * rocketMq配置 - */ - @Autowired - private RocketmqCustomProperties rocketmqCustomProperties; - - - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) - public void updateEsGoodsIndexPromotions(UpdateEsGoodsIndexPromotionsEvent event) { - //更新商品促销消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, event.getPromotionsJsonStr(), RocketmqSendCallbackBuilder.commonCallback()); - } - - -} diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index c46eb258..05682167 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.map.MapBuilder; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; +import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.vo.PageVO; @@ -11,19 +12,16 @@ import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; -import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent; import cn.lili.modules.promotion.service.AbstractPromotionsService; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.tools.PromotionTools; import cn.lili.mybatis.util.PageUtil; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; 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.transaction.annotation.Transactional; @@ -48,12 +46,6 @@ public abstract class AbstractPromotionsServiceImpl, T e @Autowired private RocketmqCustomProperties rocketmqCustomProperties; - /** - * rocketMq - */ - @Autowired - private RocketMQTemplate rocketMQTemplate; - @Autowired private ApplicationEventPublisher applicationEventPublisher; @@ -253,13 +245,12 @@ public abstract class AbstractPromotionsServiceImpl, T e * @param promotions 促销实体 */ @Override + @Transactional(rollbackFor = {Exception.class}) public void updateEsGoodsIndex(T promotions) { if (promotions.getStartTime() == null && promotions.getEndTime() == null) { Map build = MapBuilder.create().put("promotionKey", this.getPromotionType() + "-" + promotions.getId()).put("scopeId", promotions.getScopeId()).build(); //删除商品促销消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(build), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("删除商品促销事件", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.DELETE_GOODS_INDEX_PROMOTIONS.name(), JSONUtil.toJsonStr(build))); } else { String esPromotionKey = this.getPromotionType().name() + "-" + promotions.getId(); @@ -270,7 +261,7 @@ public abstract class AbstractPromotionsServiceImpl, T e map.put("promotionsType", promotions.getClass().getName()); // 促销实体 map.put("promotions", promotions); - applicationEventPublisher.publishEvent(new UpdateEsGoodsIndexPromotionsEvent("更新商品索引促销事件", JSONUtil.toJsonStr(map))); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品索引促销事件", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(), JSONUtil.toJsonStr(map))); } } From ad1f5a297e8af308dbb532945dd996a57d883a9a Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 17:32:19 +0800 Subject: [PATCH 142/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E9=92=B1=E5=8C=85=E5=8F=AF=E8=83=BD=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/wallet/serviceimpl/MemberWalletServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java index d411481d..be6f99ee 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java @@ -84,7 +84,7 @@ public class MemberWalletServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("member_id", memberId); //执行查询 - MemberWallet memberWallet = this.baseMapper.selectOne(queryWrapper); + MemberWallet memberWallet = this.getOne(queryWrapper, false); //如果没有钱包,则创建钱包 if (memberWallet == null) { memberWallet = this.save(memberId, memberService.getById(memberId).getUsername()); @@ -186,7 +186,7 @@ public class MemberWalletServiceImpl extends ServiceImpl().eq("member_id", memberId)); + MemberWallet memberWallet = this.getOne(new QueryWrapper().eq("member_id", memberId), false); //如果会员预存款信息不存在则同步重新建立预存款信息 if (memberWallet == null) { Member member = memberService.getById(memberId); From f01236cc96651c47096930e734e00febd4ba1915 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 17:44:40 +0800 Subject: [PATCH 143/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=8F=91=E9=80=81mq?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E4=B8=BA=E8=AE=A2=E5=8D=95=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E5=8F=91=E9=80=81mq=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=8F=90=E4=BA=A4=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/serviceimpl/OrderServiceImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index fab02420..76491576 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -502,7 +502,8 @@ public class OrderServiceImpl extends ServiceImpl implements * @param order 订单 * @param orderSn 订单编号 */ - private void complete(Order order, String orderSn) {//修改订单状态为完成 + @Transactional(rollbackFor = Exception.class) + public void complete(Order order, String orderSn) {//修改订单状态为完成 this.updateStatus(orderSn, OrderStatusEnum.COMPLETED); //修改订单货物可以进行评价 @@ -784,9 +785,10 @@ public class OrderServiceImpl extends ServiceImpl implements /** * 订单状态变更消息 * - * @param order + * @param order 订单信息 */ - private void orderStatusMessage(Order order) { + @Transactional(rollbackFor = Exception.class) + public void orderStatusMessage(Order order) { OrderMessage orderMessage = new OrderMessage(); orderMessage.setOrderSn(order.getSn()); orderMessage.setNewStatus(OrderStatusEnum.valueOf(order.getOrderStatus())); @@ -913,7 +915,8 @@ public class OrderServiceImpl extends ServiceImpl implements * * @param orderSn 订单编号 */ - private void normalOrderConfirm(String orderSn) { + @Transactional(rollbackFor = Exception.class) + public void normalOrderConfirm(String orderSn) { //修改订单 this.update(new LambdaUpdateWrapper() .eq(Order::getSn, orderSn) @@ -932,7 +935,8 @@ public class OrderServiceImpl extends ServiceImpl implements * * @param orderSn 订单编号 */ - private void virtualOrderConfirm(String orderSn) { + @Transactional(rollbackFor = Exception.class) + public void virtualOrderConfirm(String orderSn) { //修改订单 this.update(new LambdaUpdateWrapper() .eq(Order::getSn, orderSn) From 1a221eefe340395758467bd641b6359c7c9cd94c Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 18:42:04 +0800 Subject: [PATCH 144/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=EF=BC=8C=E5=A6=82=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E5=BD=93=E5=89=8D=E5=95=86=E5=93=81=E5=88=99?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/listener/GoodsMessageListener.java | 9 ++------- .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index f8f8a35e..82df940e 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -32,7 +32,6 @@ import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; -import cn.lili.modules.store.service.StoreService; import cn.lili.rocketmq.tags.GoodsTagsEnum; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.common.message.MessageExt; @@ -204,13 +203,8 @@ public class GoodsMessageListener implements RocketMQListener { try { String goodsIdsJsonStr = new String(messageExt.getBody()); for (String goodsId : JSONUtil.toList(goodsIdsJsonStr, String.class)) { - Goods goodsById = this.goodsService.getById(goodsId); - if (goodsById != null) { - this.deleteGoods(goodsById); - goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); - } + goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); } - } catch (Exception e) { log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } @@ -451,6 +445,7 @@ public class GoodsMessageListener implements RocketMQListener { distributionGoodsService.removeById(distributionGoods.getId()); } } + /** * 商品购买完成 * 1.更新商品购买数量 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 94bec3dc..65baa2b9 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 @@ -250,11 +250,16 @@ public class GoodsSkuServiceImpl extends ServiceImpl i GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); //如果使用商品ID无法查询SKU则返回错误 if (goodsVO == null || goodsSku == null) { + //发送mq消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsId)), RocketmqSendCallbackBuilder.commonCallback()); throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } //商品下架||商品未审核通过||商品删除,则提示:商品已下架 if (GoodsStatusEnum.DOWN.name().equals(goodsVO.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goodsVO.getAuthFlag()) || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsId)), RocketmqSendCallbackBuilder.commonCallback()); throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } From 3c2e73b5f5901e30ff8cc9bd86f58d10676b23f5 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 23 Jun 2022 09:11:33 +0800 Subject: [PATCH 145/185] =?UTF-8?q?=E8=B0=83=E6=95=B4es=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index fd25cf2b..b3cff51f 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -83,7 +83,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { } NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo); NativeSearchQuery searchQuery = searchQueryBuilder.build(); - log.info("searchGoods DSL:{}", searchQuery.getQuery()); + log.debug("searchGoods DSL:{}", searchQuery.getQuery()); SearchHits search = restTemplate.search(searchQuery, EsGoodsIndex.class); return SearchHitSupport.searchPageFor(search, searchQuery.getPageable()); } @@ -109,7 +109,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { NativeSearchQuery searchQuery = builder.build(); SearchHits search = restTemplate.search(searchQuery, EsGoodsIndex.class); - log.info("getSelector DSL:{}", searchQuery.getQuery()); + log.debug("getSelector DSL:{}", searchQuery.getQuery()); Map aggregationMap = Objects.requireNonNull(search.getAggregations()).getAsMap(); return convertToEsGoodsRelatedInfo(aggregationMap, goodsSearch); } From b6c70d1530af14ca3d08160feb1f2c381d13f010 Mon Sep 17 00:00:00 2001 From: Chopper711 <1814994716@qq.com> Date: Thu, 23 Jun 2022 01:46:05 +0000 Subject: [PATCH 146/185] update README.md. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3ea8ed39..17a91599 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ ##### 交流 qq 1群 961316482(已满) Lilishop交流群点击快捷加群 -##### 交流 qq 2群 875294241(最后63名额) +##### 交流 qq 2群 875294241(已满) Lilishop交流群2群点击快捷加群 -##### 交流 qq 3群 263785057(2022-06-13建立) +##### 交流 qq 3群 263785057 Lilishop交流群3群点击快捷加群 @@ -167,5 +167,5 @@ PS:手机验证码为 ‘111111’ ### 交流群 ##### 官方qq 1群 961316482(已满) -##### 官方qq 2群 875294241 - +##### 官方qq 2群 875294241(已满) +##### 官网qq 3群 263785057 From b3a0a402d79f8c84587dddc320bb81e4471301ea Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 23 Jun 2022 09:55:52 +0800 Subject: [PATCH 147/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=8F=91=E9=80=81mq?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E4=B8=BA=E8=AE=A2=E5=8D=95=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E5=8F=91=E9=80=81mq=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=8F=90=E4=BA=A4=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 65baa2b9..5ab87344 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 @@ -589,6 +589,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goods 商品信息 */ @Override + @Transactional(rollbackFor = Exception.class) public void generateEs(Goods goods) { // 不生成没有审核通过且没有上架的商品 if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { From 170aa0194603b8e723febbd128e8e41101ce0a10 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 27 Jun 2022 17:57:48 +0800 Subject: [PATCH 148/185] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E4=BC=9A=E5=AF=BC=E8=87=B4=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/cart/service/CartServiceImpl.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index f6a3fe26..51007a39 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -199,9 +199,9 @@ public class CartServiceImpl implements CartService { this.checkGoodsSaleModel(dataSku, tradeDTO.getSkuList()); tradeDTO.setCartTypeEnum(cartTypeEnum); - //如购物车发生更改,则重置优惠券 - tradeDTO.setStoreCoupons(null); - tradeDTO.setPlatformCoupon(null); + + remoteCoupon(tradeDTO); + this.resetTradeDTO(tradeDTO); } catch (ServiceException serviceException) { throw serviceException; @@ -245,6 +245,9 @@ public class CartServiceImpl implements CartService { @Override public void checked(String skuId, boolean checked) { TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); + + remoteCoupon(tradeDTO); + List cartSkuVOS = tradeDTO.getSkuList(); for (CartSkuVO cartSkuVO : cartSkuVOS) { if (cartSkuVO.getGoodsSku().getId().equals(skuId)) { @@ -257,6 +260,9 @@ public class CartServiceImpl implements CartService { @Override public void checkedStore(String storeId, boolean checked) { TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); + + remoteCoupon(tradeDTO); + List cartSkuVOS = tradeDTO.getSkuList(); for (CartSkuVO cartSkuVO : cartSkuVOS) { if (cartSkuVO.getStoreId().equals(storeId)) { @@ -269,6 +275,9 @@ public class CartServiceImpl implements CartService { @Override public void checkedAll(boolean checked) { TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); + + remoteCoupon(tradeDTO); + List cartSkuVOS = tradeDTO.getSkuList(); for (CartSkuVO cartSkuVO : cartSkuVOS) { cartSkuVO.setChecked(checked); @@ -276,6 +285,15 @@ public class CartServiceImpl implements CartService { cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); } + /** + * 当购物车商品发生变更时,取消已选择当优惠券 + * @param tradeDTO + */ + private void remoteCoupon(TradeDTO tradeDTO){ + tradeDTO.setPlatformCoupon(null); + tradeDTO.setStoreCoupons(new HashMap<>()); + } + @Override @Transactional(rollbackFor = Exception.class) public void delete(String[] skuIds) { From 60a210a45fc833b4b1c76aec2bf0c83ff0ec3a91 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 29 Jun 2022 09:33:02 +0800 Subject: [PATCH 149/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=B0=86?= =?UTF-8?q?=E5=88=86=E8=AF=8D=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?=E5=88=86=E8=AF=8D=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/entity/vo/CustomWordsVO.java | 6 ++ .../serviceimpl/CustomWordsServiceImpl.java | 2 +- .../serviceimpl/EsGoodsIndexServiceImpl.java | 90 +++++++++++-------- 3 files changed, 59 insertions(+), 39 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/entity/vo/CustomWordsVO.java b/framework/src/main/java/cn/lili/modules/search/entity/vo/CustomWordsVO.java index d6596b37..75258eba 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/vo/CustomWordsVO.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/vo/CustomWordsVO.java @@ -3,6 +3,7 @@ package cn.lili.modules.search.entity.vo; import cn.lili.modules.search.entity.dos.CustomWords; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** * @author paulG @@ -10,8 +11,13 @@ import lombok.EqualsAndHashCode; **/ @EqualsAndHashCode(callSuper = true) @Data +@NoArgsConstructor public class CustomWordsVO extends CustomWords { private static final long serialVersionUID = 143299060233417009L; + public CustomWordsVO(String name) { + this.setName(name); + this.setDisabled(1); + } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java index d366e4c8..1454c3b0 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java @@ -68,7 +68,7 @@ public class CustomWordsServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper().eq(CustomWords::getName, customWordsVO.getName()); CustomWords one = this.getOne(queryWrapper, false); if (one != null && one.getDisabled().equals(1)) { - throw new ServiceException(ResultCode.CUSTOM_WORDS_EXIST_ERROR); + return false; } else if (one != null && !one.getDisabled().equals(1)) { this.remove(queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index ae81c85d..bc348f55 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -6,7 +6,6 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ReflectUtil; -import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; @@ -19,26 +18,33 @@ import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.elasticsearch.BaseElasticsearchService; import cn.lili.elasticsearch.EsSuffix; import cn.lili.elasticsearch.config.ElasticsearchProperties; -import cn.lili.modules.goods.entity.dos.*; +import cn.lili.modules.goods.entity.dos.Brand; +import cn.lili.modules.goods.entity.dos.Category; +import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.StoreGoodsLabel; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; -import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum; -import cn.lili.modules.goods.service.*; +import cn.lili.modules.goods.service.BrandService; +import cn.lili.modules.goods.service.CategoryService; +import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.modules.goods.service.StoreGoodsLabelService; import cn.lili.modules.promotion.entity.dos.BasePromotions; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.promotion.tools.PromotionTools; +import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; +import cn.lili.modules.search.entity.vo.CustomWordsVO; import cn.lili.modules.search.repository.EsGoodsIndexRepository; +import cn.lili.modules.search.service.CustomWordsService; import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -49,6 +55,8 @@ import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.indices.AnalyzeRequest; +import org.elasticsearch.client.indices.AnalyzeResponse; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.TermQueryBuilder; @@ -82,14 +90,10 @@ import java.util.stream.Collectors; public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements EsGoodsIndexService { private static final String IGNORE_FIELD = "serialVersionUID,promotionMap,id,goodsId"; - - private final Map fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class); - - private static final String KEY_SUCCESS = "success"; private static final String KEY_FAIL = "fail"; private static final String KEY_PROCESSED = "processed"; - + private final Map fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class); @Autowired private ElasticsearchProperties elasticsearchProperties; @Autowired @@ -97,10 +101,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Autowired private EsGoodsSearchService goodsSearchService; @Autowired - private GoodsWordsService goodsWordsService; - @Autowired private PromotionService promotionService; + @Autowired + private CustomWordsService customWordsService; @Autowired private GoodsSkuService goodsSkuService; @@ -240,21 +244,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements public void addIndex(EsGoodsIndex goods) { try { //分词器分词 -// AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(getIndexName(), "ik_max_word", goods.getGoodsName()); -// AnalyzeResponse analyze = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT); -// List tokens = analyze.getTokens(); - -// if (goods.getAttrList() != null && !goods.getAttrList().isEmpty()) { -// //保存分词 -// for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) { -// wordsToDb(esGoodsAttribute.getValue()); -// } -// } -// //分析词条 -// for (AnalyzeResponse.AnalyzeToken token : tokens) { -// //保存词条进入数据库 -// wordsToDb(token.getTerm()); -// } + this.analyzeAndSaveWords(goods); //生成索引 goodsIndexRepository.save(goods); } catch (Exception e) { @@ -270,6 +260,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void addIndex(List goods) { try { + for (EsGoodsIndex esGoodsIndex : goods) { + this.analyzeAndSaveWords(esGoodsIndex); + } goodsIndexRepository.saveAll(goods); } catch (Exception e) { log.error("批量为商品生成索引异常", e); @@ -278,9 +271,39 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void updateIndex(EsGoodsIndex goods) { + this.analyzeAndSaveWords(goods); goodsIndexRepository.save(goods); } + + /** + * 商品分词 + * + * @param goods 商品信息 + */ + private void analyzeAndSaveWords(EsGoodsIndex goods) { + try { + //分词器分词 + AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(getIndexName(), "ik_max_word", goods.getGoodsName()); + AnalyzeResponse analyze = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT); + List tokens = analyze.getTokens(); + + if (goods.getAttrList() != null && !goods.getAttrList().isEmpty()) { + //保存分词 + for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) { + wordsToDb(esGoodsAttribute.getValue()); + } + } + //分析词条 + for (AnalyzeResponse.AnalyzeToken token : tokens) { + //保存词条进入数据库 + wordsToDb(token.getTerm()); + } + } catch (IOException e) { + log.info(goods + "分词错误", e); + } + } + /** * 更新商品索引的的部分属性(只填写更新的字段,不需要更新的字段不要填写) * @@ -800,18 +823,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } try { //是否有重复 - GoodsWords entity = goodsWordsService.getOne(new LambdaQueryWrapper().eq(GoodsWords::getWords, words)); - if (entity == null) { - GoodsWords goodsWords = new GoodsWords(); - goodsWords.setWords(words); - goodsWords.setWholeSpell(PinyinUtil.getPinyin(words, "")); - goodsWords.setAbbreviate(PinyinUtil.getFirstLetter(words, "")); - goodsWords.setType(GoodsWordsTypeEnum.SYSTEM.name()); - goodsWords.setSort(0); - goodsWordsService.save(goodsWords); - } + customWordsService.addCustomWords(new CustomWordsVO(words)); } catch (MyBatisSystemException me) { - log.error(words + "关键字已存在!"); + log.error(words + "关键字已存在!", me); } catch (Exception e) { log.error("关键字入库异常!", e); } From a28547c5815aeeb0e51515b6172a8de16df53ae6 Mon Sep 17 00:00:00 2001 From: zypy333 Date: Wed, 29 Jun 2022 03:10:05 +0000 Subject: [PATCH 150/185] =?UTF-8?q?update=20framework/src/main/java/cn/lil?= =?UTF-8?q?i/modules/member/serviceimpl/MemberServiceImpl.java.=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=94=99=E5=88=AB=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/serviceimpl/MemberServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 415a1d85..0126e81f 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -203,7 +203,7 @@ public class MemberServiceImpl extends ServiceImpl impleme loginBindUser(member, authUser.getUuid(), authUser.getSource()); return memberTokenGenerate.createToken(member, false); } catch (ServiceException e) { - log.error("自动注册服务泡出异常:", e); + log.error("自动注册服务抛出异常:", e); throw e; } catch (Exception e) { log.error("自动注册异常:", e); From d189f55de1e23c348a0f08555e97bb34361c442f Mon Sep 17 00:00:00 2001 From: zypy333 Date: Fri, 1 Jul 2022 03:18:20 +0000 Subject: [PATCH 151/185] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/controller/member/MemberEvaluationBuyerController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java index e33524f8..26285f54 100644 --- a/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/member/MemberEvaluationBuyerController.java @@ -48,7 +48,7 @@ public class MemberEvaluationBuyerController { @ApiOperation(value = "查看会员评价详情") @ApiImplicitParam(name = "id", value = "评价ID", required = true, paramType = "path") @GetMapping(value = "/get/{id}") - public ResultMessage save(@NotNull(message = "评价ID不能为空") @PathVariable("id") String id) { + public ResultMessage get(@NotNull(message = "评价ID不能为空") @PathVariable("id") String id) { return ResultUtil.data(memberEvaluationService.queryById(id)); } From 40e9d6f392074ff8f4f00e8bb8fecbdfc310709f Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 1 Jul 2022 15:36:07 +0800 Subject: [PATCH 152/185] =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=8D=E5=BD=92?= =?UTF-8?q?=E9=9B=B6=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/statistics/util/StatisticsDateUtil.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java b/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java index d97b1b82..0d785817 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java +++ b/framework/src/main/java/cn/lili/modules/statistics/util/StatisticsDateUtil.java @@ -92,7 +92,14 @@ public class StatisticsDateUtil { Date[] dateArray = new Date[2]; Calendar calendar = Calendar.getInstance(); - calendar.set(year, month, 0); + + //时间归到今天凌晨0点 + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + calendar.set(year, month, 1); dateArray[1] = calendar.getTime(); calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); dateArray[0] = calendar.getTime(); From 7b535434ae5e49289e4818c0aab474a5a05c9a16 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 4 Jul 2022 18:31:36 +0800 Subject: [PATCH 153/185] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=AE=A2=E5=8D=95=E6=8A=95=E8=AF=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/OrderComplaintBuyerController.java | 2 +- .../controller/security/CommonSecurityConfig.java | 12 ------------ .../java/cn/lili/listener/GoodsMessageListener.java | 5 +++++ .../timetask/handler/impl/coupon/CouponExecute.java | 2 +- .../serviceimpl/StoreCollectionServiceImpl.java | 8 ++++---- .../cn/lili/modules/sms/entity/dos/SmsReach.java | 4 ++++ .../order/OrderComplaintManagerController.java | 6 ++++-- .../passport/AdminUserManagerController.java | 4 ---- .../order/OrderComplaintStoreController.java | 2 +- 9 files changed, 20 insertions(+), 25 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java index f348c882..1d26fef2 100644 --- a/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/order/OrderComplaintBuyerController.java @@ -82,7 +82,7 @@ public class OrderComplaintBuyerController { @PostMapping("/communication") public ResultMessage addCommunication(@RequestParam String complainId, @RequestParam String content) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); - OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.BUYER.name(), currentUser.getId(), currentUser.getNickName()); + OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.BUYER.name(), currentUser.getNickName(), currentUser.getId()); orderComplaintCommunicationService.addCommunication(communicationVO); return ResultUtil.data(communicationVO); } diff --git a/common-api/src/main/java/cn/lili/controller/security/CommonSecurityConfig.java b/common-api/src/main/java/cn/lili/controller/security/CommonSecurityConfig.java index 8fa1f8c2..5ad1d4a2 100644 --- a/common-api/src/main/java/cn/lili/controller/security/CommonSecurityConfig.java +++ b/common-api/src/main/java/cn/lili/controller/security/CommonSecurityConfig.java @@ -1,8 +1,5 @@ package cn.lili.controller.security; -import cn.lili.cache.Cache; -import cn.lili.common.security.CustomAccessDeniedHandler; -import cn.lili.common.properties.IgnoredUrlsProperties; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @@ -25,19 +22,10 @@ import org.springframework.web.cors.CorsConfigurationSource; public class CommonSecurityConfig extends WebSecurityConfigurerAdapter { - /** - * 忽略验权配置 - */ - @Autowired - private IgnoredUrlsProperties ignoredUrlsProperties; /** * spring security -》 权限不足处理 */ @Autowired - private CustomAccessDeniedHandler accessDeniedHandler; - @Autowired - private Cache cache; - @Autowired private CorsConfigurationSource corsConfigurationSource; @Override diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 82df940e..429a3950 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -253,14 +253,17 @@ public class GoodsMessageListener implements RocketMQListener { try { log.info("更新商品索引促销信息: {}", promotionsJsonStr); JSONObject jsonObject = JSONUtil.parseObj(promotionsJsonStr); + // 转换为详细的促销信息(注:促销信息必须继承自 BasePromotions,且必须保证派生类存在与sdk包下) BasePromotions promotions = (BasePromotions) jsonObject.get("promotions", ClassLoaderUtil.loadClass(jsonObject.get("promotionsType").toString())); + // 获取促销唯一key,由 促销类型 + 促销id 组成 String esPromotionKey = jsonObject.get("esPromotionKey").toString(); if (PromotionsScopeTypeEnum.PORTION_GOODS.name().equals(promotions.getScopeType())) { PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); searchParams.setPromotionId(promotions.getId()); List promotionGoodsList = this.promotionGoodsService.listFindAll(searchParams); List skuIds = promotionGoodsList.stream().map(PromotionGoods::getSkuId).collect(Collectors.toList()); + // 更新商品索引促销信息(删除原索引中相关的促销信息,更新索引中促销信息) this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(skuIds, esPromotionKey); this.goodsIndexService.updateEsGoodsIndexByList(promotionGoodsList, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(promotions.getScopeType())) { @@ -268,9 +271,11 @@ public class GoodsMessageListener implements RocketMQListener { searchParams.setCategoryPath(promotions.getScopeId()); List goodsSkuByList = this.goodsSkuService.getGoodsSkuByList(searchParams); List skuIds = goodsSkuByList.stream().map(GoodsSku::getId).collect(Collectors.toList()); + // 更新商品索引促销信息(删除原索引中相关的促销信息,更新索引中促销信息) this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(skuIds, esPromotionKey); this.goodsIndexService.updateEsGoodsIndexPromotions(skuIds, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) { + // 更新商品索引促销信息(删除原索引中相关的促销信息,更新索引中促销信息) this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(esPromotionKey); this.goodsIndexService.updateEsGoodsIndexAllByList(promotions, esPromotionKey); } diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponExecute.java index 613380d6..acb0503c 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/coupon/CouponExecute.java @@ -34,7 +34,7 @@ public class CouponExecute implements EveryDayExecute { */ @Override public void execute() { - //将过期优惠券变更为过期状体 + //将过期优惠券变更为过期状态 LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() .eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()) .le(MemberCoupon::getEndTime, new Date()) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java index 6772fb93..4b450d6c 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java @@ -36,7 +36,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl storeCollection(PageVO pageVo) { - QueryWrapper queryWrapper = new QueryWrapper(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("sc.member_id", UserContext.getCurrentUser().getId()); queryWrapper.orderByDesc("sc.create_time"); return this.baseMapper.storeCollectionVOList(PageUtil.initPage(pageVo), queryWrapper); @@ -44,10 +44,10 @@ public class StoreCollectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("member_id", UserContext.getCurrentUser().getId()); queryWrapper.eq("store_id", storeId); - return Optional.ofNullable(this.getOne(queryWrapper)).isPresent(); + return Optional.ofNullable(this.getOne(queryWrapper, false)).isPresent(); } @Override @@ -67,7 +67,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("member_id", UserContext.getCurrentUser().getId()); queryWrapper.eq("store_id", storeId); storeService.updateStoreCollectionNum(new CollectionDTO(storeId, -1)); diff --git a/framework/src/main/java/cn/lili/modules/sms/entity/dos/SmsReach.java b/framework/src/main/java/cn/lili/modules/sms/entity/dos/SmsReach.java index 09ec8dfa..33ff2db6 100644 --- a/framework/src/main/java/cn/lili/modules/sms/entity/dos/SmsReach.java +++ b/framework/src/main/java/cn/lili/modules/sms/entity/dos/SmsReach.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.data.annotation.CreatedDate; import org.springframework.format.annotation.DateTimeFormat; @@ -23,8 +24,11 @@ import java.util.Date; @Data @TableName("li_sms_reach") @ApiModel(value = "短信任务") +@EqualsAndHashCode(callSuper = true) public class SmsReach extends BaseIdEntity { + private static final long serialVersionUID = -8106666482841131277L; + @ApiModelProperty(value = "签名名称", required = true) private String signName; diff --git a/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java b/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java index e0cf6b43..c3286749 100644 --- a/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/order/OrderComplaintManagerController.java @@ -23,6 +23,8 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Objects; + /** * 管理端,交易投诉接口 * @@ -74,8 +76,8 @@ public class OrderComplaintManagerController { }) @PostMapping("/communication") public ResultMessage addCommunication(@RequestParam String complainId, @RequestParam String content) { - AuthUser currentUser = UserContext.getCurrentUser(); - OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.PLATFORM.name(), currentUser.getId(), currentUser.getUsername()); + AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); + OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.PLATFORM.name(), currentUser.getUsername(), currentUser.getId()); orderComplaintCommunicationService.addCommunication(communicationVO); return ResultUtil.data(communicationVO); } diff --git a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java index d93e73e1..80ca8903 100644 --- a/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/passport/AdminUserManagerController.java @@ -8,7 +8,6 @@ import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.token.Token; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.SearchVO; @@ -17,7 +16,6 @@ import cn.lili.modules.permission.entity.dos.AdminUser; import cn.lili.modules.permission.entity.dto.AdminUserDTO; import cn.lili.modules.permission.entity.vo.AdminUserVO; import cn.lili.modules.permission.service.AdminUserService; -import cn.lili.modules.permission.service.DepartmentService; import cn.lili.modules.verification.entity.enums.VerificationEnums; import cn.lili.modules.verification.service.VerificationService; import cn.lili.mybatis.util.PageUtil; @@ -49,8 +47,6 @@ import java.util.List; public class AdminUserManagerController { @Autowired private AdminUserService adminUserService; - @Autowired - private DepartmentService departmentService; /** * 会员 */ diff --git a/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java b/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java index 3913294f..72faab7b 100644 --- a/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/order/OrderComplaintStoreController.java @@ -68,7 +68,7 @@ public class OrderComplaintStoreController { @PostMapping("/communication") public ResultMessage addCommunication(@RequestParam String complainId, @RequestParam String content) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); - OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.STORE.name(), currentUser.getStoreId(), currentUser.getUsername()); + OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.STORE.name(), currentUser.getUsername(), currentUser.getStoreId()); orderComplaintCommunicationService.addCommunication(communicationVO); return ResultUtil.success(); } From 53f6910a3447244697c6429fab9802a4e051047d Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 6 Jul 2022 15:57:49 +0800 Subject: [PATCH 154/185] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E4=BD=BF=E7=94=A8=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/common/enums/ResultCode.java | 2 ++ .../lili/modules/order/cart/service/CartServiceImpl.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index e871846b..068d7ad5 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -293,6 +293,8 @@ public enum ResultCode { COUPON_MEMBER_NOT_EXIST(41015, "没有当前会员优惠券"), COUPON_MEMBER_STATUS_ERROR(41016, "当前会员优惠券已过期/作废无法变更状态!"), + SPECIAL_CANT_USE(41020, "特殊商品不能使用优惠券,不能使用"), + /** * 拼团 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 51007a39..83dd4195 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -287,9 +287,10 @@ public class CartServiceImpl implements CartService { /** * 当购物车商品发生变更时,取消已选择当优惠券 + * * @param tradeDTO */ - private void remoteCoupon(TradeDTO tradeDTO){ + private void remoteCoupon(TradeDTO tradeDTO) { tradeDTO.setPlatformCoupon(null); tradeDTO.setStoreCoupons(new HashMap<>()); } @@ -526,6 +527,12 @@ public class CartServiceImpl implements CartService { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); //获取购物车,然后重新写入优惠券 CartTypeEnum cartTypeEnum = getCartType(way); + + //积分商品不允许使用优惠券 + if (cartTypeEnum.equals(CartTypeEnum.POINTS)) { + throw new ServiceException(ResultCode.SPECIAL_CANT_USE); + } + TradeDTO tradeDTO = this.readDTO(cartTypeEnum); MemberCouponSearchParams searchParams = new MemberCouponSearchParams(); From 4d4b54ec36bd7a4dec193b975525f54075470801 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 6 Jul 2022 16:41:40 +0800 Subject: [PATCH 155/185] =?UTF-8?q?=E5=88=86=E9=94=80=E8=AE=A2=E5=8D=950?= =?UTF-8?q?=E5=85=83=E4=BD=A3=E9=87=91=E8=AE=B0=E5=BD=95=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../distribution/serviceimpl/DistributionOrderServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java index 96f2238c..6fb74ad7 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java @@ -94,6 +94,9 @@ public class DistributionOrderServiceImpl extends ServiceImpl Date: Wed, 6 Jul 2022 17:30:01 +0800 Subject: [PATCH 156/185] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/member/entity/dto/ManagerMemberEditDTO.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java index c61792aa..2f83b11f 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/ManagerMemberEditDTO.java @@ -21,14 +21,9 @@ import java.util.Date; @Data public class ManagerMemberEditDTO { - @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) - @NotNull(message = "会员用户名不能为空") + @NotNull(message = "用户ID不能为空") private String id; - @ApiModelProperty(value = "会员用户名,用户名不能进行修改", required = true) - @NotNull(message = "会员用户名不能为空") - private String username; - @ApiModelProperty(value = "会员密码") private String password; From 82a0cd0336e5196ae28419043ea077d84bb2ff88 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 7 Jul 2022 17:25:15 +0800 Subject: [PATCH 157/185] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=94=9F=E6=88=90=E5=BA=97=E9=93=BA=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cart/render/impl/CheckDataRender.java | 10 +-- .../cart/render/impl/SkuPromotionRender.java | 1 - .../order/cart/service/CartServiceImpl.java | 2 +- .../order/serviceimpl/OrderServiceImpl.java | 65 +++++++++++++++++-- 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 5b5fb2a7..19bd26a6 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -168,10 +168,12 @@ public class CheckDataRender implements CartRenderStep { try { //筛选属于当前店铺的优惠券 storeCart.getValue().forEach(i -> i.getPromotionMap().forEach((key, value) -> { - JSONObject promotionsObj = JSONUtil.parseObj(value); - Coupon coupon = JSONUtil.toBean(promotionsObj, Coupon.class); - if (key.contains(PromotionTypeEnum.COUPON.name()) && coupon.getStoreId().equals(storeCart.getKey())) { - cartVO.getCanReceiveCoupon().add(new CouponVO(coupon)); + if (key.contains(PromotionTypeEnum.COUPON.name())) { + JSONObject promotionsObj = JSONUtil.parseObj(value); + Coupon coupon = JSONUtil.toBean(promotionsObj, Coupon.class); + if (key.contains(PromotionTypeEnum.COUPON.name()) && coupon.getStoreId().equals(storeCart.getKey())) { + cartVO.getCanReceiveCoupon().add(new CouponVO(coupon)); + } } })); } catch (Exception e) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index 765b9192..280082ed 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -186,7 +186,6 @@ public class SkuPromotionRender implements CartRenderStep { */ private void checkPromotionQuantity(TradeDTO tradeDTO) { for (CartSkuVO cartSkuVO : tradeDTO.getCheckedSkuList()) { - cartSkuVO.getPromotionMap(); List joinPromotion = cartSkuVO.getPriceDetailDTO().getJoinPromotion(); if (!joinPromotion.isEmpty()) { for (PromotionSkuVO promotionSkuVO : joinPromotion) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 51007a39..97b5d221 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -136,7 +136,7 @@ public class CartServiceImpl implements CartService { } CartTypeEnum cartTypeEnum = getCartType(cartType); GoodsSku dataSku = checkGoods(skuId); - Map promotionMap = promotionGoodsService.getCurrentGoodsPromotion(dataSku, cartType); + Map promotionMap = promotionGoodsService.getCurrentGoodsPromotion(dataSku, cartTypeEnum.name()); try { //购物车方式购买需要保存之前的选择,其他方式购买,则直接抹除掉之前的记录 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 76491576..1b59db38 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -21,10 +21,7 @@ import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; import cn.lili.modules.member.entity.dto.MemberAddressDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.order.aop.OrderLogPoint; -import cn.lili.modules.order.order.entity.dos.Order; -import cn.lili.modules.order.order.entity.dos.OrderItem; -import cn.lili.modules.order.order.entity.dos.Receipt; -import cn.lili.modules.order.order.entity.dos.Trade; +import cn.lili.modules.order.order.entity.dos.*; import cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO; import cn.lili.modules.order.order.entity.dto.OrderExportDTO; import cn.lili.modules.order.order.entity.dto.OrderMessage; @@ -305,6 +302,8 @@ public class OrderServiceImpl extends ServiceImpl implements order.setCancelReason(reason); //修改订单 this.updateById(order); + //生成店铺退款流水 + this.generatorStoreRefundFlow(order); orderStatusMessage(order); return order; } else { @@ -321,6 +320,8 @@ public class OrderServiceImpl extends ServiceImpl implements order.setOrderStatus(OrderStatusEnum.CANCELLED.name()); order.setCancelReason(reason); this.updateById(order); + //生成店铺退款流水 + this.generatorStoreRefundFlow(order); orderStatusMessage(order); } @@ -795,6 +796,62 @@ public class OrderServiceImpl extends ServiceImpl implements this.sendUpdateStatusMessage(orderMessage); } + /** + * 生成店铺退款流水 + * + * @param order 订单信息 + */ + private void generatorStoreRefundFlow(Order order) { + // 判断订单是否是付款 + if (!PayStatusEnum.PAID.name().equals((order.getPayStatus()))) { + return; + } + List items = orderItemService.getByOrderSn(order.getSn()); + List storeFlows = new ArrayList<>(); + String orderPromotionType = order.getOrderPromotionType(); + for (OrderItem item : items) { + StoreFlow storeFlow = new StoreFlow(); + BeanUtil.copyProperties(item, storeFlow); + + //入账 + storeFlow.setId(SnowFlake.getIdStr()); + storeFlow.setFlowType(FlowTypeEnum.REFUND.name()); + storeFlow.setSn(SnowFlake.createStr("SF")); + storeFlow.setOrderSn(item.getOrderSn()); + storeFlow.setOrderItemSn(item.getSn()); + storeFlow.setStoreId(order.getStoreId()); + storeFlow.setStoreName(order.getStoreName()); + storeFlow.setMemberId(order.getMemberId()); + storeFlow.setMemberName(order.getMemberName()); + storeFlow.setGoodsName(item.getGoodsName()); + + storeFlow.setOrderPromotionType(item.getPromotionType()); + + //计算平台佣金 + storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); + storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); + storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); + storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice()); + //兼容为空,以及普通订单操作 + if (CharSequenceUtil.isNotEmpty(orderPromotionType)) { + //如果为砍价活动,填写砍价结算价 + if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { + storeFlow.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + //如果为砍价活动,填写砍价结算价 + else if (orderPromotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { + storeFlow.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + } + //添加支付方式 + storeFlow.setPaymentName(order.getPaymentMethod()); + //添加第三方支付流水号 + storeFlow.setTransactionId(order.getReceivableNo()); + storeFlows.add(storeFlow); + } + storeFlowService.saveBatch(storeFlows); + } + /** * 此方法只提供内部调用,调用前应该做好权限处理 * 修改订单状态 From 13a7a875a40de1d94f915578b2639b3bf2389bdb Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 7 Jul 2022 18:10:31 +0800 Subject: [PATCH 158/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=94=9F=E6=88=90=E5=BA=97=E9=93=BA=E6=B5=81?= =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/entity/dos/StoreFlow.java | 71 ++++++++++++++++++- .../order/serviceimpl/OrderServiceImpl.java | 39 +--------- .../serviceimpl/StoreFlowServiceImpl.java | 68 ++---------------- 3 files changed, 75 insertions(+), 103 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java index 0f9a9ab7..8404acc9 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java @@ -1,6 +1,13 @@ package cn.lili.modules.order.order.entity.dos; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONUtil; +import cn.lili.common.utils.BeanUtil; +import cn.lili.common.utils.CurrencyUtil; +import cn.lili.common.utils.SnowFlake; +import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; +import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum; import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.mybatis.BaseIdEntity; import com.baomidou.mybatisplus.annotation.FieldFill; @@ -10,6 +17,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; import org.springframework.data.annotation.CreatedDate; import org.springframework.format.annotation.DateTimeFormat; @@ -24,6 +33,8 @@ import java.util.Date; @Data @TableName("li_store_flow") @ApiModel(value = "商家订单流水") +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) public class StoreFlow extends BaseIdEntity { private static final long serialVersionUID = -5998757398902747939L; @@ -115,7 +126,7 @@ public class StoreFlow extends BaseIdEntity { private String transactionId; /** - * @see PaymentMethodEnum + * @see PaymentMethodEnum */ @ApiModelProperty(value = "支付方式名称") private String paymentName; @@ -129,4 +140,62 @@ public class StoreFlow extends BaseIdEntity { @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) private Date createTime; + + + public StoreFlow(Order order, OrderItem item, FlowTypeEnum flowTypeEnum) { + //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 + String promotionType = order.getOrderPromotionType(); + BeanUtil.copyProperties(item, this); + + //去掉orderitem的时间。 + this.setCreateTime(null); + //入账 + this.setId(SnowFlake.getIdStr()); + this.setFlowType(flowTypeEnum.name()); + this.setSn(SnowFlake.createStr("SF")); + this.setOrderSn(item.getOrderSn()); + this.setOrderItemSn(item.getSn()); + this.setStoreId(order.getStoreId()); + this.setStoreName(order.getStoreName()); + this.setMemberId(order.getMemberId()); + this.setMemberName(order.getMemberName()); + this.setGoodsName(item.getGoodsName()); + this.setOrderPromotionType(item.getPromotionType()); + //格式化订单价格详情 + PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class); + //站点优惠券比例=最大比例(100)-店铺承担比例 + this.setSiteCouponPoint(CurrencyUtil.sub(100, priceDetailDTO.getSiteCouponPoint())); + //平台优惠券 使用金额 + this.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice()); + //站点优惠券佣金(站点优惠券承担金额=优惠券金额 * (站点承担比例/100)) + this.setSiteCouponCommission(CurrencyUtil.mul(this.getSiteCouponPrice(), CurrencyUtil.div(this.getSiteCouponPoint(), 100))); + + /** + * @TODO 计算平台佣金 + */ + //店铺流水金额=goodsPrice(商品总金额(商品原价))+ freightPrice(配送费) - discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额) + this.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); + //平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100 + this.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); + //单品分销返现支出 + this.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); + //最终结算金额=flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出) + this.setBillPrice(item.getPriceDetailDTO().getBillPrice()); + //兼容为空,以及普通订单操作 + if (CharSequenceUtil.isNotEmpty(promotionType)) { + //如果为砍价活动,填写砍价结算价 + if (promotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { + this.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + //如果为砍价活动,填写砍价结算价 + else if (promotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { + this.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + } + //添加支付方式 + this.setPaymentName(order.getPaymentMethod()); + //添加第三方支付流水号 + this.setTransactionId(order.getReceivableNo()); + + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 1b59db38..01c61f60 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -808,45 +808,8 @@ public class OrderServiceImpl extends ServiceImpl implements } List items = orderItemService.getByOrderSn(order.getSn()); List storeFlows = new ArrayList<>(); - String orderPromotionType = order.getOrderPromotionType(); for (OrderItem item : items) { - StoreFlow storeFlow = new StoreFlow(); - BeanUtil.copyProperties(item, storeFlow); - - //入账 - storeFlow.setId(SnowFlake.getIdStr()); - storeFlow.setFlowType(FlowTypeEnum.REFUND.name()); - storeFlow.setSn(SnowFlake.createStr("SF")); - storeFlow.setOrderSn(item.getOrderSn()); - storeFlow.setOrderItemSn(item.getSn()); - storeFlow.setStoreId(order.getStoreId()); - storeFlow.setStoreName(order.getStoreName()); - storeFlow.setMemberId(order.getMemberId()); - storeFlow.setMemberName(order.getMemberName()); - storeFlow.setGoodsName(item.getGoodsName()); - - storeFlow.setOrderPromotionType(item.getPromotionType()); - - //计算平台佣金 - storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); - storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); - storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); - storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice()); - //兼容为空,以及普通订单操作 - if (CharSequenceUtil.isNotEmpty(orderPromotionType)) { - //如果为砍价活动,填写砍价结算价 - if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { - storeFlow.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { - storeFlow.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - } - //添加支付方式 - storeFlow.setPaymentName(order.getPaymentMethod()); - //添加第三方支付流水号 - storeFlow.setTransactionId(order.getReceivableNo()); + StoreFlow storeFlow = new StoreFlow(order, item, FlowTypeEnum.REFUND); storeFlows.add(storeFlow); } storeFlowService.saveBatch(storeFlows); diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index dfe3e1af..a9ec6265 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -1,8 +1,6 @@ package cn.lili.modules.order.order.serviceimpl; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.json.JSONUtil; -import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.SnowFlake; import cn.lili.common.vo.PageVO; @@ -10,11 +8,8 @@ import cn.lili.modules.order.aftersale.entity.dos.AfterSale; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dos.StoreFlow; -import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; -import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum; -import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.StoreFlowMapper; import cn.lili.modules.order.order.service.OrderItemService; import cn.lili.modules.order.order.service.OrderService; @@ -68,6 +63,7 @@ public class StoreFlowServiceImpl extends ServiceImpl orderItems = orderItemService.getByOrderSn(orderSn); //根据订单编号获取订单数据 Order order = orderService.getBySn(orderSn); - //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 - String orderPromotionType = order.getOrderPromotionType(); //循环子订单记录流水 for (OrderItem item : orderItems) { - StoreFlow storeFlow = new StoreFlow(); - BeanUtil.copyProperties(item, storeFlow); - - //去掉orderitem的时间。 - storeFlow.setCreateTime(null); - //入账 - storeFlow.setId(SnowFlake.getIdStr()); - storeFlow.setFlowType(FlowTypeEnum.PAY.name()); - storeFlow.setSn(SnowFlake.createStr("SF")); - storeFlow.setOrderSn(item.getOrderSn()); - storeFlow.setOrderItemSn(item.getSn()); - storeFlow.setStoreId(order.getStoreId()); - storeFlow.setStoreName(order.getStoreName()); - storeFlow.setMemberId(order.getMemberId()); - storeFlow.setMemberName(order.getMemberName()); - storeFlow.setGoodsName(item.getGoodsName()); - storeFlow.setOrderPromotionType(item.getPromotionType()); - //格式化订单价格详情 - PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class); - //站点优惠券比例=最大比例(100)-店铺承担比例 - storeFlow.setSiteCouponPoint(CurrencyUtil.sub(100,priceDetailDTO.getSiteCouponPoint())); - //平台优惠券 使用金额 - storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice()); - //站点优惠券佣金(站点优惠券承担金额=优惠券金额 * (站点承担比例/100)) - storeFlow.setSiteCouponCommission(CurrencyUtil.mul(storeFlow.getSiteCouponPrice(),CurrencyUtil.div(storeFlow.getSiteCouponPoint(),100))); - - /** - * @TODO 计算平台佣金 - */ - //店铺流水金额=goodsPrice(商品总金额(商品原价))+ freightPrice(配送费) - discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额) - storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); - //平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100 - storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); - //单品分销返现支出 - storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); - //最终结算金额=flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出) - storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice()); - //兼容为空,以及普通订单操作 - if (CharSequenceUtil.isNotEmpty(orderPromotionType)) { - if (orderPromotionType.equals(OrderPromotionTypeEnum.NORMAL.name())) { - //普通订单操作 - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { - storeFlow.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { - storeFlow.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - } - //添加支付方式 - storeFlow.setPaymentName(order.getPaymentMethod()); - //添加第三方支付流水号 - storeFlow.setTransactionId(order.getReceivableNo()); - + StoreFlow storeFlow = new StoreFlow(order, item, FlowTypeEnum.PAY); //添加付款交易流水 this.save(storeFlow); } @@ -145,6 +84,7 @@ public class StoreFlowServiceImpl extends ServiceImpl Date: Fri, 8 Jul 2022 03:57:53 +0000 Subject: [PATCH 159/185] =?UTF-8?q?update=20framework/src/main/java/cn/lil?= =?UTF-8?q?i/modules/sms/impl/SmsUtilAliImplService.java.=20=E6=8A=9B?= =?UTF-8?q?=E5=87=BA=E8=BF=94=E5=9B=9E=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java index f54982e2..4ade384c 100644 --- a/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/modules/sms/impl/SmsUtilAliImplService.java @@ -156,6 +156,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { .setTemplateParam(JSONUtil.toJsonStr(param)); try { SendSmsResponse response = client.sendSms(sendSmsRequest); + if (!("OK").equals(response.getBody().getCode())) { + throw new ServiceException(response.getBody().getMessage()); + } } catch (Exception e) { log.error("发送短信错误", e); } From 2c02b816b56d6c979315e8d6bb0ab4bc93b8076c Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 11 Jul 2022 18:52:31 +0800 Subject: [PATCH 160/185] =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=88=86=E9=94=80?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B1=95=E7=A4=BA=E4=BB=A5=E5=8F=8A=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=AD=97=E6=AE=B5=E6=B2=A1=E6=9C=89=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E5=AD=98=E5=82=A8=E5=80=BC=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/distribution/entity/dos/DistributionOrder.java | 3 +++ .../distribution/serviceimpl/DistributionCashServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/distribution/entity/dos/DistributionOrder.java b/framework/src/main/java/cn/lili/modules/distribution/entity/dos/DistributionOrder.java index 491a8faf..fc760ac4 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/entity/dos/DistributionOrder.java +++ b/framework/src/main/java/cn/lili/modules/distribution/entity/dos/DistributionOrder.java @@ -50,6 +50,9 @@ public class DistributionOrder extends BaseIdEntity { private String distributionId; @ApiModelProperty(value = "分销员名称") private String distributionName; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "解冻日期") private Date settleCycle; @ApiModelProperty(value = "提成金额") diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java index 805fc9db..8f3e18cc 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java @@ -73,6 +73,7 @@ public class DistributionCashServiceImpl extends ServiceImpl Date: Mon, 11 Jul 2022 18:53:07 +0800 Subject: [PATCH 161/185] =?UTF-8?q?minio=E4=B8=8A=E4=BC=A0=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=89=8D=E7=AB=AF=E6=97=A0=E6=84=9F=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/plugin/impl/MinioFilePlugin.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java index d7f992d7..a6629738 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java @@ -1,5 +1,7 @@ package cn.lili.modules.file.plugin.impl; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; import cn.lili.modules.file.entity.enums.OssEnum; import cn.lili.modules.file.plugin.FilePlugin; import cn.lili.modules.system.entity.dto.OssSetting; @@ -62,14 +64,13 @@ public class MinioFilePlugin implements FilePlugin { public String pathUpload(String filePath, String key) { try { return this.inputStreamUpload(new FileInputStream(filePath), key); - } catch (FileNotFoundException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new ServiceException(ResultCode.OSS_DELETE_ERROR, e.getMessage()); } - return null; } @Override - public String inputStreamUpload(InputStream inputStream, String key) { + public String inputStreamUpload(InputStream inputStream, String key) { String bucket = ""; try { MinioClient client = getOssClient(); @@ -80,12 +81,9 @@ public class MinioFilePlugin implements FilePlugin { .contentType("image/png") .build(); client.putObject(putObjectArgs); - } catch (ErrorResponseException e) { - e.printStackTrace(); - return null; } catch (Exception e) { log.error("上传失败2,", e); - return null; + throw new ServiceException(ResultCode.OSS_DELETE_ERROR, e.getMessage()); } //拼接出可访问的url地址 return ossSetting.getM_endpoint() + "/" + bucket + "/" + key; @@ -129,8 +127,10 @@ public class MinioFilePlugin implements FilePlugin { log.info("创建minio桶成功{}", ossSetting.getM_bucketName()); } } catch (Exception e) { - e.printStackTrace(); + //晴空配置 + minioClient = null; log.error("创建[{}]bucket失败", ossSetting.getM_bucketName()); + throw new ServiceException(ResultCode.OSS_DELETE_ERROR, e.getMessage()); } } } From a6f28d67eb7cfe1080220402cad745b41945afc6 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 12 Jul 2022 10:17:34 +0800 Subject: [PATCH 162/185] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/member/serviceimpl/MemberServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 0126e81f..c7eb0a70 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -15,10 +15,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.token.Token; import cn.lili.common.sensitive.SensitiveWordsFilter; -import cn.lili.common.utils.BeanUtil; -import cn.lili.common.utils.CookieUtil; -import cn.lili.common.utils.SnowFlake; -import cn.lili.common.utils.UuidUtils; +import cn.lili.common.utils.*; import cn.lili.common.vo.PageVO; import cn.lili.modules.connect.config.ConnectAuthEnum; import cn.lili.modules.connect.entity.Connect; @@ -405,11 +402,11 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public Member updateMember(ManagerMemberEditDTO managerMemberEditDTO) { //过滤会员昵称敏感词 - if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(managerMemberEditDTO.getNickName())) { + if (StringUtils.isNotBlank(managerMemberEditDTO.getNickName())) { managerMemberEditDTO.setNickName(SensitiveWordsFilter.filter(managerMemberEditDTO.getNickName())); } //如果密码不为空则加密密码 - if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(managerMemberEditDTO.getPassword())) { + if (StringUtils.isNotBlank(managerMemberEditDTO.getPassword())) { managerMemberEditDTO.setPassword(new BCryptPasswordEncoder().encode(managerMemberEditDTO.getPassword())); } //查询会员信息 From 682433efe42daa377f897d491abced5a02159b31 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 12 Jul 2022 17:13:17 +0800 Subject: [PATCH 163/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E5=8F=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=AE=A2=E5=8D=95=E4=B8=8B=E5=8D=95=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=AE=A2=E5=8D=95=E5=8D=95=E9=A1=B9=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/cart/render/impl/CheckDataRender.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 19bd26a6..2d59abc5 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -261,9 +261,15 @@ public class CheckDataRender implements CartRenderStep { // 将符合规则的商品设置批发价格 if (Boolean.TRUE.equals(i.getChecked())) { i.setPurchasePrice(match.getPrice()); + i.getGoodsSku().setPrice(match.getPrice()); + i.getGoodsSku().setCost(match.getPrice()); + i.setUtilPrice(match.getPrice()); i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); } else { i.setPurchasePrice(wholesaleService.match(k, fSum).getPrice()); + i.getGoodsSku().setPrice(i.getPurchasePrice()); + i.getGoodsSku().setCost(i.getPurchasePrice()); + i.setUtilPrice(i.getPurchasePrice()); i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); } }); From bce60310c5fe732f12838be6784cd12660d9e3c4 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 13 Jul 2022 19:05:59 +0800 Subject: [PATCH 164/185] =?UTF-8?q?minio=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E5=9C=B0=E5=9D=80=E3=80=82endpoint=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=BB=A7=E7=BB=AD=E8=B5=B0=E5=B1=80=E5=9F=9F=E7=BD=91?= =?UTF-8?q?ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/plugin/impl/MinioFilePlugin.java | 10 +-- .../modules/system/entity/dto/OssSetting.java | 5 ++ .../cn/lili/test/RedisLimiterHelperTest.java | 61 -------------- .../java/cn/lili/test/script/ScriptTest.java | 81 ------------------- 4 files changed, 10 insertions(+), 147 deletions(-) delete mode 100644 framework/src/test/java/cn/lili/test/RedisLimiterHelperTest.java delete mode 100644 framework/src/test/java/cn/lili/test/script/ScriptTest.java diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java index a6629738..87d580b3 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/MinioFilePlugin.java @@ -70,7 +70,7 @@ public class MinioFilePlugin implements FilePlugin { } @Override - public String inputStreamUpload(InputStream inputStream, String key) { + public String inputStreamUpload(InputStream inputStream, String key) { String bucket = ""; try { MinioClient client = getOssClient(); @@ -78,7 +78,7 @@ public class MinioFilePlugin implements FilePlugin { PutObjectArgs putObjectArgs = PutObjectArgs.builder() .bucket(bucket).stream(inputStream, inputStream.available(), 5 * 1024 * 1024) .object(key) - .contentType("image/png") + .contentType("image/png" ) .build(); client.putObject(putObjectArgs); } catch (Exception e) { @@ -86,7 +86,7 @@ public class MinioFilePlugin implements FilePlugin { throw new ServiceException(ResultCode.OSS_DELETE_ERROR, e.getMessage()); } //拼接出可访问的url地址 - return ossSetting.getM_endpoint() + "/" + bucket + "/" + key; + return ossSetting.getM_frontUrl() + "/" + bucket + "/" + key; } @@ -123,7 +123,7 @@ public class MinioFilePlugin implements FilePlugin { //创建bucket MakeBucketArgs makeBucketArgs = MakeBucketArgs.builder().bucket(ossSetting.getM_bucketName()).build(); this.minioClient.makeBucket(makeBucketArgs); - setBucketPolicy(this.minioClient, ossSetting.getM_bucketName(), "read-write"); + setBucketPolicy(this.minioClient, ossSetting.getM_bucketName(), "read-write" ); log.info("创建minio桶成功{}", ossSetting.getM_bucketName()); } } catch (Exception e) { @@ -153,7 +153,7 @@ public class MinioFilePlugin implements FilePlugin { client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).config(WRITE_ONLY.replace(BUCKET_PARAM, bucket)).build()); break; case "read-write": - client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).region("public").config(READ_WRITE.replace(BUCKET_PARAM, bucket)).build()); + client.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).region("public" ).config(READ_WRITE.replace(BUCKET_PARAM, bucket)).build()); break; case "none": default: diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java index fd71d3b3..760c191c 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/OssSetting.java @@ -50,6 +50,11 @@ public class OssSetting implements Serializable { */ private String m_endpoint; + /** + * minio 前端请求地址 + */ + private String m_frontUrl; + /** * minio用户名 */ diff --git a/framework/src/test/java/cn/lili/test/RedisLimiterHelperTest.java b/framework/src/test/java/cn/lili/test/RedisLimiterHelperTest.java deleted file mode 100644 index 936bc736..00000000 --- a/framework/src/test/java/cn/lili/test/RedisLimiterHelperTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.lili.test; - -import cn.lili.modules.order.order.entity.dos.OrderItem; -import cn.lili.modules.order.order.service.OrderItemService; -import cn.lili.modules.statistics.serviceimpl.OrderStatisticsServiceImpl; -import org.junit.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.util.ArrayList; -import java.util.List; - -/** - * RedisLimiterHelperTest - * - * @author Chopper - * @version v1.0 - * @since 2020-06-13 12:17 - */ - -@ExtendWith(SpringExtension.class) -@SpringBootTest -public class RedisLimiterHelperTest { - - @Autowired - private OrderItemService orderItemService; - - @Autowired - private OrderStatisticsServiceImpl orderStatisticsDataService; - - - @Test - public void orderTest() { - - - - } - - - @Test - public void testBatchUpdate() { - OrderItem orderItem = new OrderItem(); - orderItem.setId("1356539557729796097"); - orderItem.setCreateBy("1356539557729796097"); - - - OrderItem orderItem1 = new OrderItem(); - orderItem1.setId("1356787800921341953"); - orderItem1.setCreateBy("1356787800921341953"); - - - List orderItemList = new ArrayList<>(); - orderItemList.add(orderItem); - orderItemList.add(orderItem1); - - orderItemService.updateBatchById(orderItemList); - - } -} diff --git a/framework/src/test/java/cn/lili/test/script/ScriptTest.java b/framework/src/test/java/cn/lili/test/script/ScriptTest.java deleted file mode 100644 index 654c2071..00000000 --- a/framework/src/test/java/cn/lili/test/script/ScriptTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.lili.test.script; - -import org.junit.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.data.redis.core.script.DefaultRedisScript; -import org.springframework.scripting.support.ResourceScriptSource; -import org.springframework.test.annotation.Rollback; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; - -/** - * redis 事务测试 - * - * @author Chopper - * @version v1.0 - * @since - * 2020-02-22 20:26 - */ -@ExtendWith(SpringExtension.class) -@SpringBootTest -@Rollback() -@ContextConfiguration -@Configuration -@ComponentScan("cn.lili") -public class ScriptTest { - @Resource - private DefaultRedisScript redisScript; - @Resource - private StringRedisTemplate stringRedisTemplate; - - @Test - public void lua() { - stringRedisTemplate.opsForValue().set("key_1", "100"); - stringRedisTemplate.opsForValue().set("key_2", "95"); - stringRedisTemplate.opsForValue().set("key_3", "90"); - stringRedisTemplate.opsForValue().set("key_4", "85"); - List keys = new ArrayList<>(); - keys.add("key_1"); - keys.add("key_2"); - keys.add("key_3"); - keys.add("key_4"); - List value = new ArrayList<>(); - value.add("-1"); - value.add("-1"); - value.add("-1"); - value.add("-1"); - //启用十个线程 - for (int i = 0; i <= 10; i++) { - //每个线程循环十次 - Thread thread = new Thread(() -> { - for (int i1 = 0; i1 <= 10; i1++) { - Boolean execute = stringRedisTemplate.execute(redisScript, keys, value.toArray()); - System.out.println(Thread.currentThread().getName() + "|" + i1 + "|" + execute); - } - }); - thread.start(); - } - } - -} - -@Configuration -class LuaConfiguration { - @Bean - public DefaultRedisScript redisScript() { - DefaultRedisScript redisScript = new DefaultRedisScript<>(); - redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("script/quantity.lua"))); - redisScript.setResultType(Boolean.class); - return redisScript; - } -} From b21e30764085c85eb928de756b3b307bb5b805b5 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 13 Jul 2022 20:03:05 +0800 Subject: [PATCH 165/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=A5=BC=E5=B1=82=E8=A3=85=E4=BF=AE=E3=80=82=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E4=BC=98=E6=83=A0=E5=88=B8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/page/serviceimpl/PageDataServiceImpl.java | 5 +++-- .../lili/controller/promotion/CouponManagerController.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) 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 905c1789..82ac1338 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 @@ -1,5 +1,6 @@ package cn.lili.modules.page.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ClientTypeEnum; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; @@ -80,8 +81,8 @@ public class PageDataServiceImpl extends ServiceImpl i //如果页面为发布,则关闭其他页面,开启此页面 if (pageData.getPageShow() != null && pageData.getPageShow().equals(SwitchEnum.OPEN.name())) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); - lambdaUpdateWrapper.eq(PageData::getPageType, pageData.getPageType()); - lambdaUpdateWrapper.eq(PageData::getPageClientType, pageData.getPageClientType()); + lambdaUpdateWrapper.eq(CharSequenceUtil.isNotEmpty(pageData.getPageType()), PageData::getPageType, pageData.getPageType()); + lambdaUpdateWrapper.eq(CharSequenceUtil.isNotEmpty(pageData.getPageClientType()), PageData::getPageClientType, pageData.getPageClientType()); lambdaUpdateWrapper.set(PageData::getPageShow, SwitchEnum.CLOSE.name()); this.update(lambdaUpdateWrapper); } else { diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java index b78c98c0..8a130ef9 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/CouponManagerController.java @@ -44,7 +44,9 @@ public class CouponManagerController { @ApiOperation(value = "获取优惠券列表") @GetMapping public ResultMessage> getCouponList(CouponSearchParams queryParam, PageVO page) { - queryParam.setStoreId(PromotionTools.PLATFORM_ID); + if (queryParam.getStoreId() == null) { + queryParam.setStoreId(PromotionTools.PLATFORM_ID); + } return ResultUtil.data(couponService.pageVOFindAll(queryParam, page)); } From 8041a4a4fc4071e9e6ea6e49c1ed4396615139d7 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Fri, 15 Jul 2022 14:27:10 +0800 Subject: [PATCH 166/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/serviceimpl/StoreFlowServiceImpl.java | 8 ++++---- .../lili/modules/store/serviceimpl/BillServiceImpl.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index a9ec6265..2616b74c 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -118,10 +118,10 @@ public class StoreFlowServiceImpl extends ServiceImpl implements Bi //退单产生退还佣金金额 bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice() != null ? refundBill.getRefundCommissionPrice() : 0D); //分销订单退还,返现佣金返还 - bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission() != null ? refundBill.getRefundCommissionPrice() : 0D); + bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission() != null ? refundBill.getDistributionRefundCommission() : 0D); //退货平台优惠券补贴返还 bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission() != null ? refundBill.getSiteCouponRefundCommission() : 0D); //退款金额=店铺最终退款结算金额 From 7cbbc5751470732d6f76eb24225ba1b7856da5e9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 18 Jul 2022 12:11:16 +0800 Subject: [PATCH 167/185] =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=E9=83=A8=E5=88=86?= =?UTF-8?q?es=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common-api/src/main/resources/application.yml | 1 + .../modules/search/serviceimpl/EsGoodsIndexServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common-api/src/main/resources/application.yml b/common-api/src/main/resources/application.yml index f139f9bd..eadf556f 100644 --- a/common-api/src/main/resources/application.yml +++ b/common-api/src/main/resources/application.yml @@ -122,6 +122,7 @@ ignored: - /common/common/slider/** - /common/common/sms/** - /common/common/logo + - /common/common/site - /druid/** - /swagger-ui.html - /doc.html diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index bc348f55..f0ec4a56 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -496,6 +496,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements log.info("更新商品索引的促销信息----------"); log.info("商品ids: {}", ids); log.info("活动: {}", promotion); + log.info("key: {}", key); for (String id : ids) { UpdateRequest updateRequest = this.updateEsGoodsIndexPromotions(id, promotion, key); if (updateRequest != null) { @@ -730,8 +731,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements promotionMap = goodsIndex.getOriginPromotionMap(); } - log.info("ES修改商品活动索引-活动信息:{}", promotion); - log.info("ES修改商品活动索引-活动信息状态:{}", promotion.getPromotionStatus()); log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex); log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap); //如果活动已结束 @@ -760,6 +759,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements Map params = new HashMap<>(); params.put("promotionMap", JSONUtil.toJsonStr(promotionMap)); Script script = new Script(ScriptType.INLINE, "painless", "ctx._source.promotionMapJson=params.promotionMap;", params); + log.info("执行脚本内容:{}", script); updateRequest.script(script); return updateRequest; } From 950274f6bee20e092f4d7168a36d812f4e178ab9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 18 Jul 2022 19:06:17 +0800 Subject: [PATCH 168/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E7=9A=84=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=80=82=E4=BC=98=E5=8C=96=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=88=86=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 13 +-- .../lili/listener/GoodsMessageListener.java | 2 - consumer/src/main/resources/application.yml | 2 +- .../search/entity/dos/CustomWords.java | 4 + .../search/mapper/CustomWordsMapper.java | 3 +- .../search/service/CustomWordsService.java | 12 +++ .../serviceimpl/CustomWordsServiceImpl.java | 12 +++ .../serviceimpl/EsGoodsIndexServiceImpl.java | 92 +++++++++---------- .../mybatis/mybatisplus/SpiceBaseMapper.java | 19 ++++ .../mybatis/mybatisplus/SpiceSqlInjector.java | 33 +++++++ 10 files changed, 136 insertions(+), 56 deletions(-) create mode 100644 framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java create mode 100644 framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java diff --git a/config/application.yml b/config/application.yml index 703b96ae..201f837f 100644 --- a/config/application.yml +++ b/config/application.yml @@ -29,7 +29,7 @@ spring: type: redis # Redis redis: - host: 192.168.0.116 + host: 127.0.0.1 port: 6379 password: lilishop lettuce: @@ -60,7 +60,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.0.116:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop maxActive: 50 @@ -119,6 +119,7 @@ ignored: - /store/passport/login/refresh/** - /common/common/slider/** - /common/common/sms/** + - /common/common/site - /buyer/payment/cashier/** - /buyer/other/pageData/** - /buyer/other/article/** @@ -268,7 +269,7 @@ lili: data: elasticsearch: cluster-name: elasticsearch - cluster-nodes: 192.168.0.116:9200 + cluster-nodes: 127.0.0.1:9200 index: number-of-replicas: 0 number-of-shards: 3 @@ -279,7 +280,7 @@ lili: # password: LiLiShopES logstash: - server: 192.168.0.116:4560 + server: 127.0.0.1:4560 rocketmq: promotion-topic: lili_promotion_topic promotion-group: lili_promotion_group @@ -300,7 +301,7 @@ lili: after-sale-topic: lili_after_sale_topic after-sale-group: lili_after_sale_group rocketmq: - name-server: 192.168.0.116:9876 + name-server: 127.0.0.1:9876 isVIPChannel: false producer: group: lili_group @@ -309,7 +310,7 @@ rocketmq: xxl: job: admin: - addresses: http://192.168.0.116:9001/xxl-job-admin + addresses: http://127.0.0.1:9001/xxl-job-admin executor: appname: xxl-job-executor-lilishop address: diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 429a3950..367c7425 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -275,8 +275,6 @@ public class GoodsMessageListener implements RocketMQListener { this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(skuIds, esPromotionKey); this.goodsIndexService.updateEsGoodsIndexPromotions(skuIds, promotions, esPromotionKey); } else if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) { - // 更新商品索引促销信息(删除原索引中相关的促销信息,更新索引中促销信息) - this.goodsIndexService.deleteEsGoodsPromotionByPromotionKey(esPromotionKey); this.goodsIndexService.updateEsGoodsIndexAllByList(promotions, esPromotionKey); } } catch (Exception e) { diff --git a/consumer/src/main/resources/application.yml b/consumer/src/main/resources/application.yml index 8304cf32..ae49a9b8 100644 --- a/consumer/src/main/resources/application.yml +++ b/consumer/src/main/resources/application.yml @@ -67,7 +67,7 @@ spring: default-datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: lilishop maxActive: 20 diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java index 745e8ab9..4b53e75f 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java @@ -4,8 +4,10 @@ import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotEmpty; @@ -20,6 +22,8 @@ import javax.validation.constraints.NotEmpty; @TableName("li_custom_words") @ApiModel(value = "自定义分词") @EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor public class CustomWords extends BaseEntity { private static final long serialVersionUID = 650889506808657977L; diff --git a/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java b/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java index 359cd238..858eda75 100644 --- a/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java +++ b/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java @@ -1,6 +1,7 @@ package cn.lili.modules.search.mapper; import cn.lili.modules.search.entity.dos.CustomWords; +import cn.lili.mybatis.mybatisplus.SpiceBaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** @@ -9,5 +10,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author paulG * @since 2020/10/15 **/ -public interface CustomWordsMapper extends BaseMapper { +public interface CustomWordsMapper extends BaseMapper, SpiceBaseMapper { } diff --git a/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java b/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java index 5193cdf1..72621949 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java @@ -6,6 +6,8 @@ import cn.lili.modules.search.entity.vo.CustomWordsVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 自定义分词业务层 * @@ -52,6 +54,16 @@ public interface CustomWordsService extends IService { */ boolean deleteCustomWords(String id); + /** + * 根据名字批量删除 + * + * @param names 名称列表 + * @return 是否删除成功 + */ + boolean deleteBathByName(List names); + + long insertBatchCustomWords(List customWordsList); + /** * 分页查询自定义分词 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java index 1454c3b0..405050fa 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/CustomWordsServiceImpl.java @@ -91,6 +91,18 @@ public class CustomWordsServiceImpl extends ServiceImpl names) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(CustomWords::getName, names); + return this.remove(queryWrapper); + } + + @Override + public long insertBatchCustomWords(List customWordsList) { + return this.baseMapper.insertBatchSomeColumn(customWordsList); + } + /** * 修改自定义分词 * diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index f0ec4a56..4695102d 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -15,6 +15,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.RetryException; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; +import cn.lili.common.vo.PageVO; import cn.lili.elasticsearch.BaseElasticsearchService; import cn.lili.elasticsearch.EsSuffix; import cn.lili.elasticsearch.config.ElasticsearchProperties; @@ -35,10 +36,10 @@ import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.promotion.tools.PromotionTools; +import cn.lili.modules.search.entity.dos.CustomWords; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; -import cn.lili.modules.search.entity.vo.CustomWordsVO; import cn.lili.modules.search.repository.EsGoodsIndexRepository; import cn.lili.modules.search.service.CustomWordsService; import cn.lili.modules.search.service.EsGoodsIndexService; @@ -50,7 +51,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.spring.core.RocketMQTemplate; -import org.assertj.core.util.IterableUtil; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.update.UpdateRequest; @@ -65,8 +65,8 @@ import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; -import org.mybatis.spring.MyBatisSystemException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchPage; @@ -287,17 +287,28 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(getIndexName(), "ik_max_word", goods.getGoodsName()); AnalyzeResponse analyze = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT); List tokens = analyze.getTokens(); - + List customWordsList = new ArrayList<>(); + List keywordsList = new ArrayList<>(); if (goods.getAttrList() != null && !goods.getAttrList().isEmpty()) { //保存分词 for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) { - wordsToDb(esGoodsAttribute.getValue()); + if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(esGoodsAttribute.getValue().toLowerCase(Locale.ROOT)))) { + keywordsList.add(esGoodsAttribute.getValue()); + customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 0)); + } } } //分析词条 for (AnalyzeResponse.AnalyzeToken token : tokens) { + if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(token.getTerm().toLowerCase(Locale.ROOT)))) { + keywordsList.add(token.getTerm()); + customWordsList.add(new CustomWords(token.getTerm(), 0)); + } //保存词条进入数据库 - wordsToDb(token.getTerm()); + } + if (CollUtil.isNotEmpty(customWordsList)) { + customWordsService.deleteBathByName(keywordsList); + customWordsService.insertBatchCustomWords(customWordsList); } } catch (IOException e) { log.info(goods + "分词错误", e); @@ -537,25 +548,35 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) { ThreadUtil.execAsync(() -> { - List goodsIndices = new ArrayList<>(); - //如果storeId不为空,则表示是店铺活动 - if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) { - EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); - searchDTO.setStoreId(promotion.getStoreId()); - //查询出店铺商品 - SearchPage esGoodsIndices = goodsSearchService.searchGoods(searchDTO, null); - for (SearchHit searchHit : esGoodsIndices.getContent()) { - goodsIndices.add(searchHit.getContent()); + for (int i = 1; ; i++) { + List skuIds; + //如果storeId不为空,则表示是店铺活动 + if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) { + PageVO pageVO = new PageVO(); + pageVO.setPageNumber(i); + pageVO.setPageSize(1000); + EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); + searchDTO.setStoreId(promotion.getStoreId()); + //查询出店铺商品 + SearchPage esGoodsIndices = goodsSearchService.searchGoods(searchDTO, pageVO); + + skuIds = esGoodsIndices.isEmpty() ? new ArrayList<>() : esGoodsIndices.getContent().stream().map(SearchHit::getId).collect(Collectors.toList()); + } else { + //否则是平台活动 + org.springframework.data.domain.Page all = goodsIndexRepository.findAll(PageRequest.of(i, 1000)); + + //查询出全部商品 + skuIds = all.isEmpty() ? new ArrayList<>() : all.toList().stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); } - } else { - //否则是平台活动 - Iterable all = goodsIndexRepository.findAll(); - //查询出全部商品 - goodsIndices = new ArrayList<>(IterableUtil.toCollection(all)); + if (skuIds.isEmpty()) { + break; + } + this.deleteEsGoodsPromotionByPromotionKey(skuIds, key); + this.updateEsGoodsIndexPromotions(skuIds, promotion, key); } - List skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList()); - this.updateEsGoodsIndexPromotions(skuIds, promotion, key); + }); + } @Override @@ -730,9 +751,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { promotionMap = goodsIndex.getOriginPromotionMap(); } - - log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex); - log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap); +// log.info("ES修改商品活动索引-原商品索引信息:{}", goodsIndex); +// log.info("ES修改商品活动索引-原商品索引活动信息:{}", promotionMap); //如果活动已结束 if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {//如果存在活动 //删除活动 @@ -740,7 +760,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } else { promotionMap.put(key, promotion); } - log.info("ES修改商品活动索引-过滤后商品索引活动信息:{}", promotionMap); +// log.info("ES修改商品活动索引-过滤后商品索引活动信息:{}", promotionMap); return this.getGoodsIndexPromotionUpdateRequest(goodsIndex.getId(), promotionMap); } @@ -759,7 +779,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements Map params = new HashMap<>(); params.put("promotionMap", JSONUtil.toJsonStr(promotionMap)); Script script = new Script(ScriptType.INLINE, "painless", "ctx._source.promotionMapJson=params.promotionMap;", params); - log.info("执行脚本内容:{}", script); updateRequest.script(script); return updateRequest; } @@ -812,25 +831,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } - /** - * 将商品关键字入库 - * - * @param words 商品关键字 - */ - private void wordsToDb(String words) { - if (CharSequenceUtil.isEmpty(words)) { - return; - } - try { - //是否有重复 - customWordsService.addCustomWords(new CustomWordsVO(words)); - } catch (MyBatisSystemException me) { - log.error(words + "关键字已存在!", me); - } catch (Exception e) { - log.error("关键字入库异常!", e); - } - } - private String getIndexName() { //索引名称拼接 return elasticsearchProperties.getIndexPrefix() + "_" + EsSuffix.GOODS_INDEX_NAME; diff --git a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java b/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java new file mode 100644 index 00000000..c72055b9 --- /dev/null +++ b/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java @@ -0,0 +1,19 @@ +package cn.lili.mybatis.mybatisplus; + +import java.util.List; + +/** + * @author paulG + * @since 2022/7/18 + **/ +public interface SpiceBaseMapper { + + /** + * 批量插入 + * {@link com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn} + * + * @param entityList 要插入的数据 + * @return 成功插入的数据条数 + */ + long insertBatchSomeColumn(List entityList); +} diff --git a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java b/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java new file mode 100644 index 00000000..a7d86ae8 --- /dev/null +++ b/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java @@ -0,0 +1,33 @@ +package cn.lili.mybatis.mybatisplus; + +import com.baomidou.mybatisplus.core.injector.AbstractMethod; +import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; +import com.baomidou.mybatisplus.core.metadata.TableInfo; +import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author paulG + * @since 2022/7/18 + **/ +@Component +public class SpiceSqlInjector extends DefaultSqlInjector { + + /** + * 如果只需增加方法,保留mybatis plus自带方法, + * 可以先获取super.getMethodList(),再添加add + */ + @Override + public List getMethodList(Class mapperClass, TableInfo tableInfo) { + // 注意:此SQL注入器继承了DefaultSqlInjector(默认注入器),调用了DefaultSqlInjector的getMethodList方法,保留了mybatis-plus的自带方法 + List methodList = super.getMethodList(mapperClass, tableInfo); + // 注入InsertBatchSomeColumn + // 在!t.isLogicDelete()表示不要逻辑删除字段,!"update_time".equals(t.getColumn())表示不要字段名为 update_time 的字段,不对进行操作 + // methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete() && !"update_time".equals(t.getColumn()))); + // 要逻辑删除 t.isLogicDelete() 默认不要 + methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete())); + return methodList; + } +} From 088c6faae1eda5c0a86c4f39e84b32728228757c Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 15:15:59 +0800 Subject: [PATCH 169/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E5=A4=9A=E6=AC=A1=E5=85=A5?= =?UTF-8?q?=E9=A9=BB=E5=BA=97=E9=93=BA=E6=97=A0=E6=B3=95=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/serviceimpl/StoreServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index 90db9136..e90563fd 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -220,7 +220,7 @@ public class StoreServiceImpl extends ServiceImpl implements //获取当前操作的店铺 Store store = getStoreByMember(); //如果没有申请过店铺,新增店铺 - if (!Optional.ofNullable(store).isPresent()) { + if (store != null) { AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser()); Member member = memberService.getById(authUser.getId()); store = new Store(member); @@ -231,12 +231,20 @@ public class StoreServiceImpl extends ServiceImpl implements BeanUtil.copyProperties(storeCompanyDTO, storeDetail); return storeDetailService.save(storeDetail); } else { + store = new Store(); BeanUtil.copyProperties(storeCompanyDTO, store); this.updateById(store); //判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改 StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId()); - BeanUtil.copyProperties(storeCompanyDTO, storeDetail); - return storeDetailService.updateById(storeDetail); + //如果店铺详情为空,则new ,否则复制对象,然后保存即可。 + if (storeDetail == null) { + storeDetail = new StoreDetail(); + BeanUtil.copyProperties(storeCompanyDTO, storeDetail); + return storeDetailService.save(storeDetail); + } else { + BeanUtil.copyProperties(storeCompanyDTO, storeDetail); + return storeDetailService.updateById(storeDetail); + } } } From 2eb469b228ea810b43864f1596b2a92f410d061e Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 19 Jul 2022 15:24:39 +0800 Subject: [PATCH 170/185] improve code --- .../cn/lili/modules/search/mapper/CustomWordsMapper.java | 2 +- .../cn/lili/modules/search/service/CustomWordsService.java | 6 ++++++ .../mybatis/mybatisplus/{ => external}/SpiceBaseMapper.java | 2 +- .../mybatisplus/{ => external}/SpiceSqlInjector.java | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) rename framework/src/main/java/cn/lili/mybatis/mybatisplus/{ => external}/SpiceBaseMapper.java (89%) rename framework/src/main/java/cn/lili/mybatis/mybatisplus/{ => external}/SpiceSqlInjector.java (96%) diff --git a/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java b/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java index 858eda75..6f3d99ec 100644 --- a/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java +++ b/framework/src/main/java/cn/lili/modules/search/mapper/CustomWordsMapper.java @@ -1,7 +1,7 @@ package cn.lili.modules.search.mapper; import cn.lili.modules.search.entity.dos.CustomWords; -import cn.lili.mybatis.mybatisplus.SpiceBaseMapper; +import cn.lili.mybatis.mybatisplus.external.SpiceBaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** diff --git a/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java b/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java index 72621949..90d775bc 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/CustomWordsService.java @@ -62,6 +62,12 @@ public interface CustomWordsService extends IService { */ boolean deleteBathByName(List names); + /** + * 批量插入自定义分词 + * + * @param customWordsList 自定义分词列表 + * @return 受影响行数 + */ long insertBatchCustomWords(List customWordsList); /** diff --git a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java b/framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceBaseMapper.java similarity index 89% rename from framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java rename to framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceBaseMapper.java index c72055b9..8d56ccec 100644 --- a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceBaseMapper.java +++ b/framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceBaseMapper.java @@ -1,4 +1,4 @@ -package cn.lili.mybatis.mybatisplus; +package cn.lili.mybatis.mybatisplus.external; import java.util.List; diff --git a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java b/framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceSqlInjector.java similarity index 96% rename from framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java rename to framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceSqlInjector.java index a7d86ae8..5481579a 100644 --- a/framework/src/main/java/cn/lili/mybatis/mybatisplus/SpiceSqlInjector.java +++ b/framework/src/main/java/cn/lili/mybatis/mybatisplus/external/SpiceSqlInjector.java @@ -1,4 +1,4 @@ -package cn.lili.mybatis.mybatisplus; +package cn.lili.mybatis.mybatisplus.external; import com.baomidou.mybatisplus.core.injector.AbstractMethod; import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; From d5aadf6926d548d3339bf3c1a8765cdb0c47cc5d Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 18:38:38 +0800 Subject: [PATCH 171/185] =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E5=88=86=E6=89=B9=E4=BF=9D=E5=AD=98=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=A0=E6=B3=95=E5=85=A5=E4=BD=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index e90563fd..9710abda 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -239,6 +239,7 @@ public class StoreServiceImpl extends ServiceImpl implements //如果店铺详情为空,则new ,否则复制对象,然后保存即可。 if (storeDetail == null) { storeDetail = new StoreDetail(); + storeDetail.setStoreId(store.getId()); BeanUtil.copyProperties(storeCompanyDTO, storeDetail); return storeDetailService.save(storeDetail); } else { From 5576ae73056a13faf1050f7096c01bc6d8148d5b Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 19 Jul 2022 18:45:08 +0800 Subject: [PATCH 172/185] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20lilishop4.2.4?= =?UTF-8?q?=E4=B8=AD=E5=AD=98=E5=9C=A8=E5=BA=8F=E5=88=97=E5=8C=96=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=EF=BC=8C=E4=BF=83=E9=94=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BC=9A=E5=9C=A8=E5=BA=8F=E5=88=97=E5=8C=96=E5=90=8E=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=EF=BC=8C=E6=97=A0=E6=B3=95=E5=8F=8D=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/redis/FastJsonRedisSerializer.java | 10 ++++-- .../order/cart/service/CartService.java | 7 ---- .../order/cart/service/CartServiceImpl.java | 36 +++++-------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java b/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java index d59e29cf..f0071468 100644 --- a/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java +++ b/framework/src/main/java/cn/lili/cache/config/redis/FastJsonRedisSerializer.java @@ -6,6 +6,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * 要实现对象的缓存,定义自己的序列化和反序列化器。使用阿里的fastjson来实现的比较多 @@ -13,8 +14,8 @@ import java.nio.charset.Charset; * @author Bulbasaur */ public class FastJsonRedisSerializer implements RedisSerializer { - private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); - private Class clazz; + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + private final Class clazz; public FastJsonRedisSerializer(Class clazz) { super(); @@ -26,7 +27,10 @@ public class FastJsonRedisSerializer implements RedisSerializer { if (null == t) { return new byte[0]; } - return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); + return JSON.toJSONString(t, + SerializerFeature.WriteClassName, + SerializerFeature.DisableCircularReferenceDetect) + .getBytes(DEFAULT_CHARSET); } @Override diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java index 01b3866d..d11d8aa8 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartService.java @@ -95,13 +95,6 @@ public interface CartService { */ void clean(); - /** - * 清空购物车无效数据 - * - * @param way 购物车类型 - */ - void cleanChecked(CartTypeEnum way); - /** * 重新写入 * diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index f64769be..3fafa5be 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -16,7 +16,6 @@ import cn.lili.modules.goods.entity.dos.Wholesale; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; -import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.WholesaleService; import cn.lili.modules.member.entity.dos.Member; @@ -46,7 +45,6 @@ import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.PointsGoodsService; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; -import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsSearchService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -98,16 +96,6 @@ public class CartServiceImpl implements CartService { */ @Autowired private EsGoodsSearchService esGoodsSearchService; - /** - * 商品索引 - */ - @Autowired - private EsGoodsIndexService goodsIndexService; - /** - * ES商品 - */ - @Autowired - private GoodsService goodsService; /** * 砍价 */ @@ -161,7 +149,7 @@ public class CartServiceImpl implements CartService { int newNum = oldNum + num; this.checkSetGoodsQuantity(cartSkuVO, skuId, newNum); } - + cartSkuVO.setPromotionMap(promotionMap); //计算购物车小计 cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum())); } else { @@ -254,7 +242,8 @@ public class CartServiceImpl implements CartService { cartSkuVO.setChecked(checked); } } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + + this.resetTradeDTO(tradeDTO); } @Override @@ -269,7 +258,8 @@ public class CartServiceImpl implements CartService { cartSkuVO.setChecked(checked); } } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + + resetTradeDTO(tradeDTO); } @Override @@ -282,7 +272,7 @@ public class CartServiceImpl implements CartService { for (CartSkuVO cartSkuVO : cartSkuVOS) { cartSkuVO.setChecked(checked); } - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + resetTradeDTO(tradeDTO); } /** @@ -296,7 +286,6 @@ public class CartServiceImpl implements CartService { } @Override - @Transactional(rollbackFor = Exception.class) public void delete(String[] skuIds) { TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); List cartSkuVOS = tradeDTO.getSkuList(); @@ -309,7 +298,7 @@ public class CartServiceImpl implements CartService { } } cartSkuVOS.removeAll(deleteVos); - cache.put(this.getOriginKey(CartTypeEnum.CART), tradeDTO); + resetTradeDTO(tradeDTO); } @Override @@ -331,17 +320,8 @@ public class CartServiceImpl implements CartService { tradeDTO.setStoreCoupons(null); //清除添加过的备注 tradeDTO.setStoreRemark(null); - cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO); - } - @Override - public void cleanChecked(CartTypeEnum way) { - if (way.equals(CartTypeEnum.CART)) { - TradeDTO tradeDTO = this.readDTO(CartTypeEnum.CART); - this.cleanChecked(tradeDTO); - } else { - cache.remove(this.getOriginKey(way)); - } + resetTradeDTO(tradeDTO); } @Override From d6edb9340383524a7fa28f48323ed39fc47249d9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 21 Jul 2022 11:52:12 +0800 Subject: [PATCH 173/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84es=E5=88=86=E8=AF=8D=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy-api.yml | 651 ++++++++++++++++++ .../permission/entity/vo/SystemLogVO.java | 2 +- .../search/entity/dos/CustomWords.java | 2 +- .../serviceimpl/EsGoodsIndexServiceImpl.java | 4 +- 4 files changed, 655 insertions(+), 4 deletions(-) create mode 100644 deploy-api.yml diff --git a/deploy-api.yml b/deploy-api.yml new file mode 100644 index 00000000..baecfc31 --- /dev/null +++ b/deploy-api.yml @@ -0,0 +1,651 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: lilishop-service + +--- +apiVersion: v1 +kind: Service +metadata: + name: buyer-api-service + namespace: lilishop-service + labels: + app.kubernetes.io/name: buyer-api-service + app.kubernetes.io/instance: api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + type: NodePort + ports: + - name: "8888" + nodePort: 30888 + port: 8888 + targetPort: buyer8888 + selector: + lilishop.service: buyer-api + +--- +apiVersion: v1 +kind: Service +metadata: + name: common-api-service + namespace: lilishop-service + labels: + app.kubernetes.io/name: common-api-service + app.kubernetes.io/instance: api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + type: NodePort + ports: + - name: "8890" + nodePort: 30890 + port: 8890 + targetPort: common8890 + selector: + lilishop.service: common-api + +--- +apiVersion: v1 +kind: Service +metadata: + name: seller-api-service + namespace: lilishop-service + labels: + app.kubernetes.io/name: seller-api-service + app.kubernetes.io/instance: api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + type: NodePort + ports: + - name: "8889" + nodePort: 30889 + port: 8889 + targetPort: seller8889 + selector: + lilishop.service: seller-api + +--- +apiVersion: v1 +kind: Service +metadata: + name: manager-api-service + namespace: lilishop-service + labels: + app.kubernetes.io/name: manager-api-service + app.kubernetes.io/instance: api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + type: NodePort + ports: + - name: "8887" + nodePort: 30887 + port: 8887 + targetPort: manager8887 + selector: + lilishop.service: manager-api + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: api-config + namespace: lilishop-service + labels: + app.kubernetes.io/name: mysql-db-config + app.kubernetes.io/instance: mysql-single + app.kubernetes.io/version: "8.0.28" + app.kubernetes.io/component: database + app.kubernetes.io/part-of: lilishop +data: + application.yml: | + server: + servlet: + context-path: / + + tomcat: + uri-encoding: UTF-8 + threads: + min-spare: 50 + max: 1000 + + # 与Spring Boot 2一样,默认情况下,大多数端点都不通过http公开,我们公开了所有端点。对于生产,您应该仔细选择要公开的端点。 + management: + # health: + # elasticsearch: + # enabled: false + # datasource: + # enabled: false + endpoints: + web: + exposure: + include: '*' + spring: + # 要在其中注册的Spring Boot Admin Server的URL。 + boot: + admin: + client: + url: http://192.168.0.116:8000 + cache: + type: redis + # Redis + redis: + host: redis-service.lilishop-middleware + port: 6379 + password: lilishop + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 200 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1 + max-wait: 20 + # 连接池中的最大空闲连接 默认 8 + max-idle: 10 + # 连接池中的最小空闲连接 默认 8 + min-idle: 8 + # 文件大小上传配置 + servlet: + multipart: + max-file-size: 20MB + max-request-size: 20MB + jackson: + time-zone: GMT+8 + serialization: + #关闭jackson 对json做解析 + fail-on-empty-beans: false + + shardingsphere: + datasource: + # 数据库名称,可自定义,可以为多个,以逗号隔开,每个在这里定义的库,都要在下面定义连接属性 + names: default-datasource + default-datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://mysql.lilishop-middleware:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + username: root + password: lilishop + maxActive: 50 + initialSize: 20 + maxWait: 60000 + minIdle: 5 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + #是否缓存preparedStatement,也就是PSCache。在mysql下建议关闭。 PSCache对支持游标的数据库性能提升巨大,比如说oracle。 + poolPreparedStatements: false + #要启用PSCache,-1为关闭 必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true 可以把这个数值配置大一些,比如说100 + maxOpenPreparedStatements: -1 + #配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 + filters: stat,wall,log4j2 + #通过connectProperties属性来打开mergeSql功能;慢SQL记录 + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + #合并多个DruidDataSource的监控数据 + useGlobalDataSourceStat: true + loginUsername: druid + loginPassword: druid + # sharding: + # default-data-source-name: default-datasource + # #需要拆分的表,可以设置多个 在 li_order 级别即可 + # tables: + # #需要进行分表的逻辑表名 + # li_order: + # #实际的表结点,下面代表的是li_order_为开头的所有表,如果能确定表的范围例如按月份分表,这里的写法是data2020.li_order_$->{2020..2021}_$->{01..12} 表示例如 li_order_2020_01 li_order_2020_03 li_order_2021_01 + # actual-data-nodes: data2020.li_order_$->{2019..2021}_$->{01..12} + # table-strategy: + # # 分表策略,根据创建日期 + # standard: + # sharding-column: create_time + # #分表策略 + # precise-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm + # #范围查询实现 + # range-algorithm-class-name: cn.lili.mybatis.sharding.CreateTimeShardingTableAlgorithm + props: + #是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭 + sql: + show: true + + # 忽略鉴权url + ignored: + urls: + - /editor-app/** + - /actuator** + - /actuator/** + - /MP_verify_qSyvBPhDsPdxvOhC.txt + - /weixin/** + - /source/** + - /store/passport/login/** + - /store/passport/login/refresh/** + - /common/common/slider/** + - /common/common/sms/** + - /buyer/payment/cashier/** + - /buyer/other/pageData/** + - /buyer/other/article/** + - /buyer/goods/** + - /buyer/store/** + - /buyer/passport/connect/** + - /buyer/members/** + - /buyer/passport/member/** + - /buyer/passport/member/refresh/** + - /buyer/promotion/pintuan/** + - /buyer/promotion/seckill/** + - /buyer/promotion/pointsGoods/** + - /buyer/promotion/coupon + - /buyer/member/evaluation/**/goodsEvaluation + - /buyer/member/evaluation/**/evaluationNumber + - /buyer/other/appVersion/** + - /buyer/broadcast/studio/** + - /manager/passport/user/login + - /manager/passport/user/refresh/** + - /manager/other/elasticsearch + - /manager/other/customWords + - /druid/** + - /swagger-ui.html + - /doc.html + - /swagger-resources/** + - /swagger/** + - /webjars/** + - /v2/api-docs** + - /configuration/ui + - /boot-admin + - /manager/promotion/seckill/init + - /**/*.js + - /**/*.css + - /**/*.png + - /**/*.ico + + # Swagger界面内容配置 + swagger: + title: lilishop API接口文档 + description: lilishop Api Documentation + version: 4.2.2 + termsOfServiceUrl: https://pickmall.cn + contact: + name: lili + url: https://pickmall.cn + email: admin@pickmall.com + + # Mybatis-plus + mybatis-plus: + mapper-locations: classpath*:mapper/*.xml + configuration: + #缓存开启 + cache-enabled: true + #日志 + # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + + # 日志 + logging: + # 输出级别 + level: + cn.lili: info + # org.hibernate: debug + # org.springframework: debug + file: + # 指定路径 + path: logs + logback: + rollingpolicy: + # 最大保存天数 + max-history: 7 + # 每个文件最大大小 + max-file-size: 5MB + #加密参数 + jasypt: + encryptor: + password: lili + + + lili: + #验证码设置 + verification-code: + #图形验证码有效时间 秒 包含滑块验证码有效时间, 以及验证通过之后,缓存中存储的验证结果有效时间 + effectiveTime: 300 + #水印 + watermark: LILI-SHOP + #干扰项数量 最大2 默认0 + interfereNum: 1 + #允许误差像素 + faultTolerant: 3 + #短信模版配置 + sms: + #登录 + LOGIN: SMS_205755300 + #注册 + REGISTER: SMS_205755298 + #找回密码 + FIND_USER: SMS_205755301 + #设置密码 + UPDATE_PASSWORD: SMS_205755297 + #支付密码 + WALLET_PASSWORD: SMS_205755301 + system: + isDemoSite: false + isTestModel: true + # 脱敏级别: + # 0:不做脱敏处理 + # 1:管理端用户手机号等信息脱敏 + # 2:商家端信息脱敏(为2时,表示管理端,商家端同时脱敏) + sensitiveLevel: 1 + + statistics: + # 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数 + onlineMember: 48 + # 当前在线人数刷新时间间隔,单位秒,设置为600,则每10分钟刷新一次 + currentOnlineUpdate: 600 + #qq lbs 申请 + lbs: + key: 4BYBZ-7MT6S-PUAOA-6BNWL-FJUD7-UUFXT + sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6 + #域名 + domain: + pc: http://192.168.0.116:8888 + wap: http://192.168.0.116:8888 + seller: http://192.168.0.116:8888 + admin: http://192.168.0.116:8888 + #api地址 + api: + buyer: http://192.168.0.116:8888 + base: http://192.168.0.116:8888 + manager: http://192.168.0.116:8888 + seller: http://192.168.0.116:8888 + + # jwt 细节设定 + jwt-setting: + # token过期时间(分钟) + tokenExpireTime: 30 + + # 使用Spring @Cacheable注解失效时间 + cache: + # 过期时间 单位秒 永久不过期设为-1 + timeout: 1500 + #多线程配置 + thread: + corePoolSize: 5 + maxPoolSize: 50 + queueCapacity: 50 + data: + elasticsearch: + cluster-name: elasticsearch + cluster-nodes: elasticsearch.lilishop-middleware:9200 + index: + number-of-replicas: 0 + number-of-shards: 3 + index-prefix: lili + schema: http + # account: + # username: elastic + # password: LiLiShopES + + logstash: + server: logstash-service.lilishop-middleware:4560 + rocketmq: + promotion-topic: lili_promotion_topic + promotion-group: lili_promotion_group + msg-ext-topic: lili_msg_topic + msg-ext-group: lili_msg_group + goods-topic: lili_goods_topic + goods-group: lili_goods_group + order-topic: lili_order_topic + order-group: lili_order_group + member-topic: lili_member_topic + member-group: lili_member_group + other-topic: lili_other_topic + other-group: lili_other_group + notice-topic: lili_notice_topic + notice-group: lili_notice_group + notice-send-topic: lili_send_notice_topic + notice-send-group: lili_send_notice_group + after-sale-topic: lili_after_sale_topic + after-sale-group: lili_after_sale_group + rocketmq: + name-server: rocketmq.lilishop-middleware:9876 + isVIPChannel: false + producer: + group: lili_group + send-message-timeout: 30000 + + xxl: + job: + admin: + addresses: http://xxl-job-service.lilishop-middleware:9001/xxl-job-admin + executor: + appname: xxl-job-executor-lilishop + address: + ip: + port: 8891 + logpath: ./xxl-job/executor + logretentiondays: 7 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: buyer-api + namespace: lilishop-service + labels: + app.kubernetes.io/name: buyer-api-service + app.kubernetes.io/instance: buyer-api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + replicas: 1 + selector: + matchLabels: + lilishop.service: buyer-api + template: + metadata: + labels: + lilishop.service: buyer-api + spec: + containers: + - image: 192.168.0.108:31320/buyer-api:4.2.4.1 + name: buyer-api + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_OPTS + value: -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -Xms128m -Xmx256m -Xmn128m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC + ports: + - name: buyer8888 + containerPort: 8888 + volumeMounts: + - mountPath: /application.yml + name: application-yml + subPath: application.yml + restartPolicy: Always + volumes: + - configMap: + name: api-config + name: application-yml + + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: common-api + namespace: lilishop-service + labels: + app.kubernetes.io/name: common-api-service + app.kubernetes.io/instance: common-api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + replicas: 1 + selector: + matchLabels: + lilishop.service: common-api + template: + metadata: + labels: + lilishop.service: common-api + spec: + containers: + - image: 192.168.0.108:31320/common-api:4.2.4.1 + name: common-api + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_OPTS + value: -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -Xms128m -Xmx256m -Xmn128m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC + ports: + - name: common8890 + containerPort: 8890 + volumeMounts: + - mountPath: /application.yml + name: application-yml + subPath: application.yml + restartPolicy: Always + volumes: + - configMap: + name: api-config + name: application-yml + + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: seller-api + namespace: lilishop-service + labels: + app.kubernetes.io/name: seller-api-service + app.kubernetes.io/instance: seller-api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + replicas: 1 + selector: + matchLabels: + lilishop.service: seller-api + template: + metadata: + labels: + lilishop.service: seller-api + spec: + containers: + - image: 192.168.0.108:31320/seller-api:4.2.4.1 + name: seller-api + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_OPTS + value: -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -Xms128m -Xmx256m -Xmn128m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC + ports: + - name: seller8889 + containerPort: 8889 + volumeMounts: + - mountPath: /application.yml + name: application-yml + subPath: application.yml + restartPolicy: Always + volumes: + - configMap: + name: api-config + name: application-yml + + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: manager-api + namespace: lilishop-service + labels: + app.kubernetes.io/name: manager-api-service + app.kubernetes.io/instance: manager-api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + replicas: 1 + selector: + matchLabels: + lilishop.service: manager-api + template: + metadata: + labels: + lilishop.service: manager-api + spec: + containers: + - image: 192.168.0.108:31320/manager-api:4.2.4.1 + name: manager-api + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_OPTS + value: -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -Xms128m -Xmx256m -Xmn128m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC + ports: + - name: manager8887 + containerPort: 8887 + volumeMounts: + - mountPath: /application.yml + name: application-yml + subPath: application.yml + restartPolicy: Always + volumes: + - configMap: + name: api-config + name: application-yml + + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: consumer + namespace: lilishop-service + labels: + app.kubernetes.io/name: consumer-service + app.kubernetes.io/instance: buyer-api + app.kubernetes.io/version: "4.2.4.1" + app.kubernetes.io/component: api + app.kubernetes.io/part-of: lilishop + tier: "api-service" +spec: + replicas: 1 + selector: + matchLabels: + lilishop.service: consumer + template: + metadata: + labels: + lilishop.service: consumer + spec: + containers: + - image: 192.168.0.108:31320/consumer:4.2.4.1 + name: consumer + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_OPTS + value: -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m -Xms128m -Xmx256m -Xmn128m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC + volumeMounts: + - mountPath: /application.yml + name: application-yml + subPath: application.yml + restartPolicy: Always + volumes: + - configMap: + name: api-config + name: application-yml \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java b/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java index 8718de48..b3a9ec9c 100644 --- a/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java +++ b/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java @@ -42,7 +42,7 @@ public class SystemLogVO implements Serializable { @ApiModelProperty(value = "日志记录时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @Field(type = FieldType.Date, format = DateFormat.basic_date_time) + @Field(type = FieldType.Date, format = DateFormat.basic_date_time, fielddata = true) private Date createTime = new Date(); @ApiModelProperty(value = "请求用户") diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java index 4b53e75f..6cc49e54 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java @@ -37,7 +37,7 @@ public class CustomWords extends BaseEntity { private String name; - @ApiModelProperty(value = "是否禁用") + @ApiModelProperty(value = "是否禁用: 0,禁用;1,不禁用") private Integer disabled; diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 4695102d..27f89f79 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -294,7 +294,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) { if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(esGoodsAttribute.getValue().toLowerCase(Locale.ROOT)))) { keywordsList.add(esGoodsAttribute.getValue()); - customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 0)); + customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 1)); } } } @@ -302,7 +302,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements for (AnalyzeResponse.AnalyzeToken token : tokens) { if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(token.getTerm().toLowerCase(Locale.ROOT)))) { keywordsList.add(token.getTerm()); - customWordsList.add(new CustomWords(token.getTerm(), 0)); + customWordsList.add(new CustomWords(token.getTerm(), 1)); } //保存词条进入数据库 } From 0eebc544a6fb4c96eebfc7032b86df73efbe0316 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 25 Jul 2022 20:52:03 +0800 Subject: [PATCH 174/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E4=B9=B0=E6=97=B6=EF=BC=8C=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/order/cart/render/impl/CheckDataRender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java index 2d59abc5..c85cfbbd 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/CheckDataRender.java @@ -134,7 +134,7 @@ public class CheckDataRender implements CartRenderStep { cartSkuVO.setErrorMessage("商品库存不足,现有库存数量[" + dataSku.getQuantity() + "]"); } //如果存在商品促销活动,则判定商品促销状态 - if (CollUtil.isNotEmpty(cartSkuVO.getNotFilterPromotionMap()) || Boolean.TRUE.equals(cartSkuVO.getGoodsSku().getPromotionFlag())) { + if (!cartSkuVO.getCartType().equals(CartTypeEnum.POINTS) && (CollUtil.isNotEmpty(cartSkuVO.getNotFilterPromotionMap()) || Boolean.TRUE.equals(cartSkuVO.getGoodsSku().getPromotionFlag()))) { //获取当前最新的促销信息 cartSkuVO.setPromotionMap(this.promotionGoodsService.getCurrentGoodsPromotion(cartSkuVO.getGoodsSku(), tradeDTO.getCartTypeEnum().name())); //设定商品价格 From 99479e722a548734c818c27d79ddd3094edaf59e Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 26 Jul 2022 19:18:01 +0800 Subject: [PATCH 175/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=8F=91=E9=80=81=E4=BC=9A=E5=91=98=E6=B3=A8=E5=86=8C=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/TransactionCommitSendMQEvent.java | 4 +-- .../serviceimpl/ConnectServiceImpl.java | 20 +++++++++++--- .../member/serviceimpl/MemberServiceImpl.java | 26 +++++++------------ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java b/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java index 9f16c1e4..7b3d2e73 100644 --- a/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java +++ b/framework/src/main/java/cn/lili/common/event/TransactionCommitSendMQEvent.java @@ -21,9 +21,9 @@ public class TransactionCommitSendMQEvent extends ApplicationEvent { private final String tag; @Getter - private final String message; + private final Object message; - public TransactionCommitSendMQEvent(Object source, String topic, String tag, String message) { + public TransactionCommitSendMQEvent(Object source, String topic, String tag, Object message) { super(source); this.topic = topic; this.tag = tag; diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index e910a6c7..942bf897 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -8,7 +8,9 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.context.ThreadContextHolder; import cn.lili.common.enums.ClientTypeEnum; import cn.lili.common.enums.ResultCode; +import cn.lili.common.event.TransactionCommitSendMQEvent; import cn.lili.common.exception.ServiceException; +import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.common.security.AuthUser; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.token.Token; @@ -29,11 +31,13 @@ import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting; import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem; import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; +import cn.lili.rocketmq.tags.MemberTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -66,6 +70,14 @@ public class ConnectServiceImpl extends ServiceImpl impl private MemberTokenGenerate memberTokenGenerate; @Autowired private Cache cache; + /** + * RocketMQ 配置 + */ + @Autowired + private RocketmqCustomProperties rocketmqCustomProperties; + + @Autowired + private ApplicationEventPublisher applicationEventPublisher; @Override @Transactional(rollbackFor = Exception.class) @@ -235,6 +247,8 @@ public class ConnectServiceImpl extends ServiceImpl impl memberService.save(newMember); newMember = memberService.findByUsername(newMember.getUsername()); bindMpMember(openId, unionId, newMember); + // 发送会员注册信息 + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), newMember)); return memberTokenGenerate.createToken(newMember, true); } @@ -262,9 +276,9 @@ public class ConnectServiceImpl extends ServiceImpl impl * 这样,微信小程序注册之后,其他app 公众号页面,都可以实现绑定自动登录功能 *

* - * @param openId 微信openid - * @param unionId 微信unionid - * @param member 会员 + * @param openId 微信openid + * @param unionId 微信unionid + * @param member 会员 */ private void bindMpMember(String openId, String unionId, Member member) { diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index c7eb0a70..71397bbf 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.context.ThreadContextHolder; 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.AuthUser; @@ -35,7 +36,6 @@ import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.entity.enums.StoreStatusEnum; import cn.lili.modules.store.service.StoreService; import cn.lili.mybatis.util.PageUtil; -import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.MemberTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -43,8 +43,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.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -88,11 +88,9 @@ public class MemberServiceImpl extends ServiceImpl impleme */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; - /** - * RocketMQ - */ + @Autowired - private RocketMQTemplate rocketMQTemplate; + private ApplicationEventPublisher applicationEventPublisher; /** * 缓存 */ @@ -247,8 +245,8 @@ public class MemberServiceImpl extends ServiceImpl impleme member.setId(SnowFlake.getIdStr()); //保存会员 this.save(member); - String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name(); - rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback()); + // 发送会员注册信息 + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), member)); } @Override @@ -288,10 +286,7 @@ public class MemberServiceImpl extends ServiceImpl impleme throw new ServiceException(ResultCode.USER_NOT_LOGIN); } Member member = this.getById(tokenUser.getId()); - if (member.getPassword().equals(DEFAULT_PASSWORD)) { - return true; - } - return false; + return member.getPassword().equals(DEFAULT_PASSWORD); } @@ -350,8 +345,7 @@ public class MemberServiceImpl extends ServiceImpl impleme Member member = new Member(userName, new BCryptPasswordEncoder().encode(password), mobilePhone); //注册成功后用户自动登录 registerHandler(member); - Token token = memberTokenGenerate.createToken(member, false); - return token; + return memberTokenGenerate.createToken(member, false); } @Override @@ -463,8 +457,8 @@ public class MemberServiceImpl extends ServiceImpl impleme memberPointMessage.setPoint(point); memberPointMessage.setType(type); memberPointMessage.setMemberId(memberId); - String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_POINT_CHANGE.name(); - rocketMQTemplate.asyncSend(destination, memberPointMessage, RocketmqSendCallbackBuilder.commonCallback()); + // 发送会员注册信息 + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), member)); return true; } return false; From a2a923809e89feec9e075f30ada226a210909003 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 27 Jul 2022 12:06:47 +0800 Subject: [PATCH 176/185] add transactional --- .../modules/member/serviceimpl/MemberServiceImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 71397bbf..a26632cf 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -180,6 +180,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @Transactional public Token autoRegister(ConnectAuthUser authUser) { if (CharSequenceUtil.isEmpty(authUser.getNickname())) { @@ -223,6 +224,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @Transactional public Token mobilePhoneLogin(String mobilePhone) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("mobile", mobilePhone); @@ -241,7 +243,8 @@ public class MemberServiceImpl extends ServiceImpl impleme * * @param member */ - private void registerHandler(Member member) { + @Transactional + public void registerHandler(Member member) { member.setId(SnowFlake.getIdStr()); //保存会员 this.save(member); @@ -338,6 +341,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @Transactional public Token register(String userName, String password, String mobilePhone) { //检测会员信息 checkMember(userName, mobilePhone); @@ -382,6 +386,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @Transactional public Member addMember(MemberAddDTO memberAddDTO) { //检测会员信息 @@ -458,7 +463,7 @@ public class MemberServiceImpl extends ServiceImpl impleme memberPointMessage.setType(type); memberPointMessage.setMemberId(memberId); // 发送会员注册信息 - applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), member)); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("update member point", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_POINT_CHANGE.name(), memberPointMessage)); return true; } return false; From ed976e90dcaedd55321a6f01aaa0c8ac4aaaeba9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 27 Jul 2022 17:21:48 +0800 Subject: [PATCH 177/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=83=E9=94=80?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=95=86=E5=93=81=EF=BC=8C=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=98=AF=E5=90=A6=E5=8F=AF=E4=BB=A5=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E4=BF=83=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/service/GoodsSkuService.java | 10 ++++- .../serviceimpl/GoodsSkuServiceImpl.java | 10 +++++ .../member/serviceimpl/MemberServiceImpl.java | 1 - .../serviceimpl/CouponServiceImpl.java | 2 +- .../KanjiaActivityGoodsServiceImpl.java | 6 +-- .../KanjiaActivityServiceImpl.java | 2 +- .../serviceimpl/PintuanServiceImpl.java | 2 +- .../serviceimpl/PointsGoodsServiceImpl.java | 2 +- .../PromotionGoodsServiceImpl.java | 39 +------------------ .../serviceimpl/SeckillApplyServiceImpl.java | 6 +-- 10 files changed, 30 insertions(+), 50 deletions(-) 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 8a322a79..a78f9bb0 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 @@ -82,6 +82,14 @@ public interface GoodsSkuService extends IService { */ GoodsSku getGoodsSkuByIdFromCache(String id); + /** + * 从缓存中获取可参与促销商品 + * + * @param skuId skuid + * @return 商品详情 + */ + GoodsSku getCanPromotionGoodsSkuByIdFromCache(String skuId); + /** * 获取商品sku详情 * @@ -143,7 +151,7 @@ public interface GoodsSkuService extends IService { /** * 分页查询商品sku信息 * - * @param page 分页参数 + * @param page 分页参数 * @param queryWrapper 查询参数 * @return 商品sku信息 */ diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 5ab87344..5438ae95 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 @@ -22,6 +22,7 @@ import cn.lili.modules.goods.entity.dto.GoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO; import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; +import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO; import cn.lili.modules.goods.entity.vos.GoodsSkuVO; @@ -237,6 +238,15 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return goodsSku; } + @Override + public GoodsSku getCanPromotionGoodsSkuByIdFromCache(String skuId) { + GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); + if (goodsSku != null && GoodsSalesModeEnum.WHOLESALE.name().equals(goodsSku.getSalesModel())) { + throw new ServiceException(ResultCode.PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE, goodsSku.getGoodsName()); + } + return goodsSku; + } + @Override public Map getGoodsSkuDetail(String goodsId, String skuId) { Map map = new HashMap<>(16); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index a26632cf..86031a0c 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -462,7 +462,6 @@ public class MemberServiceImpl extends ServiceImpl impleme memberPointMessage.setPoint(point); memberPointMessage.setType(type); memberPointMessage.setMemberId(memberId); - // 发送会员注册信息 applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("update member point", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_POINT_CHANGE.name(), memberPointMessage)); return true; } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 4f08616f..167fd2eb 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -291,7 +291,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl promotionGoods = PromotionTools.promotionGoodsInit(pintuan.getPromotionGoodsList(), pintuan, PromotionTypeEnum.PINTUAN); for (PromotionGoods promotionGood : promotionGoods) { - if (goodsSkuService.getGoodsSkuByIdFromCache(promotionGood.getSkuId()) == null) { + if (goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(promotionGood.getSkuId()) == null) { log.error("商品[" + promotionGood.getGoodsName() + "]不存在或处于不可售卖状态!"); throw new ServiceException("商品[" + promotionGood.getGoodsName() + "]不存在或处于不可售卖状态!"); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java index 95f37f19..2be950f4 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PointsGoodsServiceImpl.java @@ -278,7 +278,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl findSkuValidPromotion(String skuId, String storeIds) { - GoodsSku sku = goodsSkuService.getGoodsSkuByIdFromCache(skuId); + GoodsSku sku = goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(skuId); if (sku == null) { return new ArrayList<>(); } @@ -316,40 +313,6 @@ public class PromotionGoodsServiceImpl extends ServiceImpl entityList) { - for (PromotionGoods promotionGoods : entityList) { - this.checkGoodsSku(promotionGoods.getSkuId()); - } - return super.saveBatch(entityList); - } - - @Override - public boolean saveOrUpdateBatch(Collection entityList) { - for (PromotionGoods promotionGoods : entityList) { - this.checkGoodsSku(promotionGoods.getSkuId()); - } - return super.saveOrUpdateBatch(entityList); - } - - /** - * 检查是否为不能参加促销活动的商品 - * - * @param skuId 商品skuId - */ - private void checkGoodsSku(String skuId) { - GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(skuId); - if (goodsSku != null && GoodsSalesModeEnum.WHOLESALE.name().equals(goodsSku.getSalesModel())) { - throw new ServiceException(ResultCode.PROMOTION_GOODS_DO_NOT_JOIN_WHOLESALE, goodsSku.getGoodsName()); - } - } - private void setGoodsPromotionInfo(GoodsSku dataSku, Map.Entry promotionInfo) { JSONObject promotionsObj = JSONUtil.parseObj(promotionInfo.getValue()); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 07572e9c..6d5eaec9 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -161,7 +161,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl promotionGoodsList = new ArrayList<>(); for (SeckillApplyVO seckillApply : seckillApplyList) { //获取参与活动的商品信息 - GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(seckillApply.getSkuId()); + GoodsSku goodsSku = goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(seckillApply.getSkuId()); if (!goodsSku.getStoreId().equals(storeId)) { continue; } @@ -262,7 +262,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl list = this.list(queryWrapper).stream().filter(i -> i.getTimeLine() != null && seckill.getHours().contains(i.getTimeLine().toString())).collect(Collectors.toList()); for (SeckillApply seckillApply : list) { //获取参与活动的商品信息 - GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(seckillApply.getSkuId()); + GoodsSku goodsSku = goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(seckillApply.getSkuId()); //获取促销商品 PromotionGoods promotionGoods = this.setSeckillGoods(goodsSku, seckillApply, seckill); promotionGoodsList.add(promotionGoods); @@ -373,7 +373,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl collect = seckillApplyList.stream().filter(i -> i.getTimeLine().equals(startTimeline) && i.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())).collect(Collectors.toList()); for (SeckillApply seckillApply : collect) { - GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(seckillApply.getSkuId()); + GoodsSku goodsSku = goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(seckillApply.getSkuId()); if (goodsSku != null) { SeckillGoodsVO goodsVO = new SeckillGoodsVO(); BeanUtil.copyProperties(seckillApply, goodsVO); From 40bf6d3010526f94a8afad89bb6f36eb2ed141a4 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 27 Jul 2022 22:13:56 +0800 Subject: [PATCH 178/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=A7=92=E6=9D=80=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/serviceimpl/SeckillApplyServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 6d5eaec9..7369ff78 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -339,7 +339,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl= hour || ((i + 1) < hoursSored.length && hoursSored[i + 1] > hour) || hoursSored.length == 1); + boolean hoursSoredHour = (hoursSored[i] >= hour || i + 1 == hoursSored.length); if (hoursSoredHour) { SimpleDateFormat format = new SimpleDateFormat(DatePattern.NORM_DATE_PATTERN); String date = format.format(new Date()); From fdf81d1b39baf715c0e015d83a266290eb8c0a1a Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 2 Aug 2022 10:51:10 +0800 Subject: [PATCH 179/185] =?UTF-8?q?=E5=88=86=E8=AF=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/entity/dos/CustomWords.java | 5 ++ .../serviceimpl/EsGoodsIndexServiceImpl.java | 49 ++++++++++++------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java index 4b53e75f..00d7ab44 100644 --- a/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java +++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/CustomWords.java @@ -11,6 +11,7 @@ import lombok.NoArgsConstructor; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotEmpty; +import java.util.Date; /** * 自定义分词 @@ -41,4 +42,8 @@ public class CustomWords extends BaseEntity { private Integer disabled; + public CustomWords(String name) { + this.name = name; + this.disabled = 0; + } } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 4695102d..a2054507 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -283,38 +283,51 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements */ private void analyzeAndSaveWords(EsGoodsIndex goods) { try { - //分词器分词 - AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(getIndexName(), "ik_max_word", goods.getGoodsName()); - AnalyzeResponse analyze = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT); - List tokens = analyze.getTokens(); - List customWordsList = new ArrayList<>(); List keywordsList = new ArrayList<>(); + //根据商品参数分词 if (goods.getAttrList() != null && !goods.getAttrList().isEmpty()) { //保存分词 for (EsGoodsAttribute esGoodsAttribute : goods.getAttrList()) { if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(esGoodsAttribute.getValue().toLowerCase(Locale.ROOT)))) { keywordsList.add(esGoodsAttribute.getValue()); - customWordsList.add(new CustomWords(esGoodsAttribute.getValue(), 0)); } } } - //分析词条 - for (AnalyzeResponse.AnalyzeToken token : tokens) { - if (keywordsList.stream().noneMatch(i -> i.toLowerCase(Locale.ROOT).equals(token.getTerm().toLowerCase(Locale.ROOT)))) { - keywordsList.add(token.getTerm()); - customWordsList.add(new CustomWords(token.getTerm(), 0)); + //根据商品名称生成分词 + keywordsList.add(goods.getGoodsName().substring(0, Math.min(goods.getGoodsName().length(), 10))); + + //如果有分词 + if (!keywordsList.isEmpty()) { + //去除重复词 + removeDuplicate(keywordsList); + //入库自定义分词 + List customWordsArrayList = new ArrayList<>(); + keywordsList.stream().forEach(item -> { + customWordsArrayList.add(new CustomWords(item)); + }); + //这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大 + if (CollUtil.isNotEmpty(customWordsArrayList)) { + customWordsService.deleteBathByName(keywordsList); + customWordsService.insertBatchCustomWords(customWordsArrayList); } - //保存词条进入数据库 } - if (CollUtil.isNotEmpty(customWordsList)) { - customWordsService.deleteBathByName(keywordsList); - customWordsService.insertBatchCustomWords(customWordsList); - } - } catch (IOException e) { - log.info(goods + "分词错误", e); + } catch (Exception e) { + log.info(goods + "自定义分词错误", e); } } + /** + * 去除 重复元素 + * + * @param list + * @return + */ + public static void removeDuplicate(List list) { + HashSet h = new HashSet(list); + list.clear(); + list.addAll(h); + } + /** * 更新商品索引的的部分属性(只填写更新的字段,不需要更新的字段不要填写) * From b860c2eed0f97de04ef5495b3abf752cd8164b0b Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 2 Aug 2022 10:52:47 +0800 Subject: [PATCH 180/185] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EsGoodsIndexServiceImpl.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index a2054507..1d3ed8ca 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -296,20 +296,15 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //根据商品名称生成分词 keywordsList.add(goods.getGoodsName().substring(0, Math.min(goods.getGoodsName().length(), 10))); - //如果有分词 - if (!keywordsList.isEmpty()) { - //去除重复词 - removeDuplicate(keywordsList); - //入库自定义分词 - List customWordsArrayList = new ArrayList<>(); - keywordsList.stream().forEach(item -> { - customWordsArrayList.add(new CustomWords(item)); - }); - //这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大 - if (CollUtil.isNotEmpty(customWordsArrayList)) { - customWordsService.deleteBathByName(keywordsList); - customWordsService.insertBatchCustomWords(customWordsArrayList); - } + //去除重复词 + removeDuplicate(keywordsList); + //入库自定义分词 + List customWordsArrayList = new ArrayList<>(); + keywordsList.forEach(item -> customWordsArrayList.add(new CustomWords(item))); + //这里采用先批量删除再插入的方法,故意这么做。否则需要挨个匹配是否存在,性能消耗更大 + if (CollUtil.isNotEmpty(customWordsArrayList)) { + customWordsService.deleteBathByName(keywordsList); + customWordsService.insertBatchCustomWords(customWordsArrayList); } } catch (Exception e) { log.info(goods + "自定义分词错误", e); From 002163fbdcf46baa038d61ebe773d7b9ed4556b1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Tue, 2 Aug 2022 15:21:00 +0800 Subject: [PATCH 181/185] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E7=94=9F=E6=88=90=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/serviceimpl/PromotionGoodsServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index b00b98a7..1eda7644 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -72,7 +72,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl findSkuValidPromotion(String skuId, String storeIds) { - GoodsSku sku = goodsSkuService.getCanPromotionGoodsSkuByIdFromCache(skuId); + GoodsSku sku = goodsSkuService.getGoodsSkuByIdFromCache(skuId); if (sku == null) { return new ArrayList<>(); } From ecd40523d4a7d1c7d6df060b53d19265b5a31111 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 4 Aug 2022 11:17:14 +0800 Subject: [PATCH 182/185] =?UTF-8?q?=20=E6=BC=94=E7=A4=BA=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E9=99=90=E5=88=B6=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/serviceimpl/MemberServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 86031a0c..0194434b 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; +import cn.lili.common.aop.annotation.DemoSite; import cn.lili.common.context.ThreadContextHolder; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; @@ -264,6 +265,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @DemoSite public Member modifyPass(String oldPassword, String newPassword) { AuthUser tokenUser = UserContext.getCurrentUser(); if (tokenUser == null) { From 98b863be6f510d3e508b987404686ef024b16aed Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 5 Aug 2022 17:14:20 +0800 Subject: [PATCH 183/185] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E9=AA=8C=E8=AF=81=E5=AD=98=E5=9C=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java index 0400c246..567594bf 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java @@ -49,7 +49,6 @@ public class StoreEditDTO { @ApiModelProperty(value = "公司地址地区") private String companyAddressPath; - @Mobile @ApiModelProperty(value = "公司电话") private String companyPhone; From c38a8c0475d63409869650f8654d91aa325e8239 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 8 Aug 2022 09:14:15 +0800 Subject: [PATCH 184/185] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/system/serviceimpl/RegionServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java index dfb8863e..cccf1860 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java @@ -75,7 +75,7 @@ public class RegionServiceImpl extends ServiceImpl impleme Region region = this.getOne(lambdaQueryWrapper, false); if (region != null) { sql.append(region.getPath()).append(",").append(region.getId()); - return sql.toString().replace(",0,",""); + return sql.toString().replace(",0,", ""); } return null; } @@ -92,9 +92,9 @@ public class RegionServiceImpl extends ServiceImpl impleme @Override public Map getRegion(String cityCode, String townName) { //获取地址信息 - Region region = this.baseMapper.selectOne(new QueryWrapper() + Region region = this.getOne(new QueryWrapper() .eq("city_code", cityCode) - .eq("name", townName)); + .eq("name", townName), false); if (region != null) { //获取它的层级关系 String path = region.getPath(); From 72c58059bd4a70603ba441a7b916940743becfe9 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 9 Aug 2022 16:08:54 +0800 Subject: [PATCH 185/185] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E5=88=9B=E5=BB=BA=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/common/enums/ResultCode.java | 14 ++++++++------ .../modules/store/entity/dto/StoreEditDTO.java | 1 - .../promotion/CouponActivityManagerController.java | 7 ++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 068d7ad5..8ce9a886 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -278,11 +278,6 @@ public enum ResultCode { COUPON_RECEIVE_ERROR(41005, "当前优惠券已经被领取完了,下次要早点来哦"), COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"), COUPON_NOT_EXIST(41007, "当前优惠券不存在"), - COUPON_DO_NOT_RECEIVER(41030, "当前优惠券不允许主动领取"), - COUPON_ACTIVITY_NOT_EXIST(410022, "当前优惠券活动不存在"), - COUPON_SAVE_ERROR(41020, "保存优惠券失败"), - COUPON_ACTIVITY_SAVE_ERROR(41023, "保存优惠券活动失败"), - COUPON_DELETE_ERROR(41021, "删除优惠券失败"), COUPON_LIMIT_NUM_LESS_THAN_0(41008, "领取限制数量不能为负数"), COUPON_LIMIT_GREATER_THAN_PUBLISH(41009, "领取限制数量超出发行数量"), COUPON_DISCOUNT_ERROR(41010, "优惠券折扣必须小于10且大于0"), @@ -293,8 +288,15 @@ public enum ResultCode { COUPON_MEMBER_NOT_EXIST(41015, "没有当前会员优惠券"), COUPON_MEMBER_STATUS_ERROR(41016, "当前会员优惠券已过期/作废无法变更状态!"), - SPECIAL_CANT_USE(41020, "特殊商品不能使用优惠券,不能使用"), + SPECIAL_CANT_USE(41019, "特殊商品不能使用优惠券,不能使用"), + COUPON_SAVE_ERROR(41020, "保存优惠券失败"), + COUPON_DELETE_ERROR(41021, "删除优惠券失败"), + COUPON_ACTIVITY_NOT_EXIST(41022, "当前优惠券活动不存在"), + COUPON_ACTIVITY_SAVE_ERROR(41023, "保存优惠券活动失败"), + COUPON_ACTIVITY_MAX_NUM(41024, "优惠券活动赠券数量最多为3"), + + COUPON_DO_NOT_RECEIVER(41030, "当前优惠券不允许主动领取"), /** * 拼团 diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java index 567594bf..4c460945 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java @@ -1,6 +1,5 @@ package cn.lili.modules.store.entity.dto; -import cn.lili.common.validation.Mobile; import cn.lili.common.validation.Phone; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/CouponActivityManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/CouponActivityManagerController.java index 635d9ff1..e2c4cbf6 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/CouponActivityManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/CouponActivityManagerController.java @@ -6,6 +6,7 @@ import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.promotion.entity.dos.CouponActivity; +import cn.lili.modules.promotion.entity.dos.CouponActivityItem; import cn.lili.modules.promotion.entity.dto.CouponActivityDTO; import cn.lili.modules.promotion.entity.vos.CouponActivityVO; import cn.lili.modules.promotion.service.CouponActivityService; @@ -49,8 +50,12 @@ public class CouponActivityManagerController { @ApiOperation(value = "添加优惠券活动") @PostMapping - @PutMapping(consumes = "application/json", produces = "application/json") public ResultMessage addCouponActivity(@RequestBody(required = false) CouponActivityDTO couponActivityDTO) { + for (CouponActivityItem couponActivityItem : couponActivityDTO.getCouponActivityItems()) { + if (couponActivityItem.getNum() > 3) { + throw new ServiceException(ResultCode.COUPON_ACTIVITY_MAX_NUM); + } + } if (couponActivityService.savePromotions(couponActivityDTO)) { return ResultUtil.data(couponActivityDTO); }