Zory преди 3 седмици
родител
ревизия
45e76954b9
променени са 4 файла, в които са добавени 43 реда и са изтрити 23 реда
  1. 1 1
      app/controller/admin/StoreUser.php
  2. 2 2
      app/controller/common/Login.php
  3. 16 2
      app/extra/basic/Service.php
  4. 24 18
      app/model/system/SystemUser.php

+ 1 - 1
app/controller/admin/StoreUser.php

@@ -31,7 +31,7 @@ class StoreUser extends Base
     public function getDataList(Request $request): Response
     {
         try {
-            $data = $this->service->setModel()->getList($request->all());
+            $data = $this->service->setModel()->getList($request->all(),"account");
             return successTrans(100010,pageFormat($data),200);
         } catch (\Throwable $th) {
             return error($th->getMessage());

+ 2 - 2
app/controller/common/Login.php

@@ -65,9 +65,9 @@ class Login extends Base
         if ($user->isEmpty()) return [0,trans("error.user-empty"),[]];
         if ($user['status'] <> 1) return [0,trans("error.user-status"),[]];
         if ($user['type'] > 1) {
-            $typeUser = $this->getTypeUser($user['agent_id']);
+            $typeUser = $this->getTypeUser($user['store_id']);
             if (empty($typeUser)) return [0,trans("empty.agent"),[]];
-            if ($typeUser['status'] <> 0) return [0,trans("error.agent"),[]];
+            if ($typeUser['status'] <> 1) return [0,trans("error.agent"),[]];
             if (time() > strtotime($typeUser['vip_end'])) return [0,trans("error.agent-out"),[]];
             $user['shop_name'] = $typeUser['poi_name'];
         }

+ 16 - 2
app/extra/basic/Service.php

@@ -104,9 +104,23 @@ class Service
     /**
      *
      */
-    public function getList(array $param = [])
+    public function getList(array $param = [],$with = null)
     {
-        return $this->searchVal($param,$this->searchFilter($param))->paginate([
+        $model = $this->searchVal($param,$this->searchFilter($param));
+        // 支持多种类型的 $with 参数
+        if ($with !== null) {
+            if (is_callable($with)) {
+                // 如果是函数,调用它
+                $with($model);
+            } elseif (is_string($with)) {
+                // 如果是字符串,直接 with
+                $model->with($with);
+            } elseif (is_array($with)) {
+                // 如果是数组,也直接 with
+                $model->with($with);
+            }
+        }
+        return $model->paginate([
             "list_rows" => $param['pageSize'],
             "page"      => $param['page']
         ]);

+ 24 - 18
app/model/system/SystemUser.php

@@ -3,27 +3,28 @@
 namespace app\model\system;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
- * @property integer $id (主键)
- * @property integer $agent_id 代理ID
- * @property string $username 用户名
- * @property string $truename 真实姓名
- * @property string $password 密码
- * @property mixed $salt 密钥串
- * @property string $contact_name 
- * @property string $contact_mobile 
- * @property integer $status 状态
- * @property integer $type 1管理员2代理子账号3店铺账号
- * @property integer $is_deleted 删除状态
- * @property integer $is_super 
- * @property string $remark 备注
- * @property string $login_ip 登录IP
- * @property mixed $login_at 登录时间
- * @property integer $login_num 
- * @property string $create_ip 
- * @property mixed $updated_at 更新时间
+ * @property integer $id (主键)
+ * @property integer $agent_id 代理ID
+ * @property string $username 用户名
+ * @property string $truename 真实姓名
+ * @property string $password 密码
+ * @property mixed $salt 密钥串
+ * @property string $contact_name 
+ * @property string $contact_mobile 
+ * @property integer $status 状态
+ * @property integer $type 1管理员2代理子账号3店铺账号
+ * @property integer $is_deleted 删除状态
+ * @property integer $is_super 
+ * @property string $remark 备注
+ * @property string $login_ip 登录IP
+ * @property mixed $login_at 登录时间
+ * @property integer $login_num 
+ * @property string $create_ip 
+ * @property mixed $updated_at 更新时间
  * @property mixed $create_at 创建时间
  */
 class SystemUser extends Model
@@ -57,4 +58,9 @@ class SystemUser extends Model
     public bool $timestamps = false;
 
 
+    public function account(): HasOne
+    {
+        return $this->hasOne("app\model\saas\SaasStore", "poi_id", "store_id");
+    }
+
 }