diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 8206cb0f..a8fa2add 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1651,3 +1651,23 @@ 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', + `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`), + 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..aeeecb19 --- /dev/null +++ b/sql/gamedb2006_migrate_230913_01.sql @@ -0,0 +1,17 @@ +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', + `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`), + 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; diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php new file mode 100644 index 00000000..7b9934a9 --- /dev/null +++ b/webapp/controller/MailController.class.php @@ -0,0 +1,128 @@ +propertyChgService = new services\PropertyChgService(); + $this->awardService = new services\AwardService(); + } + + 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; + } + } + error_log($mailIds); + error_log($response); + error_log($url); + $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 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 = array(); + 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() + { + if (SERVER_ENV != _ONLINE) { + return "https://gamemail-test.kingsome.cn/webapp/index.php"; + } else { + return "https://gamemail-test.cebggame.com/webapp/index.php"; + } + } + +} diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index fb9e6a4d..242111e1 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -371,8 +371,8 @@ 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; - $kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** 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)); }