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|'],
['heros', '', '武器信息 hero_id:skill_lv:weapon_lv|'],
['rank_score', 0, '排位积分'],
#['rank_score', 0, '排位积分'],
['pass_score', 0, '通行证积分'],
['items', 0, '道具|分割'],
],

View File

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

View File

@ -36,6 +36,7 @@ CREATE TABLE `t_user` (
`level` int(11) NOT NULL DEFAULT '0' COMMENT '等级',
`exp` 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 '积分',
`gold` 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',
`card_lv` 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 '赛季积分',
`max_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季最高积分',
`rank` 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_buytime1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买时间',
`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/Hero.php');
require_once('models/Season.php');
require_once('mt/Parameter.php');
require_once('mt/Drop.php');
@ -17,6 +18,7 @@ require_once('services/NameService.php');
use phpcommon\SqlHelper;
use models\User;
use models\Hero;
use models\Season;
class UserController extends BaseAuthedController {
@ -330,40 +332,53 @@ class UserController extends BaseAuthedController {
public function detailInfo()
{
$targetId = getReqVal('target_id', '');
$userDb = SqlHelper::ormSelectOne
($this->_getMysql($targetId),
't_user',
array(
'account_id' => $targetId
)
);
$userDb = User::find($targetId);
if (!$userDb) {
$this->_rspErr(1, '账号不存在');
return;
}
$userDto = User::info($userDb);
$userDto['current_rank'] = 1;
$userDto['history_best_rank'] = 1;
$userDto['history_seasons'] = array(
$userDto['current_rank'] = $userDb['rank'];
$userDto['history_seasons'] = array();
$seasonDbs = Season::getHistorySeasons($targetId);
foreach ($seasonDbs as $seasonDb) {
$battleData = json_decode($seasonDb['battle_data'], true);
$seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array();
$gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0);
$winTimes = getXVal($seasonBattleData, 'total_win_times', 0);
$winRate = $gameTimes > 0 ? intval($winTimes / $gameTimes * 100) : 0;
$totalKills = getXVal($seasonBattleData, 'total_kills_times', 0);
$totalDamage = getXVal($seasonBattleData, 'total_damage_out', 0);
$totalAlive = getXVal($seasonBattleData, 'total_alive_time', 0);
$totalRecoverHp = getXVal($seasonBattleData, 'total_recover_hp', 0);
$avgDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes) : 0;
$avgKills = $gameTimes > 0 ? intval($totalKills / $gameTimes) : 0;
$starKills = $gameTimes > 0 ? intval($totalKills / $gameTimes / 10 *100) : 0;
$starDamage = $gameTimes > 0 ? intval($totalDamage / $gameTimes / 1500 * 100) : 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' => 0,
'total_kills' => 0,
'game_times' => 0,
'win_times' => 0,
'win_rate' => 0,
'max_kills' => 0,
'avg_kills' => 0,
'max_damage_out' => 0,
'avg_damage_out' => 0,
'star_kills' => 0,
'star_damage' => 0,
'star_alive' => 0,
'star_recover' => 0,
'star_win' => 0,
)
);
'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(
'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)
{
if (in_array($packageId, array(

View File

@ -9,6 +9,18 @@ use phpcommon\SqlHelper;
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)
{
return array(
@ -22,6 +34,7 @@ class User extends BaseModel {
'exp' => $row['exp'],
'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'],
'gold' => $row['gold'],
'diamond' => $row['diamond'],
@ -45,6 +58,7 @@ class User extends BaseModel {
'exp' => $row['exp'],
'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'],
'gold' => $row['gold'],
'diamond' => $row['diamond'],