diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index eddd03b0..1bf2b240 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -47,6 +47,9 @@ function getResBaseDir() function getXVal($arr, $name, $defVal = null) { + if (is_null($arr)) { + error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT)); + } $val = array_key_exists($name, $arr) ? $arr[$name] : $defVal; return $val; } diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index f6d24f26..e357d649 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -5,11 +5,13 @@ namespace services; require_once('mt/Task.php'); require_once('models/Mission.php'); +require_once('models/Battle.php'); use phpcommon\SqlHelper; use mt; use models\User; use models\Mission; +use models\Battle; class MissionService extends BaseService { @@ -24,6 +26,28 @@ class MissionService extends BaseService { { $this->userInfo = $userInfo; $this->seasonDb = $seasonDb; + $this->hisBattleData = Battle::getMyBattleData(); + $seasonBattleData = json_decode($this->seasonDb['battle_data'], true); + if (!isset($seasonBattleData)) { + $seasonBattleData = array(); + } + $this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array()); + $this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array()); + $this->todayBattleData = getXVal($seasonBattleData, 'today_data', array()); + if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) < + myself()->_getNowDaySeconds()) { + $this->todayBattleData = array( + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ); + } + if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) < + myself()->_getMondaySeconds()) { + $this->thisWeekBattleData = array( + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ); + } } public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta) @@ -375,7 +399,7 @@ class MissionService extends BaseService { { $battleData = null; if ($missionMeta['type'] == mt\Task::DAILY_MISSON_TYPE) { - $battleData = $this->dailyBattleData; + $battleData = $this->todayBattleData; } else { if ($missionMeta['season_task'] == mt\Task::SEASON_MISSON_FLAG) { if ($missionMeta['type'] == mt\Task::SEASONCARD_MISSON_TYPE &&