1
This commit is contained in:
parent
43771c8e67
commit
408335c8e3
@ -1695,16 +1695,37 @@ CREATE TABLE `t_avatar` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
CREATE TABLE `t_hash_rate_task` (
|
--
|
||||||
|
-- Table structure for table `t_hash_rate`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_hash_rate`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_hash_rate` (
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
`task_id` int(11) NOT NULL COMMENT '配置表HashRateTask',
|
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
||||||
`season` int(11) NOT NULL DEFAULT '0' COMMENT 'taskId 为10003可用',
|
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||||
`record_total` int(64) NOT NULL DEFAULT '0' COMMENT '记录总数据',
|
`reward` int(64) NOT NULL DEFAULT '0' COMMENT '奖励',
|
||||||
`claim_day` int(64) NOT NULL DEFAULT '0' COMMENT '当天领取数据',
|
|
||||||
`claim_total` int(64) NOT NULL DEFAULT '0' COMMENT '领取总数据',
|
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
UNIQUE KEY `account_task_id` (`account_id`, `task_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_hash_rate_battle_data`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_hash_rate_battle_data`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_hash_rate_battle_data` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`battle_data` mediumblob COMMENT 'battle_data',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
begin;
|
begin;
|
||||||
|
|
||||||
CREATE TABLE `t_hash_rate_task` (
|
CREATE TABLE `t_hash_rate` (
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
`task_id` int(11) NOT NULL COMMENT '配置表id',
|
||||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
`period` int(11) NOT NULL DEFAULT '0' COMMENT '算力期数',
|
||||||
`total_num` int(64) NOT NULL DEFAULT '0' COMMENT '记录数据',
|
`reward` int(64) NOT NULL DEFAULT '0' COMMENT '奖励',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
|
@ -16,7 +16,7 @@ require_once('models/Parachute.php');
|
|||||||
require_once('models/Chip.php');
|
require_once('models/Chip.php');
|
||||||
require_once('models/Pass.php');
|
require_once('models/Pass.php');
|
||||||
require_once('models/Avatar.php');
|
require_once('models/Avatar.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRate.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('mt/LevelUp.php');
|
require_once('mt/LevelUp.php');
|
||||||
|
@ -12,7 +12,7 @@ require_once('models/User.php');
|
|||||||
require_once('models/Parachute.php');
|
require_once('models/Parachute.php');
|
||||||
require_once('models/ChipPage.php');
|
require_once('models/ChipPage.php');
|
||||||
require_once('models/Battle.php');
|
require_once('models/Battle.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRate.php');
|
||||||
require_once('services/BattleDataService.php');
|
require_once('services/BattleDataService.php');
|
||||||
require_once('services/TameBattleDataService.php');
|
require_once('services/TameBattleDataService.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('mt/HashRate.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/HashRateCommon.php');
|
require_once('mt/HashRateCommon.php');
|
||||||
require_once('mt/HashRateTask.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('services/HashRateService.php');
|
require_once('services/HashRateService.php');
|
||||||
@ -13,7 +13,7 @@ require_once('models/ComputingPower.php');
|
|||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
require_once('models/RewardsCec.php');
|
require_once('models/RewardsCec.php');
|
||||||
require_once('models/Staking.php');
|
require_once('models/Staking.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRate.php');
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
|
|
||||||
use models\ComputingPower;
|
use models\ComputingPower;
|
||||||
|
@ -20,7 +20,7 @@ class HashRateController extends BaseAuthedController
|
|||||||
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
$currentPeriod= \mt\AchievementsCycle::getCurrentPeriod();
|
||||||
$hashRateDtoList = array();
|
$hashRateDtoList = array();
|
||||||
foreach ($mateList as $mate) {
|
foreach ($mateList as $mate) {
|
||||||
$temp = $this->hashRateService->hashRateTaskDto($mate);
|
$temp = $this->hashRateService->hashRateTaskDto($mate ,$currentPeriod);
|
||||||
array_push($hashRateDtoList, $temp);
|
array_push($hashRateDtoList, $temp);
|
||||||
}
|
}
|
||||||
$obtain_end_time = strtotime($currentPeriod['obtain_end_time']);
|
$obtain_end_time = strtotime($currentPeriod['obtain_end_time']);
|
||||||
|
30
webapp/models/HashRate.php
Normal file
30
webapp/models/HashRate.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class HashRate extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function find($taskId,$period){
|
||||||
|
return SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskId,
|
||||||
|
'period' => $period,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($fieldKv){
|
||||||
|
SqlHelper::insert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hash_rate_task',
|
||||||
|
$fieldKv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,170 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace models;
|
|
||||||
|
|
||||||
require_once('mt/Rank.php');
|
|
||||||
require_once('mt/RankSeason.php');
|
|
||||||
|
|
||||||
use mt\Rank;
|
|
||||||
use mt\RankSeason;
|
|
||||||
use phpcommon\SqlHelper;
|
|
||||||
class HashRateTask extends BaseModel
|
|
||||||
{
|
|
||||||
|
|
||||||
public static function find(){
|
|
||||||
$rows = SqlHelper::ormSelect(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (count($rows) < 1){
|
|
||||||
$rows = array();
|
|
||||||
}
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function toDto($row){
|
|
||||||
array(
|
|
||||||
'task_id' => $row['task_id']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function findByTaskId($taskId){
|
|
||||||
return SqlHelper::ormSelectOne(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function incRecordNum($period,$taskId,$num){
|
|
||||||
SqlHelper::upsert
|
|
||||||
(myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'period' => $period,
|
|
||||||
'task_id' => $taskId,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'total_num' => function () use($num) {
|
|
||||||
return "total_num + ${num}";
|
|
||||||
},
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'period' => $period,
|
|
||||||
'task_id' => $taskId,
|
|
||||||
'total_num' => $num,
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getDailyReward($taskId){
|
|
||||||
$row = SqlHelper::ormSelectOne(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$modifytime = $row ? $row['modifytime'] : myself()->_getNowTime();
|
|
||||||
$num = $row ? $row['claim_day'] : 0;
|
|
||||||
|
|
||||||
if (myself()->_getDaySeconds($modifytime) < myself()->_getNowDaySeconds()) {
|
|
||||||
$num = 0;
|
|
||||||
}
|
|
||||||
return $num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function incDailyReward($taskId,$val,$total){
|
|
||||||
$oldVal = self::getDailyReward($taskId);
|
|
||||||
$val += $oldVal;
|
|
||||||
SqlHelper::upsert
|
|
||||||
(myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'claim_day' => $val,
|
|
||||||
'claim_total' => function () use($total) {
|
|
||||||
return "claim_total + ${total}";
|
|
||||||
},
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
'claim_day' => $val,
|
|
||||||
'claim_total' => $total,
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function updateKv($taskId,$fieldKv){
|
|
||||||
SqlHelper::update
|
|
||||||
(myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
),
|
|
||||||
$fieldKv
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setRankedData(){
|
|
||||||
$SeasonMeta = RankSeason::getCurrentSeason();
|
|
||||||
if (!$SeasonMeta){
|
|
||||||
error_log("当前赛季结束");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (! self::findByTaskIdOrSeason(self::RANK_TYPE,$SeasonMeta['id'])){
|
|
||||||
$userDb = myself()->_safeGetOrmUserInfo();
|
|
||||||
$rankMeta = Rank::getRankById($userDb['rank']);
|
|
||||||
SqlHelper::insert
|
|
||||||
(myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => self::RANK_TYPE,
|
|
||||||
'season' => $SeasonMeta['id'],
|
|
||||||
'record_total' => $rankMeta['rank_order2'],
|
|
||||||
'claim_total' => $rankMeta['rank_order2'],
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function findByTaskIdOrSeason($taskId,$season){
|
|
||||||
return SqlHelper::ormSelectOne(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_hash_rate_task',
|
|
||||||
array(
|
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'task_id' => $taskId,
|
|
||||||
'season' => $season,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -4,22 +4,21 @@
|
|||||||
namespace services;
|
namespace services;
|
||||||
require_once('mt/HashRate.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/HashRateTask.php');
|
require_once('mt/HashRate.php');
|
||||||
require_once('mt/Rank.php');
|
require_once('mt/Rank.php');
|
||||||
require_once('mt/RankSeason.php');
|
require_once('mt/RankSeason.php');
|
||||||
require_once('models/Bag.php');
|
require_once('models/Bag.php');
|
||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
require_once('models/Staking.php');
|
require_once('models/Staking.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRate.php');
|
||||||
require_once('models/HashRateBattleData.php');
|
require_once('models/HashRateBattleData.php');
|
||||||
|
|
||||||
use models\Bag;
|
use models\Bag;
|
||||||
use models\CrystalRecord;
|
use models\CrystalRecord;
|
||||||
use models\HashRateBattleData;
|
use models\HashRateBattleData;
|
||||||
use models\Staking;
|
use models\Staking;
|
||||||
use models\HashRateTask;
|
use models\HashRate;
|
||||||
use mt\AchievementsPower;
|
use mt\AchievementsPower;
|
||||||
use mt\HashRate;
|
|
||||||
use mt\Parameter;
|
use mt\Parameter;
|
||||||
use mt\Rank;
|
use mt\Rank;
|
||||||
use mt\RankSeason;
|
use mt\RankSeason;
|
||||||
@ -61,7 +60,7 @@ class HashRateService extends BaseService
|
|||||||
$this->mobaBattleData = $this->hashRateData['mobaData'];
|
$this->mobaBattleData = $this->hashRateData['mobaData'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hashRateTaskDto($taskMate){
|
public function hashRateTaskDto($taskMate ,$currentPeriod){
|
||||||
$taskDto = array(
|
$taskDto = array(
|
||||||
'task_id' => $taskMate['id'],
|
'task_id' => $taskMate['id'],
|
||||||
'current' => 0,
|
'current' => 0,
|
||||||
@ -144,6 +143,18 @@ class HashRateService extends BaseService
|
|||||||
if ($taskDto['current'] >= $taskDto['target']) {
|
if ($taskDto['current'] >= $taskDto['target']) {
|
||||||
$taskDto['current'] = $taskDto['target'];
|
$taskDto['current'] = $taskDto['target'];
|
||||||
$taskDto['state'] = self::FINISHED_STATE;
|
$taskDto['state'] = self::FINISHED_STATE;
|
||||||
|
$hashRateDb = HashRate::find($taskMate['id'],$currentPeriod['id']);
|
||||||
|
if (!$hashRateDb){
|
||||||
|
$fieldKv = array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'task_id' => $taskMate['id'],
|
||||||
|
'period' => $currentPeriod['id'],
|
||||||
|
'reward' => $taskMate['Reward_quantity'],
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
HashRate::add($fieldKv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $taskDto;
|
return $taskDto;
|
||||||
}
|
}
|
||||||
@ -177,236 +188,4 @@ class HashRateService extends BaseService
|
|||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------以下弃用---------------------------
|
|
||||||
const NONE_STATE = 0;
|
|
||||||
const RECEIVED_STATE = 1;
|
|
||||||
const EXCHANGE_RATE = 10;
|
|
||||||
//弃用
|
|
||||||
public function getCrystalDto($crystalMeta,&$crystalDto){
|
|
||||||
$crystalDto = array(
|
|
||||||
'item_id' => $crystalMeta['id'],
|
|
||||||
'pending' => 0,
|
|
||||||
'total' => array(),
|
|
||||||
'claimed' => 0,
|
|
||||||
'state' => self::NONE_STATE,
|
|
||||||
);
|
|
||||||
$hashRateMeta = HashRate::findHash($crystalMeta['id']);
|
|
||||||
$ownedNum = CrystalRecord::getCrystalNum($crystalMeta['id']);
|
|
||||||
$crystalDto['claimed'] = intval($ownedNum);
|
|
||||||
switch ($crystalMeta['sub_type']){
|
|
||||||
case 1 : {
|
|
||||||
$param = explode('|',$hashRateMeta['parameter']);
|
|
||||||
$killsNum = myself()->_getV(TN_TOTAL_KILLS_NUM,0);
|
|
||||||
$killsNumEd = myself()->_getV(TN_TOTAL_KILLS_NUM,-1);
|
|
||||||
$starNum = myself()->_getV(TN_TOTAL_STAR_NUM,0);
|
|
||||||
$starNumEd = myself()->_getV(TN_TOTAL_STAR_NUM,-1);
|
|
||||||
$killsNumEx = $killsNum - $killsNumEd;
|
|
||||||
$starNumEx = $starNum - $starNumEd ;
|
|
||||||
$crystalDto['total'] = array(
|
|
||||||
'param1' => floatval($killsNumEx),
|
|
||||||
'param2' => floatval($starNumEx),
|
|
||||||
);
|
|
||||||
$paramKill = explode(':',$param[0]);
|
|
||||||
$paramStar = explode(':',$param[1]);
|
|
||||||
$totalNum = max(0,floor($killsNumEx / $paramKill[0]) * $paramKill[1] +
|
|
||||||
floor($starNumEx / $paramStar[0]) * $paramStar[1] );
|
|
||||||
$crystalDto['pending'] = intval($totalNum);
|
|
||||||
$crystalDto['state'] = $crystalDto['pending'] > 0 ? self::RECEIVED_STATE : self::NONE_STATE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2 : {
|
|
||||||
// 游戏内消费总价值
|
|
||||||
$param = explode(':',$hashRateMeta['parameter']);
|
|
||||||
$consumeCost = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,0);
|
|
||||||
$consumeCostEd = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,-1);
|
|
||||||
$consumeCostEx = $consumeCost - $consumeCostEd ;
|
|
||||||
$crystalDto['total'] = array(
|
|
||||||
'param1' => floatval($consumeCostEx / self::EXCHANGE_RATE),
|
|
||||||
);
|
|
||||||
$totalNum = max(0,floor($consumeCostEx / self::EXCHANGE_RATE / $param[0]) * $param[1]);
|
|
||||||
$crystalDto['pending'] = intval($totalNum);
|
|
||||||
$crystalDto['state'] = $crystalDto['pending'] > 0 ? self::RECEIVED_STATE : self::NONE_STATE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3 : {
|
|
||||||
// Market交易总价值
|
|
||||||
$param = explode(':',$hashRateMeta['parameter']);
|
|
||||||
$consumeCost = myself()->_getV(TN_TOTAL_CEG_CONSUME,0);
|
|
||||||
$consumeCostEd = myself()->_getV(TN_TOTAL_CEG_CONSUME,-1);
|
|
||||||
$consumeCostEx = $consumeCost - $consumeCostEd ;
|
|
||||||
$crystalDto['total'] = array(
|
|
||||||
'param1' => floatval($consumeCostEx / self::EXCHANGE_RATE),
|
|
||||||
);
|
|
||||||
$totalNum = max(0,floor($consumeCostEx / self::EXCHANGE_RATE / $param[0]) * $param[1]);
|
|
||||||
$crystalDto['pending'] = intval($totalNum);
|
|
||||||
$crystalDto['state'] = $crystalDto['pending'] > 0 ? self::RECEIVED_STATE : self::NONE_STATE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4 : {
|
|
||||||
// 质压总价值
|
|
||||||
$param = explode(':',$hashRateMeta['parameter']);
|
|
||||||
// $rate = Parameter::getVal('cec_exchange_rate',10);
|
|
||||||
$cecVal = Staking::getStakingTotalValue();
|
|
||||||
$crystalDto['total'] = array(
|
|
||||||
'param1' => floatval($cecVal ),
|
|
||||||
);
|
|
||||||
$recordDb = CrystalRecord::getNewestRecordOne($crystalMeta['id']);
|
|
||||||
if ($recordDb && myself()->_getNowDaySeconds() == myself()->_getDaySeconds($recordDb['createtime'])){
|
|
||||||
$crystalDto['pending'] = 0;
|
|
||||||
}else{
|
|
||||||
$totalNum = max(0,floor($cecVal / $param[0]) * $param[1]);
|
|
||||||
$crystalDto['pending'] = intval($totalNum);
|
|
||||||
}
|
|
||||||
$crystalDto['state'] = $crystalDto['pending'] > 0 ? self::RECEIVED_STATE : self::NONE_STATE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//弃用
|
|
||||||
public function getCrystalValue(){
|
|
||||||
$chaimNum = 0;
|
|
||||||
$playing = array();
|
|
||||||
$staking = array();
|
|
||||||
$trading = array();
|
|
||||||
$consuming = array();
|
|
||||||
$nft = array();
|
|
||||||
// $hashRateMt = \mt\HashRateTask::getListByType(\mt\HashRateTask::PLAYING);
|
|
||||||
// foreach ($hashRateMt as $meta){
|
|
||||||
// $finalVal = 0;
|
|
||||||
// $uplimit = $meta['upperlimit'] ;
|
|
||||||
// if ($meta['id'] == HashRateTask::RANK_TYPE){
|
|
||||||
// $seasonMeta = RankSeason::getCurrentSeason();
|
|
||||||
// if (!$seasonMeta){
|
|
||||||
// $seasonMeta = RankSeason::getLastSeason();
|
|
||||||
// }
|
|
||||||
// $hashRateDb = HashRateTask::findByTaskIdOrSeason($meta['id'],$seasonMeta['id']);
|
|
||||||
// $userDb = myself()->_safeGetOrmUserInfo();
|
|
||||||
// $rankMeta = Rank::getRankById($userDb['rank']);
|
|
||||||
// if ($rankMeta['rank_order2'] > $hashRateDb['record_total']){
|
|
||||||
// $finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $meta['reward'];
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// $hashRateDb = HashRateTask::findByTaskId($meta['id']);
|
|
||||||
// $targetVal = 0;
|
|
||||||
// if ($hashRateDb){
|
|
||||||
// $total = $hashRateDb['record_total'] - $hashRateDb['claim_total'];
|
|
||||||
// if ($hashRateDb['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
|
||||||
// $targetVal = max(0,floor($total / 1000 / $meta['target'])) * $meta['reward'];
|
|
||||||
// }else{
|
|
||||||
// $targetVal = max(0,floor($total / $meta['target'])) * $meta['reward'];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// $claim_day = HashRateTask::getDailyReward($meta['id']);
|
|
||||||
// $uplimit = $meta['upperlimit'] - $claim_day;
|
|
||||||
// $finalVal = min($targetVal , $uplimit);
|
|
||||||
// }
|
|
||||||
// $chaimNum += $finalVal;
|
|
||||||
// array_push($detail,array(
|
|
||||||
// 'task_id' => $meta['id'],
|
|
||||||
// 'uplimit' => $uplimit,
|
|
||||||
// 'chaim_num' => $finalVal
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
$hashRateTask = \mt\HashRateTask::getMetaList();
|
|
||||||
foreach ($hashRateTask as $metaTask){
|
|
||||||
$finalVal = 0;
|
|
||||||
$uplimit = $metaTask['upperlimit'] ;
|
|
||||||
switch ($metaTask['type']){
|
|
||||||
case \mt\HashRateTask::PLAYING :{
|
|
||||||
if ($metaTask['id'] == HashRateTask::RANK_TYPE){
|
|
||||||
$seasonMeta = RankSeason::getCurrentSeason();
|
|
||||||
if (!$seasonMeta){
|
|
||||||
$seasonMeta = RankSeason::getLastSeason();
|
|
||||||
}
|
|
||||||
$hashRateDb = HashRateTask::findByTaskIdOrSeason($metaTask['id'],$seasonMeta['id']);
|
|
||||||
$userDb = myself()->_safeGetOrmUserInfo();
|
|
||||||
$rankMeta = Rank::getRankById($userDb['rank']);
|
|
||||||
//
|
|
||||||
if ($hashRateDb && $rankMeta['rank_order2'] > $hashRateDb['record_total']){
|
|
||||||
$finalVal = ($rankMeta['rank_order2'] - $hashRateDb['claim_total']) * $metaTask['reward'];
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$hashRateDb = HashRateTask::findByTaskId($metaTask['id']);
|
|
||||||
$targetVal = 0;
|
|
||||||
if ($hashRateDb){
|
|
||||||
$total = $hashRateDb['record_total'] - $hashRateDb['claim_total'];
|
|
||||||
if ($hashRateDb['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
|
||||||
$targetVal = max(0,floor($total / 1000 / $metaTask['target'])) * $metaTask['reward'];
|
|
||||||
}else{
|
|
||||||
$targetVal = max(0,floor($total / $metaTask['target'])) * $metaTask['reward'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$claim_day = HashRateTask::getDailyReward($metaTask['id']);
|
|
||||||
$uplimit = $metaTask['upperlimit'] - $claim_day;
|
|
||||||
$finalVal = min($targetVal , $uplimit);
|
|
||||||
}
|
|
||||||
$chaimNum += $finalVal;
|
|
||||||
array_push($playing,array(
|
|
||||||
'task_id' => $metaTask['id'],
|
|
||||||
'uplimit' => $uplimit,
|
|
||||||
'chaim_num' => $finalVal
|
|
||||||
));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case \mt\HashRateTask::STAKING :{
|
|
||||||
//质押价值
|
|
||||||
$stakingVal = Staking::getStakingTotalValue();
|
|
||||||
$targetVal = max(0,floor($stakingVal / $metaTask['target']) * $metaTask['reward']);
|
|
||||||
$claim_day = HashRateTask::getDailyReward($metaTask['id']);
|
|
||||||
if ($claim_day){
|
|
||||||
$finalVal = 0;
|
|
||||||
}else{
|
|
||||||
$finalVal = $targetVal;
|
|
||||||
}
|
|
||||||
$chaimNum += $finalVal;
|
|
||||||
array_push($staking,array(
|
|
||||||
'task_id' => $metaTask['id'],
|
|
||||||
'uplimit' => $uplimit,
|
|
||||||
'chaim_num' => $finalVal
|
|
||||||
));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// case \mt\HashRateTask::TRADING : {
|
|
||||||
// $consumeCost = myself()->_getV(TN_TOTAL_CEG_CONSUME,0);
|
|
||||||
// $consumeCostEd = myself()->_getV(TN_TOTAL_CEG_CONSUME,-1);
|
|
||||||
// $total = $consumeCost - $consumeCostEd ;
|
|
||||||
// $finalVal = max(0,floor($total / self::EXCHANGE_RATE / $metaTask['target']) * $metaTask['reward']);
|
|
||||||
// $chaimNum += $finalVal;
|
|
||||||
// array_push($trading,array(
|
|
||||||
// 'task_id' => $metaTask['id'],
|
|
||||||
// 'uplimit' => $uplimit,
|
|
||||||
// 'chaim_num' => $finalVal
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
case \mt\HashRateTask::CONSUMING : {
|
|
||||||
$consumeCost = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,0);
|
|
||||||
$consumeCostEd = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,-1);
|
|
||||||
$total = $consumeCost - $consumeCostEd;
|
|
||||||
$finalVal = max(0,floor($total / self::EXCHANGE_RATE / $metaTask['target']) * $metaTask['reward']);
|
|
||||||
$chaimNum += $finalVal;
|
|
||||||
array_push($consuming,array(
|
|
||||||
'task_id' => $metaTask['id'],
|
|
||||||
'uplimit' => $uplimit,
|
|
||||||
'chaim_num' => $finalVal
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array(
|
|
||||||
'totalNum' => $chaimNum,
|
|
||||||
'playing'=>$playing,
|
|
||||||
'staking'=>$staking,
|
|
||||||
'consuming'=>$consuming,
|
|
||||||
'nft'=>$nft,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -32,7 +32,7 @@ require_once('models/NftActive.php');
|
|||||||
require_once('models/FragmentRecord.php');
|
require_once('models/FragmentRecord.php');
|
||||||
require_once('models/BattleSettlement.php');
|
require_once('models/BattleSettlement.php');
|
||||||
require_once('models/RankBattle.php');
|
require_once('models/RankBattle.php');
|
||||||
require_once('models/HashRateTask.php');
|
require_once('models/HashRate.php');
|
||||||
require_once('models/HashRateBattleData.php');
|
require_once('models/HashRateBattleData.php');
|
||||||
|
|
||||||
require_once('services/RankActivityService.php');
|
require_once('services/RankActivityService.php');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user