1
This commit is contained in:
parent
6c5f84fa98
commit
e56cb2bc52
@ -1,163 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import _common
|
||||
|
||||
class ComputingPower(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'info',
|
||||
'desc': '获取算力信息',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=info',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['info', _common.ComputingPower(), '算力信息']
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getCrystalUi',
|
||||
'desc': '获取晶体ui信息',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=getCrystalUi',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['data', _common.CrystalUI(), '晶体的获取方式信息']
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'exchangeCrystal',
|
||||
'desc': '兑换晶体',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=exchangeCrystal',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['item_id', 0, '晶体item'],
|
||||
# ['item_num', 0, '晶体数量'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getExchangeCrystalRecord',
|
||||
'desc': '获取兑换晶体记录',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=getExchangeCrystalRecord',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['data', _common.ExchangeCrystalRecord(), '算力信息']
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'exchangePower',
|
||||
'desc': '晶体兑换算力',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=exchangePower',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['num1', 0, '晶体260001兑换数'],
|
||||
['num2', 0, '晶体260002兑换数'],
|
||||
['num3', 0, '晶体260003兑换数'],
|
||||
['num4', 0, '晶体260004兑换数'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'exchangeUplimit',
|
||||
'desc': '每周晶体兑换上限',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=exchangeUplimit',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['data', _common.ExchangeCrystalNum(), '本周期晶体兑换信息']
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getRewardHistory',
|
||||
'desc': '获取奖励历史',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=getRewardHistory',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['star_time', 0, '开始时间,都没传查全部'],
|
||||
['end_time', 0, '结束时间,都没传查全部'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [_common.CECRewardHistory()], '算力信息'],
|
||||
['pending_rewards', '', '剩余总计'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'exchangeCrystalInfo',
|
||||
'desc': '晶体兑换信息',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=exchangeCrystalInfo',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['totalNum', 0, '可领取的总晶体'],
|
||||
['!playing', [Info()], '游戏行为'],
|
||||
['!staking', [Info()], '质押行为'],
|
||||
['!consuming', [Info()], '支出行为'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'claimCrystal',
|
||||
'desc': '一键领取晶体',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=claimCrystal',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'exchangePowerNew',
|
||||
'desc': '晶体兑换算力',
|
||||
'group': 'ComputingPower',
|
||||
'url': 'webapp/index.php?c=ComputingPower&a=exchangePowerNew',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['num', 0, '晶体兑换数'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class Info(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['task_id', 0, 'task_id'],
|
||||
['uplimit', '', '上限数量 -1为无上限'],
|
||||
['chaim_num', 0, '可领取数量'],
|
||||
]
|
@ -1578,85 +1578,8 @@ CREATE TABLE `t_market_transaction_record` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10002 DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `t_crystal_exchange_record`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_crystal_exchange_record`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_crystal_exchange_record` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`address` varchar(60) COMMENT 'address',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
|
||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '道具数量',
|
||||
`createtime` int(11) NOT NULL COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_power_exchange_record`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_power_exchange_record`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_power_exchange_record` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`address` varchar(60) COMMENT 'address',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
|
||||
`item_num1` int(11) NOT NULL DEFAULT '0' COMMENT '晶体道具260001兑换算力数量',
|
||||
`item_num2` int(11) NOT NULL DEFAULT '0' COMMENT '晶体道具260002兑换算力数量',
|
||||
`item_num3` int(11) NOT NULL DEFAULT '0' COMMENT '晶体道具260003兑换算力数量',
|
||||
`item_num4` int(11) NOT NULL DEFAULT '0' COMMENT '晶体道具260004兑换算力数量',
|
||||
`total_num` double NOT NULL DEFAULT '0' COMMENT '算力总量',
|
||||
`createtime` int(11) NOT NULL COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_computing_power_period`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_hash_rate_reward`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_hash_rate_reward` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`address` varchar(60) COMMENT 'address',
|
||||
`period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
|
||||
`power` varchar(60) COMMENT '算力',
|
||||
`reward_cec` varchar(60) COMMENT 'reward cec',
|
||||
`reward1` int(11) NOT NULL DEFAULT '0' COMMENT '第1周奖励',
|
||||
`reward2` int(11) NOT NULL DEFAULT '0' COMMENT '第2周奖励',
|
||||
`reward3` int(11) NOT NULL DEFAULT '0' COMMENT '第3周奖励',
|
||||
`reward4` int(11) NOT NULL DEFAULT '0' COMMENT '第4周奖励',
|
||||
`txHash1` varchar(60) NOT NULL DEFAULT '' COMMENT '地址1',
|
||||
`txHash2` varchar(60) NOT NULL DEFAULT '' COMMENT '地址2',
|
||||
`txHash3` varchar(60) NOT NULL DEFAULT '' COMMENT '地址3',
|
||||
`txHash4` varchar(60) NOT NULL DEFAULT '' COMMENT '地址4',
|
||||
|
||||
`createtime` int(11) NOT NULL COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `t_computing_power_period`
|
||||
-- Table structure for table `t_ranking_settlement_record`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_ranking_settlement_record`;
|
||||
@ -1679,7 +1602,7 @@ CREATE TABLE `t_ranking_settlement_record` (
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `t_computing_power_period`
|
||||
-- Table structure for table `t_staking`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_staking`;
|
||||
|
@ -8,8 +8,7 @@ require_once('mt/LootConfig.php');
|
||||
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Nft.php');
|
||||
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
@ -20,8 +19,6 @@ require_once('services/LootService.php');
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
use services\LogService;
|
||||
|
||||
class BagController extends BaseAuthedController {
|
||||
|
@ -16,7 +16,6 @@ require_once('models/Parachute.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Pass.php');
|
||||
require_once('models/Avatar.php');
|
||||
require_once('models/HashRate.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/LevelUp.php');
|
||||
@ -40,7 +39,6 @@ use models\UserSeasonRing;
|
||||
use models\Chip;
|
||||
use models\Pass;
|
||||
use models\Avatar;
|
||||
use models\HashRateTask;
|
||||
use services\LogService;
|
||||
|
||||
class BaseAuthedController extends BaseController {
|
||||
@ -119,7 +117,6 @@ class BaseAuthedController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
$this->_userLvRestriction();
|
||||
}
|
||||
|
||||
/*if (SERVER_ENV == _ONLINE) {
|
||||
@ -132,32 +129,7 @@ class BaseAuthedController extends BaseController {
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function _userLvRestriction(){
|
||||
$userDb = $this->_getOrmUserInfo();
|
||||
$controller = getReqVal('c', '');
|
||||
switch ($controller){
|
||||
case "Chip" : {
|
||||
if (getReqVal('a', '') != 'chipList' && $userDb['star_num'] < \mt\StarLevel::STAR_NUM_CHIP_LIMIT){
|
||||
$this->_rspErr(1,'Not agreed terms. star number of need ' .\mt\StarLevel::STAR_NUM_CHIP_LIMIT);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Emoji" : {
|
||||
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_EMOJI_LIMIT){
|
||||
$this->_rspErr(1,'Not agreed terms star number of need ' .\mt\StarLevel::STAR_NUM_EMOJI_LIMIT);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Fragment" : {
|
||||
if (getReqVal('a', '') == 'syntheticFragment' && $userDb['star_num'] < \mt\StarLevel::STAR_NUM_PIECE_LIMIT){
|
||||
$this->_rspErr(1,'Not agreed terms star number of need ' .\mt\StarLevel::STAR_NUM_PIECE_LIMIT);
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function updateSession($accountId, $sessionId)
|
||||
{
|
||||
|
@ -3,23 +3,18 @@ require_once('phpcommon/tglog.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/DynData.php');
|
||||
require_once('models/BattleSettlement.php');
|
||||
require_once('models/BattleHistory.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Parachute.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('models/Battle.php');
|
||||
require_once('models/HashRate.php');
|
||||
require_once('services/BattleDataService.php');
|
||||
require_once('services/TameBattleDataService.php');
|
||||
require_once('services/RoomBattleDataService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/ServerTask.php');
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
require_once('mt/Robot.php');
|
||||
require_once('mt/Skill.php');
|
||||
require_once('mt/MapMode.php');
|
||||
@ -30,7 +25,6 @@ use models\HeroSkin;
|
||||
use models\Gun;
|
||||
use models\Bag;
|
||||
use models\DynData;
|
||||
use models\BattleHistory;
|
||||
use models\BattleSettlement;
|
||||
use models\User;
|
||||
use models\Parachute;
|
||||
|
@ -5,7 +5,6 @@ require_once('mt/Item.php');
|
||||
require_once('mt/Drop.php');
|
||||
require_once('mt/Hero.php');
|
||||
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Nft.php');
|
||||
@ -13,17 +12,14 @@ require_once('models/Chip.php');
|
||||
require_once('models/Transaction.php');
|
||||
require_once('models/BuyRecord.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/TransactionPrefee.php');
|
||||
require_once('models/BcOrder.php');
|
||||
require_once('models/Mall.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/NameService.php');
|
||||
require_once('services/BlockChainService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
@ -32,7 +28,6 @@ use models\BuyRecord;
|
||||
use models\Chip;
|
||||
use models\BcOrder;
|
||||
use models\Mall;
|
||||
use models\TransactionPrefee;
|
||||
|
||||
use services\BlockChainService;
|
||||
|
||||
|
@ -1,31 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Drop.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Nft.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/LogService.php');
|
||||
require_once('services/LootService.php');
|
||||
require_once('services/HashRateService.php');
|
||||
require_once('services/TameBattleDataService.php');
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
use services\LogService;
|
||||
|
||||
class BoxController extends BaseAuthedController {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once('mt/StarLevel.php');
|
||||
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/ChipPage.php');
|
||||
require_once('models/Hero.php');
|
||||
|
@ -1,29 +1,4 @@
|
||||
<?php
|
||||
require_once('mt/HashRate.php');
|
||||
require_once('mt/HashRateCommon.php');
|
||||
require_once('mt/HashRate.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('services/HashRateService.php');
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/NumberService.php');
|
||||
|
||||
require_once('models/ComputingPower.php');
|
||||
require_once('models/CrystalRecord.php');
|
||||
require_once('models/RewardsCec.php');
|
||||
require_once('models/Staking.php');
|
||||
require_once('models/HashRate.php');
|
||||
require_once('models/Bag.php');
|
||||
|
||||
use models\ComputingPower;
|
||||
use models\CrystalRecord;
|
||||
use models\RewardsCec;
|
||||
use models\Staking;
|
||||
use models\HashRateTask;
|
||||
use models\Bag;
|
||||
use mt\HashRate;
|
||||
use mt\Parameter;
|
||||
use phpcommon\SqlHelper;
|
||||
class ComputingPowerController extends BaseAuthedController
|
||||
{
|
||||
@ -33,488 +8,4 @@ class ComputingPowerController extends BaseAuthedController
|
||||
die;
|
||||
}
|
||||
|
||||
public function info(){
|
||||
$period_state = -1 ; //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期
|
||||
$curr_period = array(
|
||||
"period_begin" => 0,
|
||||
"period_end" => 0,
|
||||
"await_time" => 0,
|
||||
"assignable_cec" => 0,
|
||||
"cec_pool" => 0,
|
||||
"total_exchange_hash_rate" => 0,
|
||||
"total_hash_rate" => 0,
|
||||
|
||||
);
|
||||
$reward = array(
|
||||
"cec" => 0,
|
||||
"point" => 0,
|
||||
);
|
||||
$last_period = array(
|
||||
"period_begin" => 0,
|
||||
"period_end" => 0,
|
||||
"reward" => 0,
|
||||
);
|
||||
|
||||
$lastMeta = \mt\HashRateCommon::getLastPeriod();
|
||||
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
||||
$nextMeta = \mt\HashRateCommon::getNextPeriod();
|
||||
if (!$currentMeta && $lastMeta){
|
||||
$ownerNum = ComputingPower::getOwnedBH($lastMeta['id']);
|
||||
$totalNum = ComputingPower::getTotalBH($lastMeta['id']);
|
||||
$target = \services\NumberService::ceilEx(min($totalNum / $lastMeta['cec_pool'] , 1),6);
|
||||
if ($totalNum == 0) {
|
||||
$ratio = 0;
|
||||
}else{
|
||||
$ratio = $ownerNum/$totalNum;
|
||||
}
|
||||
$reward['cec'] = \services\NumberService::ceilEx($currentMeta['cec_pool'] * $target * $ratio,2);
|
||||
if ($nextMeta){
|
||||
$period_state = 1;
|
||||
$curr_period['period_begin'] = strtotime($nextMeta['start_time']);
|
||||
$curr_period['period_end'] = strtotime($nextMeta['end_time']);
|
||||
$curr_period['await_time'] = strtotime($nextMeta['start_time']) - myself()->_getNowTime();
|
||||
}else{
|
||||
$period_state = 2;
|
||||
}
|
||||
}
|
||||
if ($currentMeta){
|
||||
$period_state = 0;
|
||||
$ownerNum = ComputingPower::getOwnedBH($currentMeta['id']);
|
||||
$totalNum = ComputingPower::getTotalBH($currentMeta['id']);
|
||||
$curr_period['period_begin'] = strtotime($currentMeta['start_time']);
|
||||
$curr_period['period_end'] = strtotime($currentMeta['end_time']);
|
||||
$curr_period['assignable_cec'] = min($currentMeta['cec_pool'],$totalNum);
|
||||
$curr_period['cec_pool'] = $currentMeta['cec_pool'];
|
||||
$curr_period['total_exchange_hash_rate'] = $ownerNum;
|
||||
$curr_period['total_hash_rate'] = $totalNum;
|
||||
$curr_period['await_time'] = strtotime($currentMeta['end_time']) - myself()->_getNowTime();
|
||||
|
||||
$target = \services\NumberService::ceilEx(min($totalNum / $currentMeta['cec_pool'] , 1),6);
|
||||
if ($totalNum == 0) {
|
||||
$ratio = 0;
|
||||
}else{
|
||||
$ratio = $ownerNum/$totalNum;
|
||||
}
|
||||
$reward['cec'] = \services\NumberService::ceilEx($currentMeta['cec_pool'] * $target * $ratio,2);
|
||||
$reward['point'] = $ownerNum;
|
||||
}
|
||||
|
||||
if ($lastMeta){
|
||||
$last_period['period_begin'] = strtotime($lastMeta['start_time']);
|
||||
$last_period['period_end'] = strtotime($lastMeta['end_time']);
|
||||
$cecDb = RewardsCec::findByAccount(myself()->_getAccountId(),$lastMeta['id']);
|
||||
$last_period['reward'] = $cecDb ? $cecDb['reward_cec'] : 0;
|
||||
$last_period['last_hash_rate'] = ComputingPower::getOwnedBH($lastMeta['id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$crystalDb = Bag::find(ComputingPower::CRYSTAL_NEW);
|
||||
$info = array(
|
||||
'period_state' => $period_state,
|
||||
'curr_period' => $curr_period,
|
||||
'curr_reward' => $reward,
|
||||
'last_period' => $last_period,
|
||||
'listing_state' => LISTING_SWITCH,
|
||||
'owned_cec' => RewardsCec::getTotalCecNum(),
|
||||
'owned_total_hash_rate' =>ComputingPower::getMyTotalBH(),
|
||||
'owned_total_crystal' =>$crystalDb ? $crystalDb['item_num'] : 0,
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'info' => $info
|
||||
));
|
||||
}
|
||||
|
||||
//弃用
|
||||
public function getCrystalUi(){
|
||||
$crystalList = array();
|
||||
$itemMetas = \mt\Item::getMetaListByType(\mt\Item::CRYSTAL_TYPE);
|
||||
$hashRateService = new \services\HashRateService();
|
||||
foreach ($itemMetas as $meta){
|
||||
$crystalDto = array();
|
||||
$hashRateService->getCrystalDto($meta,$crystalDto);
|
||||
array_push($crystalList,$crystalDto);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data' => $crystalList
|
||||
));
|
||||
}
|
||||
|
||||
//弃用
|
||||
public function exchangeCrystal(){
|
||||
$itemId = getReqVal('item_id', 0);
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta || $itemMeta['type'] != \mt\Item::CRYSTAL_TYPE ){
|
||||
$this->_rspErr(1, 'param error');
|
||||
return ;
|
||||
}
|
||||
$hashRateMeta = HashRate::findHash($itemId);
|
||||
if (!$hashRateMeta){
|
||||
$this->_rspErr(1, 'param error');
|
||||
return ;
|
||||
}
|
||||
$param = explode('|',$hashRateMeta['parameter']);
|
||||
$paramEd = explode(':',$param[0]);
|
||||
$paramEx = explode(':',$param[1]);
|
||||
$crystalNum = 0;
|
||||
switch ($itemId){
|
||||
case ComputingPower::CRYSTAL1 : {
|
||||
$killsNum = myself()->_getV(TN_TOTAL_KILLS_NUM,0);
|
||||
$killsNumEd = myself()->_getV(TN_TOTAL_KILLS_NUM,-1);
|
||||
$killsNumEx = $killsNum - $killsNumEd;
|
||||
$starNum = myself()->_getV(TN_TOTAL_STAR_NUM,0);
|
||||
$starNumEd = myself()->_getV(TN_TOTAL_STAR_NUM,-1);
|
||||
$starNumEx = $starNum - $starNumEd ;
|
||||
$crystalNum = max(0,floor($killsNumEx / $paramEd[0]) * $paramEd[1] +
|
||||
floor($starNumEx / $paramEx[0]) * $paramEx[1] );
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL2 : {
|
||||
$consumeCost = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,0);
|
||||
$consumeCostEd = myself()->_getV(TN_TOTAL_DIAMOND_CONSUME,-1);
|
||||
$consumeCostEx = $consumeCost - $consumeCostEd ;
|
||||
$crystalNum = max(0,floor($consumeCostEx / \services\HashRateService::EXCHANGE_RATE / $paramEd[0]) * $paramEd[1]);
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL3 : {
|
||||
$consumeCost = myself()->_getV(TN_TOTAL_CEG_CONSUME,0);
|
||||
$consumeCostEd = myself()->_getV(TN_TOTAL_CEG_CONSUME,-1);
|
||||
$consumeCostEx = $consumeCost - $consumeCostEd;
|
||||
$crystalNum = max(0,floor($consumeCostEx / \services\HashRateService::EXCHANGE_RATE / $paramEd[0]) * $paramEd[1]);
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL4 : {
|
||||
$recordDb = CrystalRecord::getNewestRecordOne($itemId);
|
||||
error_log('exchangeCrystal:'.json_encode($recordDb));
|
||||
if ($recordDb && myself()->_getNowDaySeconds() == myself()->_getDaySeconds($recordDb['createtime'])){
|
||||
$this->_rspErr(1, 'There are no available crystals');
|
||||
return ;
|
||||
}
|
||||
// $rate = Parameter::getVal('cec_exchange_rate',10);
|
||||
$cecVal = Staking::getStakingTotalValue();
|
||||
$crystalNum = max(0,floor($cecVal / $paramEd[0]) * $paramEd[1]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($crystalNum < 1){
|
||||
$this->_rspErr(1, 'There are no available crystals');
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $crystalNum,
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_addItems($items,$awardService,$propertyChgService);
|
||||
CrystalRecord::addCrystalRecord($itemId,$crystalNum);
|
||||
switch ($itemId) {
|
||||
case ComputingPower::CRYSTAL1 : {
|
||||
|
||||
$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);
|
||||
//floor($killsNumEx / $paramEd[0]) * $paramEd[1] 222 100:3 222/100=2 2*3=6 6/3=2 2*100
|
||||
$newKillsNum = floor(($killsNum-$killsNumEd)/$paramEd[0]) * $paramEd[0];
|
||||
myself()->_incV(TN_TOTAL_KILLS_NUM,-1,$newKillsNum);
|
||||
$newStarNum = floor(($starNum-$starNumEd)/$paramEx[0]) * $paramEx[0];
|
||||
myself()->_incV(TN_TOTAL_STAR_NUM,-1,$newStarNum);
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL2 : {
|
||||
myself()->_incV(TN_TOTAL_DIAMOND_CONSUME,-1,$crystalNum / $paramEd[1] * $paramEd[0] * \services\HashRateService::EXCHANGE_RATE);
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL3 : {
|
||||
myself()->_incV(TN_TOTAL_CEG_CONSUME,-1,$crystalNum / $paramEd[1] * $paramEd[0] * \services\HashRateService::EXCHANGE_RATE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function getExchangeCrystalRecord(){
|
||||
$crystalRecordList = array();
|
||||
CrystalRecord::getCrystalRecordList(function ($row) use (&$crystalRecordList) {
|
||||
array_push($crystalRecordList,array(
|
||||
'item_id' => $row['item_id'],
|
||||
'item_num' => $row['item_num'],
|
||||
'createtime' => $row['createtime'],
|
||||
));
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'data' => $crystalRecordList,
|
||||
));
|
||||
}
|
||||
|
||||
public function exchangeUplimit(){
|
||||
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
||||
if (!$currentMeta){
|
||||
$this->_rspErr(1, 'kindly await');
|
||||
return ;
|
||||
}
|
||||
$list = ComputingPower::findByPeriod($currentMeta['id']);
|
||||
$this->_rspData(array(
|
||||
'data' => $list,
|
||||
));
|
||||
}
|
||||
|
||||
//弃用
|
||||
public function exchangePower(){
|
||||
$num1 = getReqVal('num1', 0);
|
||||
$num2 = getReqVal('num2', 0);
|
||||
$num3 = getReqVal('num3', 0);
|
||||
$num4 = getReqVal('num4', 0);
|
||||
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
||||
if (!$currentMeta){
|
||||
$this->_rspErr(1, 'kindly await');
|
||||
return ;
|
||||
}
|
||||
if (!$num1 && !$num2 && !$num3 && !$num4 ){
|
||||
$this->_rspErr(1, 'exchange none');
|
||||
return ;
|
||||
}
|
||||
$BH = 0 ;
|
||||
$costItems = array();
|
||||
if ($num1 > 0){
|
||||
$meta = \mt\HashRate::findHash(ComputingPower::CRYSTAL1);
|
||||
$this->_verificationCeiling($currentMeta['id'],$meta,$num1,$num2,$num3,$num4);
|
||||
$BH += $num1 * $meta['amount_bh'];
|
||||
array_push($costItems,array(
|
||||
'item_id' => ComputingPower::CRYSTAL1,
|
||||
'item_num' => $num1
|
||||
));
|
||||
}
|
||||
if ($num2 > 0){
|
||||
$meta = \mt\HashRate::findHash(ComputingPower::CRYSTAL2);
|
||||
$this->_verificationCeiling($currentMeta['id'],$meta,$num1,$num2,$num3,$num4);
|
||||
$BH += $num2 * $meta['amount_bh'];
|
||||
array_push($costItems,array(
|
||||
'item_id' => ComputingPower::CRYSTAL2,
|
||||
'item_num' => $num2
|
||||
));
|
||||
}
|
||||
if ($num3 > 0){
|
||||
$meta = \mt\HashRate::findHash(ComputingPower::CRYSTAL3);
|
||||
$this->_verificationCeiling($currentMeta['id'],$meta,$num1,$num2,$num3,$num4);
|
||||
$BH += $num3 * $meta['amount_bh'];
|
||||
array_push($costItems,array(
|
||||
'item_id' => ComputingPower::CRYSTAL3,
|
||||
'item_num' => $num3
|
||||
));
|
||||
}
|
||||
if ($num4 > 0){
|
||||
$meta = \mt\HashRate::findHash(ComputingPower::CRYSTAL4);
|
||||
$this->_verificationCeiling($currentMeta['id'],$meta,$num1,$num2,$num3,$num4);
|
||||
$BH += $num4 * $meta['amount_bh'];
|
||||
array_push($costItems,array(
|
||||
'item_id' => ComputingPower::CRYSTAL4,
|
||||
'item_num' => $num4
|
||||
));
|
||||
}
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
ComputingPower::addPowerRecord(
|
||||
array(
|
||||
'period' => $currentMeta['id'],
|
||||
'item_num1' => $num1,
|
||||
'item_num2' => $num2,
|
||||
'item_num3' => $num3,
|
||||
'item_num4' => $num4,
|
||||
'total_num' => $BH,
|
||||
)
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function getRewardHistory(){
|
||||
$starTime = getReqVal('star_time', 0);
|
||||
$endTime = getReqVal('end_time', 0);
|
||||
$historyDb = RewardsCec::getHistoryByTime($starTime,$endTime);
|
||||
$historyList = array();
|
||||
$pendingNum = 0;
|
||||
foreach ($historyDb as $row){
|
||||
$historyDto = RewardsCec::toDto($row);
|
||||
$pendingNum += $historyDto['pending_num'];
|
||||
array_push($historyList,$historyDto);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'data' => $historyList,
|
||||
'pending_rewards' => strval($pendingNum),
|
||||
));
|
||||
}
|
||||
|
||||
public function exchangeCrystalInfo(){
|
||||
$hashRateService = new \services\HashRateService();
|
||||
$crystalInfo = $hashRateService->getCrystalValue();
|
||||
$this->_rspData(array(
|
||||
'crystalInfo' => $crystalInfo
|
||||
));
|
||||
}
|
||||
|
||||
public function claimCrystal(){
|
||||
$hashRateService = new \services\HashRateService();
|
||||
$crystalInfo = $hashRateService->getCrystalValue();
|
||||
if ($crystalInfo['totalNum'] < 1){
|
||||
$this->_rspErr(1, 'No crystals available at this time');
|
||||
return ;
|
||||
}
|
||||
foreach ($crystalInfo['playing'] as $val){
|
||||
if ($val['chaim_num'] < 1){
|
||||
continue;
|
||||
}
|
||||
$hashRateMt = \mt\HashRateTask::find($val['task_id']);
|
||||
switch ($val['task_id']){
|
||||
case HashRateTask::RANK_TYPE :{
|
||||
$chaimUpTotal = $val['chaim_num'] / $hashRateMt['reward'];
|
||||
HashRateTask::updateKv($val['task_id'],array(
|
||||
'claim_total' => function () use($chaimUpTotal) {
|
||||
return "claim_total + ${chaimUpTotal}";
|
||||
},
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
));
|
||||
}
|
||||
break;
|
||||
default : {
|
||||
|
||||
if ($val['task_id'] == HashRateTask::BATTLE_TIME_TYPE){
|
||||
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'] * 1000;
|
||||
}else{
|
||||
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'];
|
||||
}
|
||||
HashRateTask::incDailyReward($val['task_id'],$val['chaim_num'],$chaimTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($crystalInfo['staking'] as $val){
|
||||
if ($val['chaim_num'] > 0){
|
||||
HashRateTask::updateKv($val['task_id'],array(
|
||||
'claim_day' => 1,
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($crystalInfo['consuming'] as $val){
|
||||
if ($val['chaim_num'] > 0){
|
||||
$hashRateMt = \mt\HashRateTask::find($val['task_id']);
|
||||
$chaimTotal = $val['chaim_num'] / $hashRateMt['reward'] * $hashRateMt['target'] * \services\HashRateService::EXCHANGE_RATE;
|
||||
myself()->_incV(TN_TOTAL_DIAMOND_CONSUME,-1,$chaimTotal);
|
||||
}
|
||||
}
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => ComputingPower::CRYSTAL_NEW,
|
||||
'item_num' => $crystalInfo['totalNum'],
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_addItems($items,$awardService,$propertyChgService);
|
||||
CrystalRecord::addCrystalRecord(ComputingPower::CRYSTAL_NEW,$crystalInfo['totalNum']);
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function exchangePowerNew(){
|
||||
$num = getReqVal('num', 0);
|
||||
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
||||
if (!$currentMeta){
|
||||
$this->_rspErr(1, 'kindly await');
|
||||
return ;
|
||||
}
|
||||
if (!$num){
|
||||
$this->_rspErr(1, 'exchange none');
|
||||
return ;
|
||||
}
|
||||
//校验是否兑换上限
|
||||
{
|
||||
|
||||
}
|
||||
$BH = $num;
|
||||
$costItems = array();
|
||||
array_push($costItems,array(
|
||||
'item_id' => ComputingPower::CRYSTAL_NEW,
|
||||
'item_num' => $num
|
||||
));
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
ComputingPower::addPowerRecord(
|
||||
array(
|
||||
'period' => $currentMeta['id'],
|
||||
'item_num1' =>$num,
|
||||
'item_num2' => 0,
|
||||
'item_num3' => 0,
|
||||
'item_num4' => 0,
|
||||
'total_num' => $BH,
|
||||
)
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
private function _verificationCeiling($period,$meta,$num1,$num2,$num3,$num4){
|
||||
$list = ComputingPower::findByPeriod($period);
|
||||
switch ($meta['item_id']){
|
||||
case ComputingPower::CRYSTAL1 : {
|
||||
if ($list['num1'] + $num1 > $meta['week_max']){
|
||||
$this->_rspErr(1, 'Micro crystal exchange ceiling');
|
||||
die ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL2 : {
|
||||
if ($list['num2'] + $num2 > $meta['week_max']){
|
||||
$this->_rspErr(1, 'Standard crystal exchange ceiling');
|
||||
die ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL3 : {
|
||||
if ($list['num3'] + $num3 > $meta['week_max']){
|
||||
$this->_rspErr(1, 'Large crystal exchange ceiling');
|
||||
die ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ComputingPower::CRYSTAL4 : {
|
||||
if ($list['num4'] + $num4 > $meta['week_max']){
|
||||
$this->_rspErr(1, 'Giant crystal exchange ceiling');
|
||||
die ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -11,15 +11,13 @@ require_once('mt/HashRateCommon.php');
|
||||
require_once('models/RealtimeData.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/RankingSetRecord.php');
|
||||
require_once('models/ComputingPower.php');
|
||||
require_once('models/RewardsCec.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
use models\RealtimeData;
|
||||
use models\Season;
|
||||
use models\RankingSetRecord;
|
||||
use models\ComputingPower;
|
||||
use models\RewardsCec;
|
||||
|
||||
|
||||
class DailyRequestController extends BaseAuthedController {
|
||||
private $awardService = null;
|
||||
@ -31,51 +29,6 @@ class DailyRequestController extends BaseAuthedController {
|
||||
$this->awardService = new services\AwardService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 星星之路的赛季结算
|
||||
*/
|
||||
public function missionStarSeasonSettlement(){
|
||||
$season = RealtimeData::getMissionSeason();
|
||||
$currMissionSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
||||
if ($currMissionSeasonMeta && $currMissionSeasonMeta['id'] > $season){
|
||||
$max_star_num = mt\Parameter::getVal('starroad_restart_point',400);
|
||||
$rows = myself()->_getMysql('')->execQuery(
|
||||
'SELECT account_id,star_num FROM t_user WHERE star_num>:star_num',
|
||||
array(
|
||||
"star_num"=>$max_star_num
|
||||
)
|
||||
);
|
||||
if (count($rows) > 0){
|
||||
foreach ($rows as $row){
|
||||
$crystalNum = round($row['star_num']/1000);
|
||||
myself()->switchAccount($row['account_id']);
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => ComputingPower::CRYSTAL1,
|
||||
'item_num' => $crystalNum,
|
||||
)
|
||||
);
|
||||
myself()->_addItems($items, null, $this->propertyChgService);
|
||||
myself()->_updateUserInfo(array(
|
||||
'star_num' => $max_star_num,
|
||||
));
|
||||
// myself()->_getMysql('')->execQuery(
|
||||
// 'UPDATE t_user SET star_num=:star_num WHERE account_id=:account_id',
|
||||
// array(
|
||||
// "star_num"=>$max_star_num,
|
||||
// "account_id"=>$row['account_id'],
|
||||
// )
|
||||
// );
|
||||
}
|
||||
}
|
||||
error_log("DailyRequestController : Mission Star Season ".$season." Settlement Success !" . " Request Time : ". date('Y-M-D h:i:s',time()));
|
||||
RealtimeData::setMissionSeason($currMissionSeasonMeta['id']);
|
||||
$this->_rspData(array('message'=>'星星之路结算成功'));
|
||||
return;
|
||||
}
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通行证的赛季结算
|
||||
*/
|
||||
@ -167,27 +120,5 @@ class DailyRequestController extends BaseAuthedController {
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* 算力周期cec计算
|
||||
*/
|
||||
public function computingPowerRewards(){
|
||||
$currentMeta = \mt\HashRateCommon::getLatestPeriod();
|
||||
if (\mt\HashRateCommon::checkAwaitTime()){
|
||||
$temp = ComputingPower::getAccountGroup($currentMeta['id']);
|
||||
if (! $temp){
|
||||
error_log("computingPowerRewards : No one involved");
|
||||
die;
|
||||
}
|
||||
foreach ($temp as $row){
|
||||
if ( ! RewardsCec::findByAccount($row['account_id'],$currentMeta['id'])){
|
||||
RewardsCec::celCecReward($row['account_id'],$currentMeta);
|
||||
error_log("computingPowerRewards : ACCOUNT_ID_{$row['account_id']} CEC Reward record completion");
|
||||
}
|
||||
}
|
||||
$this->_rspData(array('message'=>'算力结算成功'));
|
||||
return;
|
||||
}
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('models/Fragment.php');
|
||||
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Chip.php');
|
||||
@ -11,7 +11,6 @@ require_once('services/LogService.php');
|
||||
require_once('mt/Manufacture.php');
|
||||
|
||||
|
||||
use models\Fragment;
|
||||
use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Chip;
|
||||
|
@ -7,13 +7,12 @@ require_once('mt/AttrHelper.php');
|
||||
|
||||
require_once('models/GunSkin.php');
|
||||
require_once('models/GunTalent.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Bag.php');
|
||||
require_once('models/Chip.php');
|
||||
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/NftUpReceive.php');
|
||||
require_once('models/Transaction.php');
|
||||
|
||||
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
@ -23,13 +22,10 @@ require_once('services/LogService.php');
|
||||
use phpcommon\SqlHelper;
|
||||
use models\GunSkin;
|
||||
use models\GunTalent;
|
||||
use models\User;
|
||||
use models\Gun;
|
||||
use models\Bag;
|
||||
use models\Chip;
|
||||
use models\Nft;
|
||||
use models\NftUpReceive;
|
||||
use models\Transaction;
|
||||
|
||||
use services\LogService;
|
||||
|
||||
class GunController extends BaseAuthedController {
|
||||
|
@ -7,22 +7,15 @@ require_once('mt/QualityUpMapRule.php');
|
||||
require_once('mt/ChipAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
require_once('mt/Manufacture.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/HeroPreset.php');
|
||||
|
||||
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
|
||||
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
|
@ -1,11 +1,7 @@
|
||||
<?php
|
||||
require_once('mt/Skill.php');
|
||||
require_once('mt/Hero.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
|
||||
|
||||
use models\Hero;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class HeroSkillController extends BaseAuthedController
|
||||
|
@ -1,30 +1,16 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Fragment.php');
|
||||
require_once('models/BcOrder.php');
|
||||
|
||||
require_once('services/BlockChainService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
use models\BcOrder;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Nft;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Chip;
|
||||
use models\Fragment;
|
||||
use models\Transaction;
|
||||
use services\LogService;
|
||||
|
||||
|
||||
class MarketController extends BaseAuthedController {
|
||||
|
||||
|
@ -5,11 +5,8 @@ require_once('mt/Drop.php');
|
||||
require_once('mt/Task.php');
|
||||
require_once('mt/Season.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
|
||||
require_once('models/User.php');
|
||||
require_once('models/DynData.php');
|
||||
require_once('models/Mission.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
|
||||
@ -21,10 +18,8 @@ require_once('services/FormulaService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
use models\DynData;
|
||||
use models\Mission;
|
||||
use models\Season;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use services\LogService;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('services/MissionService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/HashRateCommon.php');
|
||||
require_once('mt/ActivityRewards.php');
|
||||
@ -8,9 +8,9 @@ require_once('mt/MapMode.php');
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
require_once('mt/AchievementsCycle.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');
|
||||
@ -24,9 +24,6 @@ require_once('models/Bag.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;
|
||||
|
@ -2,11 +2,6 @@
|
||||
|
||||
require_once('models/User.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/UserSeasonRing.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Battle.php');
|
||||
require_once('models/SignLog.php');
|
||||
require_once('models/UserHonor.php');
|
||||
@ -21,8 +16,6 @@ require_once('mt/RankSeason.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Rank.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/PveGeminiMode.php');
|
||||
require_once('mt/PveGemini.php');
|
||||
require_once('mt/Map.php');
|
||||
require_once('mt/MapMode.php');
|
||||
|
||||
@ -35,11 +28,6 @@ require_once('services/ChipPageService.php');
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Season;
|
||||
use models\Nft;
|
||||
use models\Chip;
|
||||
use models\UserSeasonRing;
|
||||
use models\Battle;
|
||||
use models\SignLog;
|
||||
use models\UserHonor;
|
||||
|
@ -1,138 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
require_once('services/NumberService.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
use services\NumberService;
|
||||
|
||||
class ComputingPower extends BaseModel
|
||||
{
|
||||
const CRYSTAL1 = 260001;
|
||||
const CRYSTAL2 = 260002;
|
||||
const CRYSTAL3 = 260003;
|
||||
const CRYSTAL4 = 260004;
|
||||
const CRYSTAL_NEW = 260010;
|
||||
|
||||
//获取我的算力
|
||||
public static function getOwnedBH($period,$account = null){
|
||||
if (!$account){
|
||||
$account = myself()->_getAccountId();
|
||||
}
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getMysql($account),
|
||||
't_power_exchange_record',
|
||||
array(
|
||||
'account_id'=>$account,
|
||||
'period' => $period
|
||||
)
|
||||
);
|
||||
$my_total_num = 0;
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$my_total_num += $row['total_num'];
|
||||
}
|
||||
}
|
||||
|
||||
return NumberService::ceilEx($my_total_num,6);
|
||||
}
|
||||
|
||||
//获取全服总算力
|
||||
public static function getTotalBH($period){
|
||||
$rows = SqlHelper::select(
|
||||
myself()->_getMysql(''),
|
||||
't_power_exchange_record',
|
||||
array(
|
||||
"period",
|
||||
"total_num"
|
||||
),
|
||||
array(
|
||||
'period' => $period
|
||||
)
|
||||
);
|
||||
$total_num = 0;
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$total_num += $row['total_num'];
|
||||
}
|
||||
}
|
||||
return $total_num;
|
||||
}
|
||||
|
||||
//获取我的总算力
|
||||
public static function getMyTotalBH(){
|
||||
$rows = SqlHelper::select(
|
||||
myself()->_getSelfMysql(),
|
||||
't_power_exchange_record',
|
||||
array(
|
||||
"period",
|
||||
"total_num"
|
||||
),
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
$total_num = 0;
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$total_num += $row['total_num'];
|
||||
}
|
||||
}
|
||||
return $total_num;
|
||||
}
|
||||
|
||||
public static function findByPeriod($period){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_power_exchange_record',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
'period' => $period
|
||||
)
|
||||
);
|
||||
$list = array(
|
||||
'num1' => 0,
|
||||
'num2' => 0,
|
||||
'num3' => 0,
|
||||
'num4' => 0,
|
||||
);
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$list['num1'] += $row['item_num1'];
|
||||
$list['num2'] += $row['item_num2'];
|
||||
$list['num3'] += $row['item_num3'];
|
||||
$list['num4'] += $row['item_num4'];
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function addPowerRecord($fieldKv){
|
||||
SqlHelper::insert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_power_exchange_record',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
'address'=>myself()->_getAddress(),
|
||||
'period'=>$fieldKv['period'],
|
||||
'item_num1'=>$fieldKv['item_num1'],
|
||||
'item_num2' => $fieldKv['item_num2'],
|
||||
'item_num3' => $fieldKv['item_num3'],
|
||||
'item_num4' => $fieldKv['item_num4'],
|
||||
'total_num' => $fieldKv['total_num'],
|
||||
'createtime'=>myself()->_getNowTime(),
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getAccountGroup($period){
|
||||
$sql = "select account_id,`period` from t_power_exchange_record where `period` = $period group by account_id";
|
||||
$rows = myself()->_getMysql('')->execQuery($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class CrystalRecord extends BaseModel
|
||||
{
|
||||
public static function getCrystalRecordList($cb){
|
||||
SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_crystal_exchange_record',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
'item_id'=>ComputingPower::CRYSTAL_NEW,
|
||||
),
|
||||
function ($row) use($cb) {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static function getCrystalNum($item_id){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_crystal_exchange_record',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
'item_id' => $item_id
|
||||
)
|
||||
);
|
||||
|
||||
$crystalNum = 0;
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$crystalNum += $row['item_num'];
|
||||
}
|
||||
}
|
||||
return $crystalNum;
|
||||
}
|
||||
|
||||
public static function addCrystalRecord($itemId,$itemNum){
|
||||
SqlHelper::insert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_crystal_exchange_record',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
'address'=>myself()->_getAddress(),
|
||||
'item_id'=>$itemId,
|
||||
'item_num' => $itemNum,
|
||||
'createtime'=>myself()->_getNowTime(),
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getNewestRecordOne($itemId){
|
||||
$sql = "select * from t_crystal_exchange_record where `account_id` = :account_id and item_id = :item_id order by idx desc limit 1";
|
||||
$rows = myself()->_getMysql('')->execQuery($sql,array(
|
||||
'account_id' =>myself()->_getAccountId(),
|
||||
'item_id' =>$itemId,
|
||||
));
|
||||
return count($rows) > 0 ? $rows[0] : array();
|
||||
}
|
||||
|
||||
}
|
@ -25,145 +25,4 @@ class RewardsCec extends BaseModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function getTotalCecNum(){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hash_rate_reward',
|
||||
array(
|
||||
'account_id'=>myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
$totalCecNum = 0;
|
||||
if ($rows){
|
||||
foreach ($rows as $row){
|
||||
$totalCecNum += $row['reward_cec'];
|
||||
}
|
||||
}
|
||||
return $totalCecNum;
|
||||
}
|
||||
|
||||
public static function getHistoryByTime($starTime,$endTime){
|
||||
if ($starTime || $endTime){
|
||||
$sql = "select * from t_hash_rate_reward where account_id=:account and createtime>:starTime and createtime<:endTime";
|
||||
$rows = myself()->_getSelfMysql()->execQuery(
|
||||
$sql,
|
||||
array(
|
||||
'account' => myself()->_getAccountId(),
|
||||
'starTime' => $starTime,
|
||||
'endTime' => $endTime,
|
||||
)
|
||||
);
|
||||
}else{
|
||||
$sql = "select * from t_hash_rate_reward where account_id=:account";
|
||||
$rows = myself()->_getSelfMysql()->execQuery(
|
||||
$sql,
|
||||
array(
|
||||
'account' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!$rows){
|
||||
$rows =array();
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function toDto($row){
|
||||
if (!$row){
|
||||
return;
|
||||
}
|
||||
$week1 = phpcommon\getMondaySeconds($row['createtime']);
|
||||
$week2 = $week1 + 60*60*24*7 ;
|
||||
$week3 = $week1 + 60*60*24*14 ;
|
||||
$week4 = $week1 + 60*60*24*21 ;
|
||||
$state = $row['reward1'] && $row['reward2'] && $row['reward3'] && $row['reward4'] ? 1 : 0;
|
||||
// $pendingNum = $row['reward_cec'];
|
||||
$pendingNum = 0;
|
||||
if (!$row['reward1']){
|
||||
// $pendingNum -= $pendingNum*0.25;
|
||||
$pendingNum += 1;
|
||||
}
|
||||
if (!$row['reward2']){
|
||||
// $pendingNum -= $pendingNum*0.5;
|
||||
$pendingNum += 1;
|
||||
}
|
||||
if (!$row['reward3']){
|
||||
// $pendingNum -= $pendingNum*0.75;
|
||||
$pendingNum += 1;
|
||||
}
|
||||
if (!$row['reward4']){
|
||||
// $pendingNum = 0;
|
||||
$pendingNum += 1;
|
||||
}
|
||||
return array(
|
||||
'hash_rate' => $row['power'],
|
||||
'cec_num' => $row['reward_cec'],
|
||||
'state' => $state,
|
||||
'week1' => $row['reward1'] ? $row['reward1'] : $week1,
|
||||
'week2' => $row['reward2'] ? $row['reward2'] : $week2,
|
||||
'week3' => $row['reward3'] ? $row['reward3'] : $week3,
|
||||
'week4' => $row['reward4'] ? $row['reward4'] : $week4,
|
||||
'txHash1' => $row['txHash1'] ? $row['txHash1'] : "",
|
||||
'txHash2' => $row['txHash2'] ? $row['txHash2'] : "",
|
||||
'txHash3' => $row['txHash3'] ? $row['txHash3'] : "",
|
||||
'txHash4' => $row['txHash4'] ? $row['txHash4'] : "",
|
||||
'create_time' => $row['createtime'],
|
||||
'pending_num' => strval($pendingNum),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static function findByAccount($account,$period){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($account),
|
||||
't_hash_rate_reward',
|
||||
array(
|
||||
'account_id'=>$account,
|
||||
'period' => $period
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
$row = null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function celCecReward($account,$hashMeta){
|
||||
$ownerNum = ComputingPower::getOwnedBH($hashMeta['id'],$account); //13.7
|
||||
$totalNum = ComputingPower::getTotalBH($hashMeta['id']); //25.9
|
||||
$target = NumberService::ceilEx(min($totalNum / $hashMeta['cec_pool'] , 1),6); // 25.9/10000
|
||||
if ($totalNum == 0) {
|
||||
$ratio = 0;
|
||||
}else{
|
||||
$ratio = $ownerNum/$totalNum;
|
||||
}
|
||||
$cecNum = NumberService::ceilEx($hashMeta['cec_pool'] * $target * $ratio,2); //10000*(25.9/10000)*(13.7/25.9)
|
||||
$address = User::findUserAddress($account);
|
||||
SqlHelper::upsert(
|
||||
myself()->_getMysql($account),
|
||||
't_hash_rate_reward',
|
||||
array(
|
||||
'account_id'=>$account,
|
||||
'period'=>$hashMeta['id'],
|
||||
),
|
||||
array(
|
||||
|
||||
),
|
||||
array(
|
||||
'account_id'=>$account,
|
||||
'address'=>$address,
|
||||
'period'=>$hashMeta['id'],
|
||||
'power'=>$ownerNum,
|
||||
'reward_cec' => $cecNum,
|
||||
// 'reward1' => 0,
|
||||
// 'reward2' => 0,
|
||||
// 'reward3' => 0,
|
||||
// 'reward4' => 0,
|
||||
'createtime'=>myself()->_getNowTime(),
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user