|
@@ -6,8 +6,6 @@ use app\common\controller\Api;
|
|
|
use app\common\service\UserService;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
-use Redis;
|
|
|
-use app\common\service\RoomService;
|
|
|
|
|
|
/**
|
|
|
* 家族控制器
|
|
@@ -28,7 +26,7 @@ class Family extends Api
|
|
|
$whereOr['name'] = array('like', '%' . $search . '%');
|
|
|
$whereOr['g_id'] = $search;
|
|
|
}
|
|
|
- $res = Db::name('guild')->field("id,g_id,user_id,group_id,name,image,desc,member")
|
|
|
+ $res = Db::name('family')->field("id,g_id,user_id,group_id,name,image,desc,member")
|
|
|
->where($where)
|
|
|
->where(function ($query) use($whereOr) {
|
|
|
$query->whereOr($whereOr);
|
|
@@ -53,10 +51,10 @@ class Family extends Api
|
|
|
if($guild_id <= 0) {
|
|
|
$is_member = 1;
|
|
|
// 获取当前用户是否是公会成员
|
|
|
- $idcardfind = \app\common\model\GuildJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
+ $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
if($idcardfind) $this->error("您存在加入公会的申请,正在审核中,请耐心等待!");
|
|
|
|
|
|
- $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
+ $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
if($memberfind) $guild_id = $memberfind->guild_id;
|
|
|
|
|
|
if(!$guild_id) {
|
|
@@ -70,17 +68,17 @@ class Family extends Api
|
|
|
$res = [];
|
|
|
|
|
|
//公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where(["id"=>$guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where(["id"=>$guild_id])->find();
|
|
|
|
|
|
// 获取公会成员信息
|
|
|
- $guildMemberInfo = \app\common\model\GuildMember::alias("a")
|
|
|
+ $guildMemberInfo = \app\common\model\FamilyMember::alias("a")
|
|
|
->field("a.id,a.user_id,a.role,u.nickname,u.avatar,u.gender")
|
|
|
->join("hx_user u","a.user_id = u.id")
|
|
|
->where(["a.guild_id"=>$guild_id])->limit(10)->order("a.role","desc")->select();
|
|
|
if(!$guildInfo || !$guildMemberInfo) $this->error("公会信息获取失败!");
|
|
|
|
|
|
// 获取公会成员总数
|
|
|
- $guildMemberCount = \app\common\model\GuildMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
+ $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
|
|
|
// 获取会长信息
|
|
|
$guilderInfo = \app\common\model\User::field("avatar,nickname,u_id")->where(["id"=>$guildInfo->user_id])->find();
|
|
@@ -106,15 +104,15 @@ class Family extends Api
|
|
|
if($guild_id <= 0) {
|
|
|
$is_member = 1;
|
|
|
// 获取当前用户是否是公会成员
|
|
|
- $idcardfind = \app\common\model\GuildJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
+ $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
if($idcardfind) $this->error("您存在加入公会的申请,正在审核中,请耐心等待!");
|
|
|
|
|
|
- $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
+ $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
if($memberfind) $guild_id = $memberfind->guild_id;
|
|
|
|
|
|
$guildWhere['user_id'] = $user_id;
|
|
|
$guildWhere['status'] = ['in',[0,1]];
|
|
|
- $guildInfo = \app\common\model\Guild::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where($guildWhere)->find();
|
|
|
+ $guildInfo = \app\common\model\Family::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where($guildWhere)->find();
|
|
|
|
|
|
if(!$guild_id) {
|
|
|
$res["is_member"] = 2; // 是否为派对成员
|
|
@@ -127,17 +125,17 @@ class Family extends Api
|
|
|
$res = [];
|
|
|
|
|
|
//公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where(["id"=>$guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where(["id"=>$guild_id])->find();
|
|
|
|
|
|
// 获取公会成员信息
|
|
|
- $guildMemberInfo = \app\common\model\GuildMember::alias("a")
|
|
|
+ $guildMemberInfo = \app\common\model\FamilyMember::alias("a")
|
|
|
->field("a.id,a.user_id,a.role,u.nickname,u.avatar,u.gender")
|
|
|
->join("hx_user u","a.user_id = u.id")
|
|
|
->where(["a.guild_id"=>$guild_id])->limit(10)->order("a.role","desc")->select();
|
|
|
if(!$guildInfo || !$guildMemberInfo) $this->error("公会信息获取失败!");
|
|
|
|
|
|
// 获取公会成员总数
|
|
|
- $guildMemberCount = \app\common\model\GuildMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
+ $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
|
|
|
// 获取会长信息
|
|
|
$guilderInfo = \app\common\model\User::field("avatar,nickname,u_id")->where(["id"=>$guildInfo->user_id])->find();
|
|
@@ -192,14 +190,14 @@ class Family extends Api
|
|
|
}
|
|
|
|
|
|
//准备创建
|
|
|
- $guildInfo = new \app\common\model\Guild();
|
|
|
+ $guildInfo = new \app\common\model\Family();
|
|
|
$guildInfo->user_id = $user_id;
|
|
|
- $ids = \app\common\model\Guild::column("g_id");
|
|
|
+ $ids = \app\common\model\Family::column("g_id");
|
|
|
$guildInfo->g_id = getUinqueId(4, [$ids]);
|
|
|
$guildInfo->status = 0;
|
|
|
} else {
|
|
|
// 获取公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::where(["id"=>$guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::where(["id"=>$guild_id])->find();
|
|
|
// 验证更新条件
|
|
|
if($user_id !== $guildInfo->user_id) throw new Exception("身份验证失败!您不是公会长,无权限更改!");
|
|
|
}
|
|
@@ -222,7 +220,7 @@ class Family extends Api
|
|
|
'status' => 1, //状态:1=签约中,2=已解约
|
|
|
'createtime' => time(),
|
|
|
];
|
|
|
- $guildRes = model('GuildMember')->insertGetId($guildMemberData);
|
|
|
+ $guildRes = model('FamilyMember')->insertGetId($guildMemberData);
|
|
|
if (!$guildRes) {
|
|
|
throw new Exception('生成成员失败');
|
|
|
}
|
|
@@ -277,23 +275,16 @@ class Family extends Api
|
|
|
// 获取用户实名认证信息
|
|
|
$authUserIdcard = \app\common\model\UserAuth::where(["user_id"=>$user_id])->value("idcard");
|
|
|
// 搜索签约申请中是否有此身份证号
|
|
|
- $idcardfind = \app\common\model\GuildJoinin::where(["user_id"=>$user_id,'guild_id'=>$guild_id,"status"=>0])->find();
|
|
|
+ $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,'guild_id'=>$guild_id,"status"=>0])->find();
|
|
|
if($idcardfind) $this->error("当前账号正在审核,请耐心等待!");
|
|
|
|
|
|
- $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
+ $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
if($memberfind) $this->error("一个账号只能加入一个公会哟!");
|
|
|
|
|
|
- // 查看是否申请过
|
|
|
- /*$applyInfo = \app\common\model\GuildApply::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
- if($applyInfo && $applyInfo->status>=0) $this->error("您已经发送过开厅申请了,请勿重复发送!");*/
|
|
|
|
|
|
-// // 获取公会信息
|
|
|
-// $guildInfo = \app\common\model\Guild::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
-// // 验证更新条件
|
|
|
-// if($guildInfo) $this->error("您存在公会会长身份,请先解散相应的公会才可申请");
|
|
|
|
|
|
// 获取公会信息
|
|
|
- $guildName = \app\common\model\Guild::where(["id"=>$guild_id])->value("name");
|
|
|
+ $guildName = \app\common\model\Family::where(["id"=>$guild_id])->value("name");
|
|
|
// 获取用户信息
|
|
|
$userInfo = \app\common\model\User::field("id,avatar,nickname")->where(["id"=>$user_id])->find();
|
|
|
// 添加数据
|
|
@@ -306,7 +297,7 @@ class Family extends Api
|
|
|
$data["user_nickname"] = $userInfo->nickname;
|
|
|
$data["guild_name"] = $guildName;
|
|
|
$data["createtime"] = time();
|
|
|
- $res = \app\common\model\GuildJoinin::insert($data);
|
|
|
+ $res = \app\common\model\FamilyJoinin::insert($data);
|
|
|
if($res) {
|
|
|
// +message
|
|
|
// \app\common\model\Message::addMessage($user_id,"公会消息","申请加入公会消息");
|
|
@@ -327,18 +318,18 @@ class Family extends Api
|
|
|
$user_id = $this->auth->id;
|
|
|
|
|
|
// 获取申请信息
|
|
|
- $joininInfo = \app\common\model\GuildJoinin::where(["id"=>$joinin_id])->find();
|
|
|
+ $joininInfo = \app\common\model\FamilyJoinin::where(["id"=>$joinin_id])->find();
|
|
|
if(empty($joininInfo)){
|
|
|
$this->error('未找到申请信息');
|
|
|
}
|
|
|
|
|
|
// 获取公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::where(["id"=>$joininInfo->guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::where(["id"=>$joininInfo->guild_id])->find();
|
|
|
// 验证更新条件
|
|
|
if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是族长,无权限更改!");
|
|
|
|
|
|
//判断重复
|
|
|
- $memberfind = \app\common\model\GuildMember::where(["user_id"=>$joininInfo['user_id'],"status"=>1])->find();
|
|
|
+ $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$joininInfo['user_id'],"status"=>1])->find();
|
|
|
if($memberfind) $this->error("该用户已有家族!");
|
|
|
|
|
|
//清理其他公会未审核的数据
|
|
@@ -346,7 +337,7 @@ class Family extends Api
|
|
|
$joinWhere['user_id'] = $joininInfo['user_id'];
|
|
|
$joinWhere['guild_id'] = ['neq',$joininInfo['guild_id']];
|
|
|
$joinWhere['status'] = 0;
|
|
|
- $joinData = model('GuildJoinin')->where($joinWhere)->delete();
|
|
|
+ $joinData = model('FamilyJoinin')->where($joinWhere)->delete();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -372,7 +363,7 @@ class Family extends Api
|
|
|
$data["sign_time_slot"] = $sign_time_slot;
|
|
|
$data["status"] = $is_pass;
|
|
|
$data["createtime"] = time();
|
|
|
- $res1 = \app\common\model\GuildJoininLog::insert($data);
|
|
|
+ $res1 = \app\common\model\FamilyJoininLog::insert($data);
|
|
|
|
|
|
// 更新申请状态
|
|
|
$joininInfo->status = $is_pass;
|
|
@@ -387,8 +378,8 @@ class Family extends Api
|
|
|
$data["role"] = 0;
|
|
|
$data["status"] = 1;
|
|
|
$data["createtime"] = time();
|
|
|
- $res3 = \app\common\model\GuildMember::insert($data);
|
|
|
- $res4 = \app\common\model\Guild::where(["id"=>$guildInfo->id])->setInc("member");
|
|
|
+ $res3 = \app\common\model\FamilyMember::insert($data);
|
|
|
+ $res4 = \app\common\model\Family::where(["id"=>$guildInfo->id])->setInc("member");
|
|
|
if($res1 && $res2 && $res3 && $res4) {
|
|
|
// +message
|
|
|
\app\common\model\Message::addMessage($joininInfo->user_id,"工会审核通知","恭喜,您的加入工会审核通过啦!工会ID:".$guildInfo->g_id);
|
|
@@ -433,7 +424,7 @@ class Family extends Api
|
|
|
$where = [];
|
|
|
$where["guild_id"] = $guildInfo->id;
|
|
|
$where["status"] = 0;
|
|
|
- $result = model('GuildJoinin')->field("id,user_id,user_avatar,user_nickname,guild_name,createtime")
|
|
|
+ $result = model('FamilyJoinin')->field("id,user_id,user_avatar,user_nickname,guild_name,createtime")
|
|
|
->with(['user'=>function($uQuery){
|
|
|
$uQuery->field('id,is_online,onlinetime');
|
|
|
}])
|
|
@@ -479,9 +470,9 @@ class Family extends Api
|
|
|
$where["a.guild_id"] = $guild_id;
|
|
|
$where["a.status"] = 1;
|
|
|
// 获取公会成员总数
|
|
|
- $guildMemberCount = \app\common\model\GuildMember::alias("a")->where($where)->count("id");
|
|
|
+ $guildMemberCount = \app\common\model\FamilyMember::alias("a")->where($where)->count("id");
|
|
|
// 获取公会成员列表
|
|
|
- $guildMemberList = \app\common\model\GuildMember::alias("a")
|
|
|
+ $guildMemberList = \app\common\model\FamilyMember::alias("a")
|
|
|
->field("a.id,a.user_id,u.avatar,u.nickname,u.gender,u.age,a.role,u.is_online,u.onlinetime")
|
|
|
->join("hx_user u","a.user_id = u.id")
|
|
|
->where($where)
|
|
@@ -523,14 +514,14 @@ class Family extends Api
|
|
|
if($member_id <= 0) $this->error("参数错误!");
|
|
|
|
|
|
//成员信息
|
|
|
- $memberData = model('GuildMember')->field('id,user_id')->find($member_id);
|
|
|
+ $memberData = model('FamilyMember')->field('id,user_id')->find($member_id);
|
|
|
|
|
|
//更新成员的 财富值 ,魅力值,收到的礼物数量
|
|
|
$userService = new UserService();
|
|
|
$userService->updateGuildMember(['user_id'=>$memberData['user_id']]);
|
|
|
|
|
|
//从user表拿一些用户信息
|
|
|
- $memberInfo = model('GuildMember')
|
|
|
+ $memberInfo = model('FamilyMember')
|
|
|
->field('id,user_id,wealth,charm,gift_num,role,guild_id,createtime')
|
|
|
->with(['user'=>function($uQuery){
|
|
|
$uQuery->field('id,avatar,nickname,gender,age,logintime,age_id,constellation_id,province_id,city_id');
|
|
@@ -560,7 +551,7 @@ class Family extends Api
|
|
|
$memberInfo["logintime"] = !empty($logintime) ? date("Y-m-d", $logintime) : '';
|
|
|
|
|
|
//我在这个工会的角色
|
|
|
- $myGuildMember = model('GuildMember')->field('role')->where(["user_id"=>$this->auth->id,"guild_id"=>$memberInfo->guild_id])->find();
|
|
|
+ $myGuildMember = model('FamilyMember')->field('role')->where(["user_id"=>$this->auth->id,"guild_id"=>$memberInfo->guild_id])->find();
|
|
|
$memberInfo["my_role"] = !empty($myGuildMember) ? $myGuildMember['role'] : -1;
|
|
|
|
|
|
//几个比较大的值,改w单位
|
|
@@ -587,12 +578,12 @@ class Family extends Api
|
|
|
$user_id = $this->auth->id;
|
|
|
|
|
|
// 获取公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::where(["id"=>$guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::where(["id"=>$guild_id])->find();
|
|
|
|
|
|
// 验证更新条件
|
|
|
if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是公会长,无权限更改!");
|
|
|
|
|
|
- $memberInfo = \app\common\model\GuildMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->find();
|
|
|
+ $memberInfo = \app\common\model\FamilyMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->find();
|
|
|
if(!$memberInfo) $this->error("会员信息查询失败!");
|
|
|
|
|
|
//取消管理员
|
|
@@ -631,11 +622,11 @@ class Family extends Api
|
|
|
// 先判断是否为公会会长
|
|
|
$user_id = $this->auth->id;
|
|
|
// 获取公会信息
|
|
|
- $guildInfo = \app\common\model\Guild::where(["id"=>$guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::where(["id"=>$guild_id])->find();
|
|
|
// 验证更新条件
|
|
|
if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是公会长,无权限更改!");
|
|
|
|
|
|
- $memberInfo = \app\common\model\GuildMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->find();
|
|
|
+ $memberInfo = \app\common\model\FamilyMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->find();
|
|
|
if(!$memberInfo) $this->error("会员信息查询失败!");
|
|
|
|
|
|
if($memberInfo['role'] == 2 || $memberInfo['user_id'] == $guildInfo['user_id']){
|
|
@@ -645,7 +636,7 @@ class Family extends Api
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
$res1 = $memberInfo->delete();
|
|
|
- $res2 = \app\common\model\Guild::where(["id"=>$guild_id])->setDec("member");
|
|
|
+ $res2 = \app\common\model\Family::where(["id"=>$guild_id])->setDec("member");
|
|
|
if($res1 && $res2) {
|
|
|
Db::commit();
|
|
|
$this->success("踢出成功!");
|
|
@@ -674,7 +665,7 @@ class Family extends Api
|
|
|
$id = input('guild_id',0);
|
|
|
$guildMemberWhere['guild_id'] = $id;
|
|
|
$guildMemberWhere['status'] = 1;
|
|
|
- $guildMember = model('GuildMember')->field('id,user_id,role')->where($guildMemberWhere)->select();
|
|
|
+ $guildMember = model('FamilyMember')->field('id,user_id,role')->where($guildMemberWhere)->select();
|
|
|
$list = [];
|
|
|
if (!empty($guildMember)) {
|
|
|
$userIds = array_column($guildMember,'user_id');
|