176 lines
6.0 KiB
PHP
176 lines
6.0 KiB
PHP
<?php
|
|
|
|
namespace services;
|
|
|
|
require_once('models/User.php');
|
|
require_once('models/Hero.php');
|
|
require_once('models/HeroSkin.php');
|
|
|
|
require_once('mt/CircuitTime.php');
|
|
require_once('mt/CircuitTime.php');
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
use models\User;
|
|
use models\Hero;
|
|
use models\HeroSkin;
|
|
|
|
class CircuitRankingService extends BaseService {
|
|
|
|
public static function fillPhaseRanking($currentCircuitMeta, $currentStageMeta)
|
|
{
|
|
$rows = myself()->_callModelStatic('Circuit', 'getCircuitPhaseList',
|
|
$currentStageMeta['circuit_season'],
|
|
$currentStageMeta['circuit_phase']);
|
|
if (count($rows) < 100) {
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
public static function fillRanking($currentCircuitMeta)
|
|
{
|
|
$rows = myself()->_callModelStatic('Circuit', 'getCircuitList',
|
|
$currentCircuitMeta['circuit_season']);
|
|
if (count($rows) < 100) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
public static function repairPhaseRanking($currentCircuitMeta)
|
|
{
|
|
$rows = myself()->_callModelStatic('Circuit', 'getCircuitPhaseList',
|
|
$currentStageMeta['circuit_season'],
|
|
$currentStageMeta['circuit_phase']);
|
|
$androidHash = array();
|
|
foreach ($rows as $row) {
|
|
$androidHash[$row['account_id']] = $row;
|
|
}
|
|
$androidHashDb = self::getAndroidHashDb($androidHash);
|
|
if (count($androidHash) < 100) {
|
|
for ($i = count($androidHash); $i < 100; $i++) {
|
|
if (!empty($androidHashDb)) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function getAndroidHashDb($alreadyAndroidHash)
|
|
{
|
|
$androidHash = array();
|
|
$rows = SqlHelper::ormSelectOne
|
|
($this->_getMysql(''),
|
|
't_android',
|
|
array(
|
|
'used' => 0
|
|
)
|
|
);
|
|
foreach ($rows as $row) {
|
|
if (!array_key_exists($row['robot_id'], $alreadyAndroidHash)) {
|
|
$androidHash[$row['robot_id']] = $row;
|
|
}
|
|
}
|
|
return $androidHash;
|
|
}
|
|
|
|
public static function repairRanking($currentCircuitMeta)
|
|
{
|
|
$rows = myself()->_callModelStatic('Circuit', 'getCircuitList',
|
|
$currentCircuitMeta['circuit_season']);
|
|
if (count($rows) < 100) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
public static function genAndroidData()
|
|
{
|
|
$currentStageMeta = mt\CircuitTime::getCurrentStage();
|
|
if (empty($currentStageMeta)) {
|
|
myself()->_rspErr(1, 'currentStageMeta Is empty');
|
|
return;
|
|
}
|
|
$rows = SqlHelper::ormSelect
|
|
(myself()->_getMysql(''),
|
|
't_android',
|
|
array(
|
|
'used' => 0
|
|
)
|
|
);
|
|
foreach ($rows as $row) {
|
|
SqlHelper::upsert
|
|
(myself()->_getMysql(''),
|
|
't_circuit_battle_phase',
|
|
array(
|
|
'account_id' => $row['robot_id'],
|
|
'season' => $currentStageMeta['circuit_season'],
|
|
'phase' => $currentStageMeta['circuit_phase'],
|
|
),
|
|
array(),
|
|
array(
|
|
'account_id' => $row['robot_id'],
|
|
'is_android' => 1,
|
|
'cumulative_score' => 10,
|
|
'season' => $currentStageMeta['circuit_season'],
|
|
'phase' => $currentStageMeta['circuit_phase'],
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
myself()->_rspOk();
|
|
}
|
|
|
|
public static function extractRankingInfo($data){
|
|
$rankingList = array();
|
|
$ranking = 0;
|
|
foreach ($data as $k=>$row){
|
|
++$ranking;
|
|
$userDb = null;
|
|
$heroDb = null;
|
|
$heroId = 0;
|
|
$skinId = 0;
|
|
if ($row['is_android']) {
|
|
$robotMeta = myself()->_callMtStatic('Robot', 'get', $row['account_id']);
|
|
$userDb = array(
|
|
'account_id' => $row['account_id'],
|
|
'name' => $robotMeta['name'],
|
|
'head_id' => 50001,
|
|
'head_frame' => 60000,
|
|
);
|
|
$heroDb = array(
|
|
'hero_id' => $robotMeta['hero_id'],
|
|
'skin_id' => 0,
|
|
);
|
|
$heroId = $heroDb ? $heroDb['hero_id']:0;
|
|
$skinId = $skinDb ? $skinDb['skin_id']:0;
|
|
} else {
|
|
$userDb = User::find($row['account_id']);
|
|
$heroDb = Hero::findByAccountId($userDb['account_id'],$userDb['hero_id']);
|
|
$skinDb = HeroSkin::findByAccountId($heroDb['skin_id'], $userDb['account_id']);
|
|
$heroId = $heroDb ? $heroDb['hero_id']:0;
|
|
$skinId = $skinDb ? $skinDb['skin_id']:0;
|
|
}
|
|
error_log(json_encode($row));
|
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
|
if ($userDb){
|
|
$info = array(
|
|
'account_id' => $userDb['account_id'],
|
|
'name' => utf8_encode($userDb['name']),
|
|
'head_id' => $userDb['head_id'],
|
|
'head_frame' => $userDb['head_frame'],
|
|
'hero_id' => $heroId,
|
|
'skin_id' => $skinId,
|
|
'ranking' => $ranking,
|
|
'weight' => $rewardWeight,
|
|
#'score' => $row['cumulative_score'],
|
|
'score' => number_format($row['cumulative_score'], 2, '.', ''),
|
|
'score_boost' => number_format($row['score_boost'], 2, '.', ''),
|
|
);
|
|
array_push($rankingList,$info);
|
|
}
|
|
}
|
|
return $rankingList;
|
|
}
|
|
|
|
}
|