| | |
| | | package com.ruoyi.goods.service.impl.lottery; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.goods.api.domain.LotteryEventQuestionsAnswers; |
| | | import com.ruoyi.goods.api.domain.UserLotteryEventQuestionsAnswers; |
| | | import com.ruoyi.goods.api.domain.TLotteryEvent; |
| | | import com.ruoyi.goods.api.domain.TLotteryEventQuestionsAnswers; |
| | | import com.ruoyi.goods.api.domain.TUserLotteryEventQuestionsAnswers; |
| | | import com.ruoyi.goods.domain.vo.MgtUserAnswersPageVO; |
| | | import com.ruoyi.goods.mapper.lottery.UserLotteryEventQuestionsAnswersMapper; |
| | | import com.ruoyi.goods.service.lottery.ILotteryEventQuestionsAnswersService; |
| | | import com.ruoyi.goods.service.lottery.ILotteryEventService; |
| | | import com.ruoyi.goods.service.lottery.IUserLotteryEventQuestionsAnswersService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | * @Date 2025/5/19 16:08 |
| | | */ |
| | | @Service |
| | | public class UserLotteryEventQuestionsAnswersServiceImpl extends ServiceImpl<UserLotteryEventQuestionsAnswersMapper, UserLotteryEventQuestionsAnswers> implements IUserLotteryEventQuestionsAnswersService { |
| | | public class UserLotteryEventQuestionsAnswersServiceImpl extends ServiceImpl<UserLotteryEventQuestionsAnswersMapper, TUserLotteryEventQuestionsAnswers> implements IUserLotteryEventQuestionsAnswersService { |
| | | |
| | | @Resource |
| | | private ILotteryEventQuestionsAnswersService lotteryEventQuestionsAnswersService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public BigDecimal getCorrectAnswerRate(Long userId, String lotteryEventId) { |
| | | int count = this.count(new QueryWrapper<UserLotteryEventQuestionsAnswers>().eq("user_id", userId).eq("lottery_event_id", lotteryEventId).eq("is_correct", 1)); |
| | | int count = this.count(new QueryWrapper<TUserLotteryEventQuestionsAnswers>().eq("user_id", userId).eq("lottery_event_id", lotteryEventId).eq("is_correct", 1)); |
| | | if (count > 0) { |
| | | int count1 = lotteryEventQuestionsAnswersService.count(new QueryWrapper<LotteryEventQuestionsAnswers>().eq("lottery_event_id", lotteryEventId)); |
| | | int count1 = lotteryEventQuestionsAnswersService.count(new QueryWrapper<TLotteryEventQuestionsAnswers>().eq("lottery_event_id", lotteryEventId)); |
| | | return new BigDecimal(count).divide(new BigDecimal(count1), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | |
| | | @Override |
| | | public List<MgtUserAnswersPageVO> getUserAnswersPage(Page<MgtUserAnswersPageVO> page, String lotteryEventId, Long userId) { |
| | | //获取分页信息 |
| | | return this.getBaseMapper().getUserAnswersPage(page,lotteryEventId,userId); |
| | | } |
| | | |
| | | |
| | | } |