1
This commit is contained in:
parent
a221a65776
commit
7404055ff0
@ -7,34 +7,59 @@ class Activity(object):
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'serverTask',
|
||||
'desc': '服务器大事件任务',
|
||||
'name': 'getInviteActivityInfo',
|
||||
'desc': '拉新活动信息',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=serverTask',
|
||||
'url': 'webapp/index.php?c=Activity&a=getInviteActivityInfo',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['obtain_start_time', 0, '完成进度阶段开始时间'],
|
||||
['obtain_end_time', 0, '完成进度阶段结束时间'],
|
||||
['income_start_time', 0, '宝箱掉落阶段开始时间'],
|
||||
['income_end_time', 0, '宝箱掉落阶段结束时间'],
|
||||
['status', 0, '0:任务未完成 1:完成任务 '],
|
||||
['switch', 0, '0:开 1:关 '],
|
||||
['!taskDtoList', [serverTask()], '任务列表'],
|
||||
['invitation_code', 0, '邀请码'],
|
||||
['invite_count', 0, '成功邀请人数'],
|
||||
['bind_state', 0, '绑定状态 1:已绑 0:未绑'],
|
||||
['!bind_rewards', [_common.AwardItem()], '绑定奖励'],
|
||||
]
|
||||
}
|
||||
},{
|
||||
'name': 'bindInvitationCode',
|
||||
'desc': '绑定邀请码',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=bindInvitationCode',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['code', 0, '邀请码'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'getInvitationTaskList',
|
||||
'desc': '拉新任务列表',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=getInvitationTaskList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!task_list',[_common.Mission()], '奖励信息'],
|
||||
]
|
||||
},{
|
||||
'name': 'commitInvitationTask',
|
||||
'desc': '提交任务(领取奖励)',
|
||||
'group': 'Activity',
|
||||
'url': 'webapp/index.php?c=Activity&a=commitInvitationTask',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
class serverTask(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['task_id', 0, '任务id'],
|
||||
['current', 0, '当前进度'],
|
||||
['target', 0, '目标进度'],
|
||||
['state', 0, '1:完成 0:未完成'],
|
||||
]
|
@ -2078,4 +2078,41 @@ CREATE TABLE `t_circuit_reward` (
|
||||
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 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_user_invitation_code`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_user_invitation_code`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_user_invitation_code` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`invitation_code` varchar(60) CHARACTER SET utf8 COMMENT '邀请码',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id` (`account_id`),
|
||||
UNIQUE KEY `invitation_code` (`invitation_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_user_invitation_code_bind`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_user_invitation_code_bind`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_user_invitation_code_bind` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`invitation_code` varchar(60) CHARACTER SET utf8 COMMENT '邀请码',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
27
sql/gamedb2006_migrate_240924_01.sql
Normal file
27
sql/gamedb2006_migrate_240924_01.sql
Normal file
@ -0,0 +1,27 @@
|
||||
begin;
|
||||
|
||||
CREATE TABLE `t_user_invitation_code` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`invitation_code` varchar(60) CHARACTER SET utf8 COMMENT '邀请码',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id` (`account_id`),
|
||||
UNIQUE KEY `invitation_code` (`invitation_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
CREATE TABLE `t_user_invitation_code_bind` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||
`invitation_code` varchar(60) CHARACTER SET utf8 COMMENT '邀请码',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2024092401);
|
||||
|
||||
commit;
|
@ -1,13 +1,142 @@
|
||||
<?php
|
||||
require_once('services/HashRateService.php');
|
||||
require_once('services/MissionService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/AwardService.php');
|
||||
|
||||
require_once('mt/ServerTaskTime.php');
|
||||
require_once('mt/ServerTask.php');
|
||||
require_once('models/GlobalData.php');
|
||||
require_once('mt/Task.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('models/UserInvitationCode.php');
|
||||
require_once('models/Mission.php');
|
||||
|
||||
|
||||
use models\GlobalData;
|
||||
use models\UserInvitationCode;
|
||||
use models\Mission;
|
||||
class ActivityController extends BaseAuthedController {
|
||||
|
||||
public function getInviteActivityInfo(){
|
||||
$myCodeDb = UserInvitationCode::findMyCode();
|
||||
if(!$myCodeDb){
|
||||
UserInvitationCode::generateCode();
|
||||
$myCodeDb = UserInvitationCode::findMyCode();
|
||||
}
|
||||
$myCode = $myCodeDb['invitation_code'];
|
||||
$count = UserInvitationCode::getMyCodeBindCount($myCode);
|
||||
$rewards = array();
|
||||
$rewardArr = \mt\Parameter::getListValue('rookie_bind_reward');
|
||||
foreach ($rewardArr as $value){
|
||||
$values = explode(':', $value);
|
||||
array_push($rewards,array(
|
||||
'item_id' => $values[0],
|
||||
'item_num' => $values[1],
|
||||
));
|
||||
}
|
||||
$bindState = 0;
|
||||
if (UserInvitationCode::verifyAccountBind()){
|
||||
$bindState = 1;
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'invitation_code' => $myCode,
|
||||
'invite_count' => $count,
|
||||
'bind_state' => $bindState,
|
||||
'bind_rewards' => $rewards
|
||||
));
|
||||
}
|
||||
|
||||
public function bindInvitationCode(){
|
||||
$code = getReqVal('code', 0);
|
||||
if (!UserInvitationCode::verifyCode($code)){
|
||||
$this->_rspErr(1, "invitation code error");
|
||||
return;
|
||||
}
|
||||
if (UserInvitationCode::verifyAccountBind()){
|
||||
$this->_rspErr(1, "The user has been bind");
|
||||
return;
|
||||
}
|
||||
UserInvitationCode::addInvitationCodeBind($code);
|
||||
$items = array();
|
||||
$rewardArr = \mt\Parameter::getListValue('rookie_bind_reward');
|
||||
foreach ($rewardArr as $value){
|
||||
$values = explode(':', $value);
|
||||
array_push($items,array(
|
||||
'item_id' => $values[0],
|
||||
'item_num' => $values[1],
|
||||
));
|
||||
}
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
myself()->_addItems($items,$awardService,$propertyChgService);
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function getInvitationTaskList(){
|
||||
$missionService = new services\MissionService();
|
||||
$missionMetaList = mt\Task::getCustomTypeMetaList(\mt\Task::NEW_USER_MISSON_TYPE, $missionService);
|
||||
$missionHash = Mission::allToHash();
|
||||
$taskDtoList = array();
|
||||
foreach ($missionMetaList as $missionMeta) {
|
||||
$missionDb = getXVal($missionHash, $missionMeta['id'], null);
|
||||
$missionDto = $missionService->getMissionDto(
|
||||
null, null, $missionDb, $missionMeta);
|
||||
array_push($taskDtoList, $missionDto);
|
||||
}
|
||||
|
||||
$this->_rspData(array(
|
||||
'task_list' => $taskDtoList,
|
||||
));
|
||||
}
|
||||
|
||||
public function commitInvitationTask(){
|
||||
$missionId = getReqVal('mission_id', 0);
|
||||
$missionMeta = mt\Task::get($missionId);
|
||||
if (!$missionMeta) {
|
||||
$this->_rspErr(1, 'mission_id parameter error');
|
||||
return;
|
||||
}
|
||||
$missionService = new services\MissionService();
|
||||
|
||||
$missionDb = Mission::find($missionId);
|
||||
$missionDto = $missionService->getMissionDto(
|
||||
null, null, $missionDb, $missionMeta);
|
||||
if (!$missionDto) {
|
||||
$this->_rspErr(10, 'server internal error');
|
||||
return;
|
||||
}
|
||||
if ($missionDto['state'] == Mission::RECEIVED_STATE) {
|
||||
$this->_rspErr(2, "Can't get it again");
|
||||
return;
|
||||
}
|
||||
if ($missionDto['state'] == Mission::NOT_FINISHED_STATE) {
|
||||
$this->_rspErr(3, 'Mission objectives not achieved');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($missionDto['state'] != Mission::RECEIVEABLE_STATE) {
|
||||
$this->_rspErr(3, 'Unknown mission status');
|
||||
return;
|
||||
}
|
||||
$dropMeta = mt\Drop::get($missionMeta['reward']);
|
||||
if (!$dropMeta) {
|
||||
$this->_rspErr(10, 'server internal error:' . $missionMeta['reward']);
|
||||
return;
|
||||
}
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$awardService = new services\AwardService();
|
||||
$this->_scatterDrop('mission:' . $missionId, $dropMeta, $awardService, $propertyChgService);
|
||||
Mission::add($missionId);
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//服务器大事件
|
||||
public function serverTask(){
|
||||
|
99
webapp/models/UserInvitationCode.php
Normal file
99
webapp/models/UserInvitationCode.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class UserInvitationCode extends BaseModel
|
||||
{
|
||||
public static function findMyCode(){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function generateCode(){
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
array(
|
||||
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'invitation_code' =>rand(100000,999999),
|
||||
'createtime' =>myself()->_getNowTime(),
|
||||
'modifytime' =>myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getMyCodeBindCount($code){
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code_bind',
|
||||
array(
|
||||
'invitation_code' => $code,
|
||||
)
|
||||
);
|
||||
return $rows ? count($rows) : 0;
|
||||
}
|
||||
|
||||
public static function verifyCode($code){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code',
|
||||
array(
|
||||
'invitation_code' => $code,
|
||||
)
|
||||
);
|
||||
if ($row){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function verifyAccountBind(){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code_bind',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
if ($row){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function addInvitationCodeBind($code){
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_user_invitation_code_bind',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
),
|
||||
array(
|
||||
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'invitation_code' =>$code,
|
||||
'createtime' =>myself()->_getNowTime(),
|
||||
'modifytime' =>myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -58,6 +58,7 @@ class Task {
|
||||
const TOTAL_USE_HERO_WINS_TIMES_COND = 51; // 使用英雄X获得Y次胜利
|
||||
const TOTAL_USE_HERO_KILLS_COND = 52; // 使用英雄X击败Y个敌人
|
||||
const TOTAL_USE_MAP_WINS_TIMES_COND = 53; // 在XX地图获得Y场胜利
|
||||
const TOTAL_INVITATION_PEOPLE_COUNT_COND = 55; // 邀请新人并绑定邀请码(邀请新人数)
|
||||
const OFFER_REWARD_COND = 99;
|
||||
|
||||
const DAILY_MISSON_TYPE = 1;
|
||||
@ -66,6 +67,7 @@ class Task {
|
||||
const RANK_MISSON_TYPE = 4;
|
||||
const SEASONCARD_MISSON_TYPE = 5;
|
||||
const OFFER_REWARD_MISSON_TYPE = 7;
|
||||
const NEW_USER_MISSON_TYPE = 10;
|
||||
|
||||
const SEASON_WEAKLY_MISSON_SUBTYPE = 1;
|
||||
const SEASON_CHALLENGE_MISSON_SUBTYPE = 2;
|
||||
@ -141,6 +143,14 @@ class Task {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::NEW_USER_MISSON_TYPE:{
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
if ($meta['type'] == self::NEW_USER_MISSON_TYPE) {
|
||||
array_push($metaList, $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $metaList;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ require_once('models/Battle.php');
|
||||
require_once('models/BigData.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/UserInvitationCode.php');
|
||||
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('services/RankActivityService.php');
|
||||
@ -23,6 +24,7 @@ use models\Battle;
|
||||
use models\BigData;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\UserInvitationCode;
|
||||
|
||||
/*
|
||||
offer.reward.missions
|
||||
@ -521,6 +523,14 @@ class MissionService extends BaseService {
|
||||
$missionDto['current'] = $this->getMapWinsTimes($missionMeta);
|
||||
}
|
||||
break;
|
||||
case mt\Task::TOTAL_INVITATION_PEOPLE_COUNT_COND:
|
||||
{
|
||||
//邀请新人并绑定邀请码(邀请新人数)
|
||||
$myCodeDb = UserInvitationCode::findMyCode();
|
||||
$count = UserInvitationCode::getMyCodeBindCount($myCodeDb['invitation_code']);
|
||||
$missionDto['current'] = $count;
|
||||
}
|
||||
break;
|
||||
case mt\Task::OFFER_REWARD_COND:
|
||||
{
|
||||
$this->getOfferRewardMissionInfo($missionDto, $missionMeta);
|
||||
|
Loading…
x
Reference in New Issue
Block a user