ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/HomeGoodsSeckillInfoVO.java
New file @@ -0,0 +1,85 @@ package com.ruoyi.system.api.domain.vo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.ruoyi.common.core.enums.StartStatusEnum; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; @Data public class HomeGoodsSeckillInfoVO { @ApiModelProperty(value = "秒杀商品id") private Long goodsSkuId; @ApiModelProperty(value = "商品名称") private String skuName; @ApiModelProperty(value = "商品年份") private String years; @ApiModelProperty(value = "商品分类") private String category; @ApiModelProperty(value = "商品系列") private String series; @ApiModelProperty(value = "商品品牌") private String brand; @ApiModelProperty(value = "商品香型") private String flavorType; @ApiModelProperty(value = "商品价格") private BigDecimal price; @ApiModelProperty(value = "已售数量") private Integer soldQuantity; @ApiModelProperty(value = "单位") private String unit; @ApiModelProperty(value = "规格") private String spec; @ApiModelProperty(value = "规格单位") private String specUnit; @ApiModelProperty(value = "封面图") private String coverPic; @ApiModelProperty(value = "详情图,不超过五张图片") private String album; @ApiModelProperty(value = "分享标题") private String shareTitle; @ApiModelProperty(value = "分享图片") private String sharePic; @ApiModelProperty(value = "商品描述") private String description; @ApiModelProperty(value = "商品说明") private String detail; @ApiModelProperty(value = "限购数量") private Integer limitNumber; @ApiModelProperty(value = "秒杀价格") private BigDecimal seckillPrice; @ApiModelProperty(value = "秒杀开始时间") private LocalDateTime startTime; @ApiModelProperty(value = "秒杀结束时间") private LocalDateTime endTime; @ApiModelProperty(value = "开始状态 0=未开始 1= 已开始 2=已结束") private StartStatusEnum startStatus; } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/vo/HomeGoodsSeckillVO.java
New file @@ -0,0 +1,47 @@ package com.ruoyi.system.api.domain.vo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; @Data public class HomeGoodsSeckillVO { @ApiModelProperty(value = "秒杀商品id") @TableId(value = "id", type = IdType.ASSIGN_ID) private Long id; @ApiModelProperty(value = "商品id") private Long goodsSkuId; @ApiModelProperty(value = "商品名称") private String skuName; @ApiModelProperty(value = "商品年份") private String years; @ApiModelProperty(value = "商品价格") private BigDecimal price; @ApiModelProperty(value = "秒杀价格") private BigDecimal seckillPrice; @ApiModelProperty(value = "已售数量") private Integer soldQuantity; @ApiModelProperty(value = "封面图") private String coverPic; @ApiModelProperty(value = "秒杀开始时间") private LocalDateTime startTime; @ApiModelProperty(value = "秒杀结束时间") private LocalDateTime endTime; } ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsBrandController.java
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.goods.service.IGoodsBrandService; import com.ruoyi.system.api.domain.GoodsBrand; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -24,6 +25,7 @@ @RestController @RequestMapping("/forepart/goods-brand") @RequiredArgsConstructor @Api(value = "商品品牌接口", tags = "商品品牌接口", description = "商品品牌接口") public class ForepartGoodsBrandController { @Resource ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsBrowseRecordController.java
@@ -6,6 +6,7 @@ import com.ruoyi.goods.service.IGoodsBrowseRecordService; import com.ruoyi.system.api.domain.dto.AuctionCollectionDTO; import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,6 +25,7 @@ */ @RestController @RequestMapping("/forepart/goods-browse-record") @Api(value = "浏览的普通商品接口", tags = "浏览的普通商品接口", description = "浏览的普通商品接口") public class ForepartGoodsBrowseRecordController { @Resource private IGoodsBrowseRecordService iGoodsBrowseRecordService; ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsCategoryController.java
@@ -7,6 +7,7 @@ import com.ruoyi.common.security.annotation.InnerAuth; import com.ruoyi.goods.service.IGoodsCategoryService; import com.ruoyi.system.api.domain.GoodsCategory; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -23,6 +24,7 @@ */ @RestController @RequestMapping("/forepart/goods-category") @Api(value = "商品分类接口", tags = "商品分类接口", description = "商品分类接口") public class ForepartGoodsCategoryController { @Resource ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsFlavorTypeController.java
@@ -8,6 +8,7 @@ import com.ruoyi.goods.service.IGoodsFlavorTypeService; import com.ruoyi.system.api.domain.GoodsCategory; import com.ruoyi.system.api.domain.GoodsFlavorType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -24,6 +25,7 @@ */ @RestController @RequestMapping("/forepart/goods-flavor-type") @Api(value = "香型接口", tags = "香型接口", description = "香型接口") public class ForepartGoodsFlavorTypeController { @Resource private IGoodsFlavorTypeService iGoodsFlavorTypeService; ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsGroupPurchaseController.java
@@ -8,6 +8,7 @@ import com.ruoyi.goods.service.IGoodsGroupPurchaseService; import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; import com.ruoyi.system.api.domain.vo.HomeGoodsSkuInfoVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -25,6 +26,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/forepart/goods-group-purchase") @Api(value = "商品团购接口", tags = "商品团购接口", description = "商品团购接口") public class ForepartGoodsGroupPurchaseController { private final IGoodsGroupPurchaseService goodsGroupPurchaseService; ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsSeckillController.java
New file @@ -0,0 +1,50 @@ package com.ruoyi.goods.controller.forepart; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.page.PageDTO; import com.ruoyi.goods.controller.forepart.vo.GoodsGroupPurchaseInfoVO; import com.ruoyi.goods.service.IGoodsSeckillService; import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillInfoVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; /** * <p> * 商品秒杀表 前端控制器 * </p> * * @author mitao * @since 2024-05-16 */ @Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/forepart/goods-seckill") @Api(value = "商品秒杀接口", tags = "商品秒杀接口", description = "商品秒杀接口") public class ForepartGoodsSeckillController { private final IGoodsSeckillService goodsSeckillService; @RequestMapping("/getHomeGoodsSeckillVOList") @ResponseBody @ApiOperation(value = "用户端-秒杀商品列表") public R<PageDTO<HomeGoodsSeckillVO>> getHomeGoodsSeckillVOList(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO) { return R.ok(goodsSeckillService.getHomeGoodsSeckillVOList(homeGoodsSkuDTO)); } @RequestMapping("/getHomeGoodsSeckillInfo") @ResponseBody @ApiOperation(value = "用户端-秒杀商品详情") public R<HomeGoodsSeckillInfoVO> getHomeGoodsSeckillInfo(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO) { return R.ok(goodsSeckillService.getHomeGoodsSeckillInfo(homeGoodsSkuDTO)); } } ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsSeriesController.java
@@ -8,6 +8,7 @@ import com.ruoyi.goods.service.IGoodsSeriesService; import com.ruoyi.system.api.domain.GoodsFlavorType; import com.ruoyi.system.api.domain.GoodsSeries; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -24,6 +25,7 @@ */ @RestController @RequestMapping("/forepart/goods-series") @Api(value = "系列接口", tags = "系列接口", description = "系列接口") public class ForepartGoodsSeriesController { @Resource ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartGoodsSkuController.java
@@ -31,14 +31,14 @@ @RequestMapping("/getHomeGoodsSkuVOList") @ResponseBody @ApiOperation(value = "用户端-普通拍卖商品列表") @ApiOperation(value = "用户端-普通商品列表") public R<PageDTO<HomeGoodsSkuListVO>> getHomeGoodsSkuVOList(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO) { return R.ok(iGoodsSkuService.getHomeGoodsSkuVOList(homeGoodsSkuDTO)); } @RequestMapping("/getHomeGoodsSkuInfoVO") @ResponseBody @ApiOperation(value = "用户端-普通拍卖商品详情") @ApiOperation(value = "用户端-普通商品详情") public R<HomeGoodsSkuInfoVO> getHomeGoodsSkuInfo(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO) { return R.ok(iGoodsSkuService.getHomeGoodsSkuInfo(homeGoodsSkuDTO)); } ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/ForepartMemberGoodsCollectionController.java
@@ -7,6 +7,7 @@ import com.ruoyi.system.api.domain.dto.AuctionCollectionDTO; import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -22,6 +23,7 @@ */ @RestController @RequestMapping("/forepart/member-goods-collection") @Api(value = "收藏普通商品接口", tags = "收藏普通商品口", description = "收藏普通商品接口") public class ForepartMemberGoodsCollectionController { @Resource ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/forepart/vo/GoodsGroupPurchaseInfoVO.java
@@ -11,7 +11,7 @@ import java.time.LocalDateTime; @Data public class GoodsGroupPurchaseInfoVO { @ApiModelProperty(value = "商品id") @ApiModelProperty(value = "团购商品id") private Long goodsSkuId; @ApiModelProperty(value = "商品名称") ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/IGoodsSeckillService.java
@@ -8,7 +8,11 @@ import com.ruoyi.goods.controller.management.dto.GoodsSeckillUpd; import com.ruoyi.goods.controller.management.vo.GoodsSeckillVO; import com.ruoyi.system.api.domain.GoodsSeckill; import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; import com.ruoyi.system.api.domain.dto.ListStatusDTO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillInfoVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillVO; import org.springframework.web.bind.annotation.RequestBody; /** * <p> @@ -70,4 +74,8 @@ * @param seckillId 秒杀id */ void endSeckill(Long seckillId) throws JsonProcessingException; PageDTO<HomeGoodsSeckillVO> getHomeGoodsSeckillVOList(HomeGoodsSkuDTO homeGoodsSkuDTO); HomeGoodsSeckillInfoVO getHomeGoodsSeckillInfo(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO); } ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java
@@ -1,5 +1,7 @@ package com.ruoyi.goods.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.core.JsonProcessingException; @@ -24,17 +26,23 @@ import com.ruoyi.goods.service.async.AsyncMethodService; import com.ruoyi.system.api.constants.DelayTaskEnum; import com.ruoyi.system.api.constants.NotificationTypeConstant; import com.ruoyi.system.api.domain.GoodsSeckill; import com.ruoyi.system.api.domain.GoodsSku; import com.ruoyi.system.api.domain.*; import com.ruoyi.system.api.domain.dto.AuctionGoodsListPageDTO; import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; import com.ruoyi.system.api.domain.dto.ListStatusDTO; import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillInfoVO; import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillVO; 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.LocalDateTime; import java.util.List; import java.util.Map; import java.util.Optional; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -55,6 +63,7 @@ private final IGoodsSkuService goodsSkuService; private final OrderClient orderClient; private final GoodsSkuClient goodsSkuClient; private final RedisService redisService; private final SysUserClient sysUserClient; private final AsyncMethodService asyncMethodService; @@ -227,4 +236,129 @@ WebSocketUsers.sendMessageToUsersByText(msg); log.info("===================>发送websocket通知,消息体{}", msg); } @Override public PageDTO<HomeGoodsSeckillVO> getHomeGoodsSeckillVOList(HomeGoodsSkuDTO homeGoodsSkuDTO) { LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery(); wrapper3.eq(GoodsSku::getDelFlag,0); wrapper3.eq(GoodsSku::getListingStatus,0); wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); wrapper3.eq(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName()); wrapper3.eq(GoodsSku::getBrandId,homeGoodsSkuDTO.getBrandId()); wrapper3.eq(GoodsSku::getCategoryId,homeGoodsSkuDTO.getCategoryId()); wrapper3.eq(GoodsSku::getSeriesId,homeGoodsSkuDTO.getSeriesId()); wrapper3.eq(GoodsSku::getFlavorTypeId,homeGoodsSkuDTO.getFlavorTypeId()); if (homeGoodsSkuDTO.getSort()==2){ wrapper3.orderByAsc(GoodsSku::getPrice); } if (homeGoodsSkuDTO.getSort()==3){ wrapper3.orderByDesc(GoodsSku::getPrice); } if (homeGoodsSkuDTO.getSort()==4){ wrapper3.orderByAsc(GoodsSku::getSoldQuantity); } if (homeGoodsSkuDTO.getSort()==5){ wrapper3.orderByDesc(GoodsSku::getSoldQuantity); } if(homeGoodsSkuDTO.getYear()==2){ 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); wrapper3.gt(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 newTime15 = now.minusYears(15); String formattedDate15 = newTime15.format(formatter); LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); wrapper3.gt(GoodsSku::getYears, parseTime15) .le(GoodsSku::getYears, parseTime7); } if(homeGoodsSkuDTO.getYear()==3){ 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 newTime15 = now.minusYears(15); String formattedDate15 = newTime15.format(formatter); LocalDateTime parseTime15= LocalDateTime.parse(formattedDate15, formatter); wrapper3.ge(GoodsSku::getYears, parseTime7) .le(GoodsSku::getYears, parseTime15); } List<GoodsSku> page1 = goodsSkuService.list(wrapper3); Set<Long> goodsSkuIdList = null; goodsSkuIdList = page1.stream().map(GoodsSku::getId) .collect(Collectors.toSet()); Page<GoodsSeckill> page = new Page<>(); page.setSize(homeGoodsSkuDTO.getPageSize()); page.setCurrent(homeGoodsSkuDTO.getPageCurr()); LambdaQueryWrapper<GoodsSeckill> wrapper4= Wrappers.lambdaQuery(); wrapper4.eq(GoodsSeckill::getDelFlag,0); wrapper4.eq(GoodsSeckill::getListingStatus,0); List<Integer> in=new ArrayList<>(); in.add(0); in.add(1); wrapper4.in(GoodsSeckill::getStartStatus,in); wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList); wrapper4.orderByAsc(GoodsSeckill::getSortNum); Page<GoodsSeckill> page2 = this.page(page, wrapper4); PageDTO<HomeGoodsSeckillVO> HomeGoodsSeckillVOPageDTO = PageDTO.of(page2, HomeGoodsSeckillVO.class); List<HomeGoodsSeckillVO> list2 = HomeGoodsSeckillVOPageDTO.getList(); for (HomeGoodsSeckillVO homeGoodsSeckillVO:list2){ GoodsSku data = goodsSkuClient.getGoodsSkuOne(homeGoodsSeckillVO.getGoodsSkuId(), SecurityConstants.INNER).getData(); homeGoodsSeckillVO.setPrice(data.getPrice()); homeGoodsSeckillVO.setYears(String.valueOf(data.getYears().getYear())); homeGoodsSeckillVO.setCoverPic(data.getCoverPic()); homeGoodsSeckillVO.setSkuName(data.getSkuName()); } return HomeGoodsSeckillVOPageDTO; } @Override public HomeGoodsSeckillInfoVO getHomeGoodsSeckillInfo(HomeGoodsSkuDTO homeGoodsSkuDTO) { GoodsSeckill byId = this.getById(homeGoodsSkuDTO.getGoodsSkuId()); GoodsSku data6 = goodsSkuClient.getGoodsSkuOne(byId.getGoodsSkuId(), SecurityConstants.INNER).getData(); HomeGoodsSeckillInfoVO homeGoodsSeckillInfoVO=new HomeGoodsSeckillInfoVO(); homeGoodsSeckillInfoVO.setGoodsSkuId(byId.getId()); homeGoodsSeckillInfoVO.setSkuName(data6.getSkuName()); homeGoodsSeckillInfoVO.setYears(String.valueOf(data6.getYears().getYear())); GoodsBrand data = goodsSkuClient.getBrandOne(data6.getBrandId(), SecurityConstants.INNER).getData(); 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()); homeGoodsSeckillInfoVO.setCategory(data1.getCategoryName()); homeGoodsSeckillInfoVO.setSeries(data2.getSeriesName()); homeGoodsSeckillInfoVO.setFlavorType(data3.getFlavorTypeName()); homeGoodsSeckillInfoVO.setPrice(data6.getPrice()); homeGoodsSeckillInfoVO.setSoldQuantity(byId.getSoldQuantity()); homeGoodsSeckillInfoVO.setUnit(data6.getUnit()); homeGoodsSeckillInfoVO.setSpecUnit(data6.getSpecUnit()); homeGoodsSeckillInfoVO.setCoverPic(data6.getCoverPic()); homeGoodsSeckillInfoVO.setAlbum(data6.getAlbum()); homeGoodsSeckillInfoVO.setShareTitle(byId.getShareTitle()); homeGoodsSeckillInfoVO.setSeckillPrice(byId.getSeckillPrice()); homeGoodsSeckillInfoVO.setDescription(data6.getDescription()); homeGoodsSeckillInfoVO.setDetail(data6.getDetail()); homeGoodsSeckillInfoVO.setLimitNumber(byId.getLimitNumber()); homeGoodsSeckillInfoVO.setSeckillPrice(byId.getSeckillPrice()); homeGoodsSeckillInfoVO.setStartTime(byId.getStartTime()); homeGoodsSeckillInfoVO.setEndTime(byId.getEndTime()); homeGoodsSeckillInfoVO.setStartStatus(byId.getStartStatus()); return homeGoodsSeckillInfoVO; } }