| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | @GetMapping("/detail/{id}") |
| | | @ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页"}) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id, String latitude, String longitude) |
| | | { |
| | | return R.ok(seckillActivityInfoService.detail(id)); |
| | | return R.ok(seckillActivityInfoService.detail(id, latitude, longitude)); |
| | | } |
| | | |
| | | |
| | |
| | | @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")); |
| | | .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.getGoodId()).eq(GoodsSeckill::getVip, info.getVip())); |
| | | GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId()).eq(GoodsSeckill::getVip, info.getVip())); |
| | | if(null != goodsSeckill){ |
| | | goodsSeckill.setEndTime(one.getEndTime().toEpochSecond(ZoneOffset.UTC) * 1000); |
| | | } |
| | | return R.ok(goodsSeckill); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取商品秒杀活动 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSeckillActivityInfoById") |
| | | public R<SeckillActivityInfo> getSeckillActivityInfoById(@RequestParam("id") Integer id){ |
| | | SeckillActivityInfo one = seckillActivityInfoService.getById(id); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | |
| | | Goods goods) |
| | | { |
| | | IPage<SeckillActivityVO> IPage = seckillActivityInfoMapper.querySeckillActivity(Page.of(pageNum, pageSize), goods); |
| | | for (SeckillActivityVO record : IPage.getRecords()) { |
| | | LocalDateTime startTime = record.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime endTime = record.getEndTime(); |
| | | if (endTime.isBefore(now)){ |
| | | record.setStatus(3); //已结束 |
| | | }else if (startTime.isBefore(now)){ |
| | | record.setStatus(2); // 已开始 |
| | | }else { |
| | | record.setStatus(1); // 未开始 |
| | | } |
| | | } |
| | | return R.ok(IPage); |
| | | } |
| | | |