邀请加入公会功能--受邀申请处理
This commit is contained in:
@@ -41,7 +41,7 @@ class Guild extends BaseCom
|
|||||||
$guild_id = input('guild_id', 0);
|
$guild_id = input('guild_id', 0);
|
||||||
$key_name = "api:guild:join_guild:".$uid;
|
$key_name = "api:guild:join_guild:".$uid;
|
||||||
redis_lock_exit($key_name);
|
redis_lock_exit($key_name);
|
||||||
$reslut = model('Guild')->join_guild($guild_id,$uid);
|
$reslut = model('Guild')->join_guild_apply($guild_id,$uid);
|
||||||
redis_unlock($key_name);
|
redis_unlock($key_name);
|
||||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
@@ -226,4 +226,15 @@ class Guild extends BaseCom
|
|||||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 受邀申请处理
|
||||||
|
*/
|
||||||
|
public function invite_apply_handle(){
|
||||||
|
$uid = $this->uid;
|
||||||
|
$apply_id = input('apply_id', 0);
|
||||||
|
$type = input('type', 0);
|
||||||
|
$reslut = model('Guild')->guild_invite_handle($uid, $apply_id, $type);
|
||||||
|
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class Guild extends Model
|
|||||||
/*
|
/*
|
||||||
* 加入工会申请
|
* 加入工会申请
|
||||||
*/
|
*/
|
||||||
public function join_guild($guild_id,$user_id=0)
|
public function join_guild_apply($guild_id,$user_id=0)
|
||||||
{
|
{
|
||||||
$user_info = model('User')->get_user_info($user_id);
|
$user_info = model('User')->get_user_info($user_id);
|
||||||
if(!$user_info){
|
if(!$user_info){
|
||||||
@@ -286,7 +286,9 @@ class Guild extends Model
|
|||||||
//增加公会人数
|
//增加公会人数
|
||||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||||
//拉用户进入工会群聊
|
//拉用户进入工会群聊
|
||||||
|
$user_nickname = db::name('user')->where('id', $is_operate['user_id'])->value('nickname');
|
||||||
model('Tencent')->add_group_member('g'.$is_operate['guild_id'], $is_operate['user_id']);
|
model('Tencent')->add_group_member('g'.$is_operate['guild_id'], $is_operate['user_id']);
|
||||||
|
model('Tencent')->send_group_system_notification('g'.$is_operate['guild_id'],"欢迎".$user_nickname.'加入公会');
|
||||||
}else if($type == 2){//拒绝
|
}else if($type == 2){//拒绝
|
||||||
$update_data = [];
|
$update_data = [];
|
||||||
$update_data['status'] = 3;
|
$update_data['status'] = 3;
|
||||||
@@ -1037,4 +1039,122 @@ class Guild extends Model
|
|||||||
}
|
}
|
||||||
return ['code'=>1,'msg'=>'获取成功','data'=>$guild_data];
|
return ['code'=>1,'msg'=>'获取成功','data'=>$guild_data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 加入工会——不用申请直接加入
|
||||||
|
*/
|
||||||
|
public function join_guild($guild_id,$user_id=0)
|
||||||
|
{
|
||||||
|
$user_info = model('User')->get_user_info($user_id);
|
||||||
|
if(!$user_info){
|
||||||
|
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||||
|
}
|
||||||
|
if($user_info['is_real']!=1 || empty($user_info['card_id'])){
|
||||||
|
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||||
|
}
|
||||||
|
//公会是否存在
|
||||||
|
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||||
|
if(!$guild_info){
|
||||||
|
return ['code' => 0, 'msg' => '该公会不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
$is_check_join = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||||
|
if($is_check_join && $is_check_join['guild_id']!=$guild_id){
|
||||||
|
return ['code'=>0,'msg'=>'您已加入别的工会,请先退出公会再加入', 'data' => null];
|
||||||
|
}
|
||||||
|
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==1){
|
||||||
|
return ['code'=>0,'msg'=>'您已加入该工会', 'data' => null];
|
||||||
|
}
|
||||||
|
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==2){
|
||||||
|
return ['code'=>0,'msg'=>'您已提交申请,请耐心等待', 'data' => null];
|
||||||
|
}
|
||||||
|
//是否被踢出过
|
||||||
|
$ti_chu = db::name('vs_guild_user')->where(['user_id'=>$user_id,'guild_id'=>$guild_id,'delete_time'=>['<>',0],'quit_type'=>2])->find();
|
||||||
|
if(!empty($ti_chu)){
|
||||||
|
return ['code' => 0, 'msg' => '已被踢出,禁止加入!', 'data' => null];
|
||||||
|
}
|
||||||
|
//退出公会是否超过30天
|
||||||
|
$map = [];
|
||||||
|
$map['user_id'] = $user_id;
|
||||||
|
$map['delete_time'] = ['<>',0];
|
||||||
|
$map['quit_type'] = 1;
|
||||||
|
$quit_guild_info = Db::name('vs_guild_user')->where($map)->order('quit_time', 'desc')->field('quit_time,guild_id,quit_type')->find();
|
||||||
|
if(!empty($quit_guild_info)) {
|
||||||
|
$quit_time = empty($quit_guild_info['quit_time']) ? 0 : $quit_guild_info['quit_time'];
|
||||||
|
$quit_type = $quit_guild_info['quit_type'];
|
||||||
|
if($quit_guild_info['guild_id'] != $guild_id) {
|
||||||
|
$last_time = 30 * 24 * 3600;
|
||||||
|
if((time() - $last_time) <= $quit_time) {
|
||||||
|
return ['code' => 0, 'msg' => '退出公会未超过30天,不能重新加入其他公会', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//是否有房间
|
||||||
|
$rid = 0;
|
||||||
|
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||||
|
if($room_info){
|
||||||
|
$rid = $room_info['id'];
|
||||||
|
}
|
||||||
|
$insert_data = [];
|
||||||
|
$insert_data['user_id'] = $user_id;
|
||||||
|
$insert_data['guild_id'] = $guild_id;
|
||||||
|
$insert_data['room_id'] = $rid;
|
||||||
|
$insert_data['status'] = 1;
|
||||||
|
$insert_data['is_deacon'] = 2;
|
||||||
|
$insert_data['createtime'] = time();
|
||||||
|
$insert_data['apply_time'] = time();
|
||||||
|
$insert_data['is_show_room'] = 1;
|
||||||
|
//结算比例
|
||||||
|
$configs = get_system_config();
|
||||||
|
//收礼人最终的收益比例 = 未加入工会的收益 + 加入工会的收益
|
||||||
|
$insert_data['settlement_ratio'] = $configs['room_gift_ratio'] + $configs['room_gift_guild_ratio'];
|
||||||
|
$reslut = db::name('vs_guild_user')->insert($insert_data);
|
||||||
|
if($reslut){
|
||||||
|
//增加公会人数
|
||||||
|
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||||
|
//拉用户进入工会群聊
|
||||||
|
model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||||
|
model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||||
|
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||||
|
}else{
|
||||||
|
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//工会邀请用户处理
|
||||||
|
public function guild_invite_handle($user_id,$message_id,$status){
|
||||||
|
$guild_user_invited = Db::name('vs_guild_user_invited')->where(['message_id'=>$message_id,'delete_time'=>0])->find();
|
||||||
|
if(empty($guild_user_invited)){
|
||||||
|
return ['code' => 0, 'msg' => '邀请信息不存在', 'data' => null];
|
||||||
|
}
|
||||||
|
if($user_id != $guild_user_invited['user_id']){
|
||||||
|
return ['code' => 0, 'msg' => '您没有权限处理此信息', 'data' => null];
|
||||||
|
}
|
||||||
|
if($guild_user_invited['status'] != 0){
|
||||||
|
return ['code' => 0, 'msg' => '此邀请信息已处理过', 'data' => null];
|
||||||
|
}
|
||||||
|
if($status == 1){
|
||||||
|
//加入工会
|
||||||
|
$res = $this->join_guild($guild_user_invited['guild_id'],$guild_user_invited['user_id']);
|
||||||
|
if($res['code'] != 1){
|
||||||
|
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||||
|
}
|
||||||
|
$guild_user_invited_data = [
|
||||||
|
'status' => 1,
|
||||||
|
'apply_time' => time(),
|
||||||
|
'updatetime' => time(),
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$guild_user_invited_data = [
|
||||||
|
'status' => 2,
|
||||||
|
'apply_time' => time(),
|
||||||
|
'updatetime' => time(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$guild_user_invited_res = Db::name('vs_guild_user_invited')->where(['message_id'=>$message_id,'delete_time'=>0])->update($guild_user_invited_data);
|
||||||
|
if($guild_user_invited_res){
|
||||||
|
return ['code' => 1, 'msg' => '处理成功', 'data' => null];
|
||||||
|
}else{
|
||||||
|
return ['code' => 0, 'msg' => '处理失败', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,19 +43,19 @@ class UserMessage extends Model
|
|||||||
{
|
{
|
||||||
//获取系统消息
|
//获取系统消息
|
||||||
$system_message = db::name('system_message')
|
$system_message = db::name('system_message')
|
||||||
->where('type', 1)//1系统消息 3公告下的房间推荐,4公告下的活动'
|
->where(['type'=>[1, 6]])//1系统消息 3公告下的房间推荐,4公告下的活动' 6工会邀请
|
||||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
//自己已经阅读过的信息
|
//自己已经阅读过的信息
|
||||||
$user_read_message = db::name('user_message')
|
$user_read_message = db::name('user_message')
|
||||||
->where(['user_id' => $uid,'type' => 1])
|
->where(['user_id' => $uid,'type' => [1, 6]])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$system_no_read_count = $system_message - $user_read_message;
|
$system_no_read_count = $system_message - $user_read_message;
|
||||||
$system_last_message = db::name('system_message')
|
$system_last_message = db::name('system_message')
|
||||||
->field('id,type,title,content,url')
|
->field('id,type,title,content,url')
|
||||||
->where('type', 1)//1系统消息 3公告下的房间推荐,4公告下的活动'
|
->where('type', [1, 6])//1系统消息 3公告下的房间推荐,4公告下的活动' 6工会邀请
|
||||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
->find() ?? null;
|
->find() ?? null;
|
||||||
@@ -104,7 +104,7 @@ class UserMessage extends Model
|
|||||||
|
|
||||||
|
|
||||||
if($type == 1){
|
if($type == 1){
|
||||||
$where['type'] = ['in' , [1, 5, 6]];
|
$where['type'] = ['in' , [1, 6]];
|
||||||
}else{
|
}else{
|
||||||
$where['type'] = ['in' , [3, 4]];
|
$where['type'] = ['in' , [3, 4]];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class SystemMessage extends GuildAdmin
|
|||||||
$page_limit = input('page_limit', 30);
|
$page_limit = input('page_limit', 30);
|
||||||
$where['delete_time'] = 0;
|
$where['delete_time'] = 0;
|
||||||
$where['receiving_id'] = $guild_id;
|
$where['receiving_id'] = $guild_id;
|
||||||
|
$where['type'] = 5;
|
||||||
$count = db::name('system_message')->where($where)->count();
|
$count = db::name('system_message')->where($where)->count();
|
||||||
$lists = db::name('system_message')->where($where)->page($page, $page_limit)->select();
|
$lists = db::name('system_message')->where($where)->page($page, $page_limit)->select();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user