merge old code
This commit is contained in:
parent
21c4162538
commit
64a5aefaf1
BIN
doc/BattlePass.py
Normal file
BIN
doc/BattlePass.py
Normal file
Binary file not shown.
@ -1156,3 +1156,22 @@ CREATE TABLE `t_shop_buy_order` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_user_pass`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_user_pass`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_user_pass` (
|
||||||
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL COMMENT '账户id',
|
||||||
|
`season_id` int(11) NOT NULL DEFAULT '0' COMMENT '通行证赛季',
|
||||||
|
`data` mediumblob COMMENT 'data',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account_season_id` (`account_id`, `season_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
19
sql/gamedb2006_migrate_230614_01.sql
Normal file
19
sql/gamedb2006_migrate_230614_01.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
update t_user set level=1 where level>1;
|
||||||
|
update t_user set exp=0 where exp>0;
|
||||||
|
|
||||||
|
CREATE TABLE `t_user_pass` (
|
||||||
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account_id` varchar(60) NOT NULL COMMENT '账户id',
|
||||||
|
`season_id` int(11) NOT NULL DEFAULT '0' COMMENT '通行证赛季',
|
||||||
|
`data` mediumblob COMMENT 'data',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account_season_id` (`account_id`, `season_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
insert into version (version) values(2023061401);
|
||||||
|
|
||||||
|
commit;
|
237
webapp/controller/PassController.class.php
Normal file
237
webapp/controller/PassController.class.php
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
<?php
|
||||||
|
require_once('services/AwardService.php');
|
||||||
|
require_once('services/PropertyChgService.php');
|
||||||
|
|
||||||
|
require_once('mt/BattlePass.php');
|
||||||
|
require_once('mt/StarLevel.php');
|
||||||
|
|
||||||
|
require_once('models/Pass.php');
|
||||||
|
require_once('models/RealtimeData.php');
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
use models\Pass;
|
||||||
|
use models\RealtimeData;
|
||||||
|
class PassController extends BaseAuthedController {
|
||||||
|
|
||||||
|
private $awardService = null;
|
||||||
|
private $propertyChgService = null;
|
||||||
|
private $userInfo = null;
|
||||||
|
private $currSeasonMeta = null;
|
||||||
|
public function _handlePre()
|
||||||
|
{
|
||||||
|
// if(getReqVal('a', '') != 'resetStar'){
|
||||||
|
parent::_handlePre();
|
||||||
|
// }
|
||||||
|
|
||||||
|
$this->currSeasonMeta = \mt\BattlePass::getCurrentSeason();
|
||||||
|
if (!$this->currSeasonMeta) {
|
||||||
|
$this->_rspErr(10, 'season server internal error');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$this->propertyChgService = new services\PropertyChgService();
|
||||||
|
$this->awardService = new services\AwardService();
|
||||||
|
$this->userInfo = $this->_getOrmUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getPassList(){
|
||||||
|
$row = Pass::find($this->currSeasonMeta['id']);
|
||||||
|
if (!$row){
|
||||||
|
$this->_initPassList($this->currSeasonMeta['id']);
|
||||||
|
$row = Pass::find($this->currSeasonMeta['id']);
|
||||||
|
}
|
||||||
|
$data = emptyReplace(json_decode($row['data'], true), array());
|
||||||
|
$this->_rspData(array(
|
||||||
|
'time_info' => array(
|
||||||
|
'begin_time'=>strtotime($this->currSeasonMeta['begin_time']),
|
||||||
|
'end_time'=>strtotime($this->currSeasonMeta['end_time'])
|
||||||
|
),
|
||||||
|
'reward_info' => $data,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commit(){
|
||||||
|
$level = getReqVal('level', 0);
|
||||||
|
$type= getReqVal('type', 0);
|
||||||
|
$passMeta = \mt\BattlePass::find($level);
|
||||||
|
if (!$passMeta){
|
||||||
|
$this->_rspErr(1, 'param error or null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->userInfo['level'] < $level){
|
||||||
|
$this->_rspErr(1, 'objectives not achieved');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$passDb = Pass::find($this->currSeasonMeta['id']);
|
||||||
|
$rewards = emptyReplace(json_decode($passDb['data'], true), array());
|
||||||
|
|
||||||
|
$data = $this->_rewardHash($rewards);
|
||||||
|
$items = array();
|
||||||
|
switch ($type){
|
||||||
|
case 0 : {
|
||||||
|
if ($data['basic'][$level]['state'] != 0){
|
||||||
|
$this->_rspErr(1, "basic Can't get it again");
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
array_push($items,array(
|
||||||
|
'item_id'=>$passMeta['basic_item_id'],
|
||||||
|
'item_num'=>$passMeta['basic_item_num'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1 : {
|
||||||
|
if ($this->userInfo['activated'] != 1){
|
||||||
|
$this->_rspErr(1, "don't is platinum pass ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($data['platinum'][$level]['state'] != 0){
|
||||||
|
$this->_rspErr(1, "platinum Can't get it again");
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
array_push($items,array(
|
||||||
|
'item_id'=>$passMeta['platinum_item_id1'],
|
||||||
|
'item_num'=>$passMeta['platinum_item_num1'],
|
||||||
|
));
|
||||||
|
array_push($items,array(
|
||||||
|
'item_id'=>$passMeta['platinum_item_id2'],
|
||||||
|
'item_num'=>$passMeta['platinum_item_num2'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default : {
|
||||||
|
$this->_rspErr(1, "param type is error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_addItems($items,$this->awardService, $this->propertyChgService);
|
||||||
|
switch ($type){
|
||||||
|
case 0 : {
|
||||||
|
$data['basic'][$level]['state'] = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1 : {
|
||||||
|
$data['platinum'][$level]['state'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pass::upsert($this->currSeasonMeta['id'],json_encode($data));
|
||||||
|
$this->_rspData(array(
|
||||||
|
'award' => $this->awardService->toDto(),
|
||||||
|
'property_chg' => $this->propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commitAll(){
|
||||||
|
$passDb = Pass::find($this->currSeasonMeta['id']);
|
||||||
|
$rewards = emptyReplace(json_decode($passDb['data'], true), array());
|
||||||
|
foreach ($rewards['basic'] as &$reward){
|
||||||
|
if ($this->userInfo['level'] >= $reward['level'] && $reward['state']==0){
|
||||||
|
$passMeta = \mt\BattlePass::find($reward['level']);
|
||||||
|
$items = array(
|
||||||
|
array(
|
||||||
|
'item_id'=>$passMeta['basic_item_id'],
|
||||||
|
'item_num'=>$passMeta['basic_item_num'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->_addItems($items,$this->awardService, $this->propertyChgService);
|
||||||
|
$reward['state'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->userInfo['activated']){
|
||||||
|
foreach ($rewards['platinum'] as &$reward){
|
||||||
|
if ($this->userInfo['level'] >= $reward['level'] && $reward['state']==0){
|
||||||
|
$passMeta = \mt\BattlePass::find($reward['level']);
|
||||||
|
$items = array(
|
||||||
|
array(
|
||||||
|
'item_id'=>$passMeta['platinum_item_id1'],
|
||||||
|
'item_num'=>$passMeta['platinum_item_num1'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'item_id'=>$passMeta['platinum_item_id2'],
|
||||||
|
'item_num'=>$passMeta['platinum_item_num2'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->_addItems($items,$this->awardService, $this->propertyChgService);
|
||||||
|
$reward['state'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pass::upsert($this->currSeasonMeta['id'],json_encode($rewards));
|
||||||
|
$this->_rspData(array(
|
||||||
|
'award' => $this->awardService->toDto(),
|
||||||
|
'property_chg' => $this->propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activePlatinumPass(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buyPassLevel(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassLevel(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _rewardHash($reward){
|
||||||
|
if (!$reward){
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$data = array();
|
||||||
|
foreach ($reward['basic'] as $value){
|
||||||
|
$data['basic'][$value['level']] = $value;
|
||||||
|
}
|
||||||
|
foreach ($reward['platinum'] as $value){
|
||||||
|
$data['platinum'][$value['level']] = $value;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _initPassList($season){
|
||||||
|
$passList = \mt\BattlePass::all();
|
||||||
|
if (!$passList){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$data = array(
|
||||||
|
'basic' => array(),
|
||||||
|
'platinum' => array()
|
||||||
|
);
|
||||||
|
foreach ($passList as $pass){
|
||||||
|
$basic_state = -1;
|
||||||
|
$platinum_state = -1;
|
||||||
|
if ($this->userInfo['level'] >= $pass['id']){
|
||||||
|
$basic_state = 0;
|
||||||
|
if ($this->userInfo['activated']){
|
||||||
|
$platinum_state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_push($data['basic'],array(
|
||||||
|
'level' => $pass['id'],
|
||||||
|
'state' => $basic_state,
|
||||||
|
// 'reward' => array(
|
||||||
|
// 'item_id' => $pass['basic_item_id'],
|
||||||
|
// 'item_num' => $pass['basic_item_num'],
|
||||||
|
// ),
|
||||||
|
));
|
||||||
|
array_push($data['platinum'],array(
|
||||||
|
'level' => $pass['id'],
|
||||||
|
'state' => $platinum_state,
|
||||||
|
// 'reward' => array(
|
||||||
|
// array(
|
||||||
|
// 'item_id' => $pass['platinum_item_id1'],
|
||||||
|
// 'item_num' => $pass['platinum_item_num1'],
|
||||||
|
// ),
|
||||||
|
// array(
|
||||||
|
// 'item_id' => $pass['platinum_item_id2'],
|
||||||
|
// 'item_num' => $pass['platinum_item_num2'],
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Pass::upsert($season,json_encode($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
44
webapp/models/Pass.php
Normal file
44
webapp/models/Pass.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
class Pass extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function find($seasonId){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_user_pass',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season_id' => $seasonId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row ? $row : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function upsert($seasonId,$fieldKv){
|
||||||
|
SqlHelper::upsert(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_user_pass',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season_id' => $seasonId,
|
||||||
|
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'data' => $fieldKv,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'season_id' => $seasonId,
|
||||||
|
'data' => $fieldKv,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -58,7 +58,7 @@ class User extends BaseModel {
|
|||||||
|
|
||||||
public static function show($row)
|
public static function show($row)
|
||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
// mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
{
|
{
|
||||||
$current_star_num = $row['star_num'];
|
$current_star_num = $row['star_num'];
|
||||||
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
||||||
@ -119,7 +119,7 @@ class User extends BaseModel {
|
|||||||
|
|
||||||
public static function info($row)
|
public static function info($row)
|
||||||
{
|
{
|
||||||
mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
// mt\LevelUp::getExpByLv($row['level'],$row['exp']);
|
||||||
{
|
{
|
||||||
$current_star_num = $row['star_num'];
|
$current_star_num = $row['star_num'];
|
||||||
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
$currSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
||||||
|
69
webapp/mt/BattlePass.php
Normal file
69
webapp/mt/BattlePass.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
|
||||||
|
class BattlePass
|
||||||
|
{
|
||||||
|
public static function find($id){
|
||||||
|
return getXVal(self::getMetaList(), $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function all(){
|
||||||
|
return self::getMetaList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExpByLv(&$lv,&$exp){
|
||||||
|
$meta = self::getMetaList();
|
||||||
|
if ($exp > 0){
|
||||||
|
for ($i=1;$i<=count($meta);$i++){
|
||||||
|
if ($exp >= $meta[count($meta)]['total_exp']){
|
||||||
|
$exp = min($exp, $meta[count($meta)]['total_exp']);
|
||||||
|
$lv = $meta[count($meta)]['id'];
|
||||||
|
}else{
|
||||||
|
if ($i<count($meta)){
|
||||||
|
if ($exp >= $meta[$i]['total_exp'] &&
|
||||||
|
$exp < $meta[$i+1]['total_exp'])
|
||||||
|
{
|
||||||
|
$lv = $meta[$i]['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCurrentSeason(){
|
||||||
|
foreach (self::getMetaCommon() as $meta) {
|
||||||
|
if (myself()->_getNowTime() >= strtotime($meta['begin_time']) &&
|
||||||
|
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getMetaList()
|
||||||
|
{
|
||||||
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('Battlepass@Battlepass.php');
|
||||||
|
}
|
||||||
|
return self::$metaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function getMetaCommon()
|
||||||
|
{
|
||||||
|
if (!self::$metaCommon) {
|
||||||
|
self::$metaCommon = getMetaTable('BattlepassCommon@BattlepassCommon.php');
|
||||||
|
}
|
||||||
|
return self::$metaCommon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected static $metaList;
|
||||||
|
protected static $metaCommon;
|
||||||
|
|
||||||
|
}
|
@ -15,26 +15,26 @@ class LevelUp
|
|||||||
const USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT = 10;
|
const USER_LEVEL_CHIP_PAGE1_MATCH_LIMIT = 10;
|
||||||
const USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT = 11;
|
const USER_LEVEL_CHIP_PAGE2_MATCH_LIMIT = 11;
|
||||||
|
|
||||||
public static function getExpByLv(&$lv,&$exp){
|
// public static function getExpByLv(&$lv,&$exp){
|
||||||
$meta = self::getMetaList();
|
// $meta = self::getMetaList();
|
||||||
if ($exp > 0){
|
// if ($exp > 0){
|
||||||
for ($i=1;$i<=count($meta);$i++){
|
// for ($i=1;$i<=count($meta);$i++){
|
||||||
if ($exp >= $meta[count($meta)]['total_exp']){
|
// if ($exp >= $meta[count($meta)]['total_exp']){
|
||||||
$exp = min($exp, $meta[count($meta)]['total_exp']);
|
// $exp = min($exp, $meta[count($meta)]['total_exp']);
|
||||||
$lv = $meta[count($meta)]['id'];
|
// $lv = $meta[count($meta)]['id'];
|
||||||
}else{
|
// }else{
|
||||||
if ($i<count($meta)){
|
// if ($i<count($meta)){
|
||||||
if ($exp >= $meta[$i]['total_exp'] &&
|
// if ($exp >= $meta[$i]['total_exp'] &&
|
||||||
$exp < $meta[$i+1]['total_exp'])
|
// $exp < $meta[$i+1]['total_exp'])
|
||||||
{
|
// {
|
||||||
$lv = $meta[$i]['id'];
|
// $lv = $meta[$i]['id'];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user