From 3b05b235bcabbe73700473cdc2e5d1597834a590 Mon Sep 17 00:00:00 2001 From: sj <1304317391@qq.com> Date: Tue, 8 Nov 2022 13:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A6=9C=E5=8D=95=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=8F=8A=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/param/ProductReplyParam.java | 4 +-- .../co/yixiang/constant/ShopConstants.java | 2 +- .../mapper/YxStoreCouponUserMapper.java | 2 +- .../rest/StoreCategoryController.java | 1 + .../impl/YxStoreHotListRecordServiceImpl.java | 8 +++--- .../impl/YxStoreHotListServiceImpl.java | 20 ++++++++++---- .../product/rest/StoreProductController.java | 26 +++++++++++++++++++ .../service/impl => utils}/TaskMsg.java | 19 +++++++++----- 8 files changed, 64 insertions(+), 18 deletions(-) rename zsw-bxg/src/main/java/co/yixiang/{modules/hotList/service/impl => utils}/TaskMsg.java (89%) diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java index 1f3c6183..4703beab 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java @@ -16,8 +16,8 @@ import javax.validation.constraints.Size; @Setter public class ProductReplyParam { - @NotBlank(message = "评论不能为空") - @Size(min = 1, max = 200,message = "长度超过了限制") +// @NotBlank(message = "评论不能为空") + @Size(min = 0, max = 200,message = "长度超过了限制") @ApiModelProperty(value = "商品评论内容") private String comment; diff --git a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java index 0bd93a76..a716a81e 100644 --- a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java +++ b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java @@ -117,7 +117,7 @@ public interface ShopConstants { /** * 热门搜索 */ - String ZSW_HOT_SEARCH = "zsw_hot_search"; + String ZSW_HOT_SEARCH = "yshop_hot_search"; /** * 个人中心菜单 */ diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java index 9feb7638..0ca1f6c3 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java @@ -39,7 +39,7 @@ public interface YxStoreCouponUserMapper extends CoreMapper { - @Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime} AND tenant_id = 138") + @Select("select *from yx_store_coupon_user where status = 0 AND is_fail=0 AND use_end_time <= #{endTime}") List selectUserCouponList(@Param("endTime") Date endTime); //"状态(0:未使用,1:已使用, 2:已过期)" } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java index edf42bbe..79666186 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java @@ -11,6 +11,7 @@ package co.yixiang.modules.category.rest; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.constant.ShopConstants; +import co.yixiang.exception.BadRequestException; import co.yixiang.logging.aop.log.Log; import co.yixiang.modules.aop.ForbidSubmit; import co.yixiang.modules.category.domain.YxStoreCategory; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java index 63f6059c..64b222ab 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListRecordServiceImpl.java @@ -8,6 +8,8 @@ */ package co.yixiang.modules.hotList.service.impl; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import co.yixiang.common.service.impl.BaseServiceImpl; import co.yixiang.common.utils.QueryHelpPlus; import co.yixiang.domain.PageResult; @@ -59,9 +61,9 @@ public class YxStoreHotListRecordServiceImpl extends BaseServiceImpl page = new PageInfo<>(queryAll(criteria)); PageResult result=generator.convertPageInfo(page,YxStoreHotListRecordDto.class); result.getContent().forEach(i->{ - i.setHotListName(yxStoreHotListMapper.selectById(i.getHotListId()).getListName()); - i.setCateName(storeCategoryMapper.selectById(i.getCateId()).getCateName()); - i.setProductName(yxStoreProductService.getById(i.getProductId()).getStoreName()); + i.setHotListName(ObjectUtil.isEmpty(yxStoreHotListMapper.selectById(i.getHotListId()))?"*原绑定榜单已被删除":yxStoreHotListMapper.selectById(i.getHotListId()).getListName()); + i.setCateName(ObjectUtil.isEmpty(storeCategoryMapper.selectById(i.getCateId()))?"*原商品分类已被删除":storeCategoryMapper.selectById(i.getCateId()).getCateName()); + i.setProductName(ObjectUtil.isEmpty(yxStoreProductService.getById(i.getProductId()))?"*原绑定商品已被删除":yxStoreProductService.getById(i.getProductId()).getStoreName()); }); return result; } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java index 63eb3bb8..324c9cc0 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java @@ -162,7 +162,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); - //获取所有评测列表(后期限制一年?) + //获取所有榜单记录列表(后期限制一年?) List list=yxStoreHotListRecordMapper.selectList(wrapper); if(list.isEmpty()){ return null; @@ -182,8 +182,13 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl wrapperList=new LambdaQueryWrapper<>(); + wrapperList.in(YxStoreHotList::getId,hotIdList).orderByAsc(YxStoreHotList::getSort); + ArrayList list1=new ArrayList<>(); + yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId())); ArrayList hotListDTOS=new ArrayList<>(); - hotIdList.forEach(hotId->{ + list1.forEach(hotId->{ LambdaQueryWrapper wrapper1= SerializationUtils.clone(wrapper); //查出当前月份当前榜单的记录 List recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); @@ -254,7 +259,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); - //获取所有评测列表(后期限制一年?) + //获取所有榜单记录列表(后期限制一年?) List list=yxStoreHotListRecordMapper.selectList(wrapper); if(list.isEmpty()){ return null; @@ -265,14 +270,19 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl recordList=yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth,mouth)); LinkedHashSet hotIdList=new LinkedHashSet<>(); - //获得不重复的榜单信息 + //获得不重复的榜单id recordList.forEach(cate->{ if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){ hotIdList.add(cate.getHotListId()); } }); + //批量查询榜单信息,并进行排序 + LambdaQueryWrapper wrapperList=new LambdaQueryWrapper<>(); + wrapperList.in(YxStoreHotList::getId,hotIdList).orderByAsc(YxStoreHotList::getSort); + ArrayList list1=new ArrayList<>(); + yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId())); ArrayList hotListDTOS=new ArrayList<>(); - hotIdList.forEach(hotId->{ + list1.forEach(hotId->{ LambdaQueryWrapper wrapper1= SerializationUtils.clone(wrapper); //查出当前月份当前榜单的记录 List recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java index 52b8ddfe..31c54036 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java @@ -112,6 +112,32 @@ public class StoreProductController { return new ResponseEntity<>(queryAll,HttpStatus.OK); } + @Log("查询所有商品分类及下面的商品") + @ApiOperation(value = "查询所有商品分类及下面的商品") + @GetMapping(value = "/yxStoreProductAndCart") + public ResponseEntity getYxStoreProductsAndCart(){ + //商品分类 + List storeCategories = yxStoreCategoryService.lambdaQuery() + .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .list(); + List> cateList = new ArrayList<>(); + storeCategories.forEach(yxStoreCategory -> { + String html = "|-----"; + String newHtml = ""; + Map map = new HashMap<>(); + newHtml = String.join("", Collections.nCopies(1,html)); + map.put("value",yxStoreCategory.getId()); + map.put("label",newHtml + yxStoreCategory.getCateName()); + List list=yxStoreProductService.lambdaQuery() + .eq(YxStoreProduct::getIsShow,ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreProduct::getCateId,yxStoreCategory.getId()) + .list(); + map.put("children",list); + cateList.add(map); + }); + return new ResponseEntity<>(cateList,HttpStatus.OK); + } + @ForbidSubmit @Log("新增/修改商品") @ApiOperation(value = "新增/修改商品") diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java b/zsw-bxg/src/main/java/co/yixiang/utils/TaskMsg.java similarity index 89% rename from zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java rename to zsw-bxg/src/main/java/co/yixiang/utils/TaskMsg.java index 746c8660..94b9a29e 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/TaskMsg.java +++ b/zsw-bxg/src/main/java/co/yixiang/utils/TaskMsg.java @@ -1,6 +1,8 @@ -package co.yixiang.modules.hotList.service.impl; +package co.yixiang.utils; import cn.hutool.core.date.DateUtil; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import co.yixiang.annotation.AnonymousAccess; import co.yixiang.enums.CommonEnum; import co.yixiang.enums.ShopCommonEnum; import co.yixiang.event.TemplateBean; @@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.Calendar; import java.util.Date; @@ -42,10 +45,11 @@ public class TaskMsg { //定时器,每天下午17点触发 @Scheduled(cron = "0 0 17 * * ?") -// @Scheduled(cron = "0 50 17 * * ?") +// @Scheduled(cron = "0/8 * * * * ? ") public void scheduled(){ log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + TenantContextHolder.setIgnore(true); //查出所有用户拥有的券使用时间小于24小时且未使用的券 Date now=new Date(); Date endTime = DateUtil.offsetDay(now,1); @@ -62,9 +66,10 @@ public class TaskMsg { }); } - @Scheduled(fixedRate = 20000) - public void execute() { - log.info("[execute][定时第 ({}) 次执行]", System.currentTimeMillis()); +// @Scheduled(fixedRate = 20000) +// public void execute() { +// log.info("[execute][定时第 ({}) 次执行]", System.currentTimeMillis()); +// TenantContextHolder.setIgnore(true); // Date now=new Date(); // Date endTime = DateUtil.offsetDay(now,1); // List storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); @@ -78,14 +83,16 @@ public class TaskMsg { // .build(); // publisher.publishEvent(new TemplateEvent(this, templateBean)); // }); - } +// } //每个月最后一天23:30生成该月的榜单 + @Transactional(rollbackFor = Exception.class) @Scheduled(cron = "0 30 23 L * ?") public void setYxStoreHotListRecord(){ log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); log.info("=====>>>>>使用cron {}",System.currentTimeMillis()); + TenantContextHolder.setIgnore(true); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) .eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue())