From fe2d5b14031edbe43238770fb1fc21e8a322b51a Mon Sep 17 00:00:00 2001 From: rentaiming <806181062@qq.com> Date: 星期四, 13 六月 2024 18:18:08 +0800 Subject: [PATCH] 用户端商品 --- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java | 39 ++++++++++++++++++++++++++++----------- 1 files changed, 28 insertions(+), 11 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 dfcc88f..898e392 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 @@ -41,6 +41,8 @@ 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; import java.util.ArrayList; @@ -281,36 +283,51 @@ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDateTime newTime7 = now.minusYears(30); String formattedDate7 = newTime7.format(formatter); - LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); - wrapper3.gt(GoodsSku::getYears,parseTime7); + LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); + wrapper3.le(GoodsSku::getYears,parseTime7); } if(homeGoodsSkuDTO.getYear()==3){ LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDateTime newTime7 = now.minusYears(30); String formattedDate7 = newTime7.format(formatter); - LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); + LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); LocalDateTime newTime15 = now.minusYears(15); String formattedDate15 = newTime15.format(formatter); - LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); - wrapper3.gt(GoodsSku::getYears, parseTime15) - .le(GoodsSku::getYears, parseTime7); + LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); + wrapper3.le(GoodsSku::getYears, parseTime15) + .gt(GoodsSku::getYears, parseTime7); } - if(homeGoodsSkuDTO.getYear()==3){ + if(homeGoodsSkuDTO.getYear()==4){ LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDateTime newTime7 = now.minusYears(5); String formattedDate7 = newTime7.format(formatter); - LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); + LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); LocalDateTime newTime15 = now.minusYears(15); String formattedDate15 = newTime15.format(formatter); - LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); - wrapper3.ge(GoodsSku::getYears, parseTime7) - .le(GoodsSku::getYears, parseTime15); + LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); + wrapper3.le(GoodsSku::getYears, parseTime7) + .gt(GoodsSku::getYears, parseTime15); } + + if(homeGoodsSkuDTO.getYear()==5){ + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDateTime newTime7 = now.minusYears(1); + String formattedDate7 = newTime7.format(formatter); + LocalDateTime parseTime7 = LocalDate.parse(formattedDate7).atStartOfDay(); + + LocalDateTime newTime15 = now.minusYears(5); + String formattedDate15 = newTime15.format(formatter); + LocalDateTime parseTime15= LocalDate.parse(formattedDate15).atStartOfDay(); + wrapper3.le(GoodsSku::getYears, parseTime7) + .ge(GoodsSku::getYears, parseTime15); + } + List<GoodsSku> page1 = goodsSkuService.list(wrapper3); Set<Long> goodsSkuIdList = null; -- Gitblit v1.7.1