From 294651882105ac221613c21dde0a92a20b4085ee Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Tue, 5 Sep 2023 19:35:33 +0800 Subject: [PATCH 1/9] 1 --- webapp/models/Staking.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index a01c19d9..45e79fd0 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -87,6 +87,9 @@ class Staking extends BaseModel { } } } + if (SERVER_ENV != _ONLINE) { + myself()->_setTimeOffset(0); + } return $totalValue; } From b5cfe0639c94f98d477b2c3e78291219d4b67448 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 6 Sep 2023 14:18:05 +0800 Subject: [PATCH 2/9] 1 --- doc/Team.py | 50 ++++++++-------------- doc/_common.py | 1 + webapp/controller/TeamController.class.php | 26 +++++++++++ webapp/models/User.php | 1 + 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/doc/Team.py b/doc/Team.py index b2e2581c..1b4925b0 100644 --- a/doc/Team.py +++ b/doc/Team.py @@ -78,34 +78,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': '转移队长职位', @@ -203,17 +175,29 @@ class Team(object): _common.RspHead(), ] },{ - 'name': 'getPveFragmentNumOrDay', - 'desc': '当天获取碎片的数量', + 'name': 'updateTeam', + 'desc': '跟新队伍信息', 'group': 'Team', - 'url': 'webapp/index.php?c=Team&a=getPveFragmentNumOrDay', + 'url': 'webapp/index.php?c=Team&a=updateTeam', 'params': [ _common.ReqHead(), + ['team_uuid', '', '队伍唯一id'], + ], + 'response': [ + _common.RspHead(), + ] + },{ + 'name': 'permission', + 'desc': '邀请许可', + 'group': 'Team', + 'url': 'webapp/index.php?c=Team&a=permission', + 'params': [ + _common.ReqHead(), + ['team_uuid', '', '队伍唯一id'], + ['target_id', '', '目标account_id'], ], 'response': [ _common.RspHead(), - ['heroNum',0,'英雄碎片数量'], - ['gunNum',0,'枪械碎片数量'] ] }, ] diff --git a/doc/_common.py b/doc/_common.py index 6dce77e0..9bf5618d 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, '账号创建时间'], ] diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index d8cf1bf3..cb6ba7fb 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -78,6 +78,7 @@ class TeamController extends BaseAuthedController { $userDto = User::toPreset($userDb); $userDto['is_leader'] = 1; $userDto['is_ready'] = 1; + $userDto['permission'] = 1; $userDto['createtime'] = $userDb['createtime']; $teamDb = array( 'team_uuid' => $teamUuid, @@ -560,6 +561,31 @@ class TeamController extends BaseAuthedController { )); } + public function permission(){ + $teamUuid = getReqVal('team_uuid', ''); + $accountId = getReqVal('target_id', ''); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ + $this->_rspErr(1, 'You are not the captain.'); + return; + } + if ($member['account_id'] == $accountId){ + $member['permission'] = 1; + } + + } + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspData(array( + 'team_uuid' => $teamUuid + )); + } + private function readTeamDb($r, $teamUuid) { diff --git a/webapp/models/User.php b/webapp/models/User.php index c1513817..25d926fd 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -311,6 +311,7 @@ class User extends BaseModel { 'presetInfo' => $preset, 'is_leader' => 0, 'is_ready' => 0, + 'permission' => 0, 'honor_info' => $honorInfo, ); From e693535cfcc6792ab3db7770881934227e29d75d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 6 Sep 2023 16:53:39 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=AE=97=E5=8A=9B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_common.py | 12 +++--- sql/gamedb.sql | 27 +++++++++++++ .../ComputingPowerController.class.php | 38 ++++++------------- webapp/models/RewardsCec.php | 4 +- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index 9bf5618d..53592c4f 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1335,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): @@ -1358,7 +1356,7 @@ class ComputingPower(object): self.fields = [ ['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'], ['curr_period', ComputingPowerCurr(), '本期相关信息'], - ['last_period', ComputingPowerLast(), '上期相关信息'], + ['last_period', 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..d8270ea5 100644 --- a/webapp/controller/ComputingPowerController.class.php +++ b/webapp/controller/ComputingPowerController.class.php @@ -24,21 +24,17 @@ 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, ); - $last_period = array( - "period_begin" => 0, - "period_end" => 0, - "reward" => 0, + $reward = array( + "cec" => 0, + "point" => 0, ); $lastMeta = \mt\HashRateCommon::getLastPeriod(); @@ -47,45 +43,35 @@ class ComputingPowerController extends BaseAuthedController if (!$currentMeta && $lastMeta){ 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 = min($totalNum / $currentMeta['cec_pool'] , 1); + $ratio = $ownerNum/$totalNum; + $reward['cec'] = $currentMeta['cec_pool'] * $target * $ratio; + $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']); - } $info = array( 'period_state' => $period_state, 'curr_period' => $curr_period, - 'last_period' => $last_period, + 'last_period' => $reward, 'listing_state' => LISTING_SWITCH, 'owned_cec' => RewardsCec::getTotalCecNum(), 'owned_total_hash_rate' =>ComputingPower::getMyTotalBH(), diff --git a/webapp/models/RewardsCec.php b/webapp/models/RewardsCec.php index ba03edd4..f49fa41d 100644 --- a/webapp/models/RewardsCec.php +++ b/webapp/models/RewardsCec.php @@ -128,8 +128,8 @@ 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 + $totalNum = ComputingPower::getTotalBH($hashMeta['id']); //25.9 + $target = min($totalNum / $hashMeta['cec_pool'] , 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) $address = User::findUserAddress($account); From 4a788bf6e12030ee085352014ceeb88932de0c9d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 7 Sep 2023 14:45:10 +0800 Subject: [PATCH 4/9] 1 --- doc/Team.py | 44 -------- webapp/controller/TeamController.class.php | 124 --------------------- 2 files changed, 168 deletions(-) diff --git a/doc/Team.py b/doc/Team.py index 1b4925b0..c34d6180 100644 --- a/doc/Team.py +++ b/doc/Team.py @@ -130,50 +130,6 @@ class Team(object): 'response': [ _common.RspHead(), ] - },{ - 'name': 'setHero', - 'desc': '设置出战英雄', - 'group': 'Team', - 'url': 'webapp/index.php?c=Team&a=setHero', - 'params': [ - _common.ReqHead(), - ['team_uuid', '', '队伍唯一id'], - ['hero_uid', 0, '英雄uniid'], - ], - 'response': [ - _common.RspHead(), - ] - },{ - 'name': 'setPreset', - 'desc': '设置备战', - 'group': 'Team', - 'url': 'webapp/index.php?c=Team&a=setPreset', - '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'], - ], - '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': 'updateTeam', 'desc': '跟新队伍信息', diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index cb6ba7fb..f7193880 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -428,130 +428,6 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } - public function setHero(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroUid = getReqVal('hero_uid', ''); - $heroDb = Hero::find($heroUid); - if (! $heroDb){ - $this->_rspErr(1, 'hero_uid param error'); - return; - } - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $this->_updateUserInfo(array( - 'hero_id' => $heroUid - )); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addUserChg(); - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto() - )); - } - - public function setPreset(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroId = getReqVal('hero_uid',0); - $chipPageId = getReqVal('chip_page',0); - $weaponUid1 = getReqVal('weapon_uid1',0); - $weaponUid2 = getReqVal('weapon_uid2',0); - $skillId = getReqVal('skill_id',0); - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $heroDb = Hero::find($heroId); - if (! $heroDb){ - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - $chipPageDb = ChipPage::find($chipPageId); - if (! $chipPageDb){ - $this->_rspErr(1, "You don't have the chip page"); - return; - } - if ($weaponUid1){ - $gunDb1 = Gun::find($weaponUid1); - if (!$gunDb1){ - $this->_rspErr(1, "You don't have the gun1 yet"); - return; - } - } - if ($weaponUid2){ - $gunDb2 = Gun::find($weaponUid2); - if (!$gunDb2){ - $this->_rspErr(1, "You don't have the gun2 yet"); - return; - } - } - $skillMeta = mt\Skill::get($skillId); - if (! $skillMeta){ - $this->_rspErr(1,'skill_id parameter error'); - return ; - } - HeroPreset::upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $this->_rspOk(); - } - - public function setHeroSkin(){ - $teamUuid = getReqVal('team_uuid', ''); - $heroUniId = getReqVal('hero_uid', 0); - $skinId = getReqVal('skin_id', 0); - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - $heroDb = Hero::find($heroUniId); - $heroSkinDb = HeroSkin::find($skinId); - if (!$heroDb) { - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - if (!$heroSkinDb) { - $this->_rspErr(2, "You don't have the skin yet"); - return; - } - HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']); - $newUserInfo = User::toPreset($this->_getOrmUserInfo()); - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId()){ - $newUserInfo['is_leader'] = $member['is_leader']; - $newUserInfo['is_ready'] = $member['is_ready']; - $member = $newUserInfo; - } - - } - $this->saveTeamDb($r, $teamUuid, $teamDb); - $this->_rspOk(); - } - public function getPveFragmentNumOrDay(){ $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0); $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0); From 665aa853f5abd6e3c1bd7df80553028ba3c0489d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 7 Sep 2023 16:34:04 +0800 Subject: [PATCH 5/9] 1 --- webapp/models/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/models/User.php b/webapp/models/User.php index 25d926fd..d71302e1 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -308,6 +308,7 @@ 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, From 6fe6da6b3deb913ac741b63df7aca81825fef37c Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 8 Sep 2023 15:42:21 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E7=AE=97=E5=8A=9B=E5=85=AC=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Team.py | 12 ++++++++++ doc/_common.py | 2 +- .../ComputingPowerController.class.php | 22 +++++++++++++++---- webapp/controller/TeamController.class.php | 19 ++++++++++++++++ webapp/models/ComputingPower.php | 6 ++++- webapp/models/RewardsCec.php | 12 +++++++--- webapp/services/NumberService.php | 15 +++++++++++++ 7 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 webapp/services/NumberService.php diff --git a/doc/Team.py b/doc/Team.py index c34d6180..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', diff --git a/doc/_common.py b/doc/_common.py index 53592c4f..f06194d4 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1356,7 +1356,7 @@ class ComputingPower(object): self.fields = [ ['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'], ['curr_period', ComputingPowerCurr(), '本期相关信息'], - ['last_period', ComputingPowerReward(), '上期相关信息'], + ['curr_reward', ComputingPowerReward(), '本期奖励信息'], ['listing_state', 0, 'listing状态 0:之前 1:之后'], ['owned_cec', 0, '拥有的cec数量'], ['owned_total_hash_rate', 0, '用户总科技值'], diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php index d8270ea5..81f31566 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'); @@ -41,6 +42,15 @@ class ComputingPowerController extends BaseAuthedController $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']); @@ -60,9 +70,13 @@ class ComputingPowerController extends BaseAuthedController $curr_period['total_exchange_hash_rate'] = $ownerNum; $curr_period['total_hash_rate'] = $totalNum; - $target = min($totalNum / $currentMeta['cec_pool'] , 1); - $ratio = $ownerNum/$totalNum; - $reward['cec'] = $currentMeta['cec_pool'] * $target * $ratio; + $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; } @@ -71,7 +85,7 @@ class ComputingPowerController extends BaseAuthedController $info = array( 'period_state' => $period_state, 'curr_period' => $curr_period, - 'last_period' => $reward, + 'curr_reward' => $reward, 'listing_state' => LISTING_SWITCH, 'owned_cec' => RewardsCec::getTotalCecNum(), 'owned_total_hash_rate' =>ComputingPower::getMyTotalBH(), diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index f7193880..6c7557c2 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -216,6 +216,25 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } + public function breakup(){ + $teamUuid = getReqVal('team_uuid', ''); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ + $this->_rspErr(1, 'You are not the captain.'); + return; + } + } + $this->delTeamDb($r, $teamUuid); + $this->_rspOk(); + } + + public function kickout() { $teamUuid = getReqVal('team_uuid', ''); 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 f49fa41d..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 { @@ -129,9 +131,13 @@ class RewardsCec extends BaseModel public static function celCecReward($account,$hashMeta){ $ownerNum = ComputingPower::getOwnedBH($hashMeta['id'],$account); //13.7 $totalNum = ComputingPower::getTotalBH($hashMeta['id']); //25.9 - $target = min($totalNum / $hashMeta['cec_pool'] , 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) + $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/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 @@ + Date: Mon, 11 Sep 2023 13:35:23 +0800 Subject: [PATCH 7/9] 1 --- webapp/models/Staking.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 6b2cadd4..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( From 9e607c788bbc234fff9faf0ff16569bc75f2844e Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 11 Sep 2023 14:47:36 +0800 Subject: [PATCH 8/9] 1 --- webapp/controller/TeamController.class.php | 165 +++++++++++++++------ 1 file changed, 122 insertions(+), 43 deletions(-) diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index 6c7557c2..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; } @@ -78,7 +78,6 @@ class TeamController extends BaseAuthedController { $userDto = User::toPreset($userDb); $userDto['is_leader'] = 1; $userDto['is_ready'] = 1; - $userDto['permission'] = 1; $userDto['createtime'] = $userDb['createtime']; $teamDb = array( 'team_uuid' => $teamUuid, @@ -148,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) { @@ -216,25 +215,6 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } - public function breakup(){ - $teamUuid = getReqVal('team_uuid', ''); - $r = $this->_getRedis($teamUuid); - $teamDb = $this->readTeamDb($r, $teamUuid); - if (empty($teamDb)) { - $this->_rspErr(1, 'The team has been disbanded'); - return; - } - foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ - $this->_rspErr(1, 'You are not the captain.'); - return; - } - } - $this->delTeamDb($r, $teamUuid); - $this->_rspOk(); - } - - public function kickout() { $teamUuid = getReqVal('team_uuid', ''); @@ -447,37 +427,136 @@ class TeamController extends BaseAuthedController { $this->_rspOk(); } - public function getPveFragmentNumOrDay(){ - $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0); - $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0); - $this->_rspData(array( - 'heroNum'=>$todayPveGetHeroFragmentNum, - 'gunNum'=>$todayPveGetGunFragmentNum, - )); - } - - public function permission(){ + public function setHero(){ $teamUuid = getReqVal('team_uuid', ''); - $accountId = getReqVal('target_id', ''); + $heroUid = getReqVal('hero_uid', ''); + $heroDb = Hero::find($heroUid); + if (! $heroDb){ + $this->_rspErr(1, 'hero_uid param error'); + return; + } $r = $this->_getRedis($teamUuid); $teamDb = $this->readTeamDb($r, $teamUuid); if (empty($teamDb)) { $this->_rspErr(1, 'The team has been disbanded'); return; } + $this->_updateUserInfo(array( + 'hero_id' => $heroUid + )); + $newUserInfo = User::toPreset($this->_getOrmUserInfo()); foreach ($teamDb['member_list'] as &$member) { - if ($member['account_id'] == $this->_getAccountId() && $member['is_leader'] != 1){ - $this->_rspErr(1, 'You are not the captain.'); - return; - } - if ($member['account_id'] == $accountId){ - $member['permission'] = 1; + if ($member['account_id'] == $this->_getAccountId()){ + $newUserInfo['is_leader'] = $member['is_leader']; + $newUserInfo['is_ready'] = $member['is_ready']; + $member = $newUserInfo; } } $this->saveTeamDb($r, $teamUuid, $teamDb); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); $this->_rspData(array( - 'team_uuid' => $teamUuid + 'property_chg' => $propertyChgService->toDto() + )); + } + + public function setPreset(){ + $teamUuid = getReqVal('team_uuid', ''); + $heroId = getReqVal('hero_uid',0); + $chipPageId = getReqVal('chip_page',0); + $weaponUid1 = getReqVal('weapon_uid1',0); + $weaponUid2 = getReqVal('weapon_uid2',0); + $skillId = getReqVal('skill_id',0); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + $heroDb = Hero::find($heroId); + if (! $heroDb){ + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $chipPageDb = ChipPage::find($chipPageId); + if (! $chipPageDb){ + $this->_rspErr(1, "You don't have the chip page"); + return; + } + if ($weaponUid1){ + $gunDb1 = Gun::find($weaponUid1); + if (!$gunDb1){ + $this->_rspErr(1, "You don't have the gun1 yet"); + return; + } + } + if ($weaponUid2){ + $gunDb2 = Gun::find($weaponUid2); + if (!$gunDb2){ + $this->_rspErr(1, "You don't have the gun2 yet"); + return; + } + } + $skillMeta = mt\Skill::get($skillId); + if (! $skillMeta){ + $this->_rspErr(1,'skill_id parameter error'); + return ; + } + HeroPreset::upsertPreset($heroId,$skillId,$chipPageId,$weaponUid1,$weaponUid2); + $newUserInfo = User::toPreset($this->_getOrmUserInfo()); + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId()){ + $newUserInfo['is_leader'] = $member['is_leader']; + $newUserInfo['is_ready'] = $member['is_ready']; + $member = $newUserInfo; + } + + } + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspOk(); + } + + public function setHeroSkin(){ + $teamUuid = getReqVal('team_uuid', ''); + $heroUniId = getReqVal('hero_uid', 0); + $skinId = getReqVal('skin_id', 0); + $r = $this->_getRedis($teamUuid); + $teamDb = $this->readTeamDb($r, $teamUuid); + if (empty($teamDb)) { + $this->_rspErr(1, 'The team has been disbanded'); + return; + } + $heroDb = Hero::find($heroUniId); + $heroSkinDb = HeroSkin::find($skinId); + if (!$heroDb) { + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + if (!$heroSkinDb) { + $this->_rspErr(2, "You don't have the skin yet"); + return; + } + HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']); + $newUserInfo = User::toPreset($this->_getOrmUserInfo()); + foreach ($teamDb['member_list'] as &$member) { + if ($member['account_id'] == $this->_getAccountId()){ + $newUserInfo['is_leader'] = $member['is_leader']; + $newUserInfo['is_ready'] = $member['is_ready']; + $member = $newUserInfo; + } + + } + $this->saveTeamDb($r, $teamUuid, $teamDb); + $this->_rspOk(); + } + + public function getPveFragmentNumOrDay(){ + $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0); + $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0); + $this->_rspData(array( + 'heroNum'=>$todayPveGetHeroFragmentNum, + 'gunNum'=>$todayPveGetGunFragmentNum, )); } From 5bd14c48229567a7d6221a0063f2283961a01e88 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 11 Sep 2023 14:53:55 +0800 Subject: [PATCH 9/9] 1 --- .../ComputingPowerController.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php index 81f31566..e9b2b197 100644 --- a/webapp/controller/ComputingPowerController.class.php +++ b/webapp/controller/ComputingPowerController.class.php @@ -37,8 +37,13 @@ class ComputingPowerController extends BaseAuthedController "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){ @@ -80,12 +85,22 @@ class ComputingPowerController extends BaseAuthedController $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']); + } + + $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(),