| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | 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.*; |
| | | 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.*; |
| | | 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; |
| | |
| | | |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private ShopService shopService; |
| | | @Autowired |
| | | private GoodsCategoryService goodsCategoryService; |
| | | @Autowired |
| | | private GoodsShopService goodsShopService; |
| | | |
| | | |
| | | /** |
| | | * 秒杀活动列表 |
| | |
| | | }else { |
| | | record.setStatus(1); // 未开始 |
| | | } |
| | | Integer saleNum = orderClient.getGoodsSaleNum(record.getGoodsId(), 2).getData(); |
| | | record.setSaleNum(saleNum); |
| | | } |
| | | return R.ok(IPage); |
| | | } |
| | |
| | | @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(); |
| | | } |
| | |
| | | @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(); |
| | | } |
| | |
| | | @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(); |
| | | } |
| | |
| | | */ |
| | | @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); |
| | | if (seckillActivityInfo==null)return R.fail("秒杀活动不存在"); |
| | | Goods goods = goodsService.getById(seckillActivityInfo.getGoodId()); |
| | | QueryWrapper<GoodsShop> queryWrapper = new QueryWrapper<GoodsShop>(); |
| | | queryWrapper.eq("goods_id", goods.getId()); |
| | | GoodsShop goodsShop = goodsShopService.getOne(queryWrapper); |
| | | GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>() |
| | | .eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); |
| | | GoodsCategory category = goodsCategoryService.getById(goods.getGoodsCategoryId()); |
| | | Shop shop = shopService.getById(goodsShop.getShopId()); |
| | | vo.setId(seckillActivityInfo.getId().toString()); |
| | | vo.setGoodsId(seckillActivityInfo.getGoodId()); |
| | | vo.setGoodsName(goods.getName()); |
| | | vo.setGoodsCategoryName(category.getName()); |
| | | vo.setSellingPrice(goods.getSellingPrice()); |
| | | vo.setOriginalPrice(goods.getOriginalPrice()); |
| | | vo.setActivityPrice(goodsSeckill.getSellingPrice()); |
| | | vo.setMaxNum(seckillActivityInfo.getMaxNum());//活动限购 |
| | | vo.setStartTime(seckillActivityInfo.getStartTime()); |
| | | vo.setEndTime(seckillActivityInfo.getEndTime()); |
| | | vo.setShopId(goodsShop.getShopId()); |
| | | vo.setShopName(shop.getName()); |
| | | |
| | | |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | /** |