diff --git a/server/game2006service/tasks/star.js b/server/game2006service/tasks/star.js index 6dcc50dd..ef49c324 100644 --- a/server/game2006service/tasks/star.js +++ b/server/game2006service/tasks/star.js @@ -4,24 +4,42 @@ const http = require('j7/http'); const constant = require('../constant'); -const url = "https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=resetStar " -// const url = "https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=resetStar " -// const url = "http://james.com/webapp/index.php?&c=Star&a=resetStar " + class Star { async start() { console.log('Star.start'); + let url = getUrl(); while (true) { - http.get(url,null) + await http.get(url,null) const nowTime = utils.getUtcTime(); const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE); const sleepTime = daySeconds + 3600 * 24 - nowTime; - console.log('Damping.sleepTime:' + sleepTime, new Date(), sleepTime / 60); + console.log('Star.sleepTime:' + sleepTime, new Date(), sleepTime / 60); await utils.sleep(sleepTime * 1000); } } +} + +function getUrl(){ + // let url = 'http://james.com/webapp/index.php?&c=Star&a=resetStar'; + let url = ''; + if (utils.isOnlineEnv()) { + url = 'https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=resetStar'; + } else { + url = 'https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=resetStar '; + } + return url; +} + +function getV(){ + +} + +function setV(){ + } function init() { diff --git a/webapp/controller/StarController.class.php b/webapp/controller/StarController.class.php index 9bf9cddc..17c99096 100644 --- a/webapp/controller/StarController.class.php +++ b/webapp/controller/StarController.class.php @@ -6,10 +6,10 @@ require_once('mt/LevelUp.php'); require_once('mt/StarLevel.php'); require_once('models/MissionStar.php'); -require_once('models/DynData.php'); +require_once('models/RealtimeData.php'); use phpcommon\SqlHelper; use models\MissionStar; -use models\DynData; +use models\RealtimeData; class StarController extends BaseAuthedController { private $awardService = null; @@ -21,7 +21,6 @@ class StarController extends BaseAuthedController { if(getReqVal('a', '') != 'resetStar'){ parent::_handlePre(); } - DynData::preload(); $this->currMissionSeasonMeta = \mt\StarLevel::getCurrentSeason(); if (!$this->currMissionSeasonMeta) { $this->_rspErr(10, 'server internal error'); @@ -134,10 +133,13 @@ class StarController extends BaseAuthedController { } public function resetStar(){ - error_log('request time :'.date('Y-m-d h:i:s',time())); - $season = $this->_getV(TN_MISSION_STAR_SEASON, 0,1); + $season = RealtimeData::getMissionSeason(); if ( $this->currMissionSeasonMeta['id'] > $season){ $meta = mt\Parameter::getByName('starroad_restart_point'); + if (!$meta){ + error_log('ERROR INFO : parameter.xlsx not param starroad_restart_point'); + return ; + } $max_star_num = getXVal($meta, 'param_value',1000); $rows = myself()->_getSelfMysql()->execQuery( 'SELECT account_id,star_num FROM t_user WHERE star_num>:star_num', @@ -156,7 +158,7 @@ class StarController extends BaseAuthedController { ); } } - $this->_setV(TN_MISSION_STAR_SEASON, 0, $this->currMissionSeasonMeta['id']); + RealtimeData::setMissionSeason($this->currMissionSeasonMeta['id']); } diff --git a/webapp/models/RealtimeData.php b/webapp/models/RealtimeData.php index d86c0dc4..9393d595 100644 --- a/webapp/models/RealtimeData.php +++ b/webapp/models/RealtimeData.php @@ -36,6 +36,32 @@ class RealtimeData extends BaseModel { return self::$serverDays; } + //获取成长任务的赛季 + public static function getMissionSeason(){ + $db = self::internalGet('star_mission_season'); + return max(1, $db ? $db['value1']: 0); + } + //设置成长任务的赛季 + public static function setMissionSeason($value){ + SqlHelper::upsert + (myself()->_getMysql(''), + 't_realtime_data', + array( + 'name' => 'star_mission_season' + ), + array( + 'value1' => $value, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'name' => 'star_mission_season', + 'value1' => $value, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + private static function internalGet($name) { $row = SqlHelper::ormSelectOne