活动
This commit is contained in:
parent
ba90c85676
commit
d88a77e92f
@ -1694,3 +1694,48 @@ CREATE TABLE `t_avatar` (
|
||||
UNIQUE KEY `hero_idx_type` (`hero_idx`, `item_type`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
CREATE TABLE `t_unlocked_map` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`map_id` int(11) NOT NULL COMMENT '地图ID',
|
||||
`unlockedtime` 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`),
|
||||
UNIQUE KEY `account_map_id` (`account_id`, `map_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
CREATE TABLE `t_exchange_code` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`exchangecode` varchar(16) NOT NULL COMMENT '兑换码',
|
||||
`packageno` varchar(32) NOT NULL COMMENT '礼包id',
|
||||
`codetype` int(11) NOT NULL COMMENT '兑换码类型',
|
||||
`memo` varchar(40) NOT NULL DEFAULT '0' COMMENT '备注',
|
||||
`channellist` varchar(255) NOT NULL DEFAULT '' COMMENT '绑定渠道列表',
|
||||
`batchid` int(11) NOT NULL DEFAULT '0' COMMENT '兑换码批次号',
|
||||
`usetimes` int(11) NOT NULL DEFAULT '0' COMMENT '使用次数',
|
||||
`last_usetime` int(11) NOT NULL DEFAULT '0' COMMENT '最后使用时间',
|
||||
`last_useuser` varchar(64) NOT NULL DEFAULT '' COMMENT '最后使用者',
|
||||
`begindate` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
|
||||
`enddate` 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`),
|
||||
UNIQUE KEY `exchangecode` (`exchangecode`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
CREATE TABLE `t_exchange_record` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`exchangecode` varchar(16) NOT NULL COMMENT '兑换码',
|
||||
`packageno` varchar(32) NOT NULL COMMENT '礼包id',
|
||||
`codetype` int(11) NOT NULL COMMENT '兑换码类型',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `exchangecode_account` (`exchangecode`,`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
49
sql/gamedb2006_migrate_231219_01.sql
Normal file
49
sql/gamedb2006_migrate_231219_01.sql
Normal file
@ -0,0 +1,49 @@
|
||||
begin;
|
||||
|
||||
CREATE TABLE `t_unlocked_map` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`map_id` int(11) NOT NULL COMMENT '地图ID',
|
||||
`unlockedtime` 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`),
|
||||
UNIQUE KEY `account_map_id` (`account_id`, `map_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
CREATE TABLE `t_exchange_code` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`exchangecode` varchar(16) NOT NULL COMMENT '兑换码',
|
||||
`packageno` varchar(32) NOT NULL COMMENT '礼包id',
|
||||
`codetype` int(11) NOT NULL COMMENT '兑换码类型',
|
||||
`memo` varchar(40) NOT NULL DEFAULT '0' COMMENT '备注',
|
||||
`channellist` varchar(255) NOT NULL DEFAULT '' COMMENT '绑定渠道列表',
|
||||
`batchid` int(11) NOT NULL DEFAULT '0' COMMENT '兑换码批次号',
|
||||
`usetimes` int(11) NOT NULL DEFAULT '0' COMMENT '使用次数',
|
||||
`last_usetime` int(11) NOT NULL DEFAULT '0' COMMENT '最后使用时间',
|
||||
`last_useuser` varchar(64) NOT NULL DEFAULT '' COMMENT '最后使用者',
|
||||
`begindate` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
|
||||
`enddate` 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`),
|
||||
UNIQUE KEY `exchangecode` (`exchangecode`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
CREATE TABLE `t_exchange_record` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`exchangecode` varchar(16) NOT NULL COMMENT '兑换码',
|
||||
`packageno` varchar(32) NOT NULL COMMENT '礼包id',
|
||||
`codetype` int(11) NOT NULL COMMENT '兑换码类型',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `exchangecode_account` (`exchangecode`,`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2023092001);
|
||||
|
||||
commit;
|
102
webapp/controller/ActivityController.class.php
Normal file
102
webapp/controller/ActivityController.class.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
require_once('models/ExchangeCode.php');
|
||||
require_once('models/Map.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
|
||||
use models\ExchangeCode;
|
||||
use models\Map;
|
||||
class ActivityController extends BaseAuthedController {
|
||||
|
||||
public function exchangeCode(){
|
||||
$code = trim(getReqVal('code', 0));
|
||||
$result = ExchangeCode::find($code);
|
||||
if (!$result){
|
||||
myself()->_rspErr(1, 'invalid code');
|
||||
return;
|
||||
}
|
||||
if ($result['begindate'] > myself()->_getNowTime() || $result['enddate'] < myself()->_getNowTime()){
|
||||
myself()->_rspErr(1, 'invalid code');
|
||||
return;
|
||||
}
|
||||
switch ($result['codetype']){
|
||||
//一对一(一码只能兑换一次,并且该类道具一人也只能兑换一次)
|
||||
case 1 :{
|
||||
$recordDb = ExchangeCode::getRecordByCode($code);
|
||||
if ($recordDb){
|
||||
myself()->_rspErr(1, 'been used code');
|
||||
return;
|
||||
}
|
||||
$recordDb2 = ExchangeCode::findRecordByPackage($result['packageno']);
|
||||
if ($recordDb2){
|
||||
myself()->_rspErr(1, 'In exchange for rewards');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
//一对多(一码可被多人使用,仅一人一次,并且该类道具一人也只能兑换一次)
|
||||
case 2 :{
|
||||
$recordDb = ExchangeCode::findRecordByCode($code);
|
||||
if ($recordDb){
|
||||
myself()->_rspErr(1, 'been used code');
|
||||
return;
|
||||
}
|
||||
$recordDb2 = ExchangeCode::findRecordByPackage($result['packageno']);
|
||||
if ($recordDb2){
|
||||
myself()->_rspErr(1, 'In exchange for rewards');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
//多对一
|
||||
case 3:{
|
||||
$recordDb = ExchangeCode::getRecordByCode($code);
|
||||
if ($recordDb){
|
||||
myself()->_rspErr(1, 'been used code');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :{
|
||||
myself()->_rspErr(1, 'invalid');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$itemMt = \mt\Item::get($result['packageno']);
|
||||
if (!$itemMt){
|
||||
myself()->_rspErr(1, "Props that don't exist");
|
||||
return;
|
||||
}
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => $itemMt['id'],
|
||||
'item_num' => 1
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_addItems($items, $awardService, $propertyChgService);
|
||||
$fieldKv = array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'exchangecode' => $code,
|
||||
'packageno' => $itemMt['id'],
|
||||
'codetype' => $result['codetype'],
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
);
|
||||
ExchangeCode::insetRecord($fieldKv);
|
||||
ExchangeCode::updateExchangeCode($code);
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function getMap(){
|
||||
$mapDb = Map::findMap();
|
||||
$this->_rspData(array("data"=>$mapDb));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ require_once('models/Parachute.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Pass.php');
|
||||
require_once('models/Avatar.php');
|
||||
require_once('models/Map.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/LevelUp.php');
|
||||
@ -38,6 +39,7 @@ use models\UserSeasonRing;
|
||||
use models\Chip;
|
||||
use models\Pass;
|
||||
use models\Avatar;
|
||||
use models\Map;
|
||||
use services\LogService;
|
||||
|
||||
class BaseAuthedController extends BaseController {
|
||||
@ -467,7 +469,7 @@ class BaseAuthedController extends BaseController {
|
||||
$headFrames = array();
|
||||
foreach ($items as $item) {
|
||||
//道具产出埋点
|
||||
LogService::productItem($item);
|
||||
// LogService::productItem($item);
|
||||
if ($awardService){
|
||||
$awardService->addItem($item['item_id'], $item['item_num']);
|
||||
}
|
||||
@ -562,6 +564,11 @@ class BaseAuthedController extends BaseController {
|
||||
Avatar::addAvatar($itemMeta);
|
||||
}
|
||||
break;
|
||||
case mt\Item::UNLOCKED_MAP_TYPE:
|
||||
{
|
||||
Map::upsertMap($itemMeta);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_addLog('additems', 'invalid_item', array(
|
||||
|
92
webapp/models/ExchangeCode.php
Normal file
92
webapp/models/ExchangeCode.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class ExchangeCode extends BaseModel
|
||||
{
|
||||
public static function find($code){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_exchange_code',
|
||||
array(
|
||||
'exchangecode'=> $code
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function updateExchangeCode($code){
|
||||
SqlHelper::update
|
||||
(myself()->_getSelfMysql(),
|
||||
't_exchange_code',
|
||||
array(
|
||||
'exchangecode'=> $code
|
||||
),
|
||||
array(
|
||||
'usetimes' => function(){
|
||||
return "usetimes + 1";
|
||||
},
|
||||
"last_usetime" => myself()->_getNowTime(),
|
||||
"last_useuser" => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getRecordByCode($code){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_exchange_record',
|
||||
array(
|
||||
'exchangecode'=> $code
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findRecordByCode($code){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_exchange_record',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
'exchangecode'=> $code,
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findRecordByPackage($package){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_exchange_record',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId(),
|
||||
'packageno'=> $package,
|
||||
)
|
||||
);
|
||||
if (!$row){
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function insetRecord($fieldKv){
|
||||
SqlHelper::insert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_exchange_record',
|
||||
$fieldKv
|
||||
);
|
||||
}
|
||||
}
|
42
webapp/models/Map.php
Normal file
42
webapp/models/Map.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
class Map extends BaseModel
|
||||
{
|
||||
|
||||
public static function findMap(){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_unlocked_map',
|
||||
array(
|
||||
'account_id'=> myself()->_getAccountId()
|
||||
)
|
||||
);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function upsertMap($itemMeta){
|
||||
SqlHelper::upsert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_unlocked_map',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'map_id' => $itemMeta['param1'],
|
||||
),
|
||||
array(
|
||||
'unlockedtime' => myself()->_getNowTime(),
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'map_id' => $itemMeta['param1'],
|
||||
'unlockedtime' => myself()->_getNowTime(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -105,6 +105,7 @@ class Item {
|
||||
const CHEST_BOX_TYPE = 23;
|
||||
const PLANET_TYPE = 28;
|
||||
const AVATAR_TYPE = 29;
|
||||
const UNLOCKED_MAP_TYPE = 30;
|
||||
|
||||
const FUNC_RENAME_CARD_SUBTYPE = 1;
|
||||
const FUNC_GUILD_CARD_SUBTYPE = 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user