|
@@ -26,7 +26,7 @@ class Family extends Api
|
|
|
$whereOr['name'] = array('like', '%' . $search . '%');
|
|
|
$whereOr['g_id'] = $search;
|
|
|
}
|
|
|
- $res = Db::name('family')->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,notice,member")
|
|
|
->where($where)
|
|
|
->where(function ($query) use($whereOr) {
|
|
|
$query->whereOr($whereOr);
|
|
@@ -48,21 +48,7 @@ class Family extends Api
|
|
|
$guild_id = input("guild_id"); //公会ID
|
|
|
$is_member = 0;
|
|
|
$user_id = $this->auth->id;
|
|
|
- if($guild_id <= 0) {
|
|
|
- $is_member = 1;
|
|
|
- // 获取当前用户是否是公会成员
|
|
|
- $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
- if($idcardfind) $this->error("您存在加入家族的申请,正在审核中,请耐心等待!");
|
|
|
-
|
|
|
- $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
- if($memberfind) $guild_id = $memberfind->guild_id;
|
|
|
-
|
|
|
- if(!$guild_id) {
|
|
|
- $res["is_member"] = 2; // 是否为派对成员
|
|
|
- $this->success("获取成功!",$res);
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
|
|
|
//结果
|
|
|
$res = [];
|
|
@@ -73,12 +59,12 @@ class Family extends Api
|
|
|
// 获取公会成员信息
|
|
|
$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();
|
|
|
+ ->join("user u","a.user_id = u.id")
|
|
|
+ ->where(["a.guild_id"=>$guild_id])->where('a.status',1)->limit(10)->order("a.role","desc")->select();
|
|
|
if(!$guildInfo || !$guildMemberInfo) $this->error("家族信息获取失败!");
|
|
|
|
|
|
// 获取公会成员总数
|
|
|
- $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
+ $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->where('status',1)->count("id");
|
|
|
|
|
|
// 获取会长信息
|
|
|
$guilderInfo = \app\common\model\User::field("avatar,nickname,u_id")->where(["id"=>$guildInfo->user_id])->find();
|
|
@@ -101,25 +87,7 @@ class Family extends Api
|
|
|
$guild_id = input("guild_id"); //公会ID
|
|
|
$is_member = 0;
|
|
|
$user_id = $this->auth->id;
|
|
|
- if($guild_id <= 0) {
|
|
|
- $is_member = 1;
|
|
|
- // 获取当前用户是否是公会成员
|
|
|
- $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
|
|
|
- if($idcardfind) $this->error("您存在加入家族的申请,正在审核中,请耐心等待!");
|
|
|
-
|
|
|
- $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\Family::field("id,image,name,g_id,user_id,group_id,desc,notice,status")->where($guildWhere)->find();
|
|
|
-
|
|
|
- if(!$guild_id) {
|
|
|
- $res["is_member"] = 2; // 是否为派对成员
|
|
|
- $res["guild_status"] = isset($guildInfo['status']) ? (int)$guildInfo['status'] : -2; // 是否为派对成员
|
|
|
- $this->success("获取成功!",$res);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
//结果
|
|
|
$res = [];
|
|
@@ -131,11 +99,11 @@ class Family extends Api
|
|
|
$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();
|
|
|
+ ->where(["a.guild_id"=>$guild_id])->where('a.status',1)->limit(10)->order("a.role","desc")->select();
|
|
|
if(!$guildInfo || !$guildMemberInfo) $this->error("家族信息获取失败!");
|
|
|
|
|
|
// 获取公会成员总数
|
|
|
- $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->count("id");
|
|
|
+ $guildMemberCount = \app\common\model\FamilyMember::where(["guild_id"=>$guild_id])->where('status',1)->count("id");
|
|
|
|
|
|
// 获取会长信息
|
|
|
$guilderInfo = \app\common\model\User::field("avatar,nickname,u_id")->where(["id"=>$guildInfo->user_id])->find();
|
|
@@ -190,16 +158,14 @@ class Family extends Api
|
|
|
}
|
|
|
|
|
|
//检查不能是其他家族的成员
|
|
|
- $checkmember = model('FamilyMember')->where('user_id',$this->auth->id)->find();
|
|
|
+ $checkmember = model('FamilyMember')->where('user_id',$this->auth->id)->where('status',1)->find();
|
|
|
if (!empty($checkmember)) {
|
|
|
$this->error('您已经加入了其他家族');
|
|
|
}
|
|
|
|
|
|
//检查删除这个人的所有加入申请
|
|
|
- $joinWhere['user_id'] = $this->auth->id;
|
|
|
- $joinWhere['status'] = 0;
|
|
|
- $joinData = model('FamilyJoinin')->where($joinWhere)->find();
|
|
|
- if (!empty($checkmember)) {
|
|
|
+ $joinData = model('FamilyMember')->where('user_id',$this->auth->id)->where('status',0)->find();
|
|
|
+ if (!empty($joinData)) {
|
|
|
$this->error('您已经申请加入了其他家族,需等待被拒或退出,才能创建家族');
|
|
|
}
|
|
|
|
|
@@ -231,7 +197,7 @@ class Family extends Api
|
|
|
'guild_id' => $guildInfo->id,
|
|
|
'user_id' => $user_id,
|
|
|
'role' => 2, //角色:0=成员,1=副会长,2=会长
|
|
|
- 'status' => 1, //状态:1=签约中,2=已解约
|
|
|
+ 'status' => 1,
|
|
|
'createtime' => time(),
|
|
|
];
|
|
|
$guildRes = model('FamilyMember')->insertGetId($guildMemberData);
|
|
@@ -274,47 +240,58 @@ class Family extends Api
|
|
|
// 一个身份证号只能申请一次
|
|
|
$user_id = $this->auth->id;
|
|
|
// 实名认证
|
|
|
- $userAuthInfo = \app\common\model\UserAuth::where(["user_id"=>$user_id])->find();
|
|
|
- if($userAuthInfo) {
|
|
|
- if($userAuthInfo->status == 0) {
|
|
|
- $this->error("您的实名认证还在这审核中...,请耐心等待!");
|
|
|
- } elseif($userAuthInfo->status == 2) {
|
|
|
- $this->error("您的实名认证审核未通过,请重新审核!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- $this->error("请先申请实名认证!");
|
|
|
+ if($this->auth->is_auth != 2){
|
|
|
+ $this->error('请先完成实名认证');
|
|
|
}
|
|
|
|
|
|
- // 获取用户实名认证信息
|
|
|
- $authUserIdcard = \app\common\model\UserAuth::where(["user_id"=>$user_id])->value("idcard");
|
|
|
- // 搜索签约申请中是否有此身份证号
|
|
|
- $idcardfind = \app\common\model\FamilyJoinin::where(["user_id"=>$user_id,'guild_id'=>$guild_id,"status"=>0])->find();
|
|
|
- if($idcardfind) $this->error("当前账号正在审核,请耐心等待!");
|
|
|
+ $check = \app\common\model\Family::where(["user_id"=>$this->auth->id])->where('status',1)->find();
|
|
|
+ if($check){
|
|
|
+ $this->error('您已经有自己的家族了');
|
|
|
+ }
|
|
|
|
|
|
- $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>1])->find();
|
|
|
- if($memberfind) $this->error("一个账号只能加入一个家族哟!");
|
|
|
+ $check = \app\common\model\FamilyMember::where(["user_id"=>$this->auth->id,'guild_id'=>$guild_id])->find();
|
|
|
+ if($check){
|
|
|
+ if($check['status'] == 0){
|
|
|
+ $this->error('您已经申请进入该家族了,请等待审核');
|
|
|
+ }
|
|
|
+ if($check['status'] == 1){
|
|
|
+ $this->error('您已经是该家族的成员了');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //
|
|
|
+ Db::startTrans();
|
|
|
+ $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$user_id,"status"=>['neq',-1]])->count();
|
|
|
+ if($memberfind >= 1){
|
|
|
+ $card = Db::name('user_decorate_family')->where(["user_id"=>$user_id,'decorate_id'=>1,"is_using"=>0])->lock(true)->find();
|
|
|
+ if(!$card){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('家族卡数量不足');
|
|
|
+ }
|
|
|
+ $rs = Db::name('user_decorate_family')->where('id',$card['id'])->update(["is_using"=>0,'updatetime'=>time()]);
|
|
|
+ if(!$rs){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('使用家族卡失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- // 获取公会信息
|
|
|
- $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();
|
|
|
// 添加数据
|
|
|
$data = [];
|
|
|
$data["user_id"] = $user_id;
|
|
|
$data["guild_id"] = $guild_id;
|
|
|
- $data["user_avatar"] = $userInfo->avatar;
|
|
|
- $data["user_idcard"] = $authUserIdcard;
|
|
|
- $data["user_nickname"] = $userInfo->nickname;
|
|
|
- $data["guild_name"] = $guildName;
|
|
|
+ $data["role"] = 0;
|
|
|
+ $data["wealth"] = 0;
|
|
|
+ $data["charm"] = 0;
|
|
|
+ $data["gift_num"] = 0;
|
|
|
+ $data["status"] = 0;
|
|
|
$data["createtime"] = time();
|
|
|
- $res = \app\common\model\FamilyJoinin::insert($data);
|
|
|
+ $res = \app\common\model\FamilyMember::insert($data);
|
|
|
if($res) {
|
|
|
- // +message
|
|
|
-// \app\common\model\Message::addMessage($user_id,"公会消息","申请加入公会消息");
|
|
|
+ Db::commit();
|
|
|
$this->success("申请发送成功!");
|
|
|
} else {
|
|
|
+ Db::rollback();
|
|
|
$this->error("网络错误,请稍后重试!");
|
|
|
}
|
|
|
}
|
|
@@ -322,80 +299,51 @@ class Family extends Api
|
|
|
/**
|
|
|
* 公会签约申请审核
|
|
|
*/
|
|
|
- public function guildJoininExamine() {
|
|
|
- $joinin_id = input("joinin_id"); // 申请加入的申请ID
|
|
|
+ public function guildMemberExamine() {
|
|
|
+ $member_id = input("member_id"); // 申请加入的申请ID
|
|
|
$is_pass = input("is_pass"); // 是否通过:1=通过,-1=拒绝
|
|
|
- if(!in_array($is_pass,[1,-1]) || !$joinin_id) $this->error("参数错误!");
|
|
|
+ if(!in_array($is_pass,[1,-1]) || !$member_id) $this->error("参数错误!");
|
|
|
|
|
|
$user_id = $this->auth->id;
|
|
|
|
|
|
// 获取申请信息
|
|
|
- $joininInfo = \app\common\model\FamilyJoinin::where(["id"=>$joinin_id])->find();
|
|
|
- if(empty($joininInfo)){
|
|
|
+ $memberInfo = \app\common\model\FamilyMember::where(["id"=>$member_id])->find();
|
|
|
+ if(empty($memberInfo)){
|
|
|
$this->error('未找到申请信息');
|
|
|
}
|
|
|
|
|
|
// 获取公会信息
|
|
|
- $guildInfo = \app\common\model\Family::where(["id"=>$joininInfo->guild_id])->find();
|
|
|
+ $guildInfo = \app\common\model\Family::where(["id"=>$memberInfo->guild_id])->find();
|
|
|
// 验证更新条件
|
|
|
if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是族长,无权限更改!");
|
|
|
|
|
|
//判断重复
|
|
|
- $memberfind = \app\common\model\FamilyMember::where(["user_id"=>$joininInfo['user_id'],"status"=>1])->find();
|
|
|
- if($memberfind) $this->error("该用户已有家族!");
|
|
|
-
|
|
|
- //清理其他公会未审核的数据
|
|
|
- if ($is_pass == 1) {
|
|
|
- $joinWhere['user_id'] = $joininInfo['user_id'];
|
|
|
- $joinWhere['guild_id'] = ['neq',$joininInfo['guild_id']];
|
|
|
- $joinWhere['status'] = 0;
|
|
|
- $joinData = model('FamilyJoinin')->where($joinWhere)->delete();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 获取用户信息
|
|
|
- $userInfo = \app\common\model\User::field("id,u_id,mobile,nickname")->where(["id"=>$joininInfo->user_id])->find();
|
|
|
+ $memberfind = \app\common\model\Family::where(["user_id"=>$memberInfo['user_id'],"status"=>1])->find();
|
|
|
+ if($memberfind) $this->error("该用户已有自己的家族!");
|
|
|
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
- //记个无用的日志
|
|
|
- $data = [];
|
|
|
- $data["user_id"] = $joininInfo->user_id;
|
|
|
- $data["operator"] = $user_id;
|
|
|
- $data["user_nickname"] = $userInfo->nickname;
|
|
|
- $data["user_u_id"] = $userInfo->u_id;
|
|
|
- $data["guild_id"] = $guildInfo->id;
|
|
|
- $data["guild_name"] = $guildInfo->name;
|
|
|
- $data["guild_g_id"] = $guildInfo->g_id;
|
|
|
- $data["status"] = $is_pass;
|
|
|
- $data["createtime"] = time();
|
|
|
- $res1 = \app\common\model\FamilyJoininLog::insert($data);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// 更新申请状态
|
|
|
- $joininInfo->status = $is_pass;
|
|
|
- $joininInfo->updatetime = time();
|
|
|
- $res2 = $joininInfo->save();
|
|
|
+ $memberInfo->status = $is_pass;
|
|
|
+ $memberInfo->updatetime = time();
|
|
|
+ $res2 = $memberInfo->save();
|
|
|
|
|
|
if($is_pass == 1) {
|
|
|
- // 同意后 加入公会成员
|
|
|
- $data = [];
|
|
|
- $data["guild_id"] = $guildInfo->id;
|
|
|
- $data["user_id"] = $joininInfo->user_id;
|
|
|
- $data["role"] = 0;
|
|
|
- $data["status"] = 1;
|
|
|
- $data["createtime"] = time();
|
|
|
- $res3 = \app\common\model\FamilyMember::insert($data);
|
|
|
+
|
|
|
$res4 = \app\common\model\Family::where(["id"=>$guildInfo->id])->setInc("member");
|
|
|
- if($res1 && $res2 && $res3 && $res4) {
|
|
|
+ if($res2 && $res4) {
|
|
|
// +message
|
|
|
- \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","恭喜,您的加入家族审核通过啦!");
|
|
|
+ \app\common\model\Message::addMessage($memberInfo->user_id,"家族审核通知","恭喜,您的加入家族审核通过啦!");
|
|
|
Db::commit();
|
|
|
$this->success("已审核通过!");
|
|
|
}
|
|
|
} else {
|
|
|
- if($res1 && $res2) {
|
|
|
+ if($res2) {
|
|
|
// +message
|
|
|
- \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","您的家族加入申请,族长审核拒绝,没关系,调整姿势再来一遍!");
|
|
|
+ \app\common\model\Message::addMessage($memberInfo->user_id,"家族审核通知","您的家族加入申请,族长审核拒绝,没关系,调整姿势再来一遍!");
|
|
|
Db::commit();
|
|
|
$this->success("已审核拒绝!");
|
|
|
}
|
|
@@ -420,39 +368,39 @@ class Family extends Api
|
|
|
/**
|
|
|
* 公会申请加入列表
|
|
|
*/
|
|
|
- public function guildJoinList() {
|
|
|
+ public function guildauditList() {
|
|
|
try {
|
|
|
$user_id = $this->auth->id;
|
|
|
// 获取公会信息
|
|
|
$guildInfo = model('Family')->where(["user_id"=>$user_id])->find();
|
|
|
- if(!$guildInfo) throw new Exception('家族信息获取失败!');
|
|
|
+ if(!$guildInfo) throw new Exception('您当前还没有家族!');
|
|
|
+
|
|
|
// 先获取申请列表
|
|
|
$where = [];
|
|
|
- $where["guild_id"] = $guildInfo->id;
|
|
|
- $where["status"] = 0;
|
|
|
- $result = model('FamilyJoinin')->field("id,user_id,user_avatar,user_nickname,guild_name,createtime")
|
|
|
- ->with(['user'=>function($uQuery){
|
|
|
- $uQuery->field('id,is_online,onlinetime');
|
|
|
- }])
|
|
|
+ $where["m.guild_id"] = $guildInfo->id;
|
|
|
+ $where["m.status"] = 0;
|
|
|
+ $result = Db::name('family_member')->alias('m')
|
|
|
+ ->field("m.*,user.is_online,user.onlinetime,user.nickname,user.avatar")
|
|
|
+ ->join('user','m.user_id = user.id','LEFT')
|
|
|
+ ->join('family','m.guild_id = family.id','LEFT')
|
|
|
->where($where)->order("createtime","desc")->select();
|
|
|
+ $result = list_domain_image($result,['avatar']);
|
|
|
+
|
|
|
if($result) {
|
|
|
foreach($result as $k => &$v) {
|
|
|
- $user = isset($v['user']) ? $v['user'] : [];
|
|
|
- $onlineText = '';
|
|
|
- if (!empty($user)) {
|
|
|
- if ($user['is_online'] == 1) {
|
|
|
- $onlineText = '在线';
|
|
|
- } else {
|
|
|
- $onlineTime = get_last_time($user['onlinetime']);
|
|
|
- $onlineText = $onlineTime.'在线';
|
|
|
- $limitTime = time() - (3600 * 6);
|
|
|
- if ($user['onlinetime'] < $limitTime) {
|
|
|
- $onlineText = '离线';
|
|
|
- }
|
|
|
+
|
|
|
+ if ($v['is_online'] == 1) {
|
|
|
+ $onlineText = '在线';
|
|
|
+ } else {
|
|
|
+ $onlineTime = get_last_time($v['onlinetime']);
|
|
|
+ $onlineText = $onlineTime.'在线';
|
|
|
+ $limitTime = time() - (3600 * 6);
|
|
|
+ if ($v['onlinetime'] < $limitTime) {
|
|
|
+ $onlineText = '离线';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$v['online_text'] = $onlineText;
|
|
|
- $v['createtime'] = !empty($v["createtime"]) ? date("Y-m-d H:i", $v["createtime"]) : '';
|
|
|
unset($v['user']);
|
|
|
}
|
|
|
}
|
|
@@ -467,11 +415,9 @@ class Family extends Api
|
|
|
*/
|
|
|
public function guildMember() {
|
|
|
$guild_id = input("guild_id",0,"intval"); //公会ID
|
|
|
- $page = input('page',1); // 分页
|
|
|
- $pageNum = input('listrow',10); // 分页
|
|
|
- // 分页搜索构建
|
|
|
- $pageStart = ($page-1)*$pageNum;
|
|
|
+
|
|
|
if($guild_id <= 0) $this->error("参数错误!");
|
|
|
+
|
|
|
$where = [];
|
|
|
$where["a.guild_id"] = $guild_id;
|
|
|
$where["a.status"] = 1;
|
|
@@ -482,7 +428,7 @@ class Family extends Api
|
|
|
->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)
|
|
|
- ->limit($pageStart,$pageNum)
|
|
|
+ ->autopage()
|
|
|
->order("a.role","desc")
|
|
|
->select();
|
|
|
|
|
@@ -587,9 +533,9 @@ class Family extends Api
|
|
|
$guildInfo = \app\common\model\Family::where(["id"=>$guild_id])->find();
|
|
|
|
|
|
// 验证更新条件
|
|
|
- if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是族长,无权限更改!");
|
|
|
+ if($user_id !== $guildInfo['user_id']) $this->error("身份验证失败!您不是族长,无权限更改!");
|
|
|
|
|
|
- $memberInfo = \app\common\model\FamilyMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->find();
|
|
|
+ $memberInfo = \app\common\model\FamilyMember::where(["id"=>$member_id,'guild_id'=>$guild_id])->where('status',1)->find();
|
|
|
if(!$memberInfo) $this->error("会员信息查询失败!");
|
|
|
|
|
|
//取消管理员
|