This commit is contained in:
hujiabin 2023-06-25 17:25:01 +08:00
parent 96e1d87ba9
commit f10bcce6a4
4 changed files with 174 additions and 117 deletions

View File

@ -8,10 +8,12 @@ const constant = require('../constant');
class Star { class Star {
async start() { async start() {
console.log('Star.start'); console.log('Star And Pass Start');
let url = getUrl(); let url_star = getUrl('resetStar');
let url_pass = getUrl('resetPassLevel');
while (true) { while (true) {
await http.get(url,null) await http.get(url_star,null)
await http.get(url_pass,null)
const nowTime = utils.getUtcTime(); const nowTime = utils.getUtcTime();
const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE); const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE);
const sleepTime = daySeconds + 3600 * 24 - nowTime; const sleepTime = daySeconds + 3600 * 24 - nowTime;
@ -23,13 +25,13 @@ class Star {
} }
function getUrl(){ function getUrl(action){
// let url = 'http://james.com/webapp/index.php?&c=Star&a=resetStar'; // let url = 'http://james.com/webapp/index.php?&c=Star&a=resetStar';
let url = ''; let url = '';
if (utils.isOnlineEnv()) { if (utils.isOnlineEnv()) {
url = 'https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=resetStar'; url = 'https://game2006api-test.cebggame.com/webapp/index.php?&c=Star&a=' + action;
} else { } else {
url = 'https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=resetStar '; url = 'https://game2006api-test.kingsome.cn/webapp/index.php?&c=Star&a=' + action;
} }
return url; return url;
} }

View File

@ -16,18 +16,20 @@ use phpcommon\SqlHelper;
use models\Pass; use models\Pass;
use models\RealtimeData; use models\RealtimeData;
use models\BcOrder; use models\BcOrder;
class PassController extends BaseAuthedController {
class PassController extends BaseAuthedController
{
private $awardService = null; private $awardService = null;
private $propertyChgService = null; private $propertyChgService = null;
private $userInfo = null; private $userInfo = null;
private $currSeasonMeta = null; private $currSeasonMeta = null;
public function _handlePre() public function _handlePre()
{ {
// if(getReqVal('a', '') != 'resetStar'){ if (getReqVal('a', '') != 'resetPassLevel') {
parent::_handlePre(); parent::_handlePre();
// } }
$this->currSeasonMeta = \mt\BattlePass::getCurrentSeason(); $this->currSeasonMeta = \mt\BattlePass::getCurrentSeason();
if (!$this->currSeasonMeta) { if (!$this->currSeasonMeta) {
$this->_rspErr(10, 'season server internal error'); $this->_rspErr(10, 'season server internal error');
@ -35,11 +37,12 @@ class PassController extends BaseAuthedController {
} }
$this->propertyChgService = new services\PropertyChgService(); $this->propertyChgService = new services\PropertyChgService();
$this->awardService = new services\AwardService(); $this->awardService = new services\AwardService();
$this->userInfo = $this->_getOrmUserInfo(); $this->userInfo = $this->_safeGetOrmUserInfo();
} }
public function getPassList(){ public function getPassList()
{
$row = Pass::find($this->currSeasonMeta['id']); $row = Pass::find($this->currSeasonMeta['id']);
if (!$row) { if (!$row) {
$this->_initPassList($this->currSeasonMeta['id']); $this->_initPassList($this->currSeasonMeta['id']);
@ -65,7 +68,8 @@ class PassController extends BaseAuthedController {
)); ));
} }
public function commit(){ public function commit()
{
$level = getReqVal('level', 0); $level = getReqVal('level', 0);
$type = getReqVal('type', 0); $type = getReqVal('type', 0);
$passMeta = \mt\BattlePass::find($level); $passMeta = \mt\BattlePass::find($level);
@ -83,7 +87,8 @@ class PassController extends BaseAuthedController {
$data = $this->_rewardHash($rewards); $data = $this->_rewardHash($rewards);
$items = array(); $items = array();
switch ($type) { switch ($type) {
case 0 : { case 0 :
{
if ($data['basic'][$level]['state'] != 0) { if ($data['basic'][$level]['state'] != 0) {
$this->_rspErr(1, "basic Can't get it again"); $this->_rspErr(1, "basic Can't get it again");
return; return;
@ -95,7 +100,8 @@ class PassController extends BaseAuthedController {
} }
} }
break; break;
case 1 : { case 1 :
{
if ($this->userInfo['activated'] != 1) { if ($this->userInfo['activated'] != 1) {
$this->_rspErr(1, "don't is platinum pass "); $this->_rspErr(1, "don't is platinum pass ");
return; return;
@ -115,7 +121,8 @@ class PassController extends BaseAuthedController {
} }
} }
break; break;
default : { default :
{
$this->_rspErr(1, "param type is error"); $this->_rspErr(1, "param type is error");
return; return;
} }
@ -123,12 +130,14 @@ class PassController extends BaseAuthedController {
$this->_addItems($items, $this->awardService, $this->propertyChgService); $this->_addItems($items, $this->awardService, $this->propertyChgService);
switch ($type) { switch ($type) {
case 0 : { case 0 :
{
$data['basic'][$level]['state'] = 1; $data['basic'][$level]['state'] = 1;
} }
break; break;
case 1 : { case 1 :
{
$data['platinum'][$level]['state'] = 1; $data['platinum'][$level]['state'] = 1;
} }
@ -142,7 +151,8 @@ class PassController extends BaseAuthedController {
)); ));
} }
public function commitAll(){ public function commitAll()
{
$passDb = Pass::find($this->currSeasonMeta['id']); $passDb = Pass::find($this->currSeasonMeta['id']);
$rewards = emptyReplace(json_decode($passDb['data'], true), array()); $rewards = emptyReplace(json_decode($passDb['data'], true), array());
foreach ($rewards['basic'] as &$reward) { foreach ($rewards['basic'] as &$reward) {
@ -184,7 +194,8 @@ class PassController extends BaseAuthedController {
)); ));
} }
public function buyPlatinumPass(){ public function buyPlatinumPass()
{
error_log("buyPlatinumPass : " . json_encode($_REQUEST)); error_log("buyPlatinumPass : " . json_encode($_REQUEST));
if (!$this->_isValidAddress()) { if (!$this->_isValidAddress()) {
$this->_rspErr(1, 'address is empty'); $this->_rspErr(1, 'address is empty');
@ -206,7 +217,8 @@ class PassController extends BaseAuthedController {
$this->_rspData($response); $this->_rspData($response);
} }
public function buyLevel(){ public function buyLevel()
{
error_log("buyLevel : " . json_encode($_REQUEST)); error_log("buyLevel : " . json_encode($_REQUEST));
if (!$this->_isValidAddress()) { if (!$this->_isValidAddress()) {
$this->_rspErr(1, 'address is empty'); $this->_rspErr(1, 'address is empty');
@ -234,11 +246,26 @@ class PassController extends BaseAuthedController {
$this->_rspData($response); $this->_rspData($response);
} }
public function resetPassLevel(){ public function resetPassLevel()
{
$season = RealtimeData::getPassSeason();
if ($this->currSeasonMeta['id'] > $season) {
myself()->_getSelfMysql()->execQuery(
'UPDATE t_user SET activated=:activated,level=:level,exp=:exp',
array(
"activated" => 0,
"level" => 1,
"exp" => 0,
)
);
error_log("request resetPassLevel time : ". date('Y-M-D h:i:s',time()));
RealtimeData::setPassSeason($this->currSeasonMeta['id']);
}
} }
private function _rewardHash($reward){ private function _rewardHash($reward)
{
if (!$reward) { if (!$reward) {
return array(); return array();
} }
@ -254,7 +281,8 @@ class PassController extends BaseAuthedController {
return $data; return $data;
} }
private function _initPassList($season){ private function _initPassList($season)
{
$passList = \mt\BattlePass::all(); $passList = \mt\BattlePass::all();
if (!$passList) { if (!$passList) {
return; return;

View File

@ -158,6 +158,7 @@ class StarController extends BaseAuthedController {
); );
} }
} }
error_log("request resetStar time : ". date('Y-M-D h:i:s',time()));
RealtimeData::setMissionSeason($this->currMissionSeasonMeta['id']); RealtimeData::setMissionSeason($this->currMissionSeasonMeta['id']);
} }

View File

@ -62,6 +62,32 @@ class RealtimeData extends BaseModel {
); );
} }
//获取通行证的赛季
public static function getPassSeason(){
$db = self::internalGet('battle_pass_season');
return max(1, $db ? $db['value1']: 0);
}
//设置通行证的赛季
public static function setPassSeason($value){
SqlHelper::upsert
(myself()->_getMysql(''),
't_realtime_data',
array(
'name' => 'battle_pass_season'
),
array(
'value1' => $value,
'modifytime' => myself()->_getNowTime()
),
array(
'name' => 'battle_pass_season',
'value1' => $value,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
private static function internalGet($name) private static function internalGet($name)
{ {
$row = SqlHelper::ormSelectOne $row = SqlHelper::ormSelectOne