1
This commit is contained in:
commit
2190b3c3bd
86
doc/Team.py
86
doc/Team.py
@ -63,6 +63,18 @@ class Team(object):
|
|||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
|
},{
|
||||||
|
'name': 'breakup',
|
||||||
|
'desc': '解散队伍',
|
||||||
|
'group': 'Team',
|
||||||
|
'url': 'webapp/index.php?c=Team&a=breakup',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['team_uuid', '', '队伍唯一id'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'kickout',
|
'name': 'kickout',
|
||||||
@ -78,34 +90,6 @@ class Team(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'name': 'closeSlot',
|
|
||||||
'desc': '关闭槽位',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=closeSlot',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['slot_id', '', '队伍卡槽id 共计:1 2 3 4'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'openSlot',
|
|
||||||
'desc': '开启槽位',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=openSlot',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['slot_num', '', '队伍人数'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'name': 'handover',
|
'name': 'handover',
|
||||||
'desc': '转移队长职位',
|
'desc': '转移队长职位',
|
||||||
@ -159,61 +143,29 @@ class Team(object):
|
|||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'setHero',
|
'name': 'updateTeam',
|
||||||
'desc': '设置出战英雄',
|
'desc': '跟新队伍信息',
|
||||||
'group': 'Team',
|
'group': 'Team',
|
||||||
'url': 'webapp/index.php?c=Team&a=setHero',
|
'url': 'webapp/index.php?c=Team&a=updateTeam',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['team_uuid', '', '队伍唯一id'],
|
['team_uuid', '', '队伍唯一id'],
|
||||||
['hero_uid', 0, '英雄uniid'],
|
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
'name': 'setPreset',
|
'name': 'permission',
|
||||||
'desc': '设置备战',
|
'desc': '邀请许可',
|
||||||
'group': 'Team',
|
'group': 'Team',
|
||||||
'url': 'webapp/index.php?c=Team&a=setPreset',
|
'url': 'webapp/index.php?c=Team&a=permission',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['team_uuid', '', '队伍唯一id'],
|
['team_uuid', '', '队伍唯一id'],
|
||||||
['hero_uid', 0, '英雄uniid'],
|
['target_id', '', '目标account_id'],
|
||||||
['chip_page', 0, '铭文页id'],
|
|
||||||
['skill_id', 0, '技能item id'],
|
|
||||||
['weapon_uid1', 0, '枪1uniid'],
|
|
||||||
['weapon_uid2', 0, '枪2uniid'],
|
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},{
|
|
||||||
'name': 'setHeroSkin',
|
|
||||||
'desc': '设置英雄皮肤',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=setHeroSkin',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
['team_uuid', '', '队伍唯一id'],
|
|
||||||
['hero_uid', 0, '英雄uniid'],
|
|
||||||
['skin_id', 0, '皮肤item id'],
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
]
|
|
||||||
},{
|
|
||||||
'name': 'getPveFragmentNumOrDay',
|
|
||||||
'desc': '当天获取碎片的数量',
|
|
||||||
'group': 'Team',
|
|
||||||
'url': 'webapp/index.php?c=Team&a=getPveFragmentNumOrDay',
|
|
||||||
'params': [
|
|
||||||
_common.ReqHead(),
|
|
||||||
],
|
|
||||||
'response': [
|
|
||||||
_common.RspHead(),
|
|
||||||
['heroNum',0,'英雄碎片数量'],
|
|
||||||
['gunNum',0,'枪械碎片数量']
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -685,6 +685,7 @@ class TeamMember(object):
|
|||||||
['kills', 0, '击杀数'],
|
['kills', 0, '击杀数'],
|
||||||
['is_leader', 0, '是否队长'],
|
['is_leader', 0, '是否队长'],
|
||||||
['is_ready', 0, '是否准备'],
|
['is_ready', 0, '是否准备'],
|
||||||
|
['permission', 0, '邀请许可'],
|
||||||
['createtime', 0, '账号创建时间'],
|
['createtime', 0, '账号创建时间'],
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1334,21 +1335,19 @@ class ComputingPowerCurr(object):
|
|||||||
['period_end', '', '本期结束时间(0 不显示)'],
|
['period_end', '', '本期结束时间(0 不显示)'],
|
||||||
['await_time', '', '结算等待时间'],
|
['await_time', '', '结算等待时间'],
|
||||||
['assignable_cec', '', '可分配的总cec奖励'],
|
['assignable_cec', '', '可分配的总cec奖励'],
|
||||||
['total_target', '', '全服算力总目标'],
|
# ['total_target', '', '全服算力总目标'],
|
||||||
|
|
||||||
# ['refresh_remain_time', '', '刷新剩余时间'],
|
# ['refresh_remain_time', '', '刷新剩余时间'],
|
||||||
['total_hash_rate', '', '全服总兑换算力'],
|
['total_hash_rate', '', '全服总兑换算力'],
|
||||||
['total_exchange_hash_rate', '', "玩家已兑换算力"],
|
['total_exchange_hash_rate', '', "玩家已兑换算力"],
|
||||||
]
|
]
|
||||||
|
|
||||||
class ComputingPowerLast(object):
|
class ComputingPowerReward(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fields = [
|
self.fields = [
|
||||||
['period_begin', 0, '上期开始时间(0 不显示)'],
|
['cec', 0, 'cec奖励'],
|
||||||
['period_end', 0, '上期结束时间(0 不显示)'],
|
['point', 0, '科技值'],
|
||||||
['reward', 0, '上期的cec奖励'],
|
|
||||||
['last_hash_rate', 0, '上期的科技值'],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
class ComputingPower(object):
|
class ComputingPower(object):
|
||||||
@ -1357,7 +1356,7 @@ class ComputingPower(object):
|
|||||||
self.fields = [
|
self.fields = [
|
||||||
['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'],
|
['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'],
|
||||||
['curr_period', ComputingPowerCurr(), '本期相关信息'],
|
['curr_period', ComputingPowerCurr(), '本期相关信息'],
|
||||||
['last_period', ComputingPowerLast(), '上期相关信息'],
|
['curr_reward', ComputingPowerReward(), '本期奖励信息'],
|
||||||
['listing_state', 0, 'listing状态 0:之前 1:之后'],
|
['listing_state', 0, 'listing状态 0:之前 1:之后'],
|
||||||
['owned_cec', 0, '拥有的cec数量'],
|
['owned_cec', 0, '拥有的cec数量'],
|
||||||
['owned_total_hash_rate', 0, '用户总科技值'],
|
['owned_total_hash_rate', 0, '用户总科技值'],
|
||||||
|
@ -1624,3 +1624,30 @@ CREATE TABLE `t_ranking_settlement_record` (
|
|||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
KEY `account_id` (`account_id`)
|
KEY `account_id` (`account_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `t_staking` (
|
||||||
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
|
`address` varchar(60) NOT NULL DEFAULT '' COMMENT 'address',
|
||||||
|
`order_id` varchar(60) COMMENT 'order_id',
|
||||||
|
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||||
|
`item_id` int(11) NOT NULL COMMENT 'item_id',
|
||||||
|
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章',
|
||||||
|
`net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
|
||||||
|
`contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',
|
||||||
|
`stacked_num` varchar(60) NOT NULL DEFAULT '' COMMENT 'stacked_num',
|
||||||
|
`start_time` bigint NOT NULL DEFAULT '0' COMMENT '质押开始时间',
|
||||||
|
`stake_time` bigint NOT NULL DEFAULT '0' COMMENT '质押结束时间',
|
||||||
|
`redeem_time` bigint NOT NULL DEFAULT '0' COMMENT '赎回时间',
|
||||||
|
`status` int(11) NOT NULL COMMENT '0:质押中 1:已解押',
|
||||||
|
`txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash',
|
||||||
|
`nft_type` int(11) NOT NULL COMMENT '',
|
||||||
|
`nft_reward` double NOT NULL DEFAULT '0' COMMENT '利息',
|
||||||
|
`createtime` int(11) NOT NULL COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `unikey1` (`token_id`, `contract_address`, `net_id`, `start_time`),
|
||||||
|
UNIQUE KEY `unikey2` (`token_id`, `contract_address`, `net_id`, `order_id`),
|
||||||
|
KEY `address` (`address`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;
|
||||||
|
@ -6,6 +6,7 @@ require_once('mt/Parameter.php');
|
|||||||
require_once('services/HashRateService.php');
|
require_once('services/HashRateService.php');
|
||||||
require_once('services/AwardService.php');
|
require_once('services/AwardService.php');
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
|
require_once('services/NumberService.php');
|
||||||
|
|
||||||
require_once('models/ComputingPower.php');
|
require_once('models/ComputingPower.php');
|
||||||
require_once('models/CrystalRecord.php');
|
require_once('models/CrystalRecord.php');
|
||||||
@ -24,53 +25,64 @@ class ComputingPowerController extends BaseAuthedController
|
|||||||
public function info(){
|
public function info(){
|
||||||
$period_state = -1 ; //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期
|
$period_state = -1 ; //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期
|
||||||
$curr_period = array(
|
$curr_period = array(
|
||||||
// "current_state" => -1, //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期
|
|
||||||
"period_begin" => 0,
|
"period_begin" => 0,
|
||||||
"period_end" => 0,
|
"period_end" => 0,
|
||||||
"await_time" => 0,
|
"await_time" => 0,
|
||||||
"assignable_cec" => 0,
|
"assignable_cec" => 0,
|
||||||
"total_target" => 0,
|
|
||||||
"total_exchange_hash_rate" => 0,
|
"total_exchange_hash_rate" => 0,
|
||||||
"total_hash_rate" => 0,
|
"total_hash_rate" => 0,
|
||||||
// "refresh_remain_time" => 0,
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
$reward = array(
|
||||||
|
"cec" => 0,
|
||||||
|
"point" => 0,
|
||||||
|
);
|
||||||
$last_period = array(
|
$last_period = array(
|
||||||
"period_begin" => 0,
|
"period_begin" => 0,
|
||||||
"period_end" => 0,
|
"period_end" => 0,
|
||||||
"reward" => 0,
|
"reward" => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
$lastMeta = \mt\HashRateCommon::getLastPeriod();
|
$lastMeta = \mt\HashRateCommon::getLastPeriod();
|
||||||
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
$currentMeta = \mt\HashRateCommon::getCurrentPeriod();
|
||||||
$nextMeta = \mt\HashRateCommon::getNextPeriod();
|
$nextMeta = \mt\HashRateCommon::getNextPeriod();
|
||||||
if (!$currentMeta && $lastMeta){
|
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){
|
if ($nextMeta){
|
||||||
$period_state = 1;
|
$period_state = 1;
|
||||||
// $curr_period['current_state'] = 1;
|
|
||||||
$curr_period['period_begin'] = strtotime($nextMeta['start_time']);
|
$curr_period['period_begin'] = strtotime($nextMeta['start_time']);
|
||||||
$curr_period['period_end'] = strtotime($nextMeta['end_time']);
|
$curr_period['period_end'] = strtotime($nextMeta['end_time']);
|
||||||
$curr_period['await_time'] = strtotime($nextMeta['start_time']) - myself()->_getNowTime();
|
$curr_period['await_time'] = strtotime($nextMeta['start_time']) - myself()->_getNowTime();
|
||||||
}else{
|
}else{
|
||||||
// $curr_period['current_state'] = 2;
|
|
||||||
$period_state = 2;
|
$period_state = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($currentMeta){
|
if ($currentMeta){
|
||||||
|
|
||||||
$period_state = 0;
|
$period_state = 0;
|
||||||
// $curr_period['current_state'] = 0;
|
$ownerNum = ComputingPower::getOwnedBH($currentMeta['id']);
|
||||||
|
$totalNum = ComputingPower::getTotalBH($currentMeta['id']);
|
||||||
$curr_period['period_begin'] = strtotime($currentMeta['start_time']);
|
$curr_period['period_begin'] = strtotime($currentMeta['start_time']);
|
||||||
$curr_period['period_end'] = strtotime($currentMeta['end_time']);
|
$curr_period['period_end'] = strtotime($currentMeta['end_time']);
|
||||||
$curr_period['assignable_cec'] = $currentMeta['cec_pool'];
|
$curr_period['assignable_cec'] = $currentMeta['cec_pool'];
|
||||||
$curr_period['total_target'] = $currentMeta['target'];
|
$curr_period['total_exchange_hash_rate'] = $ownerNum;
|
||||||
|
$curr_period['total_hash_rate'] = $totalNum;
|
||||||
|
|
||||||
$curr_period['total_exchange_hash_rate'] = ComputingPower::getOwnedBH($currentMeta['id']);
|
|
||||||
// $rowDb = ComputingPower::getTotalBH($currentMeta['id']);
|
|
||||||
$curr_period['total_hash_rate'] = ComputingPower::getTotalBH($currentMeta['id']) + $currentMeta['hashrate_add'];
|
|
||||||
// $curr_period['refresh_remain_time'] = $rowDb ? $rowDb['modifytime'] + 3600 - myself()->_getNowTime() : 0;
|
|
||||||
|
|
||||||
|
$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){
|
if ($lastMeta){
|
||||||
@ -82,9 +94,12 @@ class ComputingPowerController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$info = array(
|
$info = array(
|
||||||
'period_state' => $period_state,
|
'period_state' => $period_state,
|
||||||
'curr_period' => $curr_period,
|
'curr_period' => $curr_period,
|
||||||
|
'curr_reward' => $reward,
|
||||||
'last_period' => $last_period,
|
'last_period' => $last_period,
|
||||||
'listing_state' => LISTING_SWITCH,
|
'listing_state' => LISTING_SWITCH,
|
||||||
'owned_cec' => RewardsCec::getTotalCecNum(),
|
'owned_cec' => RewardsCec::getTotalCecNum(),
|
||||||
|
@ -35,8 +35,8 @@ class TeamController extends BaseAuthedController {
|
|||||||
$pveInstanceId = getReqVal('pve_instance_id', 0);
|
$pveInstanceId = getReqVal('pve_instance_id', 0);
|
||||||
$zid = myself()->_getZid();
|
$zid = myself()->_getZid();
|
||||||
$teamUuid = $nodeId . '_' .
|
$teamUuid = $nodeId . '_' .
|
||||||
$zid . '_' .
|
$zid . '_' .
|
||||||
md5($this->_getAccountId() . $this->_getNowTime());
|
md5($this->_getAccountId() . $this->_getNowTime());
|
||||||
|
|
||||||
/*if (!in_array(array
|
/*if (!in_array(array
|
||||||
(
|
(
|
||||||
@ -70,7 +70,7 @@ class TeamController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
if ($matchMode == self::MATCH_MODE_RANK){
|
if ($matchMode == self::MATCH_MODE_RANK){
|
||||||
// if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
|
// if ($userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
|
||||||
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
|
if ($userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
|
||||||
$this->_rspErr(1,'Not agreed terms');
|
$this->_rspErr(1,'Not agreed terms');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -147,8 +147,8 @@ class TeamController extends BaseAuthedController {
|
|||||||
if ($teamDb['match_mode'] == self::MATCH_MODE_RANK &&
|
if ($teamDb['match_mode'] == self::MATCH_MODE_RANK &&
|
||||||
// $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
|
// $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){
|
||||||
$userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
|
$userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){
|
||||||
$this->_rspErr(1,'Not agreed terms');
|
$this->_rspErr(1,'Not agreed terms');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($teamDb['member_list'] as $member) {
|
foreach ($teamDb['member_list'] as $member) {
|
||||||
|
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace models;
|
namespace models;
|
||||||
|
require_once('services/NumberService.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
use services\NumberService;
|
||||||
|
|
||||||
class ComputingPower extends BaseModel
|
class ComputingPower extends BaseModel
|
||||||
{
|
{
|
||||||
const CRYSTAL1 = 260001;
|
const CRYSTAL1 = 260001;
|
||||||
@ -31,7 +34,8 @@ class ComputingPower extends BaseModel
|
|||||||
$my_total_num += $row['total_num'];
|
$my_total_num += $row['total_num'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $my_total_num;
|
|
||||||
|
return NumberService::ceilEx($my_total_num,6);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取全服总算力
|
//获取全服总算力
|
||||||
|
@ -7,6 +7,8 @@ namespace models;
|
|||||||
use mt;
|
use mt;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
|
use services\NumberService;
|
||||||
|
|
||||||
class RewardsCec extends BaseModel
|
class RewardsCec extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -128,10 +130,14 @@ class RewardsCec extends BaseModel
|
|||||||
|
|
||||||
public static function celCecReward($account,$hashMeta){
|
public static function celCecReward($account,$hashMeta){
|
||||||
$ownerNum = ComputingPower::getOwnedBH($hashMeta['id'],$account); //13.7
|
$ownerNum = ComputingPower::getOwnedBH($hashMeta['id'],$account); //13.7
|
||||||
$totalNum = ComputingPower::getTotalBH($hashMeta['id']) + $hashMeta['hashrate_add']; //25.9
|
$totalNum = ComputingPower::getTotalBH($hashMeta['id']); //25.9
|
||||||
$target = min($totalNum / $hashMeta['target'] , 1); // 25.9/10000
|
$target = NumberService::ceilEx(min($totalNum / $hashMeta['cec_pool'] , 1),6); // 25.9/10000
|
||||||
$ratio = $ownerNum/$totalNum; // 13.7/25.9
|
if ($totalNum == 0) {
|
||||||
$cecNum = $hashMeta['cec_pool'] * $target * $ratio; //10000*(25.9/10000)*(13.7/25.9)
|
$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);
|
$address = User::findUserAddress($account);
|
||||||
SqlHelper::upsert(
|
SqlHelper::upsert(
|
||||||
myself()->_getMysql($account),
|
myself()->_getMysql($account),
|
||||||
|
@ -41,7 +41,7 @@ class Staking extends BaseModel {
|
|||||||
public static function all($address)
|
public static function all($address)
|
||||||
{
|
{
|
||||||
if (SERVER_ENV != _ONLINE) {
|
if (SERVER_ENV != _ONLINE) {
|
||||||
myself()->_setTimeOffset(3600 * 24 * 360 * 2);
|
//myself()->_setTimeOffset(3600 * 24 * 360 * 2);
|
||||||
}
|
}
|
||||||
$result = array();
|
$result = array();
|
||||||
$rows = SqlHelper::ormSelect(
|
$rows = SqlHelper::ormSelect(
|
||||||
@ -87,6 +87,9 @@ class Staking extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (SERVER_ENV != _ONLINE) {
|
||||||
|
myself()->_setTimeOffset(0);
|
||||||
|
}
|
||||||
return $totalValue;
|
return $totalValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,9 +308,11 @@ class User extends BaseModel {
|
|||||||
'hero_uniId' => $row['hero_id'],
|
'hero_uniId' => $row['hero_id'],
|
||||||
'hero_id' => $heroId,
|
'hero_id' => $heroId,
|
||||||
'hero_skin' =>$skinDb['skin_id'],
|
'hero_skin' =>$skinDb['skin_id'],
|
||||||
|
'hero_lv' =>$heroDb['hero_lv'],
|
||||||
'presetInfo' => $preset,
|
'presetInfo' => $preset,
|
||||||
'is_leader' => 0,
|
'is_leader' => 0,
|
||||||
'is_ready' => 0,
|
'is_ready' => 0,
|
||||||
|
'permission' => 0,
|
||||||
'honor_info' => $honorInfo,
|
'honor_info' => $honorInfo,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
15
webapp/services/NumberService.php
Normal file
15
webapp/services/NumberService.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
class NumberService extends BaseService
|
||||||
|
{
|
||||||
|
public static function ceilEx($number , $decimals) {
|
||||||
|
$intPart = intval($number);
|
||||||
|
$floatPart = $number - $intPart;
|
||||||
|
$finallyFloatPart = ceil($floatPart * pow(10,$decimals)) / pow(10,$decimals);
|
||||||
|
return $intPart + $finallyFloatPart;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user