From f7ad15c6bd22c78ff2b247bde2caf14260fc7000 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 23 Aug 2023 04:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=97=E5=8A=9B=E7=8E=A9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/ComputingPower.py | 76 +++-- doc/Other.py | 21 +- doc/_common.py | 77 +++-- server/game2006service/tasks/hourlyTask.js | 0 sql/gamedb.sql | 46 ++- sql/gamedb2006_migrate_230816_01.sql | 77 +++++ webapp/bootstrap/constant.php | 3 + .../ComputingPowerController.class.php | 262 ++++++++++++++++++ webapp/controller/GMController.class.php | 22 ++ webapp/controller/OtherController.class.php | 42 +++ webapp/models/ComputingPower.php | 95 +++++++ webapp/models/CrystalRecord.php | 57 ++++ webapp/mt/HashRate.php | 38 +++ webapp/mt/HashRateCommon.php | 67 +++++ webapp/mt/Item.php | 4 + webapp/services/HashRateService.php | 60 ++++ 16 files changed, 870 insertions(+), 77 deletions(-) create mode 100644 server/game2006service/tasks/hourlyTask.js create mode 100644 sql/gamedb2006_migrate_230816_01.sql create mode 100644 webapp/controller/ComputingPowerController.class.php create mode 100644 webapp/models/ComputingPower.php create mode 100644 webapp/models/CrystalRecord.php create mode 100644 webapp/mt/HashRate.php create mode 100644 webapp/mt/HashRateCommon.php create mode 100644 webapp/services/HashRateService.php diff --git a/doc/ComputingPower.py b/doc/ComputingPower.py index 2d0021bf..94e3cc85 100644 --- a/doc/ComputingPower.py +++ b/doc/ComputingPower.py @@ -19,6 +19,46 @@ class ComputingPower(object): ['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(), + ] + }, + { + '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': '晶体兑换算力', @@ -32,30 +72,20 @@ class ComputingPower(object): ] }, { - 'name': 'exchangeCrystal', - 'desc': '兑换晶体', + 'name': 'exchangeUplimit', + 'desc': '每周晶体兑换上限', 'group': 'ComputingPower', - 'url': 'webapp/index.php?c=ComputingPower&a=exchangeCrystal', + 'url': 'webapp/index.php?c=ComputingPower&a=exchangeUplimit', 'params': [ _common.ReqHead(), ], 'response': [ _common.RspHead(), + ['data', _common.ExchangeCrystalNum(), '本周期晶体兑换信息'] ] }, - { - 'name': 'getCrystalUi', - 'desc': '获取晶体ui信息', - 'group': 'ComputingPower', - 'url': 'webapp/index.php?c=ComputingPower&a=getCrystalUi', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['info', _common.ComputingPower(), '算力信息'] - ] - }, + + { 'name': 'getRewardHistorys', 'desc': '获取奖励历史', @@ -69,19 +99,7 @@ class ComputingPower(object): ['info', _common.ComputingPower(), '算力信息'] ] }, - { - 'name': 'getExchangeCrystalHistorys', - 'desc': '获取兑换晶体历史', - 'group': 'ComputingPower', - 'url': 'webapp/index.php?c=ComputingPower&a=getExchangeCrystalHistorys', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['info', _common.ComputingPower(), '算力信息'] - ] - }, + { 'name': 'getExchangePowerHistorys', 'desc': '获取兑换算力历史', diff --git a/doc/Other.py b/doc/Other.py index 0237f738..ec917d5e 100644 --- a/doc/Other.py +++ b/doc/Other.py @@ -23,5 +23,24 @@ class Other(object): ],'碎片'] ], '提示信息'], ] - } + }, + { + 'name': 'getGameModuleState', + 'desc': '功能模块的状态', + 'group': 'Other', + 'url': 'webapp/index.php?c=Other&a=getGameModuleState', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['data', [ + ['firstTopUp',0,'首充: 1 已充, 0 未充'], + ['signDayState',0,'7日签到: 1 签满, 0 未签满'], + ['rankState',0,'排位: 1 赛季开始了, 0 赛季未开始'], + ['nextRankSeasonCountdown',0,'下赛季倒计时'], + ['hashRateState',0,'算力: 1 开始, 0 未开始'], + ], '信息'], + ] + }, ] \ No newline at end of file diff --git a/doc/_common.py b/doc/_common.py index b0d391b8..2c383b22 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1325,42 +1325,77 @@ class MallGoods(object): ['modify_countdown', 0, '可修改价格倒计时:-1不可修改价格'], ] -class ComputingPowerSelf(object): - - def __init__(self): - self.fields = [ - ['exchange_hash_rate', '', "我已兑换的算力"], - ] - class ComputingPowerCurr(object): def __init__(self): self.fields = [ - ['period_begin', '', '本期开始时间'], - ['period_end', '', '本期结束时间'], - ['assignable_cec', '', '可分配的cec'], +# ['current_state', '', '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'], + ['period_begin', '', '本期开始时间(0 不显示)'], + ['period_end', '', '本期结束时间(0 不显示)'], + ['await_time', '', '结算等待时间'], + ['assignable_cec', '', '可分配的总cec奖励'], + ['total_target', '', '全服算力总目标'], - ['total_target', '', '总目标'], - ['total_hash_rate', '', '总算力'], - ['refresh_remain_time', '', '刷新剩余时间'], - ['total_exchange_hash_rate', '', "总兑换算力"], +# ['refresh_remain_time', '', '刷新剩余时间'], + ['total_hash_rate', '', '全服总兑换算力'], + ['total_exchange_hash_rate', '', "玩家已兑换算力"], ] class ComputingPowerLast(object): def __init__(self): self.fields = [ - ['period_begin', '', ''], - ['period_end', '', '商品唯一id'], - ['period_reward', '', '商品唯一id'], - ['clamid', '', ''], + ['period_begin', 0, '上期开始时间(0 不显示)'], + ['period_end', 0, '上期结束时间(0 不显示)'], + ['reward', 0, '上期的cec奖励'], ] class ComputingPower(object): def __init__(self): self.fields = [ - ['curr_period', ComputingPowerCurr(), ''], - ['curr_self', ComputingPowerSelf(), ''], - ['last_period', ComputingPowerLast(), '商品唯一id'], + ['period_state', 0, '周期状态 -1:算力周期未开始 0:正常周期 1:等待周期 2:维护周期'], + ['curr_period', ComputingPowerCurr(), '本期相关信息'], + ['last_period', ComputingPowerLast(), '上期相关信息'], + ['listing_state', 0, 'listing状态 0:之前 1:之后'], + ['owned_cec', 0, '拥有的cec数量'], ] + +class CrystalUI(object): + + def __init__(self): + self.fields = [ + ['item_id', 0, 'item_id'], + ['pending', 0, 'pending'], + ['total', CrystalUIParam(), '统计信息'], + ['claimed', 0, '已领取的数量'], + ['state', 0, '是否能领取 1:可领取 0:反之'], + ] + +class CrystalUIParam(object): + + def __init__(self): + self.fields = [ + ['param1', 0, '击杀数/其它晶体的价值数'], + ['param2', 0, '星星数'], + ['param3', 0, '升段数'], + ] + +class ExchangeCrystalRecord(object): + + def __init__(self): + self.fields = [ + ['item_id', 0, '晶体item'], + ['item_num', 0, '晶体数'], + ['createtime', 0, '领取时间'], + ] + +class ExchangeCrystalNum(object): + + def __init__(self): + self.fields = [ + ['num1', 0, '本期晶体260001兑换数'], + ['num2', 0, '本期晶体260002兑换数'], + ['num3', 0, '本期晶体260003兑换数'], + ['num4', 0, '本期晶体260004兑换数'], + ] \ No newline at end of file diff --git a/server/game2006service/tasks/hourlyTask.js b/server/game2006service/tasks/hourlyTask.js new file mode 100644 index 00000000..e69de29b diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 08747a71..17327b06 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1531,26 +1531,7 @@ CREATE TABLE `t_market_transaction_record` ( KEY `order_id` (`order_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10002 DEFAULT CHARSET=utf8; --- --- Table structure for table `t_crystal` --- -DROP TABLE IF EXISTS `t_crystal`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_crystal` ( - `idx` bigint(20) NOT NULL AUTO_INCREMENT, - `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', - `address` varchar(60) COMMENT 'address', - `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`), - UNIQUE KEY `account_id_item_id` (`account_id`, `item_id`), - 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_crystal_exchange_record` @@ -1585,8 +1566,11 @@ CREATE TABLE `t_power_exchange_record` ( `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 '道具数量', + `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`), @@ -1594,6 +1578,16 @@ CREATE TABLE `t_power_exchange_record` ( ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +CREATE TABLE `t_computing_power_period` ( + `idx` bigint(20) NOT NULL AUTO_INCREMENT, + `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期', + `total_num` varchar(60) COMMENT '全服算力总量', + `createtime` int(11) NOT NULL COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `period` (`period`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; + -- -- Table structure for table `t_computing_power_period` -- @@ -1601,17 +1595,17 @@ CREATE TABLE `t_power_exchange_record` ( DROP TABLE IF EXISTS `t_computing_power_period`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `t_computing_power_period` ( +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期奖励', + `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周奖励', `createtime` int(11) NOT NULL COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql new file mode 100644 index 00000000..3ba1d1a9 --- /dev/null +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -0,0 +1,77 @@ +begin; + +-- CREATE TABLE `t_crystal` ( +-- `idx` bigint(20) NOT NULL AUTO_INCREMENT, +-- `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', +-- `address` varchar(60) COMMENT 'address', +-- `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`), +-- UNIQUE KEY `account_id_item_id` (`account_id`, `item_id`), +-- KEY `account_id` (`account_id`) +-- ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=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; + +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; + +CREATE TABLE `t_computing_power_period` ( + `idx` bigint(20) NOT NULL AUTO_INCREMENT, + `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期', + `total_num` varchar(60) COMMENT '全服算力总量', + `createtime` int(11) NOT NULL COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `period` (`period`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=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周奖励', + + `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; + + +insert into version (version) values(2023081601); + +commit; \ No newline at end of file diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 3e85a7a0..eae00af2 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -31,6 +31,9 @@ define('TN_LAST_RANKING_TIME', 8009); define('TN_MISSION_STAR_SEASON', 8010); define('TN_RANK_STATUS', 8011); define('TN_FIRST_TUPOP_STATUS', 8012); +define('TN_TOTAL_KILLS_NUM', 8013); +define('TN_TOTAL_STAR_NUM', 8014); +define('TN_TOTAL_RANK_NUM', 8015); define('TN_DAILY_BEGIN', 9001); diff --git a/webapp/controller/ComputingPowerController.class.php b/webapp/controller/ComputingPowerController.class.php new file mode 100644 index 00000000..d968d33d --- /dev/null +++ b/webapp/controller/ComputingPowerController.class.php @@ -0,0 +1,262 @@ + -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, + ); + $lastMeta = \mt\HashRateCommon::getLastPeriod(); + $currentMeta = \mt\HashRateCommon::getCurrentPeriod(); + $nextMeta = \mt\HashRateCommon::getNextPeriod(); + 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; + $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'] = ( $rowDb ? $rowDb['total_num'] : 0 ) + $currentMeta['hashrate_add']; +// $curr_period['refresh_remain_time'] = $rowDb ? $rowDb['modifytime'] + 3600 - myself()->_getNowTime() : 0; + + } + + if ($lastMeta){ + $last_period['period_begin'] = strtotime($lastMeta['start_time']); + $last_period['period_end'] = strtotime($lastMeta['end_time']); + } + + + $info = array( + 'period_state' => $period_state, + 'curr_period' => $curr_period, + 'last_period' => $last_period, + 'listing_state' => LISTING_SWITCH, + 'owned_cec' => 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); + $itemNum = getReqVal('item_num', 0); + $itemMeta = \mt\Item::get($itemId); + if (!$itemMeta || $itemMeta['type'] != \mt\Item::CRYSTAL_TYPE || !$itemNum){ + $this->_rspErr(1, 'param error'); + return ; + } + $items = array( + array( + 'item_id' => $itemId, + 'item_num' => $itemNum, + ) + ); + $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); + $this->_addItems($items,$awardService,$propertyChgService); + CrystalRecord::addCrystalRecord($itemId,$itemNum); + $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 _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; + } + } + + + +} \ No newline at end of file diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index 994fed5d..92097f1c 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -49,6 +49,9 @@ class GMController extends BaseAuthedController { }, '.reset_mission' => function () use($params) { $this->resetMission($params); + }, + '.addtest' => function () use($params) { + $this->addDyndata($params); } ); $func = getXVal($cmdHash, $cmd); @@ -69,6 +72,7 @@ class GMController extends BaseAuthedController { .getsystime //获取服务器时间 .setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00 .reset_mission //重置任务 +.addtest //添加测试数据 1:击杀数 2:星星数 3:升段数 END )); } @@ -182,4 +186,22 @@ END myself()->_rspOk(); } + private function addDyndata($params){ + $type = getXVal($params, 0, 0); + $num = getXVal($params, 1, 0); + switch ($type){ + case 1 : { + myself()->_incV(TN_TOTAL_KILLS_NUM,0,$num); + } + break; + case 2 : { + myself()->_incV(TN_TOTAL_STAR_NUM,0,$num); + } + break; + case 3 : { + myself()->_incV(TN_TOTAL_RANK_NUM,0,$num); + } + } + } + } diff --git a/webapp/controller/OtherController.class.php b/webapp/controller/OtherController.class.php index 1287cbe5..4e04ad8a 100644 --- a/webapp/controller/OtherController.class.php +++ b/webapp/controller/OtherController.class.php @@ -1,11 +1,15 @@ $req )); } + + public function getGameModuleState(){ + //七日签到 + $signState = 0; + $signDb = SignLog::find(); + if($signDb['days'] >= 7 && $signDb['is_receive'] == 1){ + $signState = 1; + } + //排位 + $rankState = 0; + $currSeasonMeta = mt\RankSeason::getCurrentSeason(); + if($currSeasonMeta){ + $rankState = 1; + + } + $countdown = 0; + $nextCurrSeasonMeta = mt\RankSeason::getNextCurrentSeason(); + if ($nextCurrSeasonMeta){ + $countdown = strtotime($nextCurrSeasonMeta['start_time']) - myself()->_getNowTime(); + } + //算力 + $hashRateState = 0; + $hashRateMeta = \mt\HashRateCommon::find(1); + if (myself()->_getNowTime() > strtotime($hashRateMeta['start_time'])){ + $hashRateState = 1; + } + + $data = array( + "firstTopUp" => myself()->_getV(TN_FIRST_TUPOP_STATUS,0), + "signDayState" => $signState, + "rankState" => $rankState, + "nextRankSeasonCountdown" => $countdown, + "hashRateState" => $hashRateState, + ); + $this->_rspData(array( + 'data'=>$data + )); + } } diff --git a/webapp/models/ComputingPower.php b/webapp/models/ComputingPower.php new file mode 100644 index 00000000..03f0bb56 --- /dev/null +++ b/webapp/models/ComputingPower.php @@ -0,0 +1,95 @@ +_getSelfMysql(), + 't_power_exchange_record', + array( + 'account_id'=>myself()->_getAccountId(), + 'period' => $period + ) + ); + $my_total_num = 0; + if ($rows){ + foreach ($rows as $row){ + $my_total_num += $row['total_num']; + } + } + return $my_total_num; + } + + //获取全服总算力 + public static function getTotalBH($period){ + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_computing_power_period', + array( + 'period' => $period + ) + ); + if (!$row){ + $row = null; + } + return $row; + } + + 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(), + ) + ); + } + + +} \ No newline at end of file diff --git a/webapp/models/CrystalRecord.php b/webapp/models/CrystalRecord.php new file mode 100644 index 00000000..5764d1db --- /dev/null +++ b/webapp/models/CrystalRecord.php @@ -0,0 +1,57 @@ +_getSelfMysql(), + 't_crystal_exchange_record', + array( + 'account_id'=>myself()->_getAccountId() + ), + 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(), + ) + ); + } + +} \ No newline at end of file diff --git a/webapp/mt/HashRate.php b/webapp/mt/HashRate.php new file mode 100644 index 00000000..aefc73a2 --- /dev/null +++ b/webapp/mt/HashRate.php @@ -0,0 +1,38 @@ +_getNowTime() >= strtotime($meta['start_time']) && + myself()->_getNowTime() <= strtotime($meta['end_time'])) { + return $meta; + } + } + return array(); + } + + public static function getNextPeriod() + { + $metaList = self::getMetaList(); + foreach ($metaList as $key => $meta) { + if ($key == 1 && myself()->_getNowTime() <= strtotime($meta['start_time'])) { + return $meta; + } + if ($key > 1 && + myself()->_getNowTime() >= strtotime($metaList[$key-1]['end_time']) && + myself()->_getNowTime() <= strtotime($metaList[$key]['start_time'])) { + return $meta; + } + } + return array(); + } + + public static function getLastPeriod() + { + $metaList = self::getMetaList(); + $count = count($metaList); + foreach ($metaList as $key => $meta) { + if (myself()->_getNowTime() >= strtotime($metaList[$key]['end_time']) && + myself()->_getNowTime() <= strtotime($metaList[$key+1]['start_time'])) { + return $meta; + } + if ($key == $count && myself()->_getNowTime() >= strtotime($meta['end_time'])) { + return $meta; + } + } + return array(); + } + + + protected static function getMetaList() + { + if (!self::$metaList) { + self::$metaList = getMetaTable('HashRateCommon@HashRateCommon.php'); + } + return self::$metaList; + } + + protected static $metaList; + +} diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 7462ae68..85a48bc5 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -28,6 +28,8 @@ class Item { 16 降落伞皮肤 19 赛季戒指 23 随机宝箱 + 24 Gacha + 26 晶体 */ /* @@ -98,6 +100,7 @@ class Item { const EMOJI_TYPE = 20; const RANDOM_BOX_TYPE = 21; const HONOR_TYPE = 24; + const CRYSTAL_TYPE = 26; const CHEST_BOX_TYPE = 23; @@ -263,6 +266,7 @@ class Item { 14, self::FRAGMENT_BOX_TYPE, self::CHEST_BOX_TYPE, + self::CRYSTAL_TYPE, )); } diff --git a/webapp/services/HashRateService.php b/webapp/services/HashRateService.php new file mode 100644 index 00000000..01da19db --- /dev/null +++ b/webapp/services/HashRateService.php @@ -0,0 +1,60 @@ + $crystalMeta['id'], + 'pending' => 0, + 'total' => array(), + 'claimed' => 0, + 'state' => self::NONE_STATE, + ); + $hashRateMeta = HashRate::findHash($crystalMeta['id']); + switch ($crystalMeta['sub_type']){ + case 1 : { + $killsNum = myself()->_getV(TN_TOTAL_KILLS_NUM,0); + $starNum = myself()->_getV(TN_TOTAL_STAR_NUM,0); + $rankNum = myself()->_getV(TN_TOTAL_RANK_NUM,0); + $crystalDto['total'] = array( + 'param1' => intval($killsNum), + 'param2' => intval($starNum), + 'param3' => intval($rankNum), + ); + $param = explode('|',$hashRateMeta['parameter']); + $totalNum = max(0,floor($killsNum/$param[0]) + + floor($starNum/$param[1]) + $rankNum); + $ownedNum = CrystalRecord::getCrystalNum($crystalMeta['id']); + $crystalDto['pending'] = intval(max(0,$totalNum - $ownedNum)); + $crystalDto['claimed'] = intval($ownedNum); + $crystalDto['state'] = $crystalDto['pending'] > 0 ? self::RECEIVED_STATE : self::NONE_STATE; + } + break; + case 2 : { + // 游戏内消费总价值 + } + break; + case 3 : { + // Market交易总价值 + } + break; + case 4 : { + // 质压总价值 + } + break; + } + } + +} \ No newline at end of file