| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | 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.vo.GetSeckillActivityInfo; |
| | | import com.ruoyi.other.service.GoodsSeckillService; |
| | | import com.ruoyi.other.service.SeckillActivityInfoService; |
| | | import com.ruoyi.other.vo.SeckillActivityDetailVO; |
| | | import com.ruoyi.other.vo.SeckillActivityVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author luodangjia |
| | | * @since 2024-11-20 |
| | | */ |
| | | @Api(tags = "秒杀活动信息") |
| | | @Api("秒杀活动信息") |
| | | @RestController |
| | | @RequestMapping("/seckill-activity-info") |
| | | public class SeckillActivityInfoController extends BaseController { |
| | | @Resource |
| | | private SeckillActivityInfoService seckillActivityInfoService; |
| | | |
| | | @Resource |
| | | private GoodsSeckillService goodsSeckillService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 秒杀活动列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "秒杀活动列表") |
| | | public AjaxResult list(Goods goods) |
| | | @ApiOperation(value = "秒杀活动列表",tags = {"小程序-商城-首页"}) |
| | | public R<TableDataInfo> list(Goods goods) |
| | | { |
| | | startPage(); |
| | | return AjaxResult.success(seckillActivityInfoService.listSeckillActivity(goods)); |
| | | return R.ok(getDataTable(seckillActivityInfoService.listSeckillActivity(goods))); |
| | | } |
| | | |
| | | /** |
| | | * 秒杀活动详情 |
| | | */ |
| | | @GetMapping("/detail/{id}") |
| | | @ApiOperation(value = "秒杀活动详情") |
| | | public AjaxResult detail(@PathVariable("id") Integer id) |
| | | @ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页"}) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id) |
| | | { |
| | | return AjaxResult.success(seckillActivityInfoService.detail(id)); |
| | | return R.ok(seckillActivityInfoService.detail(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).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.getGoodId()).eq(GoodsSeckill::getVip, info.getVip())); |
| | | if(null != goodsSeckill){ |
| | | goodsSeckill.setEndTime(one.getEndTime().toEpochSecond(ZoneOffset.UTC) * 1000); |
| | | } |
| | | return R.ok(goodsSeckill); |
| | | } |
| | | |
| | | } |
| | | |