From 17abf0608f62cdd318dba3e7b12a32ea486cb482 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期一, 21 四月 2025 20:34:03 +0800 Subject: [PATCH] 导入导出,财务统计 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java | 56 ++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 18 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java index 0780b0f..7824684 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java @@ -12,16 +12,20 @@ import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsSeckill; import com.ruoyi.other.api.domain.SeckillActivityInfo; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.feignClient.ShopClient; import com.ruoyi.other.api.vo.GetSeckillActivityInfo; import com.ruoyi.other.mapper.SeckillActivityInfoMapper; import com.ruoyi.other.service.GoodsSeckillService; import com.ruoyi.other.service.GoodsService; import com.ruoyi.other.service.SeckillActivityInfoService; +import com.ruoyi.other.service.ShopService; import com.ruoyi.other.vo.SeckillActivityDetailVO; import com.ruoyi.other.vo.SeckillActivityVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -56,10 +60,9 @@ @Resource private OrderClient orderClient; - - - - + @Resource + private ShopService shopService; + /** * 秒杀活动列表 @@ -83,16 +86,19 @@ /** - * 根据商品id和会员等级获取对应的秒杀活动 + * 根据商品id获取对应的秒杀活动 */ @PostMapping("/getSeckillActivityInfo") public R<GoodsSeckill> getSeckillActivityInfo(@RequestBody GetSeckillActivityInfo info){ - SeckillActivityInfo one = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, info.getGoodsId()) - .eq(SeckillActivityInfo::getDelFlag, 0).eq(SeckillActivityInfo::getIsShelves, 1).last(" and now() between start_time and end_time order by create_time limit 0,1")); + SeckillActivityInfo one = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>() + .eq(SeckillActivityInfo::getGoodId, info.getGoodsId()) + .eq(SeckillActivityInfo::getDelFlag, 0) + .eq(SeckillActivityInfo::getIsShelves, 1) + .last(" and now() between start_time and end_time order by create_time limit 0,1")); if(null == one){ return R.ok(); } - GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId()).eq(GoodsSeckill::getVip, info.getVip())); + GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId())); if(null != goodsSeckill){ LocalDateTime endTime = one.getEndTime(); // 转时间戳 @@ -140,8 +146,6 @@ }else { record.setStatus(1); // 未开始 } - Integer saleNum = orderClient.getGoodsSaleNum(record.getGoodsId(), 2).getData(); - record.setSaleNum(saleNum); } return R.ok(IPage); } @@ -153,6 +157,7 @@ @ApiOperation(value = "新增秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> save(@RequestBody SeckillActivityInfo seckillActivityInfo) { + if (seckillActivityInfo.getStartTime().isAfter(seckillActivityInfo.getEndTime()))return R.fail("开始时间不能晚于结束时间"); seckillActivityInfoService.saveSeckillActivityInfo(seckillActivityInfo); return R.ok(); } @@ -174,6 +179,7 @@ @ApiOperation(value = "修改秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> update(@RequestBody SeckillActivityInfo seckillActivityInfo) { + if (seckillActivityInfo.getStartTime().isAfter(seckillActivityInfo.getEndTime()))return R.fail("开始时间不能晚于结束时间"); seckillActivityInfoService.updateSeckillActivityInfo(seckillActivityInfo); return R.ok(); } @@ -185,6 +191,8 @@ @ApiOperation(value = "删除秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> remove(@PathVariable Integer id) { + //先删除 + goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, id)); seckillActivityInfoService.removeById(id); return R.ok(); } @@ -194,16 +202,28 @@ */ @GetMapping("/getSeckillActivityDetail") @ApiOperation(value = "获取秒杀活动明细", tags = {"后台管理-活动管理-秒杀活动" }) - public R<SeckillActivityInfo> getSeckillActivityDetail(Integer id) + public R<SeckillActivityVO> getSeckillActivityDetail(Integer id) { + SeckillActivityVO vo = new SeckillActivityVO(); + SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getById(id); - List<GoodsSeckill> goodsSeckills = goodsSeckillService.list(new LambdaQueryWrapper<GoodsSeckill>() - .eq(GoodsSeckill::getSeckillActivityInfoId, id)); - seckillActivityInfo.setGoodsSeckills(goodsSeckills); - Integer goodId = seckillActivityInfo.getGoodId(); - Goods goods = goodsService.getById(goodId); - seckillActivityInfo.setGoods(goods); - return R.ok(seckillActivityInfo); + Goods goods = goodsService.getById(seckillActivityInfo.getGoodId()); + GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>() + .eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); + + vo.setId(seckillActivityInfo.getId().toString()); + vo.setGoodsId(seckillActivityInfo.getGoodId()); + vo.setGoodsName(goods.getName()); + vo.setGoodsCategoryName(goods.getCategoryName()); + vo.setSellingPrice(goods.getSellingPrice()); + vo.setActivityPrice(goodsSeckill.getSellingPrice()); + vo.setMaxNum(seckillActivityInfo.getMaxNum());//活动限购 + vo.setStartTime(seckillActivityInfo.getStartTime()); + vo.setEndTime(seckillActivityInfo.getEndTime()); + + + + return R.ok(vo); } /** -- Gitblit v1.7.1