huliguo
3 天以前 598dd94c3dcf741c25ded76cba661ec02965a524
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppLotteryEventController.java
@@ -162,6 +162,7 @@
      Long userId = SecurityUtils.getUserId();
      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()));
      vo.setTotal(count);
      //没有答题,直接从第一题开始
@@ -190,7 +191,6 @@
            }
            current--;
         } else {
            current++;
            //下一题
            current++;
            if (current >= count) {
@@ -273,6 +273,9 @@
   public R<Boolean> endAnswerQuestion(@PathVariable("id") String id) {
      Long userId = SecurityUtils.getUserId();
      TLotteryEvent lotteryEvent = lotteryEventService.getById(id);
      if(null == lotteryEvent){
         return R.fail("无效的抽奖活动id");
      }
      TUserLotteryEventQuestions questionsServiceOne = userLotteryEventQuestionsService.getOne(new QueryWrapper<TUserLotteryEventQuestions>().eq("lottery_event_id", id).eq("user_id", userId));
      if (null == questionsServiceOne) {
         questionsServiceOne = new TUserLotteryEventQuestions();
@@ -285,9 +288,8 @@
      questionsServiceOne.setStatus(2);
      questionsServiceOne.setEndTime(LocalDateTime.now());
      //计算正确率
      List<TUserLotteryEventQuestionsAnswers> list = userLotteryEventQuestionsAnswersService.list(new QueryWrapper<TUserLotteryEventQuestionsAnswers>().eq("lottery_event_id", id).eq("user_id", userId));
      int count = list.size();
      int right = list.stream().filter(item -> 1 == item.getIsCorrect()).collect(Collectors.toList()).size();
      int count = lotteryEventQuestionsAnswersService.count(new QueryWrapper<TLotteryEventQuestionsAnswers>().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);
      userLotteryEventQuestionsService.saveOrUpdate(questionsServiceOne);