game2006api/webapp/controller/HashRateController.class.php
hujiabin 2cb9bc1bc8 1
2024-01-25 16:04:16 +08:00

56 lines
2.1 KiB
PHP

<?php
require_once('services/HashRateService.php');
require_once('mt/AchievementsPower.php');
require_once('mt/AchievementsCycle.php');
require_once('models/HashRate.php');
use models\HashRate;
class HashRateController extends BaseAuthedController
{
private $hashRateService = null;
public function _handlePre()
{
parent::_handlePre();
$this->hashRateService = new services\HashRateService();
$this->hashRateService->init();
}
public function info(){
$mateList = \mt\AchievementsPower::getMetaList();
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
$info = array(
'list' => array(),
'obtain_start_time' => 0,
'obtain_end_time' => 0,
'income_start_time' => 0,
'income_end_time' => 0,
'state' => 0,
'myHashRate' => 0,
);
if ($currentPeriod){
foreach ($mateList as $mate) {
$temp = $this->hashRateService->hashRateTaskDto($mate ,$currentPeriod);
array_push($info['list'], $temp);
}
$obtain_start_time = strtotime($currentPeriod['obtain_start_time']);
$obtain_end_time = strtotime($currentPeriod['obtain_end_time']);
$income_start_time = strtotime($currentPeriod['income_start_time']);
$income_end_time = strtotime($currentPeriod['income_end_time']);
$info['obtain_start_time'] = $obtain_start_time;
$info['obtain_end_time'] = $obtain_end_time;
$info['income_start_time'] = $income_start_time;
$info['income_end_time'] = $income_end_time;
if(myself()->_getNowTime() >= $obtain_start_time && myself()->_getNowTime() <= $obtain_end_time){
$info['state'] = 1;
}elseif (myself()->_getNowTime() >= $income_start_time && myself()->_getNowTime() <= $income_end_time){
$info['state'] = 2;
}
$info['myHashRate'] = HashRate::getMyHashRate( $currentPeriod['id']);
}
$this->_rspData($info);
}
}