From b29becf95484be48aa09e87fcc7cc19f94cf9c81 Mon Sep 17 00:00:00 2001 From: rentaiming <806181062@qq.com> Date: 星期三, 10 七月 2024 18:16:23 +0800 Subject: [PATCH] 修改bug --- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java index 5307822..e061b5c 100644 --- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java +++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java @@ -22,8 +22,10 @@ import com.ruoyi.goods.controller.management.dto.GoodsSeckillQuery; import com.ruoyi.goods.controller.management.dto.GoodsSeckillUpd; import com.ruoyi.goods.controller.management.vo.GoodsSeckillVO; +import com.ruoyi.goods.domain.GoodsSeckillAppointment; import com.ruoyi.goods.domain.MemberGoodsCollection; import com.ruoyi.goods.mapper.GoodsSeckillMapper; +import com.ruoyi.goods.service.IGoodsSeckillAppointmentService; import com.ruoyi.goods.service.IGoodsSeckillService; import com.ruoyi.goods.service.IGoodsSkuService; import com.ruoyi.goods.service.IMemberGoodsCollectionService; @@ -36,6 +38,7 @@ import com.ruoyi.system.api.domain.GoodsSeckill; import com.ruoyi.system.api.domain.GoodsSeries; import com.ruoyi.system.api.domain.GoodsSku; +import com.ruoyi.system.api.domain.WebsocketMessageDTO; import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; import com.ruoyi.system.api.domain.dto.ListStatusDTO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillInfoVO; @@ -43,7 +46,6 @@ import com.ruoyi.system.api.feignClient.GoodsSkuClient; import com.ruoyi.system.api.feignClient.OrderClient; import com.ruoyi.system.api.feignClient.SysUserClient; -import com.ruoyi.system.api.util.WebSocketUsers; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -84,6 +86,10 @@ @Resource private IMemberGoodsCollectionService iMemberGoodsCollectionService; + + @Resource + private IGoodsSeckillAppointmentService iGoodsSeckillAppointmentService; + @Override @Transactional(rollbackFor = Exception.class) public void addGoodsSeckill(GoodsSeckillDTO dto) { @@ -221,7 +227,8 @@ map.put("target_id", seckillId); map.put("message_type", "start"); String msg = objectMapper.writeValueAsString(map); - WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), msg); + sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) + .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); log.info("===================>发送websocket通知,消息体{}", msg); } @@ -248,7 +255,8 @@ map.put("target_id", seckillId); map.put("message_type", "end"); String msg = objectMapper.writeValueAsString(map); - WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), msg); + sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) + .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); log.info("===================>发送websocket通知,消息体{}", msg); } @@ -256,8 +264,7 @@ public PageDTO<HomeGoodsSeckillVO> getHomeGoodsSeckillVOList(HomeGoodsSkuDTO homeGoodsSkuDTO) { LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery(); wrapper3.eq(GoodsSku::getDelFlag,0); - wrapper3.eq(GoodsSku::getListingStatus,0); - if (homeGoodsSkuDTO.getSkuName()!=null){ + if (homeGoodsSkuDTO.getSkuName()!=null && homeGoodsSkuDTO.getSkuName()!=""){ wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); } if (homeGoodsSkuDTO.getBrandId()!=null){ @@ -351,8 +358,11 @@ in.add(0); in.add(1); wrapper4.in(GoodsSeckill::getStartStatus,in); - wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList); - wrapper4.orderByAsc(GoodsSeckill::getSortNum); + if(goodsSkuIdList.size()>0){ + wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList); + } + + wrapper4.orderByDesc(GoodsSeckill::getSortNum); Page<GoodsSeckill> page2 = this.page(page, wrapper4); PageDTO<HomeGoodsSeckillVO> HomeGoodsSeckillVOPageDTO = PageDTO.of(page2, HomeGoodsSeckillVO.class); @@ -379,10 +389,19 @@ GoodsCategory data1 = goodsSkuClient.getCategoryOne(data6.getCategoryId(), SecurityConstants.INNER).getData(); GoodsSeries data2 = goodsSkuClient.getSeriesOne(data6.getSeriesId(), SecurityConstants.INNER).getData(); GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(data6.getFlavorTypeId(), SecurityConstants.INNER).getData(); - homeGoodsSeckillInfoVO.setBrand(data.getBrandName()); + if(data!=null){ + homeGoodsSeckillInfoVO.setBrand(data.getBrandName()); + } + if(data1!=null){ homeGoodsSeckillInfoVO.setCategory(data1.getCategoryName()); + } + if(data2!=null){ homeGoodsSeckillInfoVO.setSeries(data2.getSeriesName()); + } + if(data3!=null){ homeGoodsSeckillInfoVO.setFlavorType(data3.getFlavorTypeName()); + } + homeGoodsSeckillInfoVO.setPrice(data6.getPrice()); homeGoodsSeckillInfoVO.setSoldQuantity(byId.getSoldQuantity()); homeGoodsSeckillInfoVO.setUnit(data6.getUnit()); @@ -410,6 +429,18 @@ }else{ homeGoodsSeckillInfoVO.setIsCollection(1); } + + LambdaQueryWrapper<GoodsSeckillAppointment> wrapper4= Wrappers.lambdaQuery(); + wrapper4.eq(GoodsSeckillAppointment::getDelFlag,0); + wrapper4.eq(GoodsSeckillAppointment::getMemberId,homeGoodsSkuDTO.getMemberId()); + wrapper4.eq(GoodsSeckillAppointment::getGoodsSeckillId,homeGoodsSkuDTO.getGoodsSkuId()); + List<GoodsSeckillAppointment> list2 = iGoodsSeckillAppointmentService.list(wrapper4); + if (list2.size()>0){ + homeGoodsSeckillInfoVO.setIsAppointment(2); + }else{ + homeGoodsSeckillInfoVO.setIsAppointment(1); + } + return homeGoodsSeckillInfoVO; } } -- Gitblit v1.7.1