Browse Source

自动抽奖修改查询中奖人数(全部查询) 查询个人中奖信息

yuhongqi 2 days ago
parent
commit
3248c31e30

+ 1 - 1
fs-live-socket/src/main/java/com/fs/live/task/Task.java

@@ -271,7 +271,7 @@ public class Task {
             }
 
             // 查询在线用户 并且参与了抽奖的用户
-            List<LiveWatchUser> liveWatchUsers = liveWatchUserService.selectLiveWatchAndRegisterUser(liveLottery.getLiveId(),liveLottery.getLotteryId(), totalLots);
+            List<LiveWatchUser> liveWatchUsers = liveWatchUserService.selectLiveWatchAndRegisterUser(liveLottery.getLiveId(),liveLottery.getLotteryId());
             if(liveWatchUsers.isEmpty()) continue;
             LiveLotteryRegistration liveLotteryRegistration;
             // 收集中奖信息

+ 8 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveUserLotteryRecordMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.fs.live.domain.LiveUserLotteryRecord;
 import com.fs.live.vo.LiveUserLotteryRecordVo;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 /**
@@ -65,4 +66,11 @@ public interface LiveUserLotteryRecordMapper {
     boolean existsByUserIdAndRedId(Long lotteryId, String userId);
 
     List<LiveUserLotteryRecordVo> selectRecordByLiveIdAndLotteryId(LiveUserLotteryRecord liveUserLotteryRecord);
+
+    @Select("select lulr.*,fu.nickname as user_name,fsp.product_name as product_name\n" +
+            "        from live_user_lottery_record lulr left join fs_user fu on lulr.user_id = fu.user_id\n" +
+            "        left join live_goods lg on lulr.product_id = lg.goods_id\n" +
+            "        left join fs_store_product fsp on lg.product_id = fsp.product_id\n" +
+            "        where lulr.user_id = #{userId}")
+    List<LiveUserLotteryRecordVo> selectLiveUserLotteryRecordByUserId(@Param("userId") long userId);
 }

+ 2 - 2
fs-service-system/src/main/java/com/fs/live/mapper/LiveWatchUserMapper.java

@@ -97,8 +97,8 @@ public interface LiveWatchUserMapper {
 
     @Select("select a.*,fu.nickname as nick_name from (select lws.* from live_watch_user lws where live_id=#{liveId} and online = 0 and " +
             "user_id in (select user_id from live_lottery_registration where live_id = #{liveId} and lottery_id=#{lotteryId} and registration_id >= " +
-            "(SELECT FLOOR(RAND() * (SELECT MAX(registration_id) FROM live_lottery_registration)))) limit #{totalLots} ) a left join fs_user fu on fu.user_id = a.user_id")
-    List<LiveWatchUser> selectLiveWatchAndRegisterUser(@Param("liveId") Long liveId,@Param("lotteryId") Long lotteryId,@Param("totalLots") Integer totalLots);
+            "(SELECT FLOOR(RAND() * (SELECT MAX(registration_id) FROM live_lottery_registration)))) ) a left join fs_user fu on fu.user_id = a.user_id")
+    List<LiveWatchUser> selectLiveWatchAndRegisterUser(@Param("liveId") Long liveId,@Param("lotteryId") Long lotteryId);
 
     @Select("select * from live_watch_user where live_id = #{liveId} and user_id = #{userId}")
     LiveWatchUser selectUserByLiveIdAndUserId(@Param("liveId") long liveId,@Param("userId")  long userId);

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveLotteryConfService.java

@@ -7,6 +7,7 @@ import com.fs.live.param.LiveLotteryProductSaveParam;
 import com.fs.live.param.LotteryPO;
 import com.fs.live.vo.LiveLotteryConfVo;
 import com.fs.live.vo.LiveLotteryProductVO;
+import com.fs.live.vo.LiveUserLotteryRecordVo;
 
 import java.util.List;
 import java.util.Set;
@@ -97,4 +98,6 @@ public interface ILiveLotteryConfService {
     void finishStatusByLotteryIds(List<Long> ids);
 
     List<LiveLotteryConf> selectLiveLotteryConfListOn(LiveLotteryConf liveLotteryConf);
+
+    List<LiveUserLotteryRecordVo> myLottery(long l);
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/live/service/ILiveWatchUserService.java

@@ -107,7 +107,7 @@ public interface ILiveWatchUserService {
     int blockUser(Long userId);
 
 
-    List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId,Integer totalLots);
+    List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId);
 
 
     List<LiveWatchUserVO> asyncToCache(Long liveId);

+ 10 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java

@@ -6,9 +6,11 @@ import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
 import com.fs.live.domain.LiveLotteryConf;
 import com.fs.live.domain.LiveLotteryRegistration;
+import com.fs.live.domain.LiveUserLotteryRecord;
 import com.fs.live.mapper.LiveLotteryConfMapper;
 import com.fs.live.mapper.LiveLotteryProductConfMapper;
 import com.fs.live.mapper.LiveLotteryRegistrationMapper;
+import com.fs.live.mapper.LiveUserLotteryRecordMapper;
 import com.fs.live.param.LiveLotteryProduct;
 import com.fs.live.param.LiveLotteryProductSaveParam;
 import com.fs.live.param.LotteryPO;
@@ -16,6 +18,7 @@ import com.fs.live.service.ILiveLotteryConfService;
 import com.fs.live.vo.LiveLotteryConfVo;
 import com.fs.live.vo.LiveLotteryProductListVo;
 import com.fs.live.vo.LiveLotteryProductVO;
+import com.fs.live.vo.LiveUserLotteryRecordVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,6 +45,8 @@ public class LiveLotteryConfServiceImpl implements ILiveLotteryConfService {
     private RedisCache redisCache;
     @Autowired
     private LiveLotteryRegistrationMapper lotteryRegistrationMapper;
+    @Autowired
+    private LiveUserLotteryRecordMapper liveUserLotteryRecordMapper;
 
     @Autowired
     private LiveLotteryConfMapper baseMapper;
@@ -271,5 +276,10 @@ public class LiveLotteryConfServiceImpl implements ILiveLotteryConfService {
         return baseMapper.selectLiveLotteryConfListOn(liveLotteryConf);
     }
 
+    @Override
+    public List<LiveUserLotteryRecordVo> myLottery(long userId) {
+        return liveUserLotteryRecordMapper.selectLiveUserLotteryRecordByUserId(userId);
+    }
+
 
 }

+ 2 - 2
fs-service-system/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java

@@ -230,8 +230,8 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
     }
 
     @Override
-    public List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId,Integer totalLots) {
-        return baseMapper.selectLiveWatchAndRegisterUser(liveId, lotteryId,totalLots);
+    public List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId) {
+        return baseMapper.selectLiveWatchAndRegisterUser(liveId, lotteryId);
     }
 
     @Override

+ 22 - 4
fs-user-app/src/main/java/com/fs/app/controller/LiveLotteryController.java

@@ -3,13 +3,18 @@ package com.fs.app.controller;
 import com.fs.app.annotation.Login;
 import com.fs.app.facade.LiveFacadeService;
 import com.fs.common.core.domain.R;
+import com.fs.common.param.BaseQueryParam;
 import com.fs.live.param.LotteryPO;
 import com.fs.live.service.ILiveLotteryConfService;
+import com.fs.live.vo.LiveUserLotteryRecordVo;
+import com.fs.store.param.FsMyStoreOrderQueryParam;
+import com.fs.store.vo.FsMyStoreOrderListQueryVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 @RestController
 @RequestMapping("/app/live/liveLottery")
@@ -50,4 +55,17 @@ public class LiveLotteryController extends AppBaseController{
         return liveLotteryConfService.detail(lottery);
     }
 
+    /**
+     * 查询抽奖信息
+     * */
+    @Login
+    @GetMapping("/myLottery")
+    public R myLottery(BaseQueryParam  param) {
+        PageHelper.startPage(param.getPage(), param.getPageSize());
+
+        List<LiveUserLotteryRecordVo> list = liveLotteryConfService.myLottery(Long.parseLong(getUserId()));
+        PageInfo<LiveUserLotteryRecordVo> listPageInfo=new PageInfo<>(list);
+        return R.ok().put("data",listPageInfo);
+    }
+
 }