This commit is contained in:
aozhiwei 2021-12-17 14:03:38 +08:00
parent fea8a073dd
commit ebdbd71f6c
6 changed files with 74 additions and 30 deletions

View File

@ -40,7 +40,7 @@ class Battle(object):
['weapons_slot', '', '武器信息 weapon_id:use_times|'], ['weapons_slot', '', '武器信息 weapon_id:use_times|'],
['heros', '', '武器信息 hero_id:skill_lv:weapon_lv|'], ['heros', '', '武器信息 hero_id:skill_lv:weapon_lv|'],
['rank_score', 0, '排位积分'], #['rank_score', 0, '排位积分'],
['pass_score', 0, '通行证积分'], ['pass_score', 0, '通行证积分'],
['items', 0, '道具|分割'], ['items', 0, '道具|分割'],
], ],

View File

@ -45,6 +45,8 @@ class UserInfo(object):
['level', 0, '等级'], ['level', 0, '等级'],
['exp', 0, '经验'], ['exp', 0, '经验'],
['max_exp', 0, '经验(上限)'], ['max_exp', 0, '经验(上限)'],
['rank', 0, '当前段位'],
['history_best_rank', 0, '历史最高段位'],
['gold', 0, '金币'], ['gold', 0, '金币'],
['diamond', 0, '钻石'], ['diamond', 0, '钻石'],
['hero_id', 0, '当前使用的英雄ID'], ['hero_id', 0, '当前使用的英雄ID'],

View File

