From 44d6edd53b7955d2047bf7b39d81a168b0df409f Mon Sep 17 00:00:00 2001 From: lifenlong Date: Tue, 15 Jun 2021 09:59:32 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=BC=94=E7=A4=BA=E7=AB=99=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/goods/serviceimpl/CategoryServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 b4207081..0e617814 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 @@ -168,6 +168,7 @@ public class CategoryServiceImpl extends ServiceImpl i Category parentCategory = this.getById(category.getParentId()); category.setDeleteFlag(parentCategory.getDeleteFlag()); } + this.save(category); removeCache(); return true; } From 00182f5cfb710cd237be6fd0ebb456b2dfdfe2d1 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 16 Jun 2021 10:49:17 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E9=99=90=E5=88=B6=E5=AE=98=E7=BD=91?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/setting/RegionManagerController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java index 436de03a..ff6ce5d5 100644 --- a/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/RegionManagerController.java @@ -2,6 +2,7 @@ package cn.lili.controller.setting; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; +import cn.lili.modules.base.aspect.DemoSite; import cn.lili.modules.base.service.RegionService; import cn.lili.modules.system.entity.dos.Region; import io.swagger.annotations.Api; @@ -29,6 +30,7 @@ public class RegionManagerController { @Autowired private RegionService regionService; + @DemoSite @PostMapping(value = "/sync") @ApiOperation(value = "同步高德行政地区数据") public void synchronizationData(String url) { From 6205693df6c315efb5b2ecaa1ef1dfb36065d864 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 16 Jun 2021 15:54:54 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=B3=A8=E8=A7=86=EF=BC=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AE=9Dh5=E6=94=AF=E4=BB=98=E6=97=A5=E5=BF=97=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/serviceimpl/OrderServiceImpl.java | 11 ++++++++--- .../payment/kit/plugin/alipay/AliPayRequest.java | 5 +++-- 2 files changed, 11 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 c7178617..f8ebe134 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 @@ -121,16 +121,21 @@ public class OrderServiceImpl extends ServiceImpl implements @Override public void intoDB(TradeDTO tradeDTO) { + //存放购物车,即业务中的订单 List orders = new ArrayList<>(tradeDTO.getCartList().size()); + //存放自订单/订单日志 List orderItems = new ArrayList<>(); List orderLogs = new ArrayList<>(); + //拼团判定,不能参与自己创建的拼团 if (tradeDTO.getParentOrderSn() != null) { Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn()); if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) { throw new ServiceException("不能参与自己发起的拼团活动!"); } } - List list = new ArrayList<>(); + //订单集合 + List orderVOS = new ArrayList<>(); + //循环购物车商品集合 tradeDTO.getCartList().forEach(item -> { Order order = new Order(item, tradeDTO); if (OrderTypeEnum.PINTUAN.name().equals(order.getOrderType())) { @@ -150,9 +155,9 @@ public class OrderServiceImpl extends ServiceImpl implements sku -> orderItems.add(new OrderItem(sku, item, tradeDTO)) ); orderVO.setOrderItems(orderItems); - list.add(orderVO); + orderVOS.add(orderVO); }); - tradeDTO.setOrderVO(list); + tradeDTO.setOrderVO(orderVOS); //批量保存订单 this.saveBatch(orders); //批量保存 子订单 diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayRequest.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayRequest.java index ceb0d134..f721a281 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayRequest.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayRequest.java @@ -13,6 +13,7 @@ import com.alipay.api.request.AlipayTradePrecreateRequest; import com.alipay.api.request.AlipayTradeWapPayRequest; import com.alipay.api.response.AlipayTradeAppPayResponse; import com.alipay.api.response.AlipayTradePrecreateResponse; +import lombok.extern.slf4j.Slf4j; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -24,7 +25,7 @@ import java.io.PrintWriter; * @author Chopper * @date 2020/12/15 19:26 */ - +@Slf4j public class AliPayRequest { /** @@ -40,7 +41,7 @@ public class AliPayRequest { public static void wapPay(HttpServletResponse response, AlipayTradeWapPayModel model, String returnUrl, String notifyUrl) throws AlipayApiException, IOException { String form = wapPayStr(model, returnUrl, notifyUrl); response.setContentType("text/html;charset=UTF-8"); - + log.info("支付表单{}", form); PrintWriter out = response.getWriter(); out.write(form); out.flush(); From c69cd0c22d6015f4e27a7ec4b74dc1a5675d75c9 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 17 Jun 2021 09:11:16 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=BC=E5=9B=A2?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=8B=E5=8D=95=E9=97=AE=E9=A2=98=E5=92=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E6=98=AF=E5=90=A6=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/goods/entity/dos/Goods.java | 11 ++++ .../serviceimpl/GoodsSkuServiceImpl.java | 52 +++++++++++----- .../modules/order/order/entity/dos/Order.java | 3 +- .../search/entity/dos/EsGoodsIndex.java | 59 ++++++++++--------- .../other/ElasticsearchController.java | 41 +++++++++++-- 5 files changed, 116 insertions(+), 50 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 c0e50d69..253f36ab 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 @@ -1,15 +1,18 @@ package cn.lili.modules.goods.entity.dos; +import cn.hutool.json.JSONUtil; import cn.lili.base.BaseEntity; 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 com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import javax.validation.constraints.Max; @@ -187,6 +190,11 @@ public class Goods extends BaseEntity { @ApiModelProperty(value = "销售模式", required = true) private String salesModel; + @ApiModelProperty(value = "商品参数json", hidden = true) + @Column(columnDefinition = "TEXT") + @JsonIgnore + private String params; + public Goods() { } @@ -207,6 +215,9 @@ public class Goods extends BaseEntity { this.intro = goodsOperationDTO.getIntro(); this.mobileIntro = goodsOperationDTO.getMobileIntro(); this.cost = goodsOperationDTO.getCost(); + if (goodsOperationDTO.getGoodsParamsList() != null && goodsOperationDTO.getGoodsParamsList().isEmpty()) { + this.params = JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsList()); + } //如果立即上架则 this.marketEnable = goodsOperationDTO.isRelease() ? GoodsStatusEnum.UPPER.name() : GoodsStatusEnum.DOWN.name(); 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 6959fc89..d2c8def3 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 @@ -11,10 +11,7 @@ import cn.lili.common.rocketmq.tags.GoodsTagsEnum; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.PageUtil; import cn.lili.config.rocketmq.RocketmqCustomProperties; -import cn.lili.modules.goods.entity.dos.Goods; -import cn.lili.modules.goods.entity.dos.GoodsSku; -import cn.lili.modules.goods.entity.dos.SpecValues; -import cn.lili.modules.goods.entity.dos.Specification; +import cn.lili.modules.goods.entity.dos.*; 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,6 +23,7 @@ import cn.lili.modules.member.entity.dos.FootPrint; import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.service.MemberEvaluationService; +import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsAttribute; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; @@ -83,14 +81,20 @@ public class GoodsSkuServiceImpl extends ServiceImpl i private GoodsService goodsService; //商品索引 private EsGoodsIndexService goodsIndexService; + @Autowired + private ParametersService parametersService; + @Autowired + private PromotionService promotionService; @Override public void add(List> skuList, Goods goods) { + // 检查是否需要生成索引 + boolean needIndex = checkNeedIndex(goods); List newSkuList; // 如果有规格 if (skuList != null && !skuList.isEmpty()) { // 添加商品sku - newSkuList = this.addGoodsSku(skuList, goods); + newSkuList = this.addGoodsSku(skuList, goods, needIndex); } else { throw new ServiceException("规格必须要有一个!"); } @@ -99,8 +103,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl i generateEsCheck(goods); } + private boolean checkNeedIndex(Goods goods) { + if (goods.getParams() != null && !goods.getParams().isEmpty()) { + List goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class); + for (GoodsParams goodsParam : goodsParams) { + Parameters parameters = parametersService.getById(goodsParam.getParamId()); + if (parameters.getIsIndex() == 1) { + return true; + } + } + } + return false; + } + @Override public void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag) { + // 检查是否需要生成索引 + boolean needIndex = checkNeedIndex(goods); // 是否存在规格 if (skuList == null || skuList.isEmpty()) { throw new ServiceException("规格必须要有一个!"); @@ -120,7 +139,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //删除sku相册 goodsGalleryService.removeByIds(oldSkuIds); // 添加商品sku - newSkuList = this.addGoodsSku(skuList, goods); + newSkuList = this.addGoodsSku(skuList, goods, needIndex); //发送mq消息 String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.SKU_DELETE.name(); @@ -142,7 +161,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i this.updateBatchById(newSkuList); } this.updateStock(newSkuList); - generateEsCheck(goods); + if (Boolean.TRUE.equals(needIndex)) { + generateEsCheck(goods); + } } /** @@ -198,7 +219,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i // 获取当前商品的索引信息 EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); if (goodsIndex == null) { - goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku); + goodsIndex = new EsGoodsIndex(goodsSku); + goodsIndex.setPromotionMap(promotionService.getGoodsCurrentPromotionMap(goodsIndex)); } //商品规格 GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku); @@ -416,7 +438,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //修改规格 this.update(goodsSku); //修改规格索引 - goodsIndexService.updateIndexCommentNum(goodsSku.getId(), goodsSku.getCommentNum(), (int) highPraiseNum, grade); + goodsIndexService.updateIndexCommentNum(goodsSku.getId(), goodsSku.getCommentNum(), highPraiseNum, grade); //修改商品的评价数量 goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); @@ -479,7 +501,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param skuList sku列表 * @param goods 商品信息 */ - private List addGoodsSku(List> skuList, Goods goods) { + private List addGoodsSku(List> skuList, Goods goods, Boolean needIndex) { List skus = new ArrayList<>(); List goodsIndices = new ArrayList<>(); for (Map skuVO : skuList) { @@ -494,9 +516,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl i stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString()); } this.saveBatch(skus); - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIndices), RocketmqSendCallbackBuilder.commonCallback()); + if (Boolean.TRUE.equals(needIndex)) { + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); + //发送mq消息 + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIndices), RocketmqSendCallbackBuilder.commonCallback()); + } return skus; } @@ -615,7 +639,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i sku.setThumbnail(thumbnail); //规格信息 - sku.setId(Convert.toStr(map.get("id"), "").toString()); + 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)); 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 a1418dca..78ebeac1 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 @@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil; import cn.lili.base.BaseEntity; import cn.lili.common.utils.BeanUtil; import cn.lili.modules.base.entity.enums.ClientTypeEnum; +import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.DeliverStatusEnum; @@ -210,7 +211,7 @@ public class Order extends BaseEntity { this.setId(oldId); this.setOrderType(OrderTypeEnum.NORMAL.name()); //促销信息填充 - if (cartVO.getSkuList().get(0).getPromotions() != null) { + if (cartVO.getSkuList().get(0).getPromotions() != null && tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN)) { Optional pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst(); if (pintuanId.isPresent()) { promotionId = pintuanId.get(); 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 76f54d9e..e9ccef56 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 @@ -25,6 +25,7 @@ import java.util.Map; /** * 商品索引 + * * @author paulG * @date 2020/10/13 **/ @@ -243,35 +244,6 @@ public class EsGoodsIndex implements Serializable { private Map promotionMap; - public void setGoodsSku(GoodsSku sku) { - if (sku != null) { - this.id = sku.getId(); - this.goodsId = sku.getGoodsId(); - this.goodsName = sku.getGoodsName(); - this.price = sku.getPrice(); - this.storeName = sku.getStoreName(); - this.storeId = sku.getStoreId(); - this.thumbnail = sku.getThumbnail(); - this.categoryPath = sku.getCategoryPath(); - this.goodsVideo = sku.getGoodsVideo(); - this.mobileIntro = sku.getMobileIntro(); - this.buyCount = sku.getBuyCount(); - this.commentNum = sku.getCommentNum(); - this.small = sku.getSmall(); - this.brandId = sku.getBrandId(); - this.sn = sku.getSn(); - this.storeCategoryPath = sku.getStoreCategoryPath(); - this.sellingPoint = sku.getSellingPoint(); - this.selfOperated = sku.getSelfOperated(); - this.salesModel = sku.getSalesModel(); - this.marketEnable = sku.getMarketEnable(); - this.isAuth = sku.getIsAuth(); - this.intro = sku.getIntro(); - this.grade = sku.getGrade(); - this.releaseTime = new Date(); - } - } - public EsGoodsIndex(GoodsSku sku) { if (sku != null) { this.id = sku.getId(); @@ -315,4 +287,33 @@ public class EsGoodsIndex implements Serializable { } } + + public void setGoodsSku(GoodsSku sku) { + if (sku != null) { + this.id = sku.getId(); + this.goodsId = sku.getGoodsId(); + this.goodsName = sku.getGoodsName(); + this.price = sku.getPrice(); + this.storeName = sku.getStoreName(); + this.storeId = sku.getStoreId(); + this.thumbnail = sku.getThumbnail(); + this.categoryPath = sku.getCategoryPath(); + this.goodsVideo = sku.getGoodsVideo(); + this.mobileIntro = sku.getMobileIntro(); + this.buyCount = sku.getBuyCount(); + this.commentNum = sku.getCommentNum(); + this.small = sku.getSmall(); + this.brandId = sku.getBrandId(); + this.sn = sku.getSn(); + this.storeCategoryPath = sku.getStoreCategoryPath(); + this.sellingPoint = sku.getSellingPoint(); + this.selfOperated = sku.getSelfOperated(); + this.salesModel = sku.getSalesModel(); + this.marketEnable = sku.getMarketEnable(); + this.isAuth = sku.getIsAuth(); + this.intro = sku.getIntro(); + this.grade = sku.getGrade(); + this.releaseTime = new Date(); + } + } } 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 25f8a32f..7c2141e8 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 @@ -1,9 +1,15 @@ package cn.lili.controller.other; +import cn.hutool.json.JSONUtil; +import cn.lili.modules.goods.entity.dos.Goods; +import cn.lili.modules.goods.entity.dos.GoodsParams; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.dos.Parameters; 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.goods.service.ParametersService; import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsIndexService; @@ -38,12 +44,18 @@ public class ElasticsearchController { @Autowired private GoodsSkuService goodsSkuService; + @Autowired + private GoodsService goodsService; + @Autowired private StringRedisTemplate stringRedisTemplate; @Autowired private PromotionService promotionService; + @Autowired + private ParametersService parametersService; + @GetMapping public void init() { //查询商品信息 @@ -53,16 +65,33 @@ public class ElasticsearchController { List list = goodsSkuService.list(queryWrapper); List esGoodsIndices = new ArrayList<>(); + String goodsId = null; //库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量 for (GoodsSku goodsSku : list) { - EsGoodsIndex index = new EsGoodsIndex(goodsSku); - Map goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); - index.setPromotionMap(goodsCurrentPromotionMap); - esGoodsIndices.add(index); - stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString()); + boolean needIndex = false; + if (goodsId == null || !goodsId.equals(goodsSku.getGoodsId())) { + goodsId = goodsSku.getGoodsId(); + Goods goods = goodsService.getById(goodsId); + if (goods.getParams() != null && !goods.getParams().isEmpty()) { + List goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class); + for (GoodsParams goodsParam : goodsParams) { + Parameters parameters = parametersService.getById(goodsParam.getParamId()); + if (parameters.getIsIndex() == 1) { + needIndex = true; + break; + } + } + } + } + if (Boolean.TRUE.equals(needIndex)) { + EsGoodsIndex index = new EsGoodsIndex(goodsSku); + Map goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); + index.setPromotionMap(goodsCurrentPromotionMap); + esGoodsIndices.add(index); + stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString()); + } } //初始化商品索引 esGoodsIndexService.initIndex(esGoodsIndices); - Assertions.assertTrue(true); } } From 7ce5b517fc092f0ab7d161e5d044e563bd80e7a6 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 10:37:11 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=EF=BC=8C=E6=9F=A5=E8=AF=A2=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=8C=E4=BB=A3=E7=A0=81=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=EF=BC=8C=E5=89=8D=E7=AB=AF=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=88=B0=E5=90=8E=E7=AB=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9A=84=E8=AF=84=E4=BB=B7=E5=86=85=E5=AE=B9?= =?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 --- .../MemberEvaluationBuyerController.java | 6 +- .../entity/dto/EvaluationQueryParams.java | 13 +++- .../dto/StoreEvaluationQueryParams.java | 59 ------------------- .../member/mapper/MemberEvaluationMapper.java | 2 +- .../service/MemberEvaluationService.java | 15 +---- .../MemberEvaluationServiceImpl.java | 23 +++----- .../MemberEvaluationManagerController.java | 2 +- .../MemberEvaluationStoreController.java | 7 +-- 8 files changed, 30 insertions(+), 97 deletions(-) delete mode 100644 framework/src/main/java/cn/lili/modules/member/entity/dto/StoreEvaluationQueryParams.java 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 14c47cb9..dc13e010 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 @@ -1,5 +1,6 @@ package cn.lili.controller.member; +import cn.lili.common.enums.SwitchEnum; import cn.lili.common.security.context.UserContext; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; @@ -55,7 +56,7 @@ public class MemberEvaluationBuyerController { public ResultMessage> queryMineEvaluation(EvaluationQueryParams evaluationQueryParams) { //设置当前登录会员 evaluationQueryParams.setMemberId(UserContext.getCurrentUser().getId()); - return ResultUtil.data(memberEvaluationService.queryByParams(evaluationQueryParams)); + return ResultUtil.data(memberEvaluationService.managerQuery(evaluationQueryParams)); } @ApiOperation(value = "查看某一个商品的评价列表") @@ -65,7 +66,8 @@ public class MemberEvaluationBuyerController { @NotNull @PathVariable("goodsId") String goodsId) { //设置查询查询商品 evaluationQueryParams.setGoodsId(goodsId); - return ResultUtil.data(memberEvaluationService.queryByParams(evaluationQueryParams)); + evaluationQueryParams.setStatus(SwitchEnum.OPEN.name()); + return ResultUtil.data(memberEvaluationService.managerQuery(evaluationQueryParams)); } @ApiOperation(value = "查看某一个商品的评价数量") diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java index aa150722..63881cd3 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/EvaluationQueryParams.java @@ -15,6 +15,10 @@ import lombok.Data; @Data public class EvaluationQueryParams extends PageVO { + + @ApiModelProperty(value = "买家ID") + private String memberId; + @ApiModelProperty(value = "会员名称") private String memberName; @@ -24,9 +28,6 @@ public class EvaluationQueryParams extends PageVO { @ApiModelProperty(value = "卖家ID") private String storeId; - @ApiModelProperty(value = "买家ID", hidden = true) - private String memberId; - @ApiModelProperty(value = "商品名称") private String goodsName; @@ -45,6 +46,9 @@ public class EvaluationQueryParams extends PageVO { @ApiModelProperty(value = "评论日期--结束时间") private String endTime; + @ApiModelProperty(value = "状态") + private String status; + public EvaluationQueryParams() { } @@ -78,6 +82,9 @@ public class EvaluationQueryParams extends PageVO { if (StringUtils.isNotEmpty(haveImage)) { queryWrapper.eq("have_image", haveImage); } + if (StringUtils.isNotEmpty(status)) { + queryWrapper.eq("status", status); + } queryWrapper.eq("delete_flag", false); queryWrapper.orderByDesc("create_time"); return queryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/StoreEvaluationQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/StoreEvaluationQueryParams.java deleted file mode 100644 index d1d76775..00000000 --- a/framework/src/main/java/cn/lili/modules/member/entity/dto/StoreEvaluationQueryParams.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.lili.modules.member.entity.dto; - -import cn.hutool.core.date.DateUtil; -import cn.lili.common.security.context.UserContext; -import cn.lili.common.utils.StringUtils; -import cn.lili.common.vo.PageVO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 店铺评价查询参数 - * - * @author Chopper - * @date 2021/3/20 10:43 - */ - -@Data -public class StoreEvaluationQueryParams extends PageVO { - - @ApiModelProperty(value = "会员名称") - private String memberName; - - @ApiModelProperty(value = "商品名称") - private String goodsName; - - @ApiModelProperty(value = "好中差评 good:好评,neutral:中评,bad:差评", allowableValues = "GOOD,NEUTRAL,BAD") - private String grade; - - @ApiModelProperty(value = "评论日期--开始时间") - private String startDate; - - @ApiModelProperty(value = "评论日期--结束时间") - private String endDate; - - - public QueryWrapper queryWrapper() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - - queryWrapper.eq("store_id", UserContext.getCurrentUser().getStoreId()); - - if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) { - queryWrapper.between("create_time", DateUtil.parse(startDate), DateUtil.parse(endDate)); - } - - if (StringUtils.isNotEmpty(grade)) { - queryWrapper.eq("grade", grade); - } - - if (StringUtils.isNotEmpty(goodsName)) { - queryWrapper.eq("goods_name", goodsName); - } - - if (StringUtils.isNotEmpty(memberName)) { - queryWrapper.eq("member_name", memberName); - } - return queryWrapper; - } -} 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 829b1b44..5c021159 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 @@ -25,7 +25,7 @@ public interface MemberEvaluationMapper extends BaseMapper { @Select("select me.* from li_member_evaluation as me ${ew.customSqlSegment}") IPage getMemberEvaluationList(IPage page, @Param(Constants.WRAPPER) Wrapper queryWrapper); - @Select("select grade,count(1) as num from li_member_evaluation Where goods_id=#{goodsId} GROUP BY grade") + @Select("select grade,count(1) as num from li_member_evaluation Where goods_id=#{goodsId} and status='OPEN' GROUP BY grade") List> getEvaluationNumber(String goodsId); @Select("SELECT round( AVG( delivery_score ), 2 ) AS delivery_score" + diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java index 0e1d44f2..1bebd5bc 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberEvaluationService.java @@ -1,10 +1,8 @@ package cn.lili.modules.member.service; -import cn.lili.common.vo.PageVO; import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.dto.MemberEvaluationDTO; -import cn.lili.modules.member.entity.dto.StoreEvaluationQueryParams; import cn.lili.modules.member.entity.vo.EvaluationNumberVO; import cn.lili.modules.member.entity.vo.MemberEvaluationListVO; import cn.lili.modules.member.entity.vo.MemberEvaluationVO; @@ -25,23 +23,14 @@ public interface MemberEvaluationService extends IService { * @param evaluationQueryParams 评价查询 * @return 评价分页 */ - IPage queryByParams(EvaluationQueryParams evaluationQueryParams); - - /** - * 商家查询会员的评价分页列表 - * - * @param storeEvaluationQueryParams 评价查询 - * @return 会员的评价分页 - */ - IPage queryByParams(StoreEvaluationQueryParams storeEvaluationQueryParams); + IPage managerQuery(EvaluationQueryParams evaluationQueryParams); /** * 查询评价分页列表 * @param evaluationQueryParams 评价查询条件 - * @param page 分页查询参数 * @return 评价分页列表 */ - IPage queryPage(EvaluationQueryParams evaluationQueryParams, PageVO page); + IPage queryPage(EvaluationQueryParams evaluationQueryParams); /** * 添加会员评价 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 388b9f61..28c5ec5e 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 @@ -3,8 +3,8 @@ package cn.lili.modules.member.serviceimpl; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONUtil; -import cn.lili.common.enums.SwitchEnum; import cn.lili.common.enums.ResultCode; +import cn.lili.common.enums.SwitchEnum; import cn.lili.common.exception.ServiceException; import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.common.rocketmq.tags.GoodsTagsEnum; @@ -12,7 +12,6 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.StringUtils; -import cn.lili.common.vo.PageVO; import cn.lili.config.rocketmq.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.service.GoodsSkuService; @@ -20,7 +19,6 @@ import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberEvaluation; import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.dto.MemberEvaluationDTO; -import cn.lili.modules.member.entity.dto.StoreEvaluationQueryParams; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.entity.vo.EvaluationNumberVO; import cn.lili.modules.member.entity.vo.MemberEvaluationListVO; @@ -42,7 +40,6 @@ 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 lombok.RequiredArgsConstructor; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -84,20 +81,16 @@ public class MemberEvaluationServiceImpl extends ServiceImpl queryByParams(EvaluationQueryParams queryParams) { + public IPage managerQuery(EvaluationQueryParams queryParams) { //获取评价分页 return this.page(PageUtil.initPage(queryParams), queryParams.queryWrapper()); } @Override - public IPage queryByParams(StoreEvaluationQueryParams storeEvaluationQueryParams) { - return memberEvaluationMapper.getMemberEvaluationList(PageUtil.initPage(storeEvaluationQueryParams), storeEvaluationQueryParams.queryWrapper()); + public IPage queryPage(EvaluationQueryParams evaluationQueryParams) { + return memberEvaluationMapper.getMemberEvaluationList(PageUtil.initPage(evaluationQueryParams), evaluationQueryParams.queryWrapper()); } - @Override - public IPage queryPage(EvaluationQueryParams evaluationQueryParams, PageVO page) { - return memberEvaluationMapper.getMemberEvaluationList(PageUtil.initPage(page), evaluationQueryParams.queryWrapper()); - } @Override public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO) { @@ -106,7 +99,7 @@ public class MemberEvaluationServiceImpl extends ServiceImpl> list = memberEvaluationMapper.getEvaluationNumber(goodsId); + Integer good = 0; Integer moderate = 0; Integer worse = 0; @@ -204,10 +198,11 @@ public class MemberEvaluationServiceImpl extends ServiceImpl> getByPage(EvaluationQueryParams evaluationQueryParams, PageVO page) { - return ResultUtil.data(memberEvaluationService.queryPage(evaluationQueryParams, page)); + return ResultUtil.data(memberEvaluationService.queryPage(evaluationQueryParams)); } @ApiOperation(value = "修改评价状态") diff --git a/seller-api/src/main/java/cn/lili/controller/trade/MemberEvaluationStoreController.java b/seller-api/src/main/java/cn/lili/controller/trade/MemberEvaluationStoreController.java index 937a9a8b..71b77c08 100644 --- a/seller-api/src/main/java/cn/lili/controller/trade/MemberEvaluationStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/trade/MemberEvaluationStoreController.java @@ -2,7 +2,7 @@ package cn.lili.controller.trade; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.member.entity.dto.StoreEvaluationQueryParams; +import cn.lili.modules.member.entity.dto.EvaluationQueryParams; import cn.lili.modules.member.entity.vo.MemberEvaluationListVO; import cn.lili.modules.member.entity.vo.MemberEvaluationVO; import cn.lili.modules.member.service.MemberEvaluationService; @@ -30,9 +30,8 @@ public class MemberEvaluationStoreController { @ApiOperation(value = "分页获取会员评论列表") @GetMapping - public ResultMessage> getByPage(StoreEvaluationQueryParams storeEvaluationQueryParams) { - - return ResultUtil.data(memberEvaluationService.queryByParams(storeEvaluationQueryParams)); + public ResultMessage> getByPage(EvaluationQueryParams evaluationQueryParams) { + return ResultUtil.data(memberEvaluationService.queryPage(evaluationQueryParams)); } @ApiOperation(value = "通过id获取") From e4b968e0af58bffa87bbc68bf482be1ba6dfd46f Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 10:37:45 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=89=A3=E5=87=8F?= =?UTF-8?q?=EF=BC=8C=E5=BA=93=E5=AD=98=E5=9B=9E=E6=BB=9A=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82=20=E4=B9=8B=E5=89=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E5=95=86=E5=93=81=E5=8F=96=E6=B6=88=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=9B=9E=E6=BB=9A=E5=BA=93=E5=AD=98=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E6=98=AF=E5=BF=BD=E7=95=A5=E4=BA=86=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=AF=E8=83=BD=E6=98=AF=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=B8=8D=E8=B6=B3=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/StockUpdateExecute.java | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 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 aa226c27..c8449df3 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -12,6 +12,7 @@ import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum; import cn.lili.modules.promotion.service.PromotionGoodsService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.script.DefaultRedisScript; @@ -26,9 +27,12 @@ import java.util.List; * @author Chopper * @date 2020-07-03 11:20 */ +@Slf4j @Service public class StockUpdateExecute implements OrderStatusChangeEvent { + //出库失败消息 + static String outOfStockMessage = "库存不足,出库失败"; //Redis @Autowired private StringRedisTemplate stringRedisTemplate; @@ -52,7 +56,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { switch (orderMessage.getNewStatus()) { case PAID: { - + //获取订单详情 OrderDetailVO order = orderService.queryDetail(orderMessage.getOrderSn()); //库存key 和 扣减数量 List keys = new ArrayList<>(); @@ -67,33 +71,41 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { Boolean skuResult = stringRedisTemplate.execute(quantityScript, keys, values.toArray()); //如果库存扣减都成功,则记录成交订单 if (Boolean.TRUE.equals(skuResult)) { + log.info("库存扣减成功,参数为{};{}", keys, values); //库存确认之后对结构处理 orderService.afterOrderConfirm(orderMessage.getOrderSn()); //成功之后,同步库存 synchroDB(order); } else { + log.info("库存扣件失败,变更缓存key{} 变更缓存value{}", keys, values); //失败之后取消订单 this.errorOrder(orderMessage.getOrderSn()); } break; } case CANCELLED: { - + //获取订单详情 OrderDetailVO order = orderService.queryDetail(orderMessage.getOrderSn()); - if (order.getOrder().getPayStatus().equals(PayStatusEnum.PAID.name())) { + //判定是否已支付 并且 非库存不足导致库存回滚 则需要考虑订单库存返还业务 + if (order.getOrder().getPayStatus().equals(PayStatusEnum.PAID.name()) && order.getOrder().getCancelReason().equals(outOfStockMessage)) { + //库存key 和 还原数量 + List keys = new ArrayList<>(); + List values = new ArrayList<>(); + + //返还商品库存,促销库存不与返还,不然前台展示层有展示逻辑错误 for (OrderItem orderItem : order.getOrderItems()) { - if (PromotionTypeEnum.haveStock(orderItem.getPromotionType())) { - PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType()); - Integer goodsPromotionOriginStock = promotionGoodsService.getPromotionGoodsStock(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId()); - int goodsPromotionStock = goodsPromotionOriginStock + orderItem.getNum(); - String promotionGoodsStockCacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId()); - stringRedisTemplate.opsForValue().set(promotionGoodsStockCacheKey, Integer.toString(goodsPromotionStock)); - } - String stockCacheKey = GoodsSkuService.getStockCacheKey(orderItem.getSkuId()); - Integer goodsOriginStock = goodsSkuService.getStock(orderItem.getSkuId()); - int goodsStock = goodsOriginStock + orderItem.getNum(); - stringRedisTemplate.opsForValue().set(stockCacheKey, Integer.toString(goodsStock)); + keys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId())); + int i = orderItem.getNum(); + values.add(Integer.toString(i)); } + //批量脚本执行库存回退 + Boolean skuResult = stringRedisTemplate.execute(quantityScript, keys, values.toArray()); + + //返还失败,则记录日志 + if (Boolean.FALSE.equals(skuResult)) { + log.error("库存回退异常,keys:{},回复库存值为: {}", keys, values); + } + rollbackOrderStock(order); } break; } @@ -108,7 +120,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { * @param orderSn 失败入库订单信息 */ private void errorOrder(String orderSn) { - orderService.systemCancel(orderSn, "库存不足,出库失败"); + orderService.systemCancel(orderSn, outOfStockMessage); } @@ -132,8 +144,9 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { } } + /** - * 写入需要更改促销库存的商品 + * 同步库存和促销库存 * * @param order 订单 */ @@ -159,6 +172,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { if (PromotionTypeEnum.haveStock(orderItem.getPromotionType())) { PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType()); PromotionGoods pGoods = promotionGoodsService.getPromotionGoods(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId()); + //记录需要更新的促销库存信息 promotionKey.add( PromotionGoodsService.getPromotionGoodsStockCacheKey( promotionTypeEnum, @@ -170,6 +184,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { goodsSkus.add(goodsSku); } + //批量获取商品库存 List skuStocks = cache.multiGet(skuKeys); //循环写入商品库存 for (int i = 0; i < skuStocks.size(); i++) { @@ -188,8 +203,41 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { } promotionGoodsService.updateBatchById(promotionGoods); } + //商品库存,包含sku库存集合,批量更新商品库存相关 goodsSkuService.updateGoodsStuck(goodsSkus); + log.info("订单确认,库存同步:商品信息--{};促销信息---{}", goodsSkus, promotionGoods); + } + /** + * 恢复商品库存 + * + * @param order 订单 + */ + private void rollbackOrderStock(OrderDetailVO order) { + + //sku商品 + List goodsSkus = new ArrayList<>(); + //sku库存key 集合 + List skuKeys = new ArrayList<>(); + // 循环订单 + for (OrderItem orderItem : order.getOrderItems()) { + skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId())); + GoodsSku goodsSku = new GoodsSku(); + goodsSku.setId(orderItem.getSkuId()); + goodsSkus.add(goodsSku); + } + //批量获取商品库存 + List skuStocks = cache.multiGet(skuKeys); + //循环写入商品SKU库存 + for (int i = 0; i < skuStocks.size(); i++) { + goodsSkus.get(i).setQuantity(Integer.parseInt(skuStocks.get(i).toString())); + } + log.info("订单取消,库存还原:{}", goodsSkus); + //批量修改商品库存 + goodsSkuService.updateBatchById(goodsSkus); + goodsSkuService.updateGoodsStuck(goodsSkus); + + } } From bf023ccad5721d6781d148e6e037a2678680ff38 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 10:41:53 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/generator/CodeGenerator.java | 2 +- .../templates/{java => }/controller.btl | 0 .../resources/templates/{java => }/entity.btl | 0 .../resources/templates/{java => }/mapper.btl | 0 .../templates/{java => }/mapperXml.btl | 0 .../templates/{java => }/service.btl | 0 .../templates/{java => }/serviceImpl.btl | 0 .../main/resources/templates/vue/table.btl | 735 ------------------ .../src/main/resources/templates/vue/tree.btl | 687 ---------------- 9 files changed, 1 insertion(+), 1423 deletions(-) rename framework/src/main/resources/templates/{java => }/controller.btl (100%) rename framework/src/main/resources/templates/{java => }/entity.btl (100%) rename framework/src/main/resources/templates/{java => }/mapper.btl (100%) rename framework/src/main/resources/templates/{java => }/mapperXml.btl (100%) rename framework/src/main/resources/templates/{java => }/service.btl (100%) rename framework/src/main/resources/templates/{java => }/serviceImpl.btl (100%) delete mode 100644 framework/src/main/resources/templates/vue/table.btl delete mode 100644 framework/src/main/resources/templates/vue/tree.btl diff --git a/framework/src/main/java/cn/lili/generator/CodeGenerator.java b/framework/src/main/java/cn/lili/generator/CodeGenerator.java index be7e6666..2924574c 100644 --- a/framework/src/main/java/cn/lili/generator/CodeGenerator.java +++ b/framework/src/main/java/cn/lili/generator/CodeGenerator.java @@ -101,7 +101,7 @@ public class CodeGenerator { */ public static void main(String[] args) throws IOException { // 模板路径 - ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/java/"); + ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/"); Configuration cfg = Configuration.defaultConfiguration(); GroupTemplate gt = new GroupTemplate(resourceLoader, cfg); // 生成代码 diff --git a/framework/src/main/resources/templates/java/controller.btl b/framework/src/main/resources/templates/controller.btl similarity index 100% rename from framework/src/main/resources/templates/java/controller.btl rename to framework/src/main/resources/templates/controller.btl diff --git a/framework/src/main/resources/templates/java/entity.btl b/framework/src/main/resources/templates/entity.btl similarity index 100% rename from framework/src/main/resources/templates/java/entity.btl rename to framework/src/main/resources/templates/entity.btl diff --git a/framework/src/main/resources/templates/java/mapper.btl b/framework/src/main/resources/templates/mapper.btl similarity index 100% rename from framework/src/main/resources/templates/java/mapper.btl rename to framework/src/main/resources/templates/mapper.btl diff --git a/framework/src/main/resources/templates/java/mapperXml.btl b/framework/src/main/resources/templates/mapperXml.btl similarity index 100% rename from framework/src/main/resources/templates/java/mapperXml.btl rename to framework/src/main/resources/templates/mapperXml.btl diff --git a/framework/src/main/resources/templates/java/service.btl b/framework/src/main/resources/templates/service.btl similarity index 100% rename from framework/src/main/resources/templates/java/service.btl rename to framework/src/main/resources/templates/service.btl diff --git a/framework/src/main/resources/templates/java/serviceImpl.btl b/framework/src/main/resources/templates/serviceImpl.btl similarity index 100% rename from framework/src/main/resources/templates/java/serviceImpl.btl rename to framework/src/main/resources/templates/serviceImpl.btl diff --git a/framework/src/main/resources/templates/vue/table.btl b/framework/src/main/resources/templates/vue/table.btl deleted file mode 100644 index 260f5772..00000000 --- a/framework/src/main/resources/templates/vue/table.btl +++ /dev/null @@ -1,735 +0,0 @@ - - - - \ No newline at end of file diff --git a/framework/src/main/resources/templates/vue/tree.btl b/framework/src/main/resources/templates/vue/tree.btl deleted file mode 100644 index 269738b6..00000000 --- a/framework/src/main/resources/templates/vue/tree.btl +++ /dev/null @@ -1,687 +0,0 @@ - - - - \ No newline at end of file From 4a9d54cbf4638ee268827658426091f752c7e871 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 12:12:45 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=AD=94=E5=BA=94=EF=BC=8Cwap=E6=94=AF=E4=BB=983m=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E9=97=AE=E9=A2=98=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/kit/plugin/alipay/AliPayPlugin.java | 14 +++++++++----- .../kit/plugin/wechat/model/package-info.java | 2 -- .../java/cn/lili/modules/payment/package-info.java | 5 +++++ 3 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/package-info.java create mode 100644 framework/src/main/java/cn/lili/modules/payment/package-info.java 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 f1ea1041..529a8b43 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 @@ -4,8 +4,8 @@ import cn.hutool.core.net.URLDecoder; import cn.hutool.core.net.URLEncoder; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; @@ -67,7 +67,6 @@ public class AliPayPlugin implements Payment { @Override public ResultMessage h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) { - CashierParam cashierParam = cashierSupport.cashierParam(payParam); //请求订单编号 String outTradeNo = SnowFlake.getIdStr(); @@ -79,10 +78,11 @@ public class AliPayPlugin implements Payment { //回传数据 payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); //3分钟超时 - payModel.setTimeoutExpress("3m"); + payModel.setTimeoutExpress("30m"); payModel.setOutTradeNo(outTradeNo); payModel.setProductCode("QUICK_WAP_PAY"); try { + log.info("支付宝H5支付:{}", payModel); AliPayRequest.wapPay(response, payModel, callbackUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY), notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)); } catch (Exception e) { @@ -119,7 +119,9 @@ public class AliPayPlugin implements Payment { payModel.setOutTradeNo(outTradeNo); payModel.setProductCode("QUICK_MSECURITY_PAY"); + log.info("支付宝APP支付:{}", payModel); String orderInfo = AliPayRequest.appPayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody(); + log.info("支付宝APP支付返回内容:{}", orderInfo); return ResultUtil.data(orderInfo); } catch (AlipayApiException e) { log.error("支付宝支付异常:", e); @@ -150,8 +152,10 @@ public class AliPayPlugin implements Payment { // payModel.setStoreId("store_id"); payModel.setTimeoutExpress("3m"); payModel.setOutTradeNo(outTradeNo); - + log.info("支付宝扫码:{}", payModel); String resultStr = AliPayRequest.tradePrecreatePayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody(); + + log.info("支付宝扫码交互返回:{}", resultStr); JSONObject jsonObject = JSONObject.parseObject(resultStr); return ResultUtil.data(jsonObject.getJSONObject("alipay_trade_precreate_response").getString("qr_code")); } catch (Exception e) { @@ -212,7 +216,7 @@ public class AliPayPlugin implements Payment { } refundLogService.save(refundLog); } catch (Exception e) { - log.error("支付宝退款异常",e); + log.error("支付宝退款异常", e); } } diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/package-info.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/package-info.java deleted file mode 100644 index f32da037..00000000 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/model/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -package cn.lili.modules.payment.kit.plugin.wechat.model; -//这个目录的很多类的属性都是下划线分割,不符合本产品的驼峰类型约定,后续会进行处理 \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/payment/package-info.java b/framework/src/main/java/cn/lili/modules/payment/package-info.java new file mode 100644 index 00000000..81001980 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/payment/package-info.java @@ -0,0 +1,5 @@ +/** + * 项目部分参考 IJPay + * git地址 https://gitee.com/javen205/IJPay + */ +package cn.lili.modules.payment; \ No newline at end of file From 4bc5cb0f1bd69d18926aca8dfc07eb1e5ae0b680 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 12:21:41 +0800 Subject: [PATCH 09/15] =?UTF-8?q?wap=E6=94=AF=E4=BB=98=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=EF=BC=8C=E7=9C=8B=E8=B5=B7=E6=9D=A5=E6=98=AF=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E5=8E=9F=E5=9B=A0=EF=BC=8C=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 529a8b43..d4953bae 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 @@ -78,7 +78,7 @@ public class AliPayPlugin implements Payment { //回传数据 payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); //3分钟超时 - payModel.setTimeoutExpress("30m"); +// payModel.setTimeoutExpress("30m"); payModel.setOutTradeNo(outTradeNo); payModel.setProductCode("QUICK_WAP_PAY"); try { From 383dbb2d4e03b8f8a8895e8d7454920d524899d4 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 15:05:50 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A46=E4=B8=AA1=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common-api/src/main/resources/application.yml | 3 +-- .../common/sms/impl/SmsUtilAliImplService.java | 15 ++++++++++++--- .../cn/lili/config/properties/SystemSetting.java | 6 ++++++ .../payment/kit/plugin/alipay/AliPayPlugin.java | 9 ++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/common-api/src/main/resources/application.yml b/common-api/src/main/resources/application.yml index 36d03d74..23bbc5c0 100644 --- a/common-api/src/main/resources/application.yml +++ b/common-api/src/main/resources/application.yml @@ -225,8 +225,7 @@ lili: #支付密码 WALLET_PASSWORD: SMS_205755301 system: - isDemoSite: true - licences: 'temporary' + isTestModel: true statistics: # 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数 onlineMember: 48 diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index 5e62b76e..6a64bfaf 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -11,6 +11,7 @@ import cn.lili.common.sms.SmsUtil; import cn.lili.common.utils.CommonUtil; import cn.lili.common.verification.enums.VerificationEnums; import cn.lili.config.properties.SmsTemplateSetting; +import cn.lili.config.properties.SystemSetting; import cn.lili.modules.connect.util.Base64Utils; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.service.MemberService; @@ -55,6 +56,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Autowired private SmsTemplateSetting smsTemplateSetting; + @Autowired + private SystemSetting systemSetting; + @Override public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) { //获取短信配置 @@ -115,11 +119,16 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { default: return; } + + //如果是测试模式 默认验证码 6个1 + if (systemSetting.getIsTestModel()) { + code = "111111"; + } else { + //发送短信 + this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode); + } //缓存中写入要验证的信息 cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); - //发送短信 - this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode); - } @Override diff --git a/framework/src/main/java/cn/lili/config/properties/SystemSetting.java b/framework/src/main/java/cn/lili/config/properties/SystemSetting.java index 955ff058..17186884 100644 --- a/framework/src/main/java/cn/lili/config/properties/SystemSetting.java +++ b/framework/src/main/java/cn/lili/config/properties/SystemSetting.java @@ -20,6 +20,12 @@ public class SystemSetting { */ private Boolean isDemoSite = false; + /** + * 测试模式 + * 验证码短信为6个1 + */ + private Boolean isTestModel = false; + /** * 授权信息 */ 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 d4953bae..c622b008 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 @@ -10,6 +10,7 @@ import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; import cn.lili.config.properties.ApiProperties; +import cn.lili.config.properties.DomainProperties; import cn.lili.modules.payment.entity.RefundLog; import cn.lili.modules.payment.kit.CashierSupport; import cn.lili.modules.payment.kit.Payment; @@ -62,7 +63,9 @@ public class AliPayPlugin implements Payment { //API域名 @Autowired private ApiProperties apiProperties; - + //域名配置 + @Autowired + private DomainProperties domainProperties; @Override public ResultMessage h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) { @@ -78,11 +81,11 @@ public class AliPayPlugin implements Payment { //回传数据 payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); //3分钟超时 -// payModel.setTimeoutExpress("30m"); + payModel.setTimeoutExpress("3m"); payModel.setOutTradeNo(outTradeNo); payModel.setProductCode("QUICK_WAP_PAY"); try { - log.info("支付宝H5支付:{}", payModel); + log.info("支付宝H5支付:{}", JSONUtil.toJsonStr(payModel)); AliPayRequest.wapPay(response, payModel, callbackUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY), notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)); } catch (Exception e) { From 897600335ea86e850e670cb12e155e4d02151801 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 15:06:24 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E6=94=AF=E4=BB=98title=20=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.yml | 1 + .../java/cn/lili/common/utils/StringUtils.java | 14 ++++++++++++++ .../payment/kit/params/dto/CashierParam.java | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/config/application.yml b/config/application.yml index d78a5624..ae0c6ec4 100644 --- a/config/application.yml +++ b/config/application.yml @@ -226,6 +226,7 @@ lili: WALLET_PASSWORD: SMS_205755301 system: isDemoSite: false + isTestModel: true statistics: # 在线人数统计 X 小时。这里设置48,即统计过去48小时每小时在线人数 onlineMember: 48 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 cbb4547f..5fa90f30 100644 --- a/framework/src/main/java/cn/lili/common/utils/StringUtils.java +++ b/framework/src/main/java/cn/lili/common/utils/StringUtils.java @@ -12,6 +12,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 字串工具类 @@ -250,6 +252,18 @@ public class StringUtils extends StrUtil { } return str.concat(appendStr); } + + /** + * 过滤特殊字符串 + * @param str + * @return + */ + public static String filterSpecialChart(String str){ + String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(str); + return m.replaceAll("").trim(); + } } 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 47391397..d7e9b279 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.lili.common.utils.StringUtils; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; @@ -41,4 +42,11 @@ public class CashierParam { @ApiModelProperty(value = "剩余余额") private Double walletValue; + + public String getDetail() { + if (StringUtils.isEmpty(detail)) { + return "清单详细"; + } + return StringUtils.filterSpecialChart(detail); + } } From e01c279cfe0fdc4ad22f42952df7665bf777f721 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 16:31:40 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E6=94=AF?= =?UTF-8?q?=E4=BB=98h5=20=E6=97=A0=E6=B3=95=E6=94=AF=E4=BB=98=E6=88=90?= =?UTF-8?q?=E5=8A=9F=EF=BC=8C=E6=A3=80=E6=9F=A5=E6=97=B6=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E7=8E=B0=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/security/filter/XssFilter.java | 7 +- .../java/cn/lili/common/utils/BeanUtil.java | 73 +++++++++++++++++++ .../cn/lili/common/utils/StringUtils.java | 5 +- .../kit/plugin/alipay/AliPayPlugin.java | 13 ++-- 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java b/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java index ead0a2b1..8bec61e9 100644 --- a/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java +++ b/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java @@ -1,10 +1,7 @@ package cn.lili.common.security.filter; -import org.springframework.stereotype.Component; - import javax.servlet.*; -import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import java.io.IOException; @@ -15,8 +12,8 @@ import java.io.IOException; * @version v1.0 * 2021-06-04 10:37 */ -@WebFilter -@Component +//@WebFilter +//@Component public class XssFilter implements Filter { FilterConfig filterConfig = null; diff --git a/framework/src/main/java/cn/lili/common/utils/BeanUtil.java b/framework/src/main/java/cn/lili/common/utils/BeanUtil.java index b525fa64..3ce1c762 100644 --- a/framework/src/main/java/cn/lili/common/utils/BeanUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/BeanUtil.java @@ -1,5 +1,7 @@ package cn.lili.common.utils; +import cn.hutool.json.JSONUtil; +import cn.lili.modules.payment.kit.dto.PayParam; import org.springframework.beans.BeanUtils; import java.lang.reflect.Field; @@ -56,4 +58,75 @@ public class BeanUtil { return null; } } + + + /** + * 将对象转换为key value + * A=a&B=b&C=c 格式 + */ + public static String formatKeyValuePair(Object object) { + //准备接受的字符串 + StringBuilder stringBuffer = new StringBuilder(); + //获取对象字段 + String[] fieldNames = BeanUtil.getFiledName(object); + //遍历所有属性 + for (int j = 0; j < fieldNames.length; j++) { + //不是第一个并且不是最后一个,拼接& + if (j != 0) { + stringBuffer.append("&"); + } + //获取属性的名字 + String key = fieldNames[j]; + //获取值 + Object value = BeanUtil.getFieldValueByName(key, object); + stringBuffer.append(key).append("=").append(value.toString()); + } + return stringBuffer.toString(); + } + + /** + * key value键值对 转换为 对象 + * A=a&B=b&C=c 格式 转换为对象 + */ + public static T formatKeyValuePair(String str, T t) { + //填写对参数键值对 + String[] params = str.split("&"); + + //获取对象字段 + String[] fieldNames = BeanUtil.getFiledName(t); + + try { + //循环每个参数 + for (String param : params) { + String[] keyValues = param.split("="); + for (int i = 0; i < fieldNames.length; i++) { + if (fieldNames[i].equals(keyValues[0])) { + Field f = t.getClass().getDeclaredField(fieldNames[i]); + f.setAccessible(true); + //长度为2 才转换,否则不转 + if (keyValues.length == 2) { + f.set(t, keyValues[1]); + } + } + } + + } + } catch (Exception e) { + e.printStackTrace(); + } + return t; + } + + public static void main(String[] args) throws IllegalAccessException { + PayParam payParam = new PayParam(); + payParam.setClientType("client"); + payParam.setOrderType(""); + payParam.setSn("sn"); + String val = formatKeyValuePair(payParam); + System.out.println(val); + + PayParam param = formatKeyValuePair(val, new PayParam()); + System.out.println(JSONUtil.toJsonStr(param)); + } + } 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 5fa90f30..e97c61c4 100644 --- a/framework/src/main/java/cn/lili/common/utils/StringUtils.java +++ b/framework/src/main/java/cn/lili/common/utils/StringUtils.java @@ -255,11 +255,12 @@ public class StringUtils extends StrUtil { /** * 过滤特殊字符串 + * * @param str * @return */ - public static String filterSpecialChart(String str){ - String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; + public static String filterSpecialChart(String str) { + String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.replaceAll("").trim(); 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 c622b008..e42f2d97 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 @@ -6,11 +6,11 @@ import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; +import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.SnowFlake; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; import cn.lili.config.properties.ApiProperties; -import cn.lili.config.properties.DomainProperties; import cn.lili.modules.payment.entity.RefundLog; import cn.lili.modules.payment.kit.CashierSupport; import cn.lili.modules.payment.kit.Payment; @@ -63,9 +63,6 @@ public class AliPayPlugin implements Payment { //API域名 @Autowired private ApiProperties apiProperties; - //域名配置 - @Autowired - private DomainProperties domainProperties; @Override public ResultMessage h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) { @@ -79,7 +76,7 @@ public class AliPayPlugin implements Payment { payModel.setSubject(cashierParam.getDetail()); payModel.setTotalAmount(cashierParam.getPrice() + ""); //回传数据 - payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); + payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8)); //3分钟超时 payModel.setTimeoutExpress("3m"); payModel.setOutTradeNo(outTradeNo); @@ -118,7 +115,7 @@ public class AliPayPlugin implements Payment { //3分钟超时 payModel.setTimeoutExpress("3m"); //回传数据 - payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); + payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8)); payModel.setOutTradeNo(outTradeNo); payModel.setProductCode("QUICK_MSECURITY_PAY"); @@ -151,7 +148,7 @@ public class AliPayPlugin implements Payment { payModel.setTotalAmount(cashierParam.getPrice() + ""); //回传数据 - payModel.setPassbackParams(URLEncoder.createAll().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8)); + payModel.setPassbackParams(URLEncoder.createAll().encode(BeanUtil.formatKeyValuePair(payParam), StandardCharsets.UTF_8)); // payModel.setStoreId("store_id"); payModel.setTimeoutExpress("3m"); payModel.setOutTradeNo(outTradeNo); @@ -256,7 +253,7 @@ public class AliPayPlugin implements Payment { String payParamStr = map.get("passback_params"); String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8); - PayParam payParam = JSONUtil.toBean(payParamJson, PayParam.class); + PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam()); if (verifyResult) { From cbcadc21a27e87100ae2fe9608573207a507738f Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 17 Jun 2021 16:43:37 +0800 Subject: [PATCH 13/15] =?UTF-8?q?xss=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/security/filter/XssFilter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java b/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java index 8bec61e9..ead0a2b1 100644 --- a/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java +++ b/framework/src/main/java/cn/lili/common/security/filter/XssFilter.java @@ -1,7 +1,10 @@ package cn.lili.common.security.filter; +import org.springframework.stereotype.Component; + import javax.servlet.*; +import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import java.io.IOException; @@ -12,8 +15,8 @@ import java.io.IOException; * @version v1.0 * 2021-06-04 10:37 */ -//@WebFilter -//@Component +@WebFilter +@Component public class XssFilter implements Filter { FilterConfig filterConfig = null; From 24be8f342d81a9cd1b766a94ac8b860f490874a4 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 18 Jun 2021 10:12:15 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/sms/impl/SmsUtilAliImplService.java | 5 ----- .../lili/modules/goods/entity/dos/Goods.java | 6 +++--- .../MemberEvaluationServiceImpl.java | 16 ++++------------ .../modules/order/order/entity/dos/Order.java | 18 +++++++++--------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index e55b3773..26b6e6d4 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -119,10 +119,6 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { default: return; } -<<<<<<< HEAD - log.info("短信验证码:"+code); -======= - //如果是测试模式 默认验证码 6个1 if (systemSetting.getIsTestModel()) { code = "111111"; @@ -130,7 +126,6 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { //发送短信 this.sendSmsCode(smsSetting.getSignName(), mobile, params, templateCode); } ->>>>>>> master //缓存中写入要验证的信息 cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); } 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 3cab4025..512d4498 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 @@ -185,18 +185,18 @@ public class Goods extends BaseEntity { @ApiModelProperty(value = "销售模式", required = true) private String salesModel; -<<<<<<< HEAD + /** * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum */ @ApiModelProperty(value = "商品类型", required = true) private String goodsType; -======= + @ApiModelProperty(value = "商品参数json", hidden = true) @Column(columnDefinition = "TEXT") @JsonIgnore private String params; ->>>>>>> master + public Goods() { } 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 c410ea3e..d75a37de 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 @@ -45,6 +45,7 @@ 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.List; import java.util.Map; @@ -58,6 +59,9 @@ import java.util.Map; @Transactional public class MemberEvaluationServiceImpl extends ServiceImpl implements MemberEvaluationService { + //会员评价数据层 + @Resource + private MemberEvaluationMapper memberEvaluationMapper; //订单 @Autowired private OrderService orderService; @@ -84,22 +88,10 @@ public class MemberEvaluationServiceImpl extends ServiceImpl queryByParams(StoreEvaluationQueryParams storeEvaluationQueryParams) { - return this.baseMapper.getMemberEvaluationList(PageUtil.initPage(storeEvaluationQueryParams), storeEvaluationQueryParams.queryWrapper()); - } - - @Override - public IPage queryPage(EvaluationQueryParams evaluationQueryParams, PageVO page) { - return this.baseMapper.getMemberEvaluationList(PageUtil.initPage(page), evaluationQueryParams.queryWrapper()); - } -======= public IPage queryPage(EvaluationQueryParams evaluationQueryParams) { return memberEvaluationMapper.getMemberEvaluationList(PageUtil.initPage(evaluationQueryParams), evaluationQueryParams.queryWrapper()); } ->>>>>>> master - @Override public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO) { //获取子订单信息 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 8ab413c9..89782321 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 @@ -4,8 +4,6 @@ import cn.hutool.json.JSONUtil; import cn.lili.base.BaseEntity; import cn.lili.common.utils.BeanUtil; import cn.lili.modules.base.entity.enums.ClientTypeEnum; -<<<<<<< HEAD -======= import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; @@ -15,7 +13,6 @@ import cn.lili.modules.order.order.entity.enums.OrderTypeEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum; ->>>>>>> master 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.enums.DeliveryMethodEnum; @@ -33,6 +30,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import java.util.Date; +import java.util.Optional; /** * 订单 @@ -217,18 +215,16 @@ public class Order extends BaseEntity { * @param tradeDTO 交易DTO */ public Order(CartVO cartVO, TradeDTO tradeDTO) { - String orderId = this.getId(); + String oldId = this.getId(); BeanUtil.copyProperties(tradeDTO, this); BeanUtil.copyProperties(cartVO.getPriceDetailDTO(), this); BeanUtil.copyProperties(cartVO, this); -<<<<<<< HEAD - //订单类型判断--普通订单,活动订单。 if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.CART) || tradeDTO.getCartTypeEnum().equals(CartTypeEnum.BUY_NOW)) { this.setOrderType(OrderTypeEnum.NORMAL.name()); } else { this.setOrderType(tradeDTO.getCartTypeEnum().name()); -======= + } this.setId(oldId); this.setOrderType(OrderTypeEnum.NORMAL.name()); //促销信息填充 @@ -241,7 +237,6 @@ public class Order extends BaseEntity { this.setParentOrderSn(""); } } ->>>>>>> master } //设置默认支付状态 @@ -272,7 +267,12 @@ public class Order extends BaseEntity { } public PriceDetailDTO getPriceDetailDTO() { - return JSONUtil.toBean(priceDetail, PriceDetailDTO.class); + + try { + return JSONUtil.toBean(priceDetail, PriceDetailDTO.class); + } catch (Exception e) { + return null; + } } public void setPriceDetailDTO(PriceDetailDTO priceDetail) { From b361fe7d9549b4ee72dca25c69788ba23aed0b30 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 18 Jun 2021 11:27:38 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E5=B1=95=E7=A4=BA=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E6=B4=BB=E5=8A=A8=E4=B8=8B=E7=9A=84=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E5=88=97=E8=A1=A8=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/StockUpdateExecute.java | 6 ---- .../promotion/entity/dos/CouponActivity.java | 4 +-- .../entity/vos/CouponActivityItemVO.java | 30 +++++++++++++++++++ .../entity/vos/CouponActivityVO.java | 4 +-- .../mapper/CouponActivityItemMapper.java | 8 ++++- .../service/CouponActivityItemService.java | 8 +++++ .../CouponActivityItemServiceImpl.java | 8 +++++ .../CouponActivityServiceImpl.java | 2 +- 8 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityItemVO.java 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 bb024900..c8449df3 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -56,10 +56,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { switch (orderMessage.getNewStatus()) { case PAID: { -<<<<<<< HEAD -======= //获取订单详情 ->>>>>>> master OrderDetailVO order = orderService.queryDetail(orderMessage.getOrderSn()); //库存key 和 扣减数量 List keys = new ArrayList<>(); @@ -87,10 +84,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { break; } case CANCELLED: { -<<<<<<< HEAD -======= //获取订单详情 ->>>>>>> master OrderDetailVO order = orderService.queryDetail(orderMessage.getOrderSn()); //判定是否已支付 并且 非库存不足导致库存回滚 则需要考虑订单库存返还业务 if (order.getOrder().getPayStatus().equals(PayStatusEnum.PAID.name()) && order.getOrder().getCancelReason().equals(outOfStockMessage)) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java index bec05f38..18e46793 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/CouponActivity.java @@ -28,14 +28,14 @@ public class CouponActivity extends BasePromotion { * @see CouponActivityTypeEnum */ @NotNull(message = "优惠券活动类型不能为空") - @ApiModelProperty(value = "优惠券活动类型") + @ApiModelProperty(value = "优惠券活动类型", allowableValues = "REGISTERED:新人赠券,SPECIFY:精确发券") private String couponActivityType; @NotNull(message = "请选择活动范围") @ApiModelProperty(value = "活动范围", allowableValues = "ALL:全部会员,DESIGNATED:指定会员") private String activityScope; - @ApiModelProperty(value = "活动范围详情") + @ApiModelProperty(value = "活动范围详情,只有精准发券使用") private String activityScopeInfo; } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityItemVO.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityItemVO.java new file mode 100644 index 00000000..47dc2630 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityItemVO.java @@ -0,0 +1,30 @@ +package cn.lili.modules.promotion.entity.vos; + +import cn.lili.modules.promotion.entity.dos.CouponActivityItem; +import io.swagger.annotations.ApiModelProperty; + +/** + * 优惠券活动的优惠券VO + * + * @author Bulbasaur + * @date: 2021/6/18 11:00 上午 + */ +public class CouponActivityItemVO extends CouponActivityItem { + + @ApiModelProperty(value = "优惠券名称") + private String couponName; + + @ApiModelProperty(value = "面额") + private Double price; + + /** + * POINT("打折"), PRICE("减免现金"); + * + * @see cn.lili.modules.promotion.entity.enums.CouponTypeEnum + */ + @ApiModelProperty(value = "优惠券类型") + private String couponType; + + @ApiModelProperty(value = "折扣") + private Double couponDiscount; +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityVO.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityVO.java index 956c9f8c..aeaa37a8 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityVO.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/CouponActivityVO.java @@ -20,9 +20,9 @@ import java.util.List; public class CouponActivityVO extends CouponActivity { @ApiModelProperty(value = "优惠券活动下的优惠券列表") - private List couponActivityItems; + private List couponActivityItems; - public CouponActivityVO(CouponActivity couponActivity, List couponActivityItems) { + public CouponActivityVO(CouponActivity couponActivity, List couponActivityItemVOS) { BeanUtil.copyProperties(couponActivity, this); this.couponActivityItems = couponActivityItems; } diff --git a/framework/src/main/java/cn/lili/modules/promotion/mapper/CouponActivityItemMapper.java b/framework/src/main/java/cn/lili/modules/promotion/mapper/CouponActivityItemMapper.java index 000d8b5c..ec251625 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/mapper/CouponActivityItemMapper.java +++ b/framework/src/main/java/cn/lili/modules/promotion/mapper/CouponActivityItemMapper.java @@ -1,7 +1,12 @@ package cn.lili.modules.promotion.mapper; import cn.lili.modules.promotion.entity.dos.CouponActivityItem; +import cn.lili.modules.promotion.entity.vos.CouponActivityItemVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; /** * 优惠券活动 @@ -11,5 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface CouponActivityItemMapper extends BaseMapper { - + @Select("SELECT cai.*,c.coupon_name,c.price,c.coupon_type,c.coupon_discount FROM li_coupon_activity_item cai INNER JOIN li_coupon c ON cai.coupon_id = c.id WHERE cai.activity_id= #{activityId} ") + List getCouponActivityItemListVO(String activityId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/CouponActivityItemService.java b/framework/src/main/java/cn/lili/modules/promotion/service/CouponActivityItemService.java index 5616b7c8..f85206dc 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/CouponActivityItemService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/CouponActivityItemService.java @@ -1,6 +1,7 @@ package cn.lili.modules.promotion.service; import cn.lili.modules.promotion.entity.dos.CouponActivityItem; +import cn.lili.modules.promotion.entity.vos.CouponActivityItemVO; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -20,4 +21,11 @@ public interface CouponActivityItemService extends IService * @return 优惠券关联优惠券列表 */ List getCouponActivityList(String activityId); + /** + * 获取优惠券活动关联优惠券列表VO + * + * @param activityId 优惠券活动ID + * @return 优惠券关联优惠券列表 + */ + List getCouponActivityItemListVO(String activityId); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java index b5993abc..c8c1cd5a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java @@ -1,6 +1,7 @@ package cn.lili.modules.promotion.serviceimpl; import cn.lili.modules.promotion.entity.dos.CouponActivityItem; +import cn.lili.modules.promotion.entity.vos.CouponActivityItemVO; import cn.lili.modules.promotion.mapper.CouponActivityItemMapper; import cn.lili.modules.promotion.service.CouponActivityItemService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -16,8 +17,15 @@ import java.util.List; */ @Service public class CouponActivityItemServiceImpl extends ServiceImpl implements CouponActivityItemService { + @Override public List getCouponActivityList(String activityId) { return this.list(this.lambdaQuery().eq(CouponActivityItem::getActivityId, activityId)); } + + @Override + public List getCouponActivityItemListVO(String activityId) { + return this.baseMapper.getCouponActivityItemListVO(activityId); + } + } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index 8bf5734f..3dd081c6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -74,7 +74,7 @@ public class CouponActivityServiceImpl extends ServiceImpl