From a1482b9c0e90afb414083ebfaee44ba2a7f338df Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 1 Sep 2023 10:52:32 +0800 Subject: [PATCH 1/9] 1 --- webapp/services/FormulaService.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index d941ef42..242111e1 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -348,15 +348,18 @@ class FormulaService extends BaseService { //表现分=f(个人存活时间排名TopX/4)*50%+f(队伍排名TopY)*50% f(TopX) = ROUND(1-(X-1)/9,2) $expreScore = (ROUND(1-($ranked/4-1)/9,2))*0.5+ROUND(1-($teamRank-1)/9,2)*0.5; + $rankMeta = mt\Rank::getRankById($userDb['rank']); //不同段位的及格分 = ROUND(1-(大段位排名-1)/(MAX(10)-1),2) - $topRanking = mt\Rank::getRankById($userDb['rank'])?mt\Rank::getRankById($userDb['rank'])['rank_order']:0; //************** rankRank 参数表获取 ************ + $topRanking = $rankMeta['rank_order']; //************** rankRank 参数表获取 ************ $rankPint = mt\Parameter::getVal('rank_pass_point',0); //************** parameter 参数表获取 ************ $rankPintArr = explode('|',$rankPint); $askedScore = $rankPintArr[$topRanking-1]; //一个玩家的赛后积分 = 赛前积分+K*(胜负率-总胜率)+2K*(表现分-段位要求的及格分) - //一个玩家的赛后积分 = 赛前积分+K/2*(MAX(胜负率-总胜率,0))+K*(表现分-段位要求的及格分) 新 - $K = mt\Parameter::getVal('rank_k',40); //************** parameter 参数表获取 ************ - $battleAfterScore = $userDb['score'] + $K/2 * max(($winRate-$winRateSum),0) + ($K) * ($expreScore-$askedScore); + //一个玩家的赛后积分 = 赛前积分+K/2*(MAX(胜负率-总胜率,0))+K*(表现分-段位要求的及格分) + //一个玩家的赛后积分 = 赛前积分+K/2*(MAX(胜负率-0.5,0))+K/2*(表现分-段位要求的及格分) 新 + $kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************ + $K = $kArr[$rankMeta['rank_order2']-1]; + $battleAfterScore = $userDb['score'] + $K/2 * max(($winRate-0.5),0) + ($K/2) * ($expreScore-$askedScore); return round($battleAfterScore); } @@ -368,7 +371,9 @@ class FormulaService extends BaseService { $winRate = 1-($ranked-1)/($maxRanked-1); //总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400)) $winRateSum = $winningPro; - $K = mt\Parameter::getVal('rank_k',40); //************** parameter 参数表获取 ************ + $rankMeta = mt\Rank::getRankById($userDb['rank']); + $kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************ + $K = $kArr[$rankMeta['rank_order2']-1]; return round(max($userDb['elo']+$K*($winRate-$winRateSum),150)); } From f5817e2e738f76987050a331185f6b0e78deebfd Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 11 Sep 2023 14:04:42 +0800 Subject: [PATCH 2/9] 1 --- webapp/controller/MailController.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 webapp/controller/MailController.class.php diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php new file mode 100644 index 00000000..08d3f5a8 --- /dev/null +++ b/webapp/controller/MailController.class.php @@ -0,0 +1,9 @@ + Date: Wed, 13 Sep 2023 16:25:40 +0800 Subject: [PATCH 3/9] 1 --- sql/gamedb.sql | 18 ++++++++++++++++++ sql/gamedb2006_migrate_230913_01.sql | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 sql/gamedb2006_migrate_230913_01.sql diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 8206cb0f..16cde481 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1651,3 +1651,21 @@ CREATE TABLE `t_staking` ( UNIQUE KEY `unikey2` (`token_id`, `contract_address`, `net_id`, `order_id`), KEY `address` (`address`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8; + +-- +-- Table structure for table `t_mail` +-- + +DROP TABLE IF EXISTS `t_mail`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_mail` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_id_mailid` (`account_id`, `mailid`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/sql/gamedb2006_migrate_230913_01.sql b/sql/gamedb2006_migrate_230913_01.sql new file mode 100644 index 00000000..171e3b2d --- /dev/null +++ b/sql/gamedb2006_migrate_230913_01.sql @@ -0,0 +1,15 @@ +begin; + +CREATE TABLE `t_mail` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_id_mailid` (`account_id`, `mailid`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +insert into version (version) values(2023091301); + +commit; From bdc86b2a84781ea58d870f880729d36667e251f8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Sep 2023 16:59:28 +0800 Subject: [PATCH 4/9] 1 --- webapp/controller/MailController.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php index 08d3f5a8..6a3af676 100644 --- a/webapp/controller/MailController.class.php +++ b/webapp/controller/MailController.class.php @@ -4,6 +4,7 @@ class MailController extends BaseAuthedController { public function getAttachment() { + } } From ef699fe8cd45bccc3786d0bf068810df4f02afd7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 13:20:36 +0800 Subject: [PATCH 5/9] 1 --- sql/gamedb.sql | 2 ++ sql/gamedb2006_migrate_230913_01.sql | 2 ++ webapp/controller/MailController.class.php | 40 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 16cde481..a8fa2add 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1663,6 +1663,8 @@ CREATE TABLE `t_mail` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', + `confirmed` int(11) NOT NULL DEFAULT '0' COMMENT 'confirmed', + `attachments` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '附件', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/sql/gamedb2006_migrate_230913_01.sql b/sql/gamedb2006_migrate_230913_01.sql index 171e3b2d..aeeecb19 100644 --- a/sql/gamedb2006_migrate_230913_01.sql +++ b/sql/gamedb2006_migrate_230913_01.sql @@ -4,6 +4,8 @@ CREATE TABLE `t_mail` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `mailid` bigint NOT NULL DEFAULT '0' COMMENT '邮件id', + `confirmed` int(11) NOT NULL DEFAULT '0' COMMENT 'confirmed', + `attachments` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '附件', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php index 6a3af676..a8e1e01d 100644 --- a/webapp/controller/MailController.class.php +++ b/webapp/controller/MailController.class.php @@ -3,8 +3,48 @@ class MailController extends BaseAuthedController { public function getAttachment() + { + $mailIds = getReqVal('mail_ids', ''); + + $response = ''; + { + $params = array( + 'c' => 'Mail', + 'a' => 'getAttachment', + 'account_id' => myself()->_getAccountId(), + 'session_id' => myself()->_getSessionId(), + 'mail_ids' => $mailIds + ); + + $url = self::getMailServerUrl(); + if (!phpcommon\HttpClient::get + ($url, + $params, + $response)) { + myself()->_rspErr(500, 'server internal error 3, url:' . $url); + die(); + return; + } + } + $rspObj = json_decode($response, true); + if ($rspObj && $rspObj['errcode'] == 0) { + $this->procAttachments($rspObj['attachments']); + } + echo $response; + } + + private function procAttachments($attachments) { } + private static function getMailServerUrl() + { + if (SERVER_ENV != _ONLINE) { + return "https://gamemail-test.kingsome.cn/webapp/index.php"; + } else { + return "https://gamemail-test.cebggame.com/webapp/index.php"; + } + } + } From a634aa152c9f2bbbe841e835c473c20677fd2fd6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 13:48:51 +0800 Subject: [PATCH 6/9] 1 --- webapp/controller/MailController.class.php | 74 +++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php index a8e1e01d..aea043de 100644 --- a/webapp/controller/MailController.class.php +++ b/webapp/controller/MailController.class.php @@ -1,7 +1,19 @@ propertyChgService = new services\PropertyChgService(); + $this->awardService = new services\AwardService(); + } + public function getAttachment() { $mailIds = getReqVal('mail_ids', ''); @@ -29,13 +41,73 @@ class MailController extends BaseAuthedController { $rspObj = json_decode($response, true); if ($rspObj && $rspObj['errcode'] == 0) { $this->procAttachments($rspObj['attachments']); + $rspObj['award'] = $this->awardService->toDto(); + $rspObj['property_chg'] = $this->propertyChgService->toDto(); } - echo $response; + echo json_encode($rspObj); } private function procAttachments($attachments) { + $mailHash = array(); + { + foreach ($attachments as $item) { + if (!array_key_exists($item['mailid'], $mailHash)) { + $mailHash[$item['mailid']] = array(); + } + array_push($mailHash[$item['mailid']], $item); + } + } + foreach ($mailHash as $key => $val) { + $mailId = $key; + $items = arary(); + foreach ($val as $item) { + array_push($items, array( + 'item_id' => $item['itemid'], + 'item_num' => $item['itemnum'], + )); + } + $row = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ) + ); + if (!$row) { + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ), + array( + ), + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId, + 'attachments' => json_encode($items), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + $this->_addItems($items, $this->awardService, $this->propertyChgService); + SqlHelper::update( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ), + array( + 'confirmed' => 1 + ) + ); + } + } } private static function getMailServerUrl() From 2123964dc7ff24da76691fa3c71e4d3cef85ee3f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 14:06:13 +0800 Subject: [PATCH 7/9] 1 --- webapp/controller/MailController.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php index aea043de..7b9934a9 100644 --- a/webapp/controller/MailController.class.php +++ b/webapp/controller/MailController.class.php @@ -2,6 +2,9 @@ use phpcommon\SqlHelper; +require_once('services/AwardService.php'); +require_once('services/PropertyChgService.php'); + class MailController extends BaseAuthedController { private $propertyChgService = null; @@ -38,6 +41,9 @@ class MailController extends BaseAuthedController { return; } } + error_log($mailIds); + error_log($response); + error_log($url); $rspObj = json_decode($response, true); if ($rspObj && $rspObj['errcode'] == 0) { $this->procAttachments($rspObj['attachments']); @@ -60,7 +66,7 @@ class MailController extends BaseAuthedController { } foreach ($mailHash as $key => $val) { $mailId = $key; - $items = arary(); + $items = array(); foreach ($val as $item) { array_push($items, array( 'item_id' => $item['itemid'], From fe66d824cd923d07738c0bd5e9993d47db743c12 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 14:46:44 +0800 Subject: [PATCH 8/9] 1 --- sql/{migrate => archived}/gamedb2006_migrate_230816_01.sql | 0 sql/{ => migrate}/gamedb2006_migrate_230913_01.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sql/{migrate => archived}/gamedb2006_migrate_230816_01.sql (100%) rename sql/{ => migrate}/gamedb2006_migrate_230913_01.sql (100%) diff --git a/sql/migrate/gamedb2006_migrate_230816_01.sql b/sql/archived/gamedb2006_migrate_230816_01.sql similarity index 100% rename from sql/migrate/gamedb2006_migrate_230816_01.sql rename to sql/archived/gamedb2006_migrate_230816_01.sql diff --git a/sql/gamedb2006_migrate_230913_01.sql b/sql/migrate/gamedb2006_migrate_230913_01.sql similarity index 100% rename from sql/gamedb2006_migrate_230913_01.sql rename to sql/migrate/gamedb2006_migrate_230913_01.sql From 368e71fc3aae96cd209ad942ae0e7c0e02fb3c11 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 14:52:06 +0800 Subject: [PATCH 9/9] 1 --- sql/{migrate => archived}/gamedb2006_migrate_230913_01.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql/{migrate => archived}/gamedb2006_migrate_230913_01.sql (100%) diff --git a/sql/migrate/gamedb2006_migrate_230913_01.sql b/sql/archived/gamedb2006_migrate_230913_01.sql similarity index 100% rename from sql/migrate/gamedb2006_migrate_230913_01.sql rename to sql/archived/gamedb2006_migrate_230913_01.sql