puzhibing
2025-07-31 a95d0c4bdd96b09342c7ccf9aa1aef4b26b31302
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppLotteryEventController.java
@@ -56,7 +56,7 @@
   private IUserLotteryEventQuestionsAnswersService userLotteryEventQuestionsAnswersService;
   
   @Resource
   private ILotteryEventQuestionsService lotteryEventServiceQuestionsService;
   private ILotteryEventQuestionsService lotteryEventQuestionsService;
   
   @Resource
   private ILotteryEventQuestionsAnswersService lotteryEventQuestionsAnswersService;
@@ -69,7 +69,7 @@
         @ApiImplicitParam(name = "id", value = "抽奖活动id", required = true, dataType = "String", paramType = "path")
   })
   public R<LotteryEventVo> getLotteryEvent(@PathVariable("id") String id, @PathVariable("orderId") String orderId) {
      LotteryEventVo lotteryEvent = lotteryEventService.getLotteryEvent(id);
      LotteryEventVo lotteryEvent = lotteryEventService.getLotteryEvent(id, orderId);
      TLotteryEvent event = lotteryEventService.getById(id);
      if (LocalDateTime.now().isBefore(event.getStartTime())) {
         lotteryEvent.setStatus(1);
@@ -91,7 +91,7 @@
         @ApiImplicitParam(name = "id", value = "抽奖活动id", required = true, dataType = "String", paramType = "path")
   })
   public R<TLotteryEventPrize> lotteryDraw(@PathVariable("id") String id, @PathVariable("orderId") String orderId) {
      return lotteryEventService.lotteryDraw(id);
      return lotteryEventService.lotteryDraw(id, orderId);
   }
   
   
@@ -122,12 +122,12 @@
   
   
   @ResponseBody
   @PostMapping("/getLotteryEventInfo/{id}/{orderId}")
   @PostMapping("/getLotteryEventInfo/{id}")
   @ApiOperation(value = "获取抽奖活动详情【2.0】", tags = "抽奖活动")
   @ApiImplicitParams({
         @ApiImplicitParam(name = "id", value = "抽奖活动id", required = true, dataType = "String", paramType = "path")
   })
   public R<LotteryEventInfoVo> getLotteryEventInfo(@PathVariable("id") String id, @PathVariable("orderId") String orderId){
   public R<LotteryEventInfoVo> getLotteryEventInfo(@PathVariable("id") String id){
      Long userId = SecurityUtils.getUserId();
      TLotteryEvent lotteryEvent = lotteryEventService.getById(id);
      LotteryEventInfoVo vo = new LotteryEventInfoVo();
@@ -163,14 +163,14 @@
      TUserLotteryEventQuestions questionsServiceOne = userLotteryEventQuestionsService.getOne(new QueryWrapper<TUserLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).eq("user_id", userId));
      LotteryEventQuestionsVo vo = new LotteryEventQuestionsVo();
      vo.setId(dto.getId());
      int count = lotteryEventServiceQuestionsService.count(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()));
      int count = lotteryEventQuestionsService.count(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()));
      vo.setTotal(count);
      //没有答题,直接从第一题开始
      if (null == questionsServiceOne) {
         if (-1 == dto.getStepOrDown()) {
            return R.fail("操作失败");
         }
         TLotteryEventQuestions questions = lotteryEventServiceQuestionsService.getOne(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort").last(" limit 1"));
         TLotteryEventQuestions questions = lotteryEventQuestionsService.getOne(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort").last(" limit 1"));
         vo.setCurrent(0);
         vo.setName(questions.getName());
         List<TLotteryEventQuestionsAnswers> list = lotteryEventQuestionsAnswersService.list(new QueryWrapper<TLotteryEventQuestionsAnswers>().eq("lottery_event_questions_id", questions.getId()));
@@ -197,7 +197,7 @@
               current = count - 1;
            }
         }
         List<TLotteryEventQuestions> list = lotteryEventServiceQuestionsService.list(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort"));
         List<TLotteryEventQuestions> list = lotteryEventQuestionsService.list(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort"));
         TLotteryEventQuestions lotteryEventQuestions = list.get(current);
         vo.setCurrent(current);
         vo.setName(lotteryEventQuestions.getName());
@@ -230,7 +230,7 @@
   @PostMapping("/answerQuestion")
   @ApiOperation(value = "答题操作【2.0】", tags = "抽奖活动")
   public R answerQuestion(@RequestBody AnswerQuestionDto dto) {
      List<TLotteryEventQuestions> list = lotteryEventServiceQuestionsService.list(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort"));
      List<TLotteryEventQuestions> list = lotteryEventQuestionsService.list(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort"));
      TLotteryEventQuestions lotteryEventQuestions = list.get(dto.getCurrent());
      List<TLotteryEventQuestionsAnswers> list1 = lotteryEventQuestionsAnswersService.list(new QueryWrapper<TLotteryEventQuestionsAnswers>().eq("lottery_event_questions_id", lotteryEventQuestions.getId()));
      TLotteryEventQuestionsAnswers lotteryEventQuestionsAnswers = list1.stream().filter(item -> item.getAnswers().equals(dto.getAnswer())).findAny().orElse(null);
@@ -294,7 +294,7 @@
      questionsServiceOne.setStatus(2);
      questionsServiceOne.setEndTime(LocalDateTime.now());
      //计算正确率
      int count = lotteryEventQuestionsAnswersService.count(new QueryWrapper<TLotteryEventQuestionsAnswers>().eq("lottery_event_id", id));
      int count = lotteryEventQuestionsService.count(new QueryWrapper<TLotteryEventQuestions>().eq("lottery_event_id", id));
      int right = userLotteryEventQuestionsAnswersService.count(new QueryWrapper<TUserLotteryEventQuestionsAnswers>().eq("lottery_event_id", id).eq("user_id", userId).eq("is_correct", 1));
      BigDecimal multiply = new BigDecimal(right).divide(new BigDecimal(count), 4, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
      questionsServiceOne.setCorrectAnswerRate(multiply);