1
This commit is contained in:
parent
a4ce44cd28
commit
a6e2650fb4
@ -47,99 +47,94 @@ class teamController{
|
|||||||
$team_uuid = $_REQUEST['team_uuid'];
|
$team_uuid = $_REQUEST['team_uuid'];
|
||||||
$r = $this->getRedis($team_uuid);
|
$r = $this->getRedis($team_uuid);
|
||||||
|
|
||||||
if(!$r){
|
|
||||||
echo 'is null';
|
$accountid = $_REQUEST['account_id'];
|
||||||
}else{
|
$sessionid = $_REQUEST['session_id'];
|
||||||
$accountid = $_REQUEST['account_id'];
|
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||||
$sessionid = $_REQUEST['session_id'];
|
if (empty($user_db_str)) {
|
||||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
||||||
if (empty($user_db_str)) {
|
return;
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
}
|
||||||
return;
|
$user_db = json_decode($user_db_str, true);
|
||||||
}
|
if (empty($user_db)) {
|
||||||
$user_db = json_decode($user_db_str, true);
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
||||||
if (empty($user_db)) {
|
return;
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效2');
|
}
|
||||||
return;
|
$member_list = array();
|
||||||
}
|
foreach ($user_db['member_list'] as $member) {
|
||||||
$member_list = array();
|
array_push($member_list, array(
|
||||||
foreach ($user_db['member_list'] as $member) {
|
'idx' => $member['idx'],
|
||||||
array_push($member_list, array(
|
'account_id' => $member['account_id'],
|
||||||
'idx' => $member['idx'],
|
'name' => $member['name'],
|
||||||
'account_id' => $member['account_id'],
|
'avatar_url' => $member['avatar_url'],
|
||||||
'name' => $member['name'],
|
|
||||||
'avatar_url' => $member['avatar_url'],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 0,
|
|
||||||
'errmsg'=> '',
|
|
||||||
'team_uuid' => $team_uuid,
|
|
||||||
'auto_fill' => $user_db['auto_fill'],
|
|
||||||
'state' => $user_db['state'],
|
|
||||||
'member_list' => $member_list,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
'team_uuid' => $team_uuid,
|
||||||
|
'auto_fill' => $user_db['auto_fill'],
|
||||||
|
'state' => $user_db['state'],
|
||||||
|
'member_list' => $member_list,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function joinTeam()
|
public function joinTeam()
|
||||||
{
|
{
|
||||||
$team_uuid = $_REQUEST['team_uuid'];
|
$team_uuid = $_REQUEST['team_uuid'];
|
||||||
|
|
||||||
$r = $this->getRedis($team_uuid);
|
$r = $this->getRedis($team_uuid);
|
||||||
|
|
||||||
if (!$r){
|
|
||||||
echo 'is null';
|
|
||||||
}else {
|
|
||||||
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
|
||||||
|
|
||||||
if (empty($user_db_str)){
|
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$user_db = json_decode($user_db_str, true);
|
|
||||||
if (empty($user_db)){
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session失效2');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$member_num = count($user_db['member_list']);
|
|
||||||
|
|
||||||
if ($member_num >= 4){
|
if (empty($user_db_str)){
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2,'队伍人数已满');
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效1');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
$flag = 0;
|
|
||||||
foreach ($user_db['member_list'] as $member) {
|
|
||||||
if ($member['account_id'] == $_REQUEST['account_id']){
|
|
||||||
$flag = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($flag == 1){
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
array_push ($user_db['member_list'], array(
|
|
||||||
'idx' => $member_num + 1,
|
|
||||||
'account_id' => $_REQUEST['account_id'],
|
|
||||||
'name' => $_REQUEST['name'],
|
|
||||||
'avatar_url' => $_REQUEST['avatar_url'],
|
|
||||||
));
|
|
||||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
|
||||||
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
|
||||||
}
|
}
|
||||||
|
$user_db = json_decode($user_db_str, true);
|
||||||
|
if (empty($user_db)){
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, 'session失效2');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$member_num = count($user_db['member_list']);
|
||||||
|
|
||||||
|
if ($member_num >= 4){
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2,'队伍人数已满');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$flag = 0;
|
||||||
|
foreach ($user_db['member_list'] as $member) {
|
||||||
|
if ($member['account_id'] == $_REQUEST['account_id']){
|
||||||
|
$flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($flag == 1){
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3,'已在队伍中');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push ($user_db['member_list'], array(
|
||||||
|
'idx' => $member_num + 1,
|
||||||
|
'account_id' => $_REQUEST['account_id'],
|
||||||
|
'name' => $_REQUEST['name'],
|
||||||
|
'avatar_url' => $_REQUEST['avatar_url'],
|
||||||
|
));
|
||||||
|
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
||||||
|
$r->pexpire(TEAMID_KEY . $team_uuid, 1000 * 3600);
|
||||||
|
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
));
|
gg ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function kickoutMember()
|
public function kickoutMember()
|
||||||
{
|
{
|
||||||
$team_uuid = $_REQUEST['team_uuid'];
|
$team_uuid = $_REQUEST['team_uuid'];
|
||||||
$r = $this->getRedis($team_uuid);
|
$r = $this->getRedis($team_uuid);
|
||||||
|
|
||||||
if (!$r){
|
if (!$r){
|
||||||
echo 'is null';
|
echo 'is null';
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user