|
@@ -45,6 +45,11 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
private SimpleDateFormat simpleDateFormatGameConfig = new SimpleDateFormat("HH:mm");
|
|
|
|
|
|
@Override
|
|
|
+ public void deleteByUid(long userId) {
|
|
|
+ pushLogMapper.deleteByUid(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Result list(String search, String ordermap, Integer page, Integer size) {
|
|
|
Map<String, Object> params = JSONUtils.json2map(search);
|
|
|
Map<String, Object> order = JSONUtils.json2map(ordermap);
|
|
@@ -69,13 +74,17 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
UserConfig config = userConfigMapper.findByUid(userId);
|
|
|
|
|
|
if (config != null && config.getScaleStart() != null && config.getScaleEnd() != null){
|
|
|
-
|
|
|
try {
|
|
|
Date scaleStart = simpleDateFormatScale.parse(config.getScaleStart());
|
|
|
Date scaleEnd = simpleDateFormatScale.parse(config.getScaleEnd());
|
|
|
+ Calendar scaleEndCalendarTop = Calendar.getInstance();
|
|
|
+ scaleEndCalendarTop.setTime(scaleEnd);
|
|
|
+ scaleEndCalendarTop.add(Calendar.DATE, 1);
|
|
|
+ scaleEnd = scaleEndCalendarTop.getTime();
|
|
|
if (currentDate.getTime() >= scaleStart.getTime() && currentDate.getTime() <= scaleEnd.getTime()){
|
|
|
//当前处于量表测试期间
|
|
|
//游戏逻辑处理
|
|
|
+ System.out.println(userId + "此用户目前在测量时间内");
|
|
|
GameConfig gameConfig = inThePeriod(gameConfigMapper.listUid(userId), currentDate);
|
|
|
if (gameConfig != null){
|
|
|
Calendar scaleStartCalendar = Calendar.getInstance();
|
|
@@ -104,6 +113,7 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
result.correctNumberOccurrenceNumber = config.getCorrect();
|
|
|
result.errorNumberOccurrenceNumber = config.getSupporting();
|
|
|
result.practiseDuration = config.getPractice();
|
|
|
+ result.practiseRightNumber = config.getExerciseRight();
|
|
|
result.practiseOccurrenceNumber = config.getExercise();
|
|
|
|
|
|
String[] versionInfo = config.getVersion().split(",");
|
|
@@ -128,7 +138,7 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ System.out.println(userId + "此用户需要做游戏");
|
|
|
return ResultGenerator.genSuccessResult(result);
|
|
|
}
|
|
|
}
|
|
@@ -144,6 +154,11 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
List<GamePlayTime> gamePlayTime = gamePlayTimeMapper.getScalePlayTime(userId, simpleDateFormatScale.format(startDate.getTime()), simpleDateFormatScale.format(endDate.getTime()));
|
|
|
if (gamePlayTime != null && gamePlayTime.size() > 0){
|
|
|
GamePlayTime playTime = gamePlayTime.get(0);
|
|
|
+ if (pushedThreeTimes(playTime.getId()))
|
|
|
+ return ResultGenerator.genSuccessResult(result);
|
|
|
+
|
|
|
+ System.out.println(userId + "此用户需要做量表");
|
|
|
+
|
|
|
result.needDoGame = true;
|
|
|
result.playGameType = 1;
|
|
|
result.playGameId = playTime.getId();
|
|
@@ -160,10 +175,9 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result delayScale(Long gamePlayTimeId, int delayMin) {
|
|
|
+ public Result delayScale(Long gamePlayTimeId, int delayMin, String deviceId) {
|
|
|
if (gamePlayTimeId != null){
|
|
|
- List<PushLog> pushLogs = pushLogMapper.listByGamePlayId(gamePlayTimeId);
|
|
|
- if (pushLogs != null && pushLogs.size() >=3){
|
|
|
+ if (pushedThreeTimes(gamePlayTimeId)){
|
|
|
return new Result("已經推遲過三次,請盡快完成量表");
|
|
|
}else{
|
|
|
GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
|
|
@@ -181,12 +195,24 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
pushLog.setPushTime(new Date());
|
|
|
pushLog.setUid(gamePlayTime.getUid());
|
|
|
pushLog.setType(2);
|
|
|
- pushLog.setDeviceId("");
|
|
|
+ pushLog.setDeviceId(deviceId);
|
|
|
pushLog.setMsgId(gamePlayTimeId + "");
|
|
|
pushLog.setStatus(ConstUser.PUSH_DELAY);
|
|
|
pushLogMapper.insert(pushLog);
|
|
|
gamePlayTime.setGameTime(UtilFun.DateToString(newTime.getTime(), UtilFun.YYYYMMDDHHMMSS));
|
|
|
gamePlayTimeMapper.updateByPrimaryKey(gamePlayTime);
|
|
|
+
|
|
|
+ if (pushedThreeTimes(gamePlayTimeId)){
|
|
|
+ pushLog = new PushLog();
|
|
|
+ pushLog.setPushTime(new Date());
|
|
|
+ pushLog.setUid(gamePlayTime.getUid());
|
|
|
+ pushLog.setType(2);
|
|
|
+ pushLog.setDeviceId(deviceId);
|
|
|
+ pushLog.setMsgId(gamePlayTimeId + "");
|
|
|
+ pushLog.setStatus(ConstUser.PUSH_NO);
|
|
|
+ pushLogMapper.insert(pushLog);
|
|
|
+ }
|
|
|
+
|
|
|
return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
}
|
|
@@ -197,7 +223,21 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin) {
|
|
|
+ public Result enter(Long gamePlayTimeId, String deviceId, Integer type) {
|
|
|
+ GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
|
|
|
+ PushLog pushLog = new PushLog();
|
|
|
+ pushLog.setPushTime(new Date());
|
|
|
+ pushLog.setUid(gamePlayTime.getUid());
|
|
|
+ pushLog.setType(type);
|
|
|
+ pushLog.setDeviceId(deviceId);
|
|
|
+ pushLog.setMsgId(gamePlayTimeId + "");
|
|
|
+ pushLog.setStatus(ConstUser.PUSH_ING);
|
|
|
+ pushLogMapper.insert(pushLog);
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result delayGame(Long gamePlayTimeId, Long gameConfigId, int delayMin, String deviceId) {
|
|
|
if (gamePlayTimeId != null && gameConfigId != null){
|
|
|
GamePlayTime gamePlayTime = gamePlayTimeMapper.selectByPrimaryKey(gamePlayTimeId);
|
|
|
GameConfig gameConfig = gameConfigMapper.selectByPrimaryKey(gameConfigId);
|
|
@@ -220,14 +260,24 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
pushLog.setPushTime(new Date());
|
|
|
pushLog.setUid(gameConfig.getUid());
|
|
|
pushLog.setType(1);
|
|
|
- pushLog.setDeviceId(gameConfigId + "");
|
|
|
+ pushLog.setDeviceId(deviceId);
|
|
|
pushLog.setMsgId(gamePlayTimeId + "");
|
|
|
pushLog.setStatus(ConstUser.PUSH_DELAY);
|
|
|
pushLogMapper.insert(pushLog);
|
|
|
gamePlayTimeMapper.updateByPrimaryKey(gamePlayTime);
|
|
|
return ResultGenerator.genSuccessResult();
|
|
|
- }else
|
|
|
- return new Result("無法推遲相應時間,請盡快完成遊戲");
|
|
|
+ }else {
|
|
|
+ PushLog pushLog = new PushLog();
|
|
|
+ pushLog.setPushTime(new Date());
|
|
|
+ pushLog.setUid(gameConfig.getUid());
|
|
|
+ pushLog.setType(1);
|
|
|
+ pushLog.setDeviceId(deviceId);
|
|
|
+ pushLog.setMsgId(gamePlayTimeId + "");
|
|
|
+ pushLog.setStatus(ConstUser.PUSH_NO);
|
|
|
+ pushLogMapper.insert(pushLog);
|
|
|
+ gamePlayTimeMapper.deleteByPrimaryKey(gamePlayTime.getId());
|
|
|
+ return new Result("你選擇的延遲的時間點已超過該時間段結束前10分鐘,該時間段結束前10分鐘,將停止推送,無法進入該時間段的測試");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
} catch (Exception e){
|
|
@@ -254,6 +304,23 @@ public class PushLogServiceImpl extends AbstractService<PushLog> implements Push
|
|
|
return pushLogMapper.list(params,order);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private boolean pushedThreeTimes(long gamePlayTimeId){
|
|
|
+ List<PushLog> pushLogs = pushLogMapper.listByGamePlayId(gamePlayTimeId);
|
|
|
+ List<PushLog> pushLogsDelay = new ArrayList<>();
|
|
|
+ if(pushLogs != null && pushLogs.size() < 3){
|
|
|
+ return false;
|
|
|
+ }else if (pushLogs != null){
|
|
|
+ for (PushLog pushLog : pushLogs)
|
|
|
+ if (pushLog.getStatus() == ConstUser.PUSH_DELAY)
|
|
|
+ pushLogsDelay.add(pushLog);
|
|
|
+ if (pushLogsDelay.size() >= 3)
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private String getRandomVersion(String[] versions){
|
|
|
return versions[(int)(Math.random() * versions.length)];
|
|
|
}
|