| | |
| | | package com.ruoyi.study.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.study.domain.TGame; |
| | | import com.ruoyi.study.domain.TIntegralRecord; |
| | | import com.ruoyi.study.dto.CompleteGameDTO; |
| | | import com.ruoyi.study.mapper.TGameMapper; |
| | | import com.ruoyi.study.service.ITGameService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TGameServiceImpl extends ServiceImpl<TGameMapper, TGame> implements ITGameService { |
| | | |
| | | @Override |
| | | public Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy, |
| | | Integer gameAvailableIntegral, List<TIntegralRecord> integralRecordList) { |
| | | // 积分明细集合为空,当前为第一次完成游戏 |
| | | if (integralRecordList.isEmpty()) { |
| | | return gameAvailableIntegral; |
| | | } else { |
| | | // 积分明细不为空,根据正确率及已获取积分数量计算本次答题可获取的积分数量 |
| | | List<Integer> integralList = integralRecordList.stream() |
| | | .map(TIntegralRecord::getIntegral).collect(Collectors.toList()) |
| | | .stream().map(Integer::parseInt).collect(Collectors.toList()); |
| | | int sumIntegral = integralList.stream().mapToInt(Integer::intValue).sum(); |
| | | if (gameAvailableIntegral > sumIntegral) { |
| | | return gameAvailableIntegral - sumIntegral; |
| | | } else { |
| | | return Constants.ZERO; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public TGame gameHearing(Integer quarter, Integer week) { |
| | | return baseMapper.gameHearing(quarter, week); |
| | | } |
| | | |
| | | } |