1
This commit is contained in:
parent
11d9c368f1
commit
9780c16ff8
@ -2056,4 +2056,26 @@ CREATE TABLE `t_circuit_battle` (
|
|||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
KEY `idx_account_season` (`account_id`, `season`)
|
KEY `idx_account_season` (`account_id`, `season`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_circuit_reward`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_circuit_reward`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_circuit_reward` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`address` varchar(60) CHARACTER SET utf8 COMMENT 'address',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT '赛季',
|
||||||
|
`stage` int(11) NOT NULL DEFAULT '0' COMMENT '阶段',
|
||||||
|
`ranking` int(11) NOT NULL DEFAULT '0' COMMENT '排名',
|
||||||
|
`reward_num` int(11) NOT NULL DEFAULT '0' COMMENT '奖励',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
KEY `account_season_stage` (`account_id`, `season`, `stage`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
19
sql/gamedb2006_migrate_240920_01.sql
Normal file
19
sql/gamedb2006_migrate_240920_01.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
CREATE TABLE `t_circuit_reward` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
|
`address` varchar(60) CHARACTER SET utf8 COMMENT 'address',
|
||||||
|
`season` int(11) NOT NULL DEFAULT '0' COMMENT '赛季',
|
||||||
|
`stage` int(11) NOT NULL DEFAULT '0' COMMENT '阶段',
|
||||||
|
`ranking` int(11) NOT NULL DEFAULT '0' COMMENT '排名',
|
||||||
|
`reward_num` int(11) NOT NULL DEFAULT '0' COMMENT '奖励',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
KEY `account_season_stage` (`account_id`, `season`, `stage`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
insert into version (version) values(2024091501);
|
||||||
|
|
||||||
|
commit;
|
@ -17,6 +17,20 @@ use phpcommon\SqlHelper;
|
|||||||
class CircuitController extends BaseAuthedController {
|
class CircuitController extends BaseAuthedController {
|
||||||
private $redis_key_circuit_ranking = 'circuit_ranking';
|
private $redis_key_circuit_ranking = 'circuit_ranking';
|
||||||
|
|
||||||
|
public function _handlePre()
|
||||||
|
{
|
||||||
|
parent::_handlePre();
|
||||||
|
if (!myself()->_switchIsOpen('circuitMatch')) {
|
||||||
|
$this->_rspErr(1, 'current stage Have not yet started');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(count(CIRCUIT_MATCH_SERVER_LIST) <= 0 &&
|
||||||
|
in_array(myself()->_getZid(), CIRCUIT_MATCH_SERVER_LIST))) {
|
||||||
|
$this->_rspErr(1, 'current stage Have not yet started');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getCurrentStage(){
|
public function getCurrentStage(){
|
||||||
$circuitStageMeta = mt\CircuitTime::getCurrentStage();
|
$circuitStageMeta = mt\CircuitTime::getCurrentStage();
|
||||||
if (!$circuitStageMeta){
|
if (!$circuitStageMeta){
|
||||||
|
63
webapp/controller/OutAppCircuitController.class.php
Normal file
63
webapp/controller/OutAppCircuitController.class.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
require_once('services/ServerSwitchService.php');
|
||||||
|
|
||||||
|
require_once('mt/Parameter.php');
|
||||||
|
require_once('mt/CircuitTime.php');
|
||||||
|
require_once('mt/CircuitReward.php');
|
||||||
|
|
||||||
|
require_once('models/CircuitReward.php');
|
||||||
|
require_once('models/Circuit.php');
|
||||||
|
require_once('models/User.php');
|
||||||
|
|
||||||
|
use services\ServerSwitchService;
|
||||||
|
use models\CircuitReward;
|
||||||
|
use models\Circuit;
|
||||||
|
use models\User;
|
||||||
|
class OutAppCircuitController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
public function circuitSettlement(){
|
||||||
|
$currentStageMeta = \mt\CircuitTime::getCurrentStage();
|
||||||
|
$prevStageMeta = \mt\CircuitTime::getPrevStage();
|
||||||
|
|
||||||
|
if (!$currentStageMeta && $prevStageMeta && !CircuitReward::_verifySettlement($prevStageMeta['circuit_season'],$prevStageMeta['circuit_phase'])){
|
||||||
|
$rows = Circuit::getRankingList($prevStageMeta['circuit_season']);
|
||||||
|
if (count($rows) > 0){
|
||||||
|
$totalWeight = 0;
|
||||||
|
$rate = \mt\Parameter::getVal('circuit_reward_rate','');
|
||||||
|
$count = floor(count($rows) * $rate) ;
|
||||||
|
foreach ($rows as $k=>$value){
|
||||||
|
$ranking = $k+1;
|
||||||
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
||||||
|
if ($ranking <= $count){
|
||||||
|
$totalWeight += $rewardWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cecPool = $prevStageMeta['cec_pool'];
|
||||||
|
foreach ($rows as $k=>$value){
|
||||||
|
$cec = 0;
|
||||||
|
$ranking = $k+1;
|
||||||
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
||||||
|
if ($ranking <= $count){
|
||||||
|
$cec = ($rewardWeight / $totalWeight) * $cecPool;
|
||||||
|
}
|
||||||
|
$user = User::find($value['account_id']);
|
||||||
|
CircuitReward::add(
|
||||||
|
$user['account_id'],
|
||||||
|
$user['address'],
|
||||||
|
$prevStageMeta['circuit_season'],
|
||||||
|
$prevStageMeta['circuit_phase'],
|
||||||
|
$ranking,
|
||||||
|
$cec
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_rspErr(1,'未满足结算条件');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -47,7 +47,7 @@ class Circuit extends BaseModel
|
|||||||
$whereKv = array(
|
$whereKv = array(
|
||||||
"season" => $season,
|
"season" => $season,
|
||||||
);
|
);
|
||||||
$rows = myself()->_getSelfMysql()->execQuery($sql,$whereKv);
|
$rows = myself()->_getMysql('')->execQuery($sql,$whereKv);
|
||||||
if (!$rows){
|
if (!$rows){
|
||||||
$rows = array();
|
$rows = array();
|
||||||
}
|
}
|
||||||
|
50
webapp/models/CircuitReward.php
Normal file
50
webapp/models/CircuitReward.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class CircuitReward extends BaseModel
|
||||||
|
{
|
||||||
|
public static function _verifySettlement($season,$stage){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_circuit_reward',
|
||||||
|
array(
|
||||||
|
'season' => $season,
|
||||||
|
'stage' => $stage
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($row){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($account,$address,$season,$stage,$ranking,$rewardNum){
|
||||||
|
SqlHelper::upsert(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_circuit_reward',
|
||||||
|
array(
|
||||||
|
'account_id' => $account,
|
||||||
|
'season' => $season,
|
||||||
|
'stage' => $stage
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $account,
|
||||||
|
'address' => $address,
|
||||||
|
'season' => $season,
|
||||||
|
'stage' => $stage,
|
||||||
|
'ranking' => $ranking,
|
||||||
|
'reward_num' => $rewardNum,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,16 @@ class CircuitTime {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPrevStage(){
|
||||||
|
$prev = array();
|
||||||
|
foreach (self::getCircuitAll(self::STAGE_SEASON_TYPE) as $meta){
|
||||||
|
if (myself()->_getNowTime() > strtotime($meta['end_time'])){
|
||||||
|
$prev = $meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $prev;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getCurrentStage(){
|
public static function getCurrentStage(){
|
||||||
foreach (self::getCircuitAll(self::STAGE_SEASON_TYPE) as $meta){
|
foreach (self::getCircuitAll(self::STAGE_SEASON_TYPE) as $meta){
|
||||||
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
|
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user