@ -36,6 +36,7 @@ CREATE TABLE `t_user` (
`level` int(11) NOT NULL DEFAULT '0' COMMENT '等级', `level` int(11) NOT NULL DEFAULT '0' COMMENT '等级',
`exp` int(11) NOT NULL DEFAULT '0' COMMENT '经验', `exp` int(11) NOT NULL DEFAULT '0' COMMENT '经验',
`rank` int(11) NOT NULL DEFAULT '0' COMMENT '段位', `rank` int(11) NOT NULL DEFAULT '0' COMMENT '段位',
`history_best_rank` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高段位',
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分', `score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
`gold` int(11) NOT NULL DEFAULT '0' COMMENT '金币', `gold` int(11) NOT NULL DEFAULT '0' COMMENT '金币',
`diamond` int(11) NOT NULL DEFAULT '0' COMMENT '钻石', `diamond` int(11) NOT NULL DEFAULT '0' COMMENT '钻石',
@ -272,8 +273,8 @@ CREATE TABLE `t_season` (
`season_id` int(11) NOT NULL DEFAULT '0' COMMENT '赛季id', `season_id` int(11) NOT NULL DEFAULT '0' COMMENT '赛季id',
`card_lv` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册等级', `card_lv` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册等级',
`card_exp` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册经验', `card_exp` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册经验',
`total_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季积分', `rank` int(11) NOT NULL DEFAULT '0' COMMENT '段位',
`max_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季最高积分', `score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
`gift_state1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买状态 0:未购 1:已购', `gift_state1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买状态 0:未购 1:已购',
`gift_buytime1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买时间', `gift_buytime1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买时间',
`gift_state2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买状态 0:未购 1:已购', `gift_state2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买状态 0:未购 1:已购',

View File

@ -2,6 +2,7 @@
require_once('models/User.php'); require_once('models/User.php');
require_once('models/Hero.php'); require_once('models/Hero.php');
require_once('models/Season.php');
require_once('mt/Parameter.php'); require_once('mt/Parameter.php');
require_once('mt/Drop.php'); require_once('mt/Drop.php');
@ -17,6 +18,7 @@ require_once('services/NameService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\User; use models\User;
use models\Hero; use models\Hero;
use models\Season;
class UserController extends BaseAuthedController { class UserController extends BaseAuthedController {
@ -330,40 +332,53 @@ class UserController extends BaseAuthedController {
public function detailInfo() public function detailInfo()
{ {
$targetId = getReqVal('target_id', ''); $targetId = getReqVal('target_id', '');
$userDb = SqlHelper::ormSelectOne $userDb = User::find($targetId);
($this->_getMysql($targetId),
't_user',
array(
'account_id' => $targetId
)
);
if (!$userDb) { if (!$userDb) {
$this->_rspErr(1, '账号不存在'); $this->_rspErr(1, '账号不存在');
return; return;
} }
$userDto = User::info($userDb); $userDto = User::info($userDb);
$userDto['current_rank'] = 1; $userDto['current_rank'] = $userDb['rank'];
$userDto['history_best_rank'] = 1; $userDto['history_seasons'] = array();
$userDto['history_seasons'] = array( $seasonDbs = Season::getHistorySeasons($targetId);
array( foreach ($seasonDbs as $seasonDb) {
'season_id' => 0, $battleData = json_decode($seasonDb['battle_data'], true);
'total_kills' => 0, $seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
'game_times' => 0, $gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
'win_times' => 0, $winTimes = getXVal($seasonBattleData, 'total_win_times', 0);
'win_rate' => 0, $winRate = $gameTimes > 0 ? intval($winTimes / $gameTimes * 100) : 0;
'max_kills' => 0, $totalKills = getXVal($seasonBattleData, 'total_kills_times', 0);
'avg_kills' => 0, $totalDamage = getXVal($seasonBattleData, 'total_damage_out', 0);
'max_damage_out' => 0, $totalAlive = getXVal($seasonBattleData, 'total_alive_time', 0);
'avg_damage_out' => 0, $totalRecoverHp = getXVal($seasonBattleData, 'total_recover_hp', 0);
'star_kills' => 0, $avgDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes) : 0;
'star_damage' => 0, $avgKills = $gameTimes > 0 ? intval($totalKills / $gameTimes) : 0;
'star_alive' => 0, $starKills = $gameTimes > 0 ? intval($totalKills / $gameTimes / 10 *100) : 0;
'star_recover' => 0, $starDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes / 1500 * 100) : 0;
'star_win' => 0, $starAlive = $gameTimes > 0 ? intval($totalAlive / $gameTimes / 300 * 0.1) : 0;
) $starRecover = $gameTimes > 0 ? intval($totalRecoverHp / $gameTimes / 300 * 100) : 0;
); $starWin = $gameTimes > 0 ? intval($winTimes / $gameTimes / 0.5 * 100) : 0;
array_push($userDto['history_seasons'],
array(
'season_id' => $seasonDb['season_id'],
'total_kills' => $totalKills,
'game_times' => $gameTimes,
'win_times' => $winTimes,
'win_rate' => $winRate,
'max_kills' => getXVal($seasonBattleData, 'max_kills_times', 0),
'avg_kills' => $avgKills,
'max_damage_out' => getXVal($seasonBattleData, 'max_damage_out', 0),
'avg_damage_out' => $avgDamage,
'star_kills' => min(100, $starKills),
'star_damage' => min(100, $starDamage),
'star_alive' => min(100, $starAlive),
'star_recover' => min(100, $starRecover),
'star_win' => min(100, $starWin),
));
}
$this->_rspData(array( $this->_rspData(array(
'info' => $userDto 'info' => $userDto
)); ));
} }
} }

View File

@ -51,6 +51,18 @@ class Season extends BaseModel {
); );
} }
public static function getHistorySeasons($targetId)
{
$rows = SqlHelper::ormSelect(
myself()->_getMysql($targetId),
't_season',
array(
'account_id' => $targetId,
)
);
return $rows;
}
public static function updateGiftPackageState($seasonId, $packageId) public static function updateGiftPackageState($seasonId, $packageId)
{ {
if (in_array($packageId, array( if (in_array($packageId, array(

View File

@ -9,6 +9,18 @@ use phpcommon\SqlHelper;
class User extends BaseModel { class User extends BaseModel {
public function find($targetId)
{
$row = SqlHelper::ormSelectOne
($this->_getMysql($targetId),
't_user',
array(
'account_id' => $targetId
)
);
return $row ? $row : null;
}
public static function show($row) public static function show($row)
{ {
return array( return array(
@ -22,6 +34,7 @@ class User extends BaseModel {
'exp' => $row['exp'], 'exp' => $row['exp'],
'max_exp' => $row['exp'] + 1000, 'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'], 'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'], 'score' => $row['score'],
'gold' => $row['gold'], 'gold' => $row['gold'],
'diamond' => $row['diamond'], 'diamond' => $row['diamond'],
@ -45,6 +58,7 @@ class User extends BaseModel {
'exp' => $row['exp'], 'exp' => $row['exp'],
'max_exp' => $row['exp'] + 1000, 'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'], 'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'], 'score' => $row['score'],
'gold' => $row['gold'], 'gold' => $row['gold'],
'diamond' => $row['diamond'], 'diamond' => $row['diamond'],