Merge branch 'hjb' into james_bc

This commit is contained in:
hujiabin 2022-12-09 19:33:13 +08:00
commit c10fe7bb53

View File

@ -10,6 +10,7 @@ require_once('services/RankActivityService.php');
use models\User;
use models\Guild;
use models\EventRanking;
use phpcommon\SqlHelper;
class EventRankingController extends BaseAuthedController
{
public function eventRankingList(){
@ -458,5 +459,82 @@ class EventRankingController extends BaseAuthedController
// }
}
public function updateWinsData(){
$rows = myself()->_getSelfMysql()->execQuery(
'SELECT * FROM t_rank_activity ' .
'WHERE wave=:wave AND type=:type ',
array(
':wave' => 1,
':type' => 2
)
);
foreach ($rows as &$row){
$battle_record = myself()->_getSelfMysql()->execQuery(
'SELECT * FROM t_battle_record ' .
'WHERE account_id=:account_id AND createtime>:createtime1 AND createtime<:createtime2 ',
array(
':account_id' => $row['account_id'],
':createtime1' => 1669896000,
':createtime2' => 1670500800,
)
);
foreach ($battle_record as $value){
$request = emptyReplace(json_decode($value['request'], true), array());
if ($request['ranked'] == 1 && $request['match_mode'] == 0){
$row['new_value']+=1;
}
}
}
foreach ($rows as $row){
SqlHelper::update
(myself()->_getSelfMysql(),
't_rank_activity',
array(
'account_id' => $row['account_id'],
'wave' => 1,
'type' => 2,
),
array(
'value'=>$row['new_value']?$row['new_value']:0
)
);
}
$this->_rspOk();
}
public function compensationWins(){
$rows = myself()->_getSelfMysql()->execQuery(
'SELECT * FROM t_rank_activity ' .
'WHERE wave=:wave AND type=:type ' .
'ORDER BY value DESC ',
array(
':wave' => 1,
':type' => 2
)
);
$compensationList= array();
$ranked = 0;
foreach ($rows as $row) {
$ranked += 1;
if ($ranked>10 && $row['value'] >0){
array_push($compensationList,array(
'ranked'=>$ranked,
'account_id'=>$row['account_id'],
'rewardNum'=>5,
'value'=>$row['value']
));
}
}
if ($compensationList){
//记录此活动的CEG奖励
foreach ($compensationList as $value){
$cegNum = $value['rewardNum'];
EventRanking::setV($value['account_id'],1,9999,$cegNum);
}
}
error_log('********** WIN RANKING COMPENSATION SUCCESS ***********');
$this->_rspOk();
}
}