Git 文件整理
This commit is contained in:
320
application/guildadmin/controller/User.php
Normal file
320
application/guildadmin/controller/User.php
Normal file
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace app\guildAdmin\controller;
|
||||
|
||||
use app\admin\command\Menu;
|
||||
use app\GuildAdmin\model\AuthGroup;
|
||||
use app\GuildAdmin\model\AuthGroupAccess;
|
||||
use app\GuildAdmin\model\AuthRule;
|
||||
use app\common\controller\GuildAdmin;
|
||||
use fast\Random;
|
||||
use fast\Tree;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 管理员管理
|
||||
*
|
||||
* @icon fa fa-users
|
||||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||||
*/
|
||||
class User extends GuildAdmin
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
protected $layout = '';
|
||||
protected $table_guild_subsidy_config = 'vs_guild_subsidy_config';
|
||||
protected $table_guild_subsidy = 'vs_guild_subsidy';
|
||||
protected $table_guild_user = 'vs_guild_user';
|
||||
protected $table_guild_data = 'vs_guild_data';
|
||||
protected $table_guild = 'vs_guild';
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
// 用户列表
|
||||
public function index()
|
||||
{
|
||||
$guild_id = $this->guildId;
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search = input('search','');
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$where = [];
|
||||
if($search){
|
||||
//手机号
|
||||
if(preg_match('/^1[34578]\d{9}$/',$search)){
|
||||
$where['b.mobile'] = ['like',$search];
|
||||
}elseif(is_numeric($search) && strlen($search) <= 10){//ID 数字
|
||||
$user_id = db::name('user')->where('user_code', $search)->value('id');
|
||||
$where['a.user_id'] = ['like',$user_id];
|
||||
}else{
|
||||
$where['b.nickname'] = ['like',$search];
|
||||
}
|
||||
}
|
||||
if($search_stime){
|
||||
$where['a.createtime'] = ['>=',strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime){
|
||||
$where['a.createtime'] = ['<=',strtotime($search_etime)];
|
||||
}
|
||||
$where['a.guild_id'] = $guild_id;
|
||||
$where['a.status'] = 1;
|
||||
$count = db::name('vs_guild_user')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->count();
|
||||
$list = db::name('vs_guild_user')->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, b.status, b.nickname, b.avatar,b.user_code,b.sex,b.mobile,a.createtime,a.settlement_ratio')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$list_data =[];
|
||||
foreach ($list as $k=>$item){
|
||||
$list_data[$k]['id'] = $item['id'];
|
||||
$list_data[$k]['nickname'] = $item['user_code'].'-'.$item['nickname'];
|
||||
if($item['sex']){
|
||||
$list_data[$k]['sex'] = $item['sex'] == 1 ? '男' : '女';
|
||||
}else{
|
||||
$list_data[$k]['sex'] = '未知';
|
||||
}
|
||||
$list_data[$k]['mobile'] = $item['mobile'];
|
||||
//粉丝数量
|
||||
$list_data[$k]['fans_num'] = db::name('user_follow')->where(['follow_id' => $item['user_id'],'type'=>1])->count();
|
||||
if($search_stime==""){
|
||||
$search_stime = strtotime(date('Y-m-d'));
|
||||
}
|
||||
if($search_etime==""){
|
||||
$search_etime = time();
|
||||
}
|
||||
$list_data[$k]['fans_num_new'] = db::name('user_follow')->where(['follow_id' => $item['user_id'],'type'=>1])
|
||||
->where('createtime', '>=', strtotime($search_stime))
|
||||
->where('createtime', '<=', strtotime($search_etime))
|
||||
->count();
|
||||
$list_data[$k]['settlement_ratio'] = $item['settlement_ratio'];
|
||||
//最高比例
|
||||
//结算比例
|
||||
$configs = get_system_config();
|
||||
$list_data[$k]['max_settlement_ratio'] = $configs['room_gift_ratio'] + $configs['room_gift_guild_ratio'];
|
||||
$list_data[$k]['createtime'] = date('Y-m-d H:i:s',$item['createtime']);
|
||||
//状态 1正常,2禁止登录,0注销
|
||||
$list_data[$k]['status'] = $item['status'];
|
||||
$list_data[$k]['status_text'] = $item['status'] == 1 ? '正常' : ($item['status'] == 2 ? '禁止登录' : '注销');
|
||||
}
|
||||
$return_data =[
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list_data
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//用户申请列表
|
||||
public function apply_list(){
|
||||
$guild_id = $this->guildId;
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search = input('search','');
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$where = [];
|
||||
if($search){
|
||||
//手机号
|
||||
if(preg_match('/^1[34578]\d{9}$/',$search)){
|
||||
$where['b.mobile'] = ['like',$search];
|
||||
}elseif(is_numeric($search) && strlen($search) <= 10){//ID 数字
|
||||
$user_id = db::name('user')->where('user_code', $search)->value('id');
|
||||
$where['a.user_id'] = ['like',$user_id];
|
||||
}else{
|
||||
$where['b.nickname'] = ['like',$search];
|
||||
}
|
||||
}
|
||||
if($search_stime){
|
||||
$where['a.createtime'] = ['>=',strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime){
|
||||
$where['a.createtime'] = ['<=',strtotime($search_etime)];
|
||||
}
|
||||
$where['a.guild_id'] = $guild_id;
|
||||
$where['a.status'] = ['in','2,3'];
|
||||
$count = db::name('vs_guild_user')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->count();
|
||||
$list = db::name('vs_guild_user')->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, b.nickname, b.avatar,b.user_code,b.sex,b.mobile,a.createtime')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$list_data =[];
|
||||
foreach ($list as $k=>$item){
|
||||
$list_data[$k]['id'] = $item['id'];
|
||||
$list_data[$k]['nickname'] = $item['user_code'].'-'.$item['nickname'];
|
||||
if($item['sex']){
|
||||
$list_data[$k]['sex'] = $item['sex'] == 1 ? '男' : '女';
|
||||
}else{
|
||||
$list_data[$k]['sex'] = '未知';
|
||||
}
|
||||
$list_data[$k]['mobile'] = $item['mobile'];
|
||||
//粉丝数量
|
||||
$list_data[$k]['fans_num'] = db::name('user_follow')->where(['follow_id' => $item['user_id'],'type'=>1])->count();
|
||||
if($search_stime==""){
|
||||
$search_stime = strtotime(date('Y-m-d'));
|
||||
}
|
||||
if($search_etime==""){
|
||||
$search_etime = time();
|
||||
}
|
||||
$list_data[$k]['fans_num_new'] = db::name('user_follow')->where(['follow_id' => $item['user_id'],'type'=>1])
|
||||
->where('createtime', '>=', strtotime($search_stime))
|
||||
->where('createtime', '<=', strtotime($search_etime))
|
||||
->count();
|
||||
$list_data[$k]['createtime'] = date('Y-m-d H:i:s',$item['createtime']);
|
||||
$list_data[$k]['status'] = $item['status'];
|
||||
$list_data[$k]['status_text'] = $item['status'] == 2 ? '待审核' : '审核失败';
|
||||
}
|
||||
$return_data =[
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list_data
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 同意,拒绝申请
|
||||
*/
|
||||
public function operate_guild(){
|
||||
$id = input('id','');
|
||||
$status = input('status','');
|
||||
$remarks = input('remarks','');
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild_user = db::name('vs_guild_user')->where(['id'=>$id])->find();
|
||||
if(!$guild_user){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = model('api/Guild')->operate_guild($id, $status,$remarks);
|
||||
if($result['code'] == 1){
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
return V(0,$result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
//结算比例编辑
|
||||
public function settlement_ratio_edit(){
|
||||
$id = input('id','');
|
||||
$settlement_ratio = input('settlement_ratio','');
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild_user = db::name('vs_guild_user')->where(['id'=>$id])->find();
|
||||
if(!$guild_user){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$configs = get_system_config();
|
||||
$ratio = $configs['room_gift_ratio'] + $configs['room_gift_guild_ratio'];
|
||||
if($settlement_ratio > $ratio){
|
||||
return V(0,"最高比例不能超过".$ratio);
|
||||
}
|
||||
$result = db::name('vs_guild_user')->where(['id'=>$id])->update(['settlement_ratio'=>$settlement_ratio]);
|
||||
if($result){
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
return V(0,"操作失败");
|
||||
}
|
||||
}
|
||||
//踢出工会
|
||||
public function kick_out_user(){
|
||||
$id = input('id','');
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$guild_user = db::name('vs_guild_user')->where(['id'=>$id])->find();
|
||||
$guild = db::name('vs_guild')->where(['id'=>$guild_user['guild_id']])->find();
|
||||
$result = model('api/Guild')->kick_out_guild($guild['user_id'],$guild_user['user_id'], $guild_user['guild_id']);
|
||||
if($result['code'] == 1){
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
return V(0,$result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
//退出申请列表
|
||||
public function quit_apply_list(){
|
||||
$guild_id = $this->guildId;
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search = input('search','');
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$where = [];
|
||||
if($search){
|
||||
//手机号
|
||||
if(preg_match('/^1[34578]\d{9}$/',$search)){
|
||||
$where['b.mobile'] = ['like',$search];
|
||||
}elseif(is_numeric($search) && strlen($search) <= 10){//ID 数字
|
||||
$user_id = db::name('user')->where('user_code', $search)->value('id');
|
||||
$where['a.user_id'] = ['like',$user_id];
|
||||
}else{
|
||||
$where['b.nickname'] = ['like',$search];
|
||||
}
|
||||
}
|
||||
if($search_stime){
|
||||
$where['a.createtime'] = ['>=',strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime){
|
||||
$where['a.createtime'] = ['<=',strtotime($search_etime)];
|
||||
}
|
||||
$where['a.guild_id'] = $guild_id;
|
||||
$list = db::name('vs_guild_user_quit_log')->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id,a.createtime,a.status,b.nickname, b.avatar,b.user_code,b.mobile,a.type')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$count = db::name('vs_guild_user_quit_log')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->count();
|
||||
$list_data = [];
|
||||
foreach ($list as $k => $item){
|
||||
$list_data[$k]['id'] = $item['id'];
|
||||
$list_data[$k]['nickname'] = $item['user_code'].'-'.$item['nickname'];
|
||||
$list_data[$k]['mobile'] = $item['mobile'];
|
||||
$list_data[$k]['type'] = $item['type']==1?'主动退出':'付费退出';
|
||||
$list_data[$k]['createtime'] = date('Y-m-d H:i:s',$item['createtime']);
|
||||
// 审核状态 0默认待审核 1已通过 2已拒绝
|
||||
$list_data[$k]['status'] = $item['status'];
|
||||
$list_data[$k]['status_text'] = $item['status'] == 0 ? '待审核' : ($item['status'] == 1 ? '已通过' : '已拒绝');
|
||||
}
|
||||
|
||||
$return_data =[
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list_data
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//退出申请审核
|
||||
public function quit_apply_operate(){
|
||||
$id = input('id','');
|
||||
$status = input('status',1);
|
||||
if(!$id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$quit_apply = db::name('vs_guild_user_quit_log')->where(['id'=>$id])->find();
|
||||
if(!$quit_apply){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = model('api/Guild')->quit_apply_audit($quit_apply['user_id'],$id,$status);
|
||||
if($result['code'] == 1){
|
||||
return V(1,"操作成功");
|
||||
}else{
|
||||
return V(0,$result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user