This commit is contained in:
aozhiwei 2023-09-14 14:06:28 +08:00
commit a18d1f7f70
4 changed files with 166 additions and 1 deletions

View File

@ -1651,3 +1651,23 @@ CREATE TABLE `t_staking` (
UNIQUE KEY `unikey2` (`token_id`, `contract_address`, `net_id`, `order_id`), UNIQUE KEY `unikey2` (`token_id`, `contract_address`, `net_id`, `order_id`),
KEY `address` (`address`) KEY `address` (`address`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8; ) 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 */;

View File

@ -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;

View File

@ -0,0 +1,128 @@
<?php
use phpcommon\SqlHelper;
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
class MailController extends BaseAuthedController {
private $propertyChgService = null;
private $awardService = null;
public function _handlePre()
{
parent::_handlePre();
$this->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";
}
}
}

View File

@ -371,8 +371,8 @@ class FormulaService extends BaseService {
$winRate = 1-($ranked-1)/($maxRanked-1); $winRate = 1-($ranked-1)/($maxRanked-1);
//总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400)) //总胜率=70%*P(个人ELO值-敌队平均ELO值)+30%*P(己队平均ELO值-敌队平均ELO值) --> P(D)=1/(1+10^(-D/400))
$winRateSum = $winningPro; $winRateSum = $winningPro;
$kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************
$rankMeta = mt\Rank::getRankById($userDb['rank']); $rankMeta = mt\Rank::getRankById($userDb['rank']);
$kArr = explode('|',mt\Parameter::getVal('rank_k',0)); //************** parameter 参数表获取 ************
$K = $kArr[$rankMeta['rank_order2']-1]; $K = $kArr[$rankMeta['rank_order2']-1];
return round(max($userDb['elo']+$K*($winRate-$winRateSum),150)); return round(max($userDb['elo']+$K*($winRate-$winRateSum),150));
} }