diff --git a/doc/Team.py b/doc/Team.py index b2e2581c..30c48576 100644 --- a/doc/Team.py +++ b/doc/Team.py @@ -63,6 +63,18 @@ class Team(object): 'response': [ _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', @@ -78,34 +90,6 @@ class Team(object): _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', 'desc': '转移队长职位', @@ -159,61 +143,29 @@ class Team(object): _common.RspHead(), ] },{ - 'name': 'setHero', - 'desc': '设置出战英雄', + 'name': 'updateTeam', + 'desc': '跟新队伍信息', 'group': 'Team', - 'url': 'webapp/index.php?c=Team&a=setHero', + 'url': 'webapp/index.php?c=Team&a=updateTeam', 'params': [ _common.ReqHead(), ['team_uuid', '', '队伍唯一id'], - ['hero_uid', 0, '英雄uniid'], ], 'response': [ _common.RspHead(), ] },{ - 'name': 'setPreset', - 'desc': '设置备战', + 'name': 'permission', + 'desc': '邀请许可', 'group': 'Team', - 'url': 'webapp/index.php?c=Team&a=setPreset', + 'url': 'webapp/index.php?c=Team&a=permission', 'params': [ _common.ReqHead(), ['team_uuid', '', '队伍唯一id'], - ['hero_uid', 0, '英雄uniid'], - ['chip_page', 0, '铭文页id'], - ['skill_id', 0, '技能item id'], - ['weapon_uid1', 0, '枪1uniid'], - ['weapon_uid2', 0, '枪2uniid'], + ['target_id', '', '目标account_id'], ], 'response': [ _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,'枪械碎片数量'] - ] }, ] diff --git a/doc/_common.py b/doc/_common.py index 6dce77e0..f06194d4 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -685,6 +685,7 @@ class TeamMember(object): ['kills', 0, '击杀数'], ['is_leader', 0, '是否队长'], ['is_ready', 0, '是否准备'], + ['permission', 0, '邀请许可'], ['createtime', 0, '账号创建时间'], ] @@ -1334,21 +1335,19 @@ class ComputingPowerCurr(object): ['period_end', '', '本期结束时间(0 不显示)'], ['await_time', '', '结算等待时间'], ['assignable_cec', '', '可分配的总cec奖励'], - ['total_target', '', '全服算力总目标'], +# ['total_target', '', '全服算力总目标'], # ['refresh_remain_time', '', '刷新剩余时间'], ['total_hash_rate', '', '全服总兑换算力'], ['total_exchange_hash_rate', '', "玩家已兑换算力"], ] -class ComputingPowerLast(object): +class ComputingPowerReward(object): def __init__(self): self.fields = [ - ['period_begin', 0, '上期开始时间(0 不显示)'], - ['period_end', 0, '上期结束时间(0 不显示)'], - ['reward', 0, '上期的cec奖励'], - ['last_hash_rate', 0, '上期的科技值'], + ['cec', 0, 'cec奖励'], + ['point', 0, '科技值'], ] class ComputingPower(object): @@ -1357,7 +1356,7 @@ class ComputingPower(object): self.fields = [ ['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'], ['curr_period', ComputingPowerCurr(), '本期相关信息'], - ['last_period', ComputingPowerLast(), '上期相关信息'], + ['curr_reward', ComputingPowerReward(), '本期奖励信息'], ['listing_state', 0, 'listing状态 0:之前 1:之后'], ['owned_cec', 0, '拥有的cec数量'], ['owned_total_hash_rate', 0, '用户总科技值'], diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9d4583f6..8206cb0f 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1624,3 +1624,30 @@ CREATE TABLE `t_ranking_settlement_record` ( PRIMARY KEY (`idx`), KEY `account_id` (`account_id`) ) 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; diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php index d453fcb6..e9b2b197 100644 --- a/webapp/controller/ComputingPowerController.class.php +++ b/webapp/controller/ComputingPowerController.class.php @@ -6,6 +6,7 @@ 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'); @@ -24,53 +25,64 @@ class ComputingPowerController extends BaseAuthedController public function info(){ $period_state = -1 ; //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期 $curr_period = array( -// "current_state" => -1, //-1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期 "period_begin" => 0, "period_end" => 0, "await_time" => 0, "assignable_cec" => 0, - "total_target" => 0, "total_exchange_hash_rate" => 0, "total_hash_rate" => 0, -// "refresh_remain_time" => 0, ); + $reward = array( + "cec" => 0, + "point" => 0, + ); $last_period = array( "period_begin" => 0, "period_end" => 0, "reward" => 0, ); - $lastMeta = \mt\HashRateCommon::getLastPeriod(); + $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['current_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{ -// $curr_period['current_state'] = 2; $period_state = 2; } } if ($currentMeta){ - $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_end'] = strtotime($currentMeta['end_time']); $curr_period['assignable_cec'] = $currentMeta['cec_pool']; - $curr_period['total_target'] = $currentMeta['target']; - - - $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; + $curr_period['total_exchange_hash_rate'] = $ownerNum; + $curr_period['total_hash_rate'] = $totalNum; + $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){ @@ -82,9 +94,12 @@ class ComputingPowerController extends BaseAuthedController } + + $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(), diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index d8cf1bf3..0cb3c110 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -35,8 +35,8 @@ class TeamController extends BaseAuthedController { $pveInstanceId = getReqVal('pve_instance_id', 0); $zid = myself()->_getZid(); $teamUuid = $nodeId . '_' . - $zid . '_' . - md5($this->_getAccountId() . $this->_getNowTime()); + $zid . '_' . + md5($this->_getAccountId() . $this->_getNowTime()); /*if (!in_array(array ( @@ -70,7 +70,7 @@ class TeamController extends BaseAuthedController { } if ($matchMode == self::MATCH_MODE_RANK){ // 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'); return; } @@ -147,8 +147,8 @@ class TeamController extends BaseAuthedController { if ($teamDb['match_mode'] == self::MATCH_MODE_RANK && // $userDb['level'] < \mt\LevelUp::USER_LEVEL_RANK_MATCH_LIMIT){ $userDb['star_num'] < \mt\StarLevel::STAR_NUM_RANK_MATCH_LIMIT){ - $this->_rspErr(1,'Not agreed terms'); - return; + $this->_rspErr(1,'Not agreed terms'); + return; } foreach ($teamDb['member_list'] as $member) { diff --git a/webapp/models/ComputingPower.php b/webapp/models/ComputingPower.php index e15f6b6f..28930925 100644 --- a/webapp/models/ComputingPower.php +++ b/webapp/models/ComputingPower.php @@ -2,9 +2,12 @@ namespace models; +require_once('services/NumberService.php'); use mt; use phpcommon\SqlHelper; +use services\NumberService; + class ComputingPower extends BaseModel { const CRYSTAL1 = 260001; @@ -31,7 +34,8 @@ class ComputingPower extends BaseModel $my_total_num += $row['total_num']; } } - return $my_total_num; + + return NumberService::ceilEx($my_total_num,6); } //获取全服总算力 diff --git a/webapp/models/RewardsCec.php b/webapp/models/RewardsCec.php index ba03edd4..dc57006e 100644 --- a/webapp/models/RewardsCec.php +++ b/webapp/models/RewardsCec.php @@ -7,6 +7,8 @@ namespace models; use mt; use phpcommon\SqlHelper; use phpcommon; +use services\NumberService; + class RewardsCec extends BaseModel { @@ -128,10 +130,14 @@ class RewardsCec extends BaseModel public static function celCecReward($account,$hashMeta){ $ownerNum = ComputingPower::getOwnedBH($hashMeta['id'],$account); //13.7 - $totalNum = ComputingPower::getTotalBH($hashMeta['id']) + $hashMeta['hashrate_add']; //25.9 - $target = min($totalNum / $hashMeta['target'] , 1); // 25.9/10000 - $ratio = $ownerNum/$totalNum; // 13.7/25.9 - $cecNum = $hashMeta['cec_pool'] * $target * $ratio; //10000*(25.9/10000)*(13.7/25.9) + $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), diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 71bb4789..54943978 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -41,7 +41,7 @@ class Staking extends BaseModel { public static function all($address) { if (SERVER_ENV != _ONLINE) { - myself()->_setTimeOffset(3600 * 24 * 360 * 2); + //myself()->_setTimeOffset(3600 * 24 * 360 * 2); } $result = array(); $rows = SqlHelper::ormSelect( @@ -87,6 +87,9 @@ class Staking extends BaseModel { } } } + if (SERVER_ENV != _ONLINE) { + myself()->_setTimeOffset(0); + } return $totalValue; } diff --git a/webapp/models/User.php b/webapp/models/User.php index c1513817..d71302e1 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -308,9 +308,11 @@ class User extends BaseModel { 'hero_uniId' => $row['hero_id'], 'hero_id' => $heroId, 'hero_skin' =>$skinDb['skin_id'], + 'hero_lv' =>$heroDb['hero_lv'], 'presetInfo' => $preset, 'is_leader' => 0, 'is_ready' => 0, + 'permission' => 0, 'honor_info' => $honorInfo, ); diff --git a/webapp/services/NumberService.php b/webapp/services/NumberService.php new file mode 100644 index 00000000..e2db629e --- /dev/null +++ b/webapp/services/NumberService.php @@ -0,0 +1,15 @@ +