zxhxx 3 years ago
parent
commit
038255f4ee
2 changed files with 38 additions and 2 deletions
  1. 14 2
      application/api/controller/User.php
  2. 24 0
      application/common/model/UserApply.php

+ 14 - 2
application/api/controller/User.php

@@ -2,6 +2,7 @@
 
 namespace app\api\controller;
 
+use app\common\model\UserApply;
 use liuniu\IdentityCard;
 use app\admin\model\user\{UserExt};
 use app\admin\model\{User as UserModel};
@@ -400,14 +401,25 @@ class User extends Api
                 }
             }
         }
-        if(sizeof($user)>0)
+        if(sizeof($user)>0 )
         {
             UserModel::where('id',$this->auth->getUserinfo()['id'])->update($user);
         }
         if(sizeof($user_ext)>0)
         {
-            UserExt::where('id',$this->auth->getUserinfo()['id'])->update($user_ext);
+            if(UserExt::where('user_id',$this->auth->getUserinfo()['id'])->find()) {
+                UserExt::where('user_id', $this->auth->getUserinfo()['id'])->update($user_ext);
+            }
+            else
+            {
+                $user_ext['cid'] = $this->cid;
+                $user_ext['user_id'] = $this->auth->getUserinfo()['id'];
+                UserExt::create($user_ext);
+            }
         }
+        $where['cid'] = $this->cid;
+        $where['user_id'] = $this->auth->getUserinfo()['id'];
+        UserApply::create($where);
         $this->success('修改成功');
     }
 }

+ 24 - 0
application/common/model/UserApply.php

@@ -0,0 +1,24 @@
+<?php
+namespace app\common\model;
+use liuniu\BaseModel;
+
+class UserApply extends BaseModel
+{
+    // 表名
+    protected $name = 'user_apply';
+
+
+    public static function lst($where)
+    {
+        $model = new self;
+        if (isset($where['cid']) && $where['cid'] > 0) $model->where('cid', $where['cid']);
+        if (isset($where['user_id']) && $where['user_id'] > 0) $model->where('user_id', $where['user_id']);
+        if (isset($where['status']) && $where['status'] > -2) $model->where('status', $where['status']);
+        $data = $model->order('id desc')->page($where['page'], $where['limit'])->select();
+        foreach ($data as &$v)
+        {
+            $v['info'] = Help::info($v['cid'],$v['id'],$v['user_id']);
+        }
+        return $data;
+    }
+}