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