zxhxx 3 yıl önce
ebeveyn
işleme
e353f7d3a6

+ 8 - 3
application/api/controller/User.php

@@ -417,9 +417,14 @@ class User extends Api
                 UserExt::create($user_ext);
             }
         }
-        $where['cid'] = $this->cid;
-        $where['user_id'] = $this->auth->getUserinfo()['id'];
-        UserApply::create($where);
+        if(!UserApply::where('user_id',$this->auth->getUserinfo()['id'])->find()) {
+            $where['cid'] = $this->cid;
+            $where['user_id'] = $this->auth->getUserinfo()['id'];
+            UserApply::create($where);
+        }else
+        {
+            UserApply::where('user_id',$this->auth->getUserinfo()['id'])->update($where);
+        }
         $this->success('修改成功');
     }
 }

+ 1 - 1
application/common/library/Auth.php

@@ -27,7 +27,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score','level','money','spread_uid','login_type','vip_forever','vip_endtime'];
+    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score','level','money','spread_uid','login_type','vip_forever','vip_endtime','group_id'];
 
     public function __construct($options = [])
     {

+ 1 - 0
application/common/model/User.php

@@ -359,6 +359,7 @@ class User extends BaseModel
             $data['vip_endtime'] = strtotime("+{$level['validity_month']} month",$user['vip_endtime']);
         }
         $data['group_id'] = $level_id;
+        $data['level'] = $level_id;
         $data['user_type'] = $level['user_type'];
         self::where('user_id',$user_id)->update($data);
         return true;