|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yingyangfly.common.dto.ResultResponse;
|
|
|
@@ -17,10 +18,7 @@ import com.yingyangfly.core.dto.GamePlayRecordDetailDto;
|
|
|
import com.yingyangfly.core.dto.GamePlayRecordDto;
|
|
|
import com.yingyangfly.core.mapper.*;
|
|
|
import com.yingyangfly.core.security.util.TokenUtil;
|
|
|
-import com.yingyangfly.core.service.GamePlayRecordService;
|
|
|
-import com.yingyangfly.core.service.GameService;
|
|
|
-import com.yingyangfly.core.service.GameUserService;
|
|
|
-import com.yingyangfly.core.service.MsgWarnService;
|
|
|
+import com.yingyangfly.core.service.*;
|
|
|
import com.yingyangfly.core.util.DateUtil;
|
|
|
import io.swagger.models.auth.In;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -39,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
@@ -80,6 +79,10 @@ public class GamePlayRecordServiceImpl implements GamePlayRecordService {
|
|
|
@Value("${query-daily-trai}")
|
|
|
private String queryDailyTrai;
|
|
|
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private GameTaskService gameTaskService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Async
|
|
|
@@ -108,6 +111,7 @@ public class GamePlayRecordServiceImpl implements GamePlayRecordService {
|
|
|
}
|
|
|
gameUser.setUpdateTime(new Date());
|
|
|
gameUserMapper.updateById(gameUser);
|
|
|
+ gamePlayRecord.setGameRelevancyId(gameUser.getId());
|
|
|
}
|
|
|
//如果是任务 则更新当前关卡
|
|
|
if ("A".equals(gamePlayRecord.getPlayClass())) {
|
|
|
@@ -120,18 +124,23 @@ public class GamePlayRecordServiceImpl implements GamePlayRecordService {
|
|
|
}
|
|
|
//如果是任务 则更新当前关卡
|
|
|
if ("A".equals(gamePlayRecord.getPlayClass())) {
|
|
|
- QueryWrapper<GameTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("game_code", gamePlayRecord.getGameCode());
|
|
|
- queryWrapper.eq("user_id", appCurrentLoginUser.getId());
|
|
|
- queryWrapper.eq("status", "1");
|
|
|
- GameTaskDetail gameTaskDetail = gameTaskDetailMapper.selectOne(queryWrapper);
|
|
|
- gameTaskDetail.setStatus("0");
|
|
|
- gameTaskDetail.setIsPass(gamePlayRecord.getIsPass());
|
|
|
- gameTaskDetail.setGameScore(gamePlayRecord.getGameScore());
|
|
|
- gameTaskDetail.setPlayTime(gamePlayRecord.getDuration());
|
|
|
- gameTaskDetailMapper.updateById(gameTaskDetail);
|
|
|
- //更新任务当前进度
|
|
|
- updateTaskProgress(gameTaskDetail);
|
|
|
+ if ("0".equals(gamePlayRecord.getIsPass()) || "1".equals(gamePlayRecord.getIsPass())){
|
|
|
+ GameTask gameTask = gameTaskService.findMyCurrentTask(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,new Date()), appCurrentLoginUser.getId(),"1");
|
|
|
+ QueryWrapper<GameTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("game_code", gamePlayRecord.getGameCode());
|
|
|
+ queryWrapper.eq("user_id", appCurrentLoginUser.getId());
|
|
|
+ queryWrapper.eq("status", "1");
|
|
|
+ queryWrapper.eq("task_id", gameTask.getId());
|
|
|
+ GameTaskDetail gameTaskDetail = gameTaskDetailMapper.selectOne(queryWrapper);
|
|
|
+ gamePlayRecord.setGameRelevancyId(gameTaskDetail.getId());
|
|
|
+ gameTaskDetail.setStatus("0");
|
|
|
+ gameTaskDetail.setIsPass(gamePlayRecord.getIsPass());
|
|
|
+ gameTaskDetail.setGameScore(gamePlayRecord.getGameScore());
|
|
|
+ gameTaskDetail.setPlayTime(gamePlayRecord.getDuration());
|
|
|
+ gameTaskDetailMapper.updateById(gameTaskDetail);
|
|
|
+ //更新任务当前进度
|
|
|
+ updateTaskProgress(gameTaskDetail);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -162,9 +171,11 @@ public class GamePlayRecordServiceImpl implements GamePlayRecordService {
|
|
|
}
|
|
|
|
|
|
private void updateTaskProgress(GameTaskDetail gameTaskDetail) {
|
|
|
+ // 获取专属任务信息
|
|
|
QueryWrapper<GameTask> taskQueryWrapper = new QueryWrapper<>();
|
|
|
taskQueryWrapper.eq("id", gameTaskDetail.getTaskId());
|
|
|
GameTask gameTask = gameTaskMapper.selectOne(taskQueryWrapper);
|
|
|
+ // 获取专属任务游戏数量
|
|
|
QueryWrapper<GameTaskDetail> taskQueryDetailWrapper = new QueryWrapper<>();
|
|
|
taskQueryDetailWrapper.eq("task_id",gameTaskDetail.getTaskId());
|
|
|
Long gameTaskCount = gameTaskDetailMapper.selectCount(taskQueryDetailWrapper);
|
|
|
@@ -472,8 +483,12 @@ public class GamePlayRecordServiceImpl implements GamePlayRecordService {
|
|
|
for (Map<String,Object> map : mappedResults) {
|
|
|
GamePlayRecordDto gamePlayRecordDto = new GamePlayRecordDto();
|
|
|
Game game = gameService.selectByGameCode(map.get("gameCode").toString());
|
|
|
- gamePlayRecordDto.setGameCoverImage(game.getGameCoverImage());
|
|
|
- gamePlayRecordDto.setGameName(game.getGameName());
|
|
|
+ if (ObjectUtils.isNotNull(game)){
|
|
|
+ gamePlayRecordDto.setGameCoverImage(game.getGameCoverImage());
|
|
|
+ gamePlayRecordDto.setGameName(game.getGameName());
|
|
|
+ }else {
|
|
|
+ gamePlayRecordDto.setGameName(map.get("gameName").toString());
|
|
|
+ }
|
|
|
gamePlayRecordDto.setTotalGameScore(map.get("totalScore").toString());
|
|
|
gamePlayRecordDto.setIsPass(map.get("isPass").toString());
|
|
|
gamePlayRecordDto.setGameTotalTime(map.get("totalDuration").toString());
|