工会-我的工会页面接口提交
This commit is contained in:
@@ -216,5 +216,14 @@ class Guild extends BaseCom
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 我的工会
|
||||
*
|
||||
*/
|
||||
public function my_guild(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Guild')->my_guild($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,11 @@ class Guild extends Model
|
||||
public function get_guild_list($page,$page_limit,$search='',$user_id=0)
|
||||
{
|
||||
$where =[];
|
||||
if ($search) {
|
||||
//判断是不是数字
|
||||
if (is_numeric($search)) {
|
||||
$where = ['guild_special_id'=>['like',$search.'%']]; //通过工会ID搜索
|
||||
}else{
|
||||
$where = ['guild_name'=>['like',$search.'%']];
|
||||
}
|
||||
$list = [];
|
||||
$list = Db::name('vs_guild')
|
||||
@@ -983,4 +986,55 @@ class Guild extends Model
|
||||
$return = model('Tencent')->modify_group_base_info('g'.$guild_id, $name,$avatar, $notice);
|
||||
return ['code' => $return['code'], 'msg' => $return['msg'], 'data' => $return['data']];
|
||||
}
|
||||
|
||||
/*
|
||||
* 我的公会
|
||||
* @param $id
|
||||
* @param $user_id
|
||||
*/
|
||||
public function my_guild($user_id)
|
||||
{
|
||||
$guild_user = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])->find();
|
||||
if(empty($guild_user)){
|
||||
return ['code' => 0, 'msg' => '您没有加入任何公会', 'data'=>null];
|
||||
}
|
||||
$info = Db::name('vs_guild')
|
||||
->field('id,guild_special_id,user_id,guild_name,cover,num,intro,createtime,income')
|
||||
->where(['id'=>$guild_user['guild_id'],'is_show'=>1,'delete_time'=>0])
|
||||
->find();
|
||||
$guild_data = [];
|
||||
if($info){
|
||||
//用户信息
|
||||
$user_data = Db::name('user')->where(['id'=>$user_id])->field('id,nickname,avatar')->find();
|
||||
$guild_data['user_id'] = $user_data['id'];
|
||||
$guild_data['user_nickname'] = $user_data['nickname'];
|
||||
$guild_data['user_code'] = model('Decorate')->user_decorate_detail($user_id, 6);
|
||||
$guild_data['user_avatar'] = localpath_to_netpath($user_data['avatar']);
|
||||
$guild_data['is_leader'] = $info['user_id'] == $user_id ? 1 : 0;//当前用户是否是会长
|
||||
$guild_data['guild_id'] = $info['id'];
|
||||
$guild_data['guild_name'] = $info['guild_name'];
|
||||
//加入公会时间
|
||||
$guild_data['join_time'] = date('Y-m-d H:i:s',$guild_user['apply_time']);
|
||||
//本周金额
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$week_end_time = time();
|
||||
$guild_data['week_income'] = db::name('vs_give_gift')
|
||||
->whereIn('gift_user',$user_id)
|
||||
->where(['createtime' => ['between', [$week, $week_end_time]]])
|
||||
->sum('total_price');
|
||||
//厅主收益
|
||||
$guild_data['room_author_ratio'] = $guild_user['room_id']==0 ? 0 : get_system_config_value('room_author_ratio');
|
||||
//礼物分成
|
||||
$guild_data['settlement_ratio'] = $guild_user['settlement_ratio'];
|
||||
//付费退出公会所需金
|
||||
$guild_data['quit_guild_gold'] = get_system_config_value('quit_guild_gold');
|
||||
//工会群组ID
|
||||
$guild_data['guild_group_id'] = "g".$info['id'];
|
||||
//工会基础信息
|
||||
$guild_data_info = Db::name('vs_guild_data')->where(['guild_id'=>$info['id']])->find();
|
||||
$guild_data['agreement'] = $guild_data_info['agreement'] ?? '';
|
||||
}
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$guild_data];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user