Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c9fbc71f71 | ||
![]() |
101bab3142 | ||
![]() |
d4120df25c | ||
![]() |
1548872505 | ||
![]() |
9a338dde91 | ||
![]() |
8ecb034b9b | ||
![]() |
587b4c2c53 | ||
![]() |
bff4607081 | ||
![]() |
ab02301b32 | ||
![]() |
114835ca6d | ||
![]() |
2699be5296 | ||
![]() |
2f75aa1e1d | ||
![]() |
2c1f98ad82 |
@ -3,6 +3,7 @@
|
|||||||
require_once('services/MissionService.php');
|
require_once('services/MissionService.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/HashRateCommon.php');
|
require_once('mt/HashRateCommon.php');
|
||||||
|
require_once('mt/ActivityRewards.php');
|
||||||
|
|
||||||
require_once('models/Mission.php');
|
require_once('models/Mission.php');
|
||||||
require_once('models/Fragment.php');
|
require_once('models/Fragment.php');
|
||||||
@ -156,6 +157,78 @@ class OtherController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$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" => strtotime($reward['time'])
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->_rspData(array(
|
||||||
|
'cec'=>$totalCecVal,
|
||||||
|
'list'=>$historyList,
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCecRewardHistory2(){
|
||||||
|
$address = getReqVal('address', '');
|
||||||
|
$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($address);
|
||||||
|
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" => strtotime($reward['time'])
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'cec'=>$totalCecVal,
|
'cec'=>$totalCecVal,
|
||||||
'list'=>$historyList,
|
'list'=>$historyList,
|
||||||
|
42
webapp/controller/OutAppNftController.class.php
Normal file
42
webapp/controller/OutAppNftController.class.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
require_once('models/Nft.php');
|
||||||
|
|
||||||
|
use models\Nft;
|
||||||
|
class OutAppNftController extends BaseController {
|
||||||
|
|
||||||
|
public function getNftList(){
|
||||||
|
$address = getReqVal('address', '');
|
||||||
|
$type = getReqVal('type', '');
|
||||||
|
if ($type){
|
||||||
|
$nftList = Nft::getNftListByType($address,$type);
|
||||||
|
}else{
|
||||||
|
$nftList = Nft::getNftList($address);
|
||||||
|
}
|
||||||
|
$listInfo = array();
|
||||||
|
if ($nftList){
|
||||||
|
foreach ($nftList as $nft) {
|
||||||
|
$image = 'https://www.cebg.games/res/avatars/' . $nft['item_id'] . '.png';
|
||||||
|
$full_image = 'https://www.cebg.games/res/avatars/full_' . $nft['item_id'] . '.png';
|
||||||
|
$info = array(
|
||||||
|
"idx" => $nft['idx'],
|
||||||
|
"owner_address" => $nft['owner_address'],
|
||||||
|
"item_id" => $nft['item_id'],
|
||||||
|
"token_id" => $nft['token_id'],
|
||||||
|
"token_type" => $nft['token_type'],
|
||||||
|
"contract_address" => $nft['contract_address'],
|
||||||
|
'image' => $image,
|
||||||
|
'full_image' => $full_image,
|
||||||
|
"details" => array(),
|
||||||
|
);
|
||||||
|
array_push($listInfo,$info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_rspData(array(
|
||||||
|
'nfts' => $listInfo,
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
require_once("models/Staking.php");
|
||||||
|
|
||||||
|
use models\Staking;
|
||||||
|
|
||||||
class TempToolsController extends BaseController {
|
class TempToolsController extends BaseController {
|
||||||
|
|
||||||
public function _handlePre()
|
public function _handlePre()
|
||||||
@ -348,4 +352,12 @@ class TempToolsController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exportStaking()
|
||||||
|
{
|
||||||
|
$userHash = Staking::exportStatData();
|
||||||
|
foreach ($userHash as $key => $val) {
|
||||||
|
echo $key . ',' . $val . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,12 @@ namespace models;
|
|||||||
require_once("mt/Staking.php");
|
require_once("mt/Staking.php");
|
||||||
|
|
||||||
require_once("models/User.php");
|
require_once("models/User.php");
|
||||||
|
require_once("models/Nft.php");
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
|
use models\Nft;
|
||||||
|
|
||||||
class Staking extends BaseModel {
|
class Staking extends BaseModel {
|
||||||
|
|
||||||
@ -244,6 +246,14 @@ class Staking extends BaseModel {
|
|||||||
$passedDays = intval(((myself()->_getNowDaySeconds()) -
|
$passedDays = intval(((myself()->_getNowDaySeconds()) -
|
||||||
(myself()->_getDaySeconds($row['start_time']) + 3600 * 24)) /
|
(myself()->_getDaySeconds($row['start_time']) + 3600 * 24)) /
|
||||||
3600 / 24);
|
3600 / 24);
|
||||||
|
//这是后面加的
|
||||||
|
$endTime = getReqVal('end_time', 0);
|
||||||
|
if ($endTime > 0) {
|
||||||
|
$passedDays = intval(((myself()->_getDaySeconds($endTime)) -
|
||||||
|
(myself()->_getDaySeconds($row['start_time']) + 3600 * 24)) /
|
||||||
|
3600 / 24);
|
||||||
|
}
|
||||||
|
|
||||||
$passedDays = max(0, $passedDays);
|
$passedDays = max(0, $passedDays);
|
||||||
$saveDays = max(0, intval($row['stake_time'] / 3600 / 24));
|
$saveDays = max(0, intval($row['stake_time'] / 3600 / 24));
|
||||||
$dto['stacked_days'] = $passedDays;
|
$dto['stacked_days'] = $passedDays;
|
||||||
@ -272,6 +282,7 @@ class Staking extends BaseModel {
|
|||||||
if ($stakedDays >= $saveDays) {
|
if ($stakedDays >= $saveDays) {
|
||||||
$rate = 1;
|
$rate = 1;
|
||||||
}
|
}
|
||||||
|
$rate = 1;
|
||||||
if ($saveDays >= 30 * 12 * 2) {
|
if ($saveDays >= 30 * 12 * 2) {
|
||||||
$stakedDays = max($stakedDays, 0);
|
$stakedDays = max($stakedDays, 0);
|
||||||
$dto['cec_rewards'] = ($dto['cec_value'] * (0.6 / 30 / 12)) * min(30 * 12, $stakedDays) * $rate;
|
$dto['cec_rewards'] = ($dto['cec_value'] * (0.6 / 30 / 12)) * min(30 * 12, $stakedDays) * $rate;
|
||||||
@ -354,4 +365,146 @@ class Staking extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function exportStatData()
|
||||||
|
{
|
||||||
|
$userHash = array();
|
||||||
|
$addressHash = self::getAllAddressHash();
|
||||||
|
$poolSize = 8000 * 10000 - self::getAllStakingValue();
|
||||||
|
foreach ($addressHash as $key => $val) {
|
||||||
|
$address = $key;
|
||||||
|
$rows = $val;
|
||||||
|
$info = array(
|
||||||
|
'pool_size' => $poolSize,
|
||||||
|
'total_staking_value' => '0',
|
||||||
|
'daily_staking_value' => '0',
|
||||||
|
'total_rewards' => 0,
|
||||||
|
'planet' => array(
|
||||||
|
'type' => self::PLANET_TYPE,
|
||||||
|
'is_open' => 1
|
||||||
|
),
|
||||||
|
'badge' => array(
|
||||||
|
'type' => self::BADGE_TYPE,
|
||||||
|
'is_open' => 1
|
||||||
|
),
|
||||||
|
'cec' => array(
|
||||||
|
'type' => self::CEC_TYPE,
|
||||||
|
'is_open' => 0
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self::fillStakingInfo($info, 'planet', $rows);
|
||||||
|
self::fillStakingInfo($info, 'badge', $rows);
|
||||||
|
self::fillStakingInfo($info, 'cec', $rows);
|
||||||
|
$userHash[$address] = $info['total_rewards'];
|
||||||
|
}
|
||||||
|
return $userHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function fillStakingInfo(&$info, $fieldName, $rows)
|
||||||
|
{
|
||||||
|
$stackingInfo = &$info[$fieldName];
|
||||||
|
$stackingInfo['staked_quant'] = 0;
|
||||||
|
$stackingInfo['claim_rewards'] = 0;
|
||||||
|
$stackingInfo['daily_rewards'] = 0;
|
||||||
|
$stackingInfo['staking_value'] = 0;
|
||||||
|
$stackingInfo['maturity_quant'] = 0;
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$stakingMeta = mt\Staking::get($row['item_id']);
|
||||||
|
if (self::isTypeNft($stackingInfo['type'], $row) && $stakingMeta) {
|
||||||
|
$stakingDto = self::toDto($row);
|
||||||
|
if ($stakingDto['status'] == self::STAKING_STATUS) {
|
||||||
|
if ($stakingDto['remain_days'] <= 0) {
|
||||||
|
$stackingInfo['maturity_quant'] += $stakingDto['stacked_num'];
|
||||||
|
} else {
|
||||||
|
$stackingInfo['daily_rewards'] += $stakingDto['daily_rewards'];
|
||||||
|
$info['daily_staking_value'] += $stakingDto['daily_rewards'];
|
||||||
|
}
|
||||||
|
$stackingInfo['staked_quant'] += $stakingDto['stacked_num'];
|
||||||
|
$stackingInfo['staking_value'] += $stakingDto['cec_value'];
|
||||||
|
$info['total_staking_value'] += $stakingDto['cec_value'] + $stakingDto['total_rewards'];
|
||||||
|
} else {
|
||||||
|
$stackingInfo['claim_rewards'] += $stakingDto['total_rewards'];
|
||||||
|
//$info['total_staking_value'] += $stakingDto['cec_value'] + $stakingDto['total_rewards'];
|
||||||
|
$info['total_rewards'] += $stakingDto['total_rewards'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllAddressHash()
|
||||||
|
{
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_staking',
|
||||||
|
array(
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$addressHash = array();
|
||||||
|
foreach ($rows as &$row) {
|
||||||
|
if (SERVER_ENV != _ONLINE) {
|
||||||
|
if ($row['status'] == self::REDEEM_STATUS) {
|
||||||
|
$row['redeem_time'] += myself()->_getTimeOffset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($row['nft_type'] == self::NFT721) {
|
||||||
|
if (!$row['item_id']) {
|
||||||
|
$itemId = 0;
|
||||||
|
$tokenType = 0;
|
||||||
|
if (!self::repair721NftInfo($row['token_id'], $row['contract_address'], $row['net_id'],
|
||||||
|
$row['start_time'], $itemId, $tokenType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$row['item_id'] = $itemId;
|
||||||
|
$row['token_type'] = $tokenType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!array_key_exists($row['address'], $addressHash)) {
|
||||||
|
$addressHash[$row['address']] = array();
|
||||||
|
}
|
||||||
|
array_push($addressHash[$row['address']], $row);
|
||||||
|
}
|
||||||
|
return $addressHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function isTypeNft($type, $dbInfo)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case self::PLANET_TYPE:
|
||||||
|
{
|
||||||
|
if (in_array($dbInfo['token_type'], array(
|
||||||
|
Nft::PLANET_TYPE
|
||||||
|
))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::BADGE_TYPE:
|
||||||
|
{
|
||||||
|
if (SERVER_ENV != _ONLINE) {
|
||||||
|
if (in_array($dbInfo['token_type'], array(
|
||||||
|
Nft::HONOR1_TYPE
|
||||||
|
))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (in_array($dbInfo['token_type'], array(
|
||||||
|
Nft::GENESIS_TYPE
|
||||||
|
))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::CEC_TYPE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLANET_TYPE = 1;
|
||||||
|
const BADGE_TYPE = 2;
|
||||||
|
const CEC_TYPE = 3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
27
webapp/mt/ActivityRewards.php
Normal file
27
webapp/mt/ActivityRewards.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?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