1
This commit is contained in:
parent
13f3ec521b
commit
3549a07d5f
@ -1,167 +1,180 @@
|
||||
<?php
|
||||
|
||||
require_once('services/MissionService.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/HashRateCommon.php');
|
||||
|
||||
require_once('models/Mission.php');
|
||||
require_once('models/Fragment.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/SignLog.php');
|
||||
require_once('models/RankingSetRecord.php');
|
||||
require_once('models/Staking.php');
|
||||
require_once('models/SeasonRanking.php');
|
||||
require_once('models/RewardsCec.php');
|
||||
|
||||
use models\SignLog;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Mission;
|
||||
use models\Fragment;
|
||||
use models\Season;
|
||||
use models\RankingSetRecord;
|
||||
use models\Staking;
|
||||
use models\SeasonRanking;
|
||||
use models\RewardsCec;
|
||||
class OtherController extends BaseAuthedController {
|
||||
const MISSION = 1;
|
||||
const PIECE = 2;
|
||||
|
||||
public function tag()
|
||||
{
|
||||
$param = getReqVal('param', 0);
|
||||
$req = array(
|
||||
'mission' => 0,
|
||||
'piece' => array(),
|
||||
);
|
||||
switch ($param){
|
||||
case self::MISSION : {
|
||||
$userInfo = $this->_safeGetOrmUserInfo();
|
||||
// $currRankSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||
// $seasonDb = Season::find($currRankSeasonMeta['id']);
|
||||
$missionService = new services\MissionService();
|
||||
$missionService->init($userInfo, null);;
|
||||
$missionMetaList = mt\Task::getCustomTypeMetaList(1, $missionService);
|
||||
$missionHash = Mission::allToHash();
|
||||
foreach ($missionMetaList as $missionMeta) {
|
||||
$missionDb = getXVal($missionHash, $missionMeta['id'], null);
|
||||
$missionDto = $missionService->getMissionDto('', '', $missionDb, $missionMeta);
|
||||
if ($missionDto['state'] == Mission::RECEIVEABLE_STATE){
|
||||
$req['mission'] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::PIECE : {
|
||||
$req['piece'] = Fragment::isSatisfy();
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
$req = array(
|
||||
'mission' => 0,
|
||||
'piece' => array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data'=>$req
|
||||
));
|
||||
}
|
||||
|
||||
public function getGameModuleState(){
|
||||
//七日签到
|
||||
$signState = 0;
|
||||
$signDb = SignLog::find();
|
||||
if(($signDb['days'] == 7 && $signDb['is_receive'] == 1) || $signDb['days'] > 7){
|
||||
$signState = 1;
|
||||
}
|
||||
//排位
|
||||
$rankState = 0;
|
||||
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||
if($currSeasonMeta){
|
||||
$rankState = 1;
|
||||
|
||||
}
|
||||
$countdown = 0;
|
||||
$nextCurrSeasonMeta = mt\RankSeason::getNextCurrentSeason();
|
||||
if ($nextCurrSeasonMeta){
|
||||
$countdown = strtotime($nextCurrSeasonMeta['start_time']) - myself()->_getNowTime();
|
||||
}
|
||||
//算力
|
||||
$hashRateState = 0;
|
||||
$hashRateMeta = \mt\HashRateCommon::find(1);
|
||||
if (myself()->_getNowTime() > strtotime($hashRateMeta['start_time'])){
|
||||
$hashRateState = 1;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
"firstTopUp" => myself()->_getV(TN_FIRST_TUPOP_STATUS,0),
|
||||
"signDayState" => $signState,
|
||||
"rankState" => $rankState,
|
||||
"nextRankSeasonCountdown" => $countdown,
|
||||
"hashRateState" => $hashRateState,
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'data'=>$data
|
||||
));
|
||||
}
|
||||
|
||||
public function getRankingState(){
|
||||
$recordDb = RankingSetRecord::find();
|
||||
$data = array(
|
||||
'state' => 0 ,
|
||||
);
|
||||
if ($recordDb){
|
||||
$data = RankingSetRecord::toDto($recordDb);;
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data'=>$data
|
||||
));
|
||||
}
|
||||
|
||||
public function getCecRewardHistory(){
|
||||
$historyList = array();
|
||||
$totalCecVal = 0;
|
||||
SeasonRanking::getSeasonList(function ($row) use (&$historyList,&$totalCecVal) {
|
||||
if ($row && $row['ranking_point'] > 0){
|
||||
$totalCecVal += ($row['ranking_point'] * 0.15);
|
||||
array_push($historyList,array(
|
||||
'type' => 1,
|
||||
'cecVal' => $row['ranking_point'] * 0.15,
|
||||
'createtime' => $row['createtime'],
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
\models\RewardsCec::all(function ($row) use (&$historyList,&$totalCecVal) {
|
||||
if ($row){
|
||||
$totalCecVal += $row['reward_cec'];
|
||||
array_push($historyList,array(
|
||||
'type' => 2,
|
||||
'cecVal' => $row['reward_cec'],
|
||||
'createtime' => $row['createtime'],
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
$stakingDb = Staking::all(myself()->_getAddress());
|
||||
foreach ($stakingDb as $row) {
|
||||
if ($row['status'] == Staking::REDEEM_STATUS) {
|
||||
$item = Staking::toDto($row);
|
||||
$totalCecVal += $item['total_rewards'];
|
||||
array_push($historyList, array(
|
||||
"type" => 3,
|
||||
"cecVal" => $item['total_rewards'],
|
||||
"createtime" => $item['redeem_time']
|
||||
));
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'cec'=>$totalCecVal,
|
||||
'list'=>$historyList,
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
require_once('services/MissionService.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/HashRateCommon.php');
|
||||
require_once('mt/ActivityRewards.php');
|
||||
|
||||
require_once('models/Mission.php');
|
||||
require_once('models/Fragment.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/SignLog.php');
|
||||
require_once('models/RankingSetRecord.php');
|
||||
require_once('models/Staking.php');
|
||||
require_once('models/SeasonRanking.php');
|
||||
require_once('models/RewardsCec.php');
|
||||
|
||||
use models\SignLog;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Mission;
|
||||
use models\Fragment;
|
||||
use models\Season;
|
||||
use models\RankingSetRecord;
|
||||
use models\Staking;
|
||||
use models\SeasonRanking;
|
||||
use models\RewardsCec;
|
||||
class OtherController extends BaseAuthedController {
|
||||
const MISSION = 1;
|
||||
const PIECE = 2;
|
||||
|
||||
public function tag()
|
||||
{
|
||||
$param = getReqVal('param', 0);
|
||||
$req = array(
|
||||
'mission' => 0,
|
||||
'piece' => array(),
|
||||
);
|
||||
switch ($param){
|
||||
case self::MISSION : {
|
||||
$userInfo = $this->_safeGetOrmUserInfo();
|
||||
// $currRankSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||
// $seasonDb = Season::find($currRankSeasonMeta['id']);
|
||||
$missionService = new services\MissionService();
|
||||
$missionService->init($userInfo, null);;
|
||||
$missionMetaList = mt\Task::getCustomTypeMetaList(1, $missionService);
|
||||
$missionHash = Mission::allToHash();
|
||||
foreach ($missionMetaList as $missionMeta) {
|
||||
$missionDb = getXVal($missionHash, $missionMeta['id'], null);
|
||||
$missionDto = $missionService->getMissionDto('', '', $missionDb, $missionMeta);
|
||||
if ($missionDto['state'] == Mission::RECEIVEABLE_STATE){
|
||||
$req['mission'] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::PIECE : {
|
||||
$req['piece'] = Fragment::isSatisfy();
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
$req = array(
|
||||
'mission' => 0,
|
||||
'piece' => array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data'=>$req
|
||||
));
|
||||
}
|
||||
|
||||
public function getGameModuleState(){
|
||||
//七日签到
|
||||
$signState = 0;
|
||||
$signDb = SignLog::find();
|
||||
if(($signDb['days'] == 7 && $signDb['is_receive'] == 1) || $signDb['days'] > 7){
|
||||
$signState = 1;
|
||||
}
|
||||
//排位
|
||||
$rankState = 0;
|
||||
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||
if($currSeasonMeta){
|
||||
$rankState = 1;
|
||||
|
||||
}
|
||||
$countdown = 0;
|
||||
$nextCurrSeasonMeta = mt\RankSeason::getNextCurrentSeason();
|
||||
if ($nextCurrSeasonMeta){
|
||||
$countdown = strtotime($nextCurrSeasonMeta['start_time']) - myself()->_getNowTime();
|
||||
}
|
||||
//算力
|
||||
$hashRateState = 0;
|
||||
$hashRateMeta = \mt\HashRateCommon::find(1);
|
||||
if (myself()->_getNowTime() > strtotime($hashRateMeta['start_time'])){
|
||||
$hashRateState = 1;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
"firstTopUp" => myself()->_getV(TN_FIRST_TUPOP_STATUS,0),
|
||||
"signDayState" => $signState,
|
||||
"rankState" => $rankState,
|
||||
"nextRankSeasonCountdown" => $countdown,
|
||||
"hashRateState" => $hashRateState,
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'data'=>$data
|
||||
));
|
||||
}
|
||||
|
||||
public function getRankingState(){
|
||||
$recordDb = RankingSetRecord::find();
|
||||
$data = array(
|
||||
'state' => 0 ,
|
||||
);
|
||||
if ($recordDb){
|
||||
$data = RankingSetRecord::toDto($recordDb);;
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data'=>$data
|
||||
));
|
||||
}
|
||||
|
||||
public function getCecRewardHistory(){
|
||||
$historyList = array();
|
||||
$totalCecVal = 0;
|
||||
SeasonRanking::getSeasonList(function ($row) use (&$historyList,&$totalCecVal) {
|
||||
if ($row && $row['ranking_point'] > 0){
|
||||
$totalCecVal += ($row['ranking_point'] * 0.15);
|
||||
array_push($historyList,array(
|
||||
'type' => 1,
|
||||
'cecVal' => $row['ranking_point'] * 0.15,
|
||||
'createtime' => $row['createtime'],
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
\models\RewardsCec::all(function ($row) use (&$historyList,&$totalCecVal) {
|
||||
if ($row){
|
||||
$totalCecVal += $row['reward_cec'];
|
||||
array_push($historyList,array(
|
||||
'type' => 2,
|
||||
'cecVal' => $row['reward_cec'],
|
||||
'createtime' => $row['createtime'],
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
$stakingDb = Staking::all(myself()->_getAddress());
|
||||
foreach ($stakingDb as $row) {
|
||||
if ($row['status'] == Staking::REDEEM_STATUS) {
|
||||
$item = Staking::toDto($row);
|
||||
$totalCecVal += $item['total_rewards'];
|
||||
array_push($historyList, array(
|
||||
"type" => 3,
|
||||
"cecVal" => $item['total_rewards'],
|
||||
"createtime" => $item['redeem_time']
|
||||
));
|
||||
}
|
||||
}
|
||||
$rewards = \mt\ActivityRewards::find(myself()->_getAccountId());
|
||||
if ($rewards){
|
||||
foreach ($rewards as $reward){
|
||||
array_push($historyList, array(
|
||||
"type" => -1,
|
||||
"event_name" => $reward['event_name'],
|
||||
"cecVal" => $reward['cec'],
|
||||
"createtime" => $reward['time']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspData(array(
|
||||
'cec'=>$totalCecVal,
|
||||
'list'=>$historyList,
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
28
webapp/mt/ActivityRewards.php
Normal file
28
webapp/mt/ActivityRewards.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace mt;
|
||||
|
||||
|
||||
class ActivityRewards
|
||||
{
|
||||
public static function find($account){
|
||||
$data = array();
|
||||
foreach (self::getMetaList() as $mate){
|
||||
if ($mate['account_id'] == $account){
|
||||
array_push($data,$mate);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('ActivityRewards@ActivityRewards.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user