From 3549a07d5f7006cf6d3e63ae150ab031b2ce0bee Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 13 Nov 2023 17:37:13 +0800 Subject: [PATCH] 1 --- webapp/controller/OtherController.class.php | 347 ++++++++++---------- webapp/mt/ActivityRewards.php | 28 ++ 2 files changed, 208 insertions(+), 167 deletions(-) create mode 100644 webapp/mt/ActivityRewards.php diff --git a/webapp/controller/OtherController.class.php b/webapp/controller/OtherController.class.php index 3fe33906..0e5fe2a1 100644 --- a/webapp/controller/OtherController.class.php +++ b/webapp/controller/OtherController.class.php @@ -1,167 +1,180 @@ - 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, - )); - - - } - -} + 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, + )); + + + } + +} diff --git a/webapp/mt/ActivityRewards.php b/webapp/mt/ActivityRewards.php new file mode 100644 index 00000000..1cda8253 --- /dev/null +++ b/webapp/mt/ActivityRewards.php @@ -0,0 +1,28 @@ +