|
@@ -351,29 +351,33 @@ class Guild extends Api
|
|
|
$joinin_id = input("joinin_id"); // 申请加入的申请ID
|
|
|
$is_pass = input("is_pass"); // 是否通过:1=通过,-1=拒绝
|
|
|
if(!in_array($is_pass,[1,-1]) || !$joinin_id) $this->error("参数错误!");
|
|
|
+
|
|
|
$user_id = $this->auth->id;
|
|
|
- $memberfind = \app\common\model\GuildMember::where(["user_id"=>$joinin_id,"status"=>1])->find();
|
|
|
- if($memberfind) $this->error("该用户已有家族!");
|
|
|
+
|
|
|
// 获取申请信息
|
|
|
$joininInfo = \app\common\model\GuildJoinin::where(["id"=>$joinin_id])->find();
|
|
|
- if ($is_pass == 1) {//清理其他公会未审核的数据
|
|
|
- if (!empty($joininInfo)) {
|
|
|
- $joinWhere['user_id'] = $joininInfo['user_id'];
|
|
|
- $joinWhere['guild_id'] = ['neq',$joininInfo['guild_id']];
|
|
|
- $joinWhere['status'] = 0;
|
|
|
- $joinData = model('GuildJoinin')->where($joinWhere)->select();
|
|
|
- if (!empty($joinData)) {
|
|
|
- $joinIds = array_column($joinData,'id');
|
|
|
- $delWhere['id'] = ['in',$joinIds];
|
|
|
- model('GuildJoinin')->where($delWhere)->delete();
|
|
|
- }
|
|
|
- }
|
|
|
+ if(empty($joininInfo)){
|
|
|
+ $this->error('未找到申请信息');
|
|
|
}
|
|
|
+
|
|
|
// 获取公会信息
|
|
|
$guildInfo = \app\common\model\Guild::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();
|
|
|
+ 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('GuildJoinin')->where($joinWhere)->delete();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 获取用户信息
|
|
|
$userInfo = \app\common\model\User::field("id,u_id,mobile,nickname")->where(["id"=>$joininInfo->user_id])->find();
|
|
|
|
|
@@ -384,6 +388,7 @@ class Guild extends Api
|
|
|
$sign_time_slot = date("Y.m.d")."-".date('Y.m.d',$endtime);
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
+ //记个无用的日志
|
|
|
$data = [];
|
|
|
$data["user_id"] = $joininInfo->user_id;
|
|
|
$data["operator"] = $user_id;
|
|
@@ -396,10 +401,12 @@ class Guild extends Api
|
|
|
$data["status"] = $is_pass;
|
|
|
$data["createtime"] = time();
|
|
|
$res1 = \app\common\model\GuildJoininLog::insert($data);
|
|
|
+
|
|
|
// 更新申请状态
|
|
|
$joininInfo->status = $is_pass;
|
|
|
$joininInfo->updatetime = time();
|
|
|
$res2 = $joininInfo->save();
|
|
|
+
|
|
|
if($is_pass == 1) {
|
|
|
// 同意后 加入公会成员
|
|
|
$data = [];
|
|
@@ -414,14 +421,14 @@ class Guild extends Api
|
|
|
$res4 = \app\common\model\Guild::where(["id"=>$guildInfo->id])->setInc("member");
|
|
|
if($res1 && $res2 && $res3 && $res4) {
|
|
|
// +message
|
|
|
- \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","恭喜,您的加入家族审核通过啦!家族ID:".$guildInfo->g_id);
|
|
|
+ \app\common\model\Message::addMessage($joininInfo->user_id,"工会审核通知","恭喜,您的加入工会审核通过啦!工会ID:".$guildInfo->g_id);
|
|
|
Db::commit();
|
|
|
$this->success("已审核通过!");
|
|
|
}
|
|
|
} else {
|
|
|
if($res1 && $res2) {
|
|
|
// +message
|
|
|
- \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","您的家族加入申请,族长审核失败,没关系,调整姿势再来一遍!");
|
|
|
+ \app\common\model\Message::addMessage($joininInfo->user_id,"工会审核通知","您的工会加入申请,会长审核拒绝,没关系,调整姿势再来一遍!");
|
|
|
Db::commit();
|
|
|
$this->success("已审核拒绝!");
|
|
|
}
|