1
This commit is contained in:
parent
0a215b7e9b
commit
b0ad92e149
@ -3,8 +3,23 @@
|
|||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
class AnncController extends BaseController {
|
class AnncController extends BaseController {
|
||||||
|
|
||||||
|
const ANNC_REDIS_KEY = 'annc_redis_key:';
|
||||||
|
|
||||||
public function getAnnc()
|
public function getAnnc()
|
||||||
{
|
{
|
||||||
|
$redis = myself()->_getRedis(self::ANNC_REDIS_KEY);
|
||||||
|
if ($redis->exists(self::ANNC_REDIS_KEY)){
|
||||||
|
$data = json_decode($redis->get(self::ANNC_REDIS_KEY),true);
|
||||||
|
}else{
|
||||||
|
$data = $this->_findAnnc();
|
||||||
|
$redis->set(self::ANNC_REDIS_KEY,json_encode($data));
|
||||||
|
$redis->pexpire(self::ANNC_REDIS_KEY , max(0, min(15, myself()->_getNowTime() - $data['end_time'])) * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
myself()->_rspData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _findAnnc(){
|
||||||
$seconds = myself()->_getNowTime() - myself()->_getNowDaySeconds();
|
$seconds = myself()->_getNowTime() - myself()->_getNowDaySeconds();
|
||||||
$data = array();
|
$data = array();
|
||||||
$row = myself()->_getConfDbMysql()->execQueryOne(
|
$row = myself()->_getConfDbMysql()->execQueryOne(
|
||||||
@ -15,13 +30,14 @@ class AnncController extends BaseController {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($row){
|
if ($row){
|
||||||
$data = array(
|
$data = array(
|
||||||
'id' => $row['uniid'],
|
'id' => $row['uniid'],
|
||||||
'title' => $row['title'],
|
'title' => $row['title'],
|
||||||
'content' => $row['content']
|
'content' => $row['content'],
|
||||||
);
|
'end_time' => $row['end_time']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
myself()->_rspData($data);
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('services/ServerSwitch.php');
|
require_once('services/ServerSwitchService.php');
|
||||||
require_once('services/HashRateService.php');
|
require_once('services/HashRateService.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/HashRateCommon.php');
|
require_once('mt/HashRateCommon.php');
|
||||||
@ -373,8 +373,7 @@ class OtherController extends BaseAuthedController {
|
|||||||
'model' => $packageId
|
'model' => $packageId
|
||||||
));
|
));
|
||||||
$examining = !empty($row) && $row['version'] == $version && $row['is_auditing'] ? 1 : 0;
|
$examining = !empty($row) && $row['version'] == $version && $row['is_auditing'] ? 1 : 0;
|
||||||
$switchObj = new ServerSwitch();
|
$con = ServerSwitchService::getGameSwitch();
|
||||||
$con = $switchObj->getGameSwitch();
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'data' => $examining ? $con['auditing'] : $con['normal']
|
'data' => $examining ? $con['auditing'] : $con['normal']
|
||||||
));
|
));
|
||||||
|
@ -2,40 +2,40 @@
|
|||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class ServerSwitch {
|
class ServerSwitchService {
|
||||||
const SERVER_SWITCH_KEY = 'server_switch_redis_key:';
|
const SERVER_SWITCH_KEY = 'server_switch_redis_key:';
|
||||||
const SERVER_AUDITING_KEY = 'server_auditing_redis_key:';
|
const SERVER_AUDITING_KEY = 'server_auditing_redis_key:';
|
||||||
|
|
||||||
public function getConfig(){
|
public static function getConfig(){
|
||||||
return $this->getGameSwitch()['normal'];
|
return self::getGameSwitch()['normal'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function heroChainIsOpen(){
|
public static function heroChainIsOpen(){
|
||||||
if ($this->getConfig()['heroChain'] > 0){
|
if (self::getConfig()['heroChain'] > 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function heroUpIsOpen(){
|
public static function heroUpIsOpen(){
|
||||||
if ($this->getConfig()['heroUp'] > 0){
|
if (self::getConfig()['heroUp'] > 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function goldSynIsOpen(){
|
public static function goldSynIsOpen(){
|
||||||
if ($this->getConfig()['goldSyn'] > 0){
|
if (self::getConfig()['goldSyn'] > 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function heroPieceSynIsOpen(){
|
public static function heroPieceSynIsOpen(){
|
||||||
if ($this->getConfig()['heroPieceSyn'] > 0){
|
if (self::getConfig()['heroPieceSyn'] > 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function chipPieceSynIsOpen(){
|
public static function chipPieceSynIsOpen(){
|
||||||
if ($this->getConfig()['chipPieceSyn'] > 0){
|
if (self::getConfig()['chipPieceSyn'] > 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -47,19 +47,19 @@ class ServerSwitch {
|
|||||||
// $this->switchConfig = getServerSwitchConfig();
|
// $this->switchConfig = getServerSwitchConfig();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function getGameSwitch(){
|
public static function getGameSwitch(){
|
||||||
$redis = myself()->_getRedis(self::SERVER_SWITCH_KEY);
|
$redis = myself()->_getRedis(self::SERVER_SWITCH_KEY);
|
||||||
if ($redis->exists(self::SERVER_SWITCH_KEY)){
|
if ($redis->exists(self::SERVER_SWITCH_KEY)){
|
||||||
$data = json_decode($redis->get(self::SERVER_SWITCH_KEY),true);
|
$data = json_decode($redis->get(self::SERVER_SWITCH_KEY),true);
|
||||||
}else{
|
}else{
|
||||||
$data = $this->selectSwitchTable();
|
$data = self::selectSwitchTable();
|
||||||
$redis->set(self::SERVER_SWITCH_KEY,json_encode($data));
|
$redis->set(self::SERVER_SWITCH_KEY,json_encode($data));
|
||||||
$redis->pexpire(self::SERVER_SWITCH_KEY , 10*1000);
|
$redis->pexpire(self::SERVER_SWITCH_KEY , 10*1000);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function selectSwitchTable(){
|
private static function selectSwitchTable(){
|
||||||
$rows = SqlHelper::ormSelect(myself()->_getConfDbMysql(), 't_game_switch', array());
|
$rows = SqlHelper::ormSelect(myself()->_getConfDbMysql(), 't_game_switch', array());
|
||||||
$data = array(
|
$data = array(
|
||||||
'normal' => array(),
|
'normal' => array(),
|
Loading…
x
Reference in New Issue
Block a user