wesmiler 2 hónapja
szülő
commit
facc24c6d5

+ 4 - 57
app/Http/Controllers/Admin/AccountController.php

@@ -23,21 +23,6 @@ use App\Services\Common\AccountService;
 class AccountController extends Backend
 {
     /**
-     * 获取商家对应的 user_id(用于数据隔离)
-     * @return int|null
-     */
-    private function getUserId()
-    {
-        if ($this->storeId > 0) {
-            // 如果是商家登录,获取商家对应的 user_id
-            $storeModel = new \App\Models\StoreModel();
-            $storeInfo = $storeModel->find($this->storeId);
-            return $storeInfo ? $storeInfo->user_id : null;
-        }
-        return null;
-    }
-
-    /**
      * 列表
      */
     public function index()
@@ -46,9 +31,10 @@ class AccountController extends Backend
         $params = request()->all();
 
         // 获取商家对应的 user_id 用于数据隔离
-        $userId = $this->getUserId();
-        if ($userId) {
-            $params['user_id'] = $userId;
+        if ($this->storeId) {
+            $params['store_id'] = $this->storeId;
+        }else if($this->memberId){
+            $params['user_id'] = $this->memberId;
         }
 
         $result = $service->getDataList($params, $params['limit']);
@@ -77,43 +63,4 @@ class AccountController extends Backend
 
         return showJson($result['msg'], $result['code'] == 0, $result['data'] ?? []);
     }
-
-    // 财务明细只能查看,不能修改、添加、删除
-    // 以下方法已禁用
-
-    // /**
-    //  * 添加
-    //  */
-    // public function add()
-    // {
-    //     $result = $this->service->add();
-    //     return showJson($result['msg'], $result['code'] == 0);
-    // }
-
-    // /**
-    //  * 编辑
-    //  */
-    // public function edit()
-    // {
-    //     $result = $this->service->edit();
-    //     return showJson($result['msg'], $result['code'] == 0);
-    // }
-
-    // /**
-    //  * 设置状态
-    //  */
-    // public function status()
-    // {
-    //     $result = $this->service->status();
-    //     return showJson($result['msg'], $result['code'] == 0);
-    // }
-
-    // /**
-    //  * 删除
-    //  */
-    // public function delete()
-    // {
-    //     $result = $this->service->delete();
-    //     return showJson($result['msg'], $result['code'] == 0);
-    // }
 }

+ 7 - 6
app/Http/Controllers/Admin/Backend.php

@@ -40,7 +40,7 @@ class Backend extends BaseController
     protected $userInfo;
     // 请求参数
     protected $param;
-    // 店铺ID
+    // 企业ID
     protected $storeId;
     /**
      * 构造函数
@@ -105,13 +105,14 @@ class Backend extends BaseController
             $adminModel = new UserModel();
             $userInfo = $adminModel->getInfo($this->userId);
             $this->userInfo = $userInfo;
-            $storeModel = new StoreModel();
 
-            // 通过 user.user_id(member ID)查询关联的商家
+            // 企业数据
+            $type = isset($userInfo['type'])? $userInfo['type'] : 1;
             $memberId = $userInfo['user_id'] ?? 0;
-            $storeInfo = $memberId > 0 ? $storeModel->getInfoByUserId($memberId) : null;
-            $this->storeId = $storeInfo ? $storeInfo['id'] : 0;
-            $this->memberId = $storeInfo ? $storeInfo['user_id'] : 0;
+            if($type==2){
+                $this->storeId = $this->userId;
+                $this->memberId = $memberId;
+            }
         }
     }
 

+ 0 - 3
app/Services/Common/FinancialService.php

@@ -4,10 +4,7 @@ namespace App\Services\Common;
 
 use App\Models\OrderModel;
 use App\Models\MemberModel;
-use App\Models\WithdrawModel;
-use App\Models\AccountLogModel;
 use App\Services\BaseService;
-use Illuminate\Support\Facades\DB;
 
 /**
  * 财务服务