1
This commit is contained in:
parent
a4ce44cd28
commit
a6e2650fb4
@ -47,99 +47,94 @@ class teamController{
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if(!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
$accountid = $_REQUEST['account_id'];
|
||||
$sessionid = $_REQUEST['session_id'];
|
||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
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_list = array();
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
array_push($member_list, array(
|
||||
'idx' => $member['idx'],
|
||||
'account_id' => $member['account_id'],
|
||||
'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,
|
||||
|
||||
$accountid = $_REQUEST['account_id'];
|
||||
$sessionid = $_REQUEST['session_id'];
|
||||
$user_db_str = $r->get(TEAMID_KEY . $team_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
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_list = array();
|
||||
foreach ($user_db['member_list'] as $member) {
|
||||
array_push($member_list, array(
|
||||
'idx' => $member['idx'],
|
||||
'account_id' => $member['account_id'],
|
||||
'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,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function joinTeam()
|
||||
{
|
||||
$team_uuid = $_REQUEST['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)){
|
||||
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']);
|
||||
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
|
||||
|
||||
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);
|
||||
if (empty($user_db_str)){
|
||||
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){
|
||||
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(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
gg ));
|
||||
}
|
||||
|
||||
public function kickoutMember()
|
||||
{
|
||||
$team_uuid = $_REQUEST['team_uuid'];
|
||||
$r = $this->getRedis($team_uuid);
|
||||
|
||||
if (!$r){
|
||||
echo 'is null';
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user