diff --git a/server/admin/be/services/rank.js b/server/admin/be/services/rank.js index c7514fd1..182343ab 100644 --- a/server/admin/be/services/rank.js +++ b/server/admin/be/services/rank.js @@ -5,6 +5,21 @@ const log = require('j7/log'); const BaseService = require('./baseservice'); const metaFactory = require('../metadata/factory'); +const ALIVE_RANK = 100; + +class CommonRank { + + constructor(rankType) { + this.rankType = rankType; + this.lastIdx = 0; + } + + async start() { + + } + +} + class Rank extends BaseService { async init() { diff --git a/sql/gamedb.sql b/sql/gamedb.sql index f7693359..52741748 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -463,6 +463,29 @@ CREATE TABLE `t_drop_log` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_rank_activity` +-- + +DROP TABLE IF EXISTS `t_rank_activity`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_rank_activity` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `channel` int(11) NOT NULL DEFAULT '0' COMMENT 'channel', + `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', + `value` bigint NOT NULL DEFAULT '0' COMMENT 'value', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_id_type` (`account_id`, `type`), + KEY `channel` (`channel`), + KEY `type` (`type`), + KEY `value` (`value`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `t_game_log` -- diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index e467367e..356572de 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -11,6 +11,7 @@ require_once('models/HeroSkin.php'); require_once('services/NftService.php'); use mt; +use phpcommon; use phpcommon\SqlHelper; use services\NftService; diff --git a/webapp/mt/RankActivity.php b/webapp/mt/RankActivity.php new file mode 100644 index 00000000..cdf18ae6 --- /dev/null +++ b/webapp/mt/RankActivity.php @@ -0,0 +1,31 @@ += myself()->_getNowTime() && + $meta['closetime'] < myself()->_getNowTime(); + } + + protected static function getMetaList() + { + if (!self::$metaList) { + self::$metaList = getMetaTable('rankActivity@rankActivity.php'); + } + return self::$metaList; + } + + + protected static $metaList; + +} diff --git a/webapp/services/RankActivityService.php b/webapp/services/RankActivityService.php new file mode 100644 index 00000000..a9018559 --- /dev/null +++ b/webapp/services/RankActivityService.php @@ -0,0 +1,107 @@ +internalUpdateRankActivity( + self::ALIVE_TYPE, + getReqVal('alive_time', 0), + self::OP_SUM); + $this->internalUpdateRankActivity( + self::KILLS_TYPE, + getReqVal('kills_time', 0), + self::OP_SUM); + } + + public function heroUpgradeQuality() + { + $this->internalUpdateRankActivity( + self::HERO_UPGRADE_QUALITY_TYPE, + getReqVal('kills_time', 0), + self::OP_GREATEST); + } + + public function heroUpgradeLevel() + { + $this->internalUpdateRankActivity( + self::HERO_UPGRADE_LEVEL_TYPE, + getReqVal('kills_time', 0), + self::OP_GREATEST); + } + + private function internalUpdateRankActivity($type, $val, $opt) + { + $meta = mt\RankActivity::get(type); + if (!$meta || !mt\RankActivity::isActivityPeriod($meta)) { + return; + } + + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_rank_activity', + array( + 'account_id' => myself()->_getAccountId(), + 'type' => $type + ), + array( + 'value' => function () use($val, $opt) { + if ($opt == self::OP_SUM) { + return "value + ${val})"; + } else if ($opt == self::OP_GREATEST) { + return "GREATEST(0, ${val})"; + } else { + return $val; + } + }, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => myself()->_getAccountId(), + 'channel' => myself()->_getChannel(), + 'type' => $type, + 'value' => $val, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + + } + +}