From c63ba8e2d0d0248e631920a39b884c29edf2b4d7 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Fri, 9 Dec 2022 14:36:02 +0800 Subject: [PATCH] 1 --- .../EventRankingController.class.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/webapp/controller/EventRankingController.class.php b/webapp/controller/EventRankingController.class.php index f9135e3f..6d501a70 100644 --- a/webapp/controller/EventRankingController.class.php +++ b/webapp/controller/EventRankingController.class.php @@ -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(); + } }