From 06f455915bb9d11caa8829942f9007809ee9ae3d Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 28 十一月 2024 16:37:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 40 insertions(+), 5 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 95242a8..a57807b 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
@@ -1,18 +1,26 @@
 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.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 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.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalUnit;
+import java.util.List;
 
 /**
  * <p>
@@ -28,6 +36,13 @@
 public class SeckillActivityInfoController extends BaseController {
     @Resource
     private SeckillActivityInfoService seckillActivityInfoService;
+    
+    @Resource
+    private GoodsSeckillService goodsSeckillService;
+    
+    
+    
+    
 
     /**
      * 秒杀活动列表
@@ -49,6 +64,26 @@
     {
         return AjaxResult.success(seckillActivityInfoService.detail(id));
     }
-
+    
+    
+    /**
+     * 根据商品id和会员等级获取对应的秒杀活动
+     * @param info
+     * @return
+     */
+    @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);
+    }
+    
 }
 

--
Gitblit v1.7.1