Browse Source

后台公会审核

lizhen_gitee 1 year ago
parent
commit
3c37ca77f6

+ 23 - 7
application/admin/controller/guild/Joinin.php

@@ -83,17 +83,27 @@ class Joinin extends Backend
 
         if ($this->request->isPost()) {
             $status = input('status',0);
-            $data = [
-                'status' => $status,
-                /*'auditremark' => input('auditremark',''),
-                'audittime' => strtotime(input('audittime','')),
-                'updatetime' => time(),*/
-            ];
+
             Db::startTrans();
-            $rs = Db::name('guild_joinin')->where('id',$id)->update($data);
+
 
             if($status == 1){
 
+                //判断重复
+                $memberfind = \app\common\model\GuildMember::where(["user_id"=>$info['user_id']])->find();
+                if($memberfind) {
+                    Db::rollback();
+                    //包括成员,副会,会长角色
+                    $this->error("该用户已有公会!");
+                }
+
+                //清理其他公会未审核的数据
+                $joinWhere['user_id'] = $info['user_id'];
+                $joinWhere['guild_id'] = ['neq',$info['guild_id']];
+                $joinWhere['status'] = 0;
+                $joinData = Db::name('guild_joinin')->where($joinWhere)->delete();
+
+
                 $data = [];
                 $data["guild_id"] = $info['guild_id'];
                 $data["user_id"] = $info['user_id'];
@@ -111,6 +121,12 @@ class Joinin extends Backend
                 $msg_id = \app\common\model\Message::addMessage($info['user_id'],'公会审核','入会审核已经被拒绝');
             }
 
+            $data = [
+                'status' => $status,
+                'updatetime' => time(),
+            ];
+            $rs = Db::name('guild_joinin')->where('id',$id)->update($data);
+
             Db::commit();
 
             $this->success('审核完成');

+ 4 - 2
application/api/controller/Guild.php

@@ -470,8 +470,10 @@ class Guild extends Api
         if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是公会长,无权限更改!");
 
         //判断重复
-        $memberfind = \app\common\model\GuildMember::where(["user_id"=>$joininInfo['user_id']])->find();
-        if($memberfind) $this->error("该用户已有公会!");//包括成员,副会,会长角色
+        if($is_pass == 1){
+            $memberfind = \app\common\model\GuildMember::where(["user_id"=>$joininInfo['user_id']])->find();
+            if($memberfind) $this->error("该用户已有公会!");//包括成员,副会,会长角色
+        }
 
         //清理其他公会未审核的数据
         if ($is_pass == 1) {