Răsfoiți Sursa

[智价云] 移动端按公司数据隔离

tangyuanwang 1 săptămână în urmă
părinte
comite
a05df626a7

+ 2 - 0
app/Http/Controllers/Api/Personnel/Employee.php

@@ -29,8 +29,10 @@ class Employee extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[]=['company_id','=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $name = request('name', '');
         // 其他条件

+ 30 - 21
app/Http/Controllers/Api/Process/LowPriceGoods.php

@@ -24,14 +24,16 @@ class LowPriceGoods extends Api
      * @date      2025-12-09
      * 
      */
-    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel,LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
+    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel, LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
     {
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $user_id = $user_info['uid'];
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '');
         $start_time = request('start_time', '');
@@ -53,47 +55,48 @@ class LowPriceGoods extends Api
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         // 其他条件
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
-        if ($store_name) $map[]   = ['store_name','like',"%$store_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
+
 
         //多选平台查询
-        if($platform && is_string($platform)){
+        if ($platform && is_string($platform)) {
             $platform = explode(',', $platform);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('platform', $platform);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('platform', $platform);
         }
         //多选处理状态查询
-        if($processing_status && is_string($processing_status)){
+        if ($processing_status && is_string($processing_status)) {
             $processing_status = explode(',', $processing_status);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('processing_status', $processing_status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('processing_status', $processing_status);
         }
         //多选状态查询
-        if($status && is_string($status)){
+        if ($status && is_string($status)) {
             $status = explode(',', $status);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('status', $status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('status', $status);
         }
         //多选店铺名称查询
-        if($store_names && is_string($store_names)){
+        if ($store_names && is_string($store_names)) {
             $store_names = explode(',', $store_names);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('store_name', $store_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('store_name', $store_names);
         }
         //多选违规挂网次数查询
-        if($online_posting_count && is_string($online_posting_count)){
+        if ($online_posting_count && is_string($online_posting_count)) {
             $online_posting_count = explode(',', $online_posting_count);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('online_posting_count', $online_posting_count);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('online_posting_count', $online_posting_count);
         }
         //多选规格查询
-        if($product_specs && is_string($product_specs)){
+        if ($product_specs && is_string($product_specs)) {
             $product_specs = explode(',', $product_specs);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('product_specs', $product_specs);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_specs', $product_specs);
         }
         //多选商品查询
         if ($product_names && is_string($product_names)) {
             $product_names = explode(',', $product_names);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('product_name', $product_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_name', $product_names);
         }
         //多选公司查询
         if ($company_name && is_string($company_name)) {
             $company_name = explode(',', $company_name);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('company_name', $company_name);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('company_name', $company_name);
         }
         //多选第一责任人
         if ($first_responsible_person && is_string($first_responsible_person)) {
@@ -123,12 +126,12 @@ class LowPriceGoods extends Api
         // 查询数据
         $result = $LowPriceGoodsModel->where($map)->where(function ($q) use ($user_id) {
             $q->where('first_responsible_person', 'like', "%,$user_id,%")
-            ->orWhere('responsible_person', 'like', "%,$user_id,%")
-            ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
+                ->orWhere('responsible_person', 'like', "%,$user_id,%")
+                ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
         })
-        ->orderByDesc('id')
-        ->paginate($limit)
-        ->toArray();
+            ->orderByDesc('id')
+            ->paginate($limit)
+            ->toArray();
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
         if (isset($result['data']) && count($result['data']) > 0) {
@@ -162,9 +165,11 @@ class LowPriceGoods extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('detail')->validate();
+        $company_id = $user_info['company_id'];
         // 接收参数
         $id = request('id', 0);
         $map = ['id' => $id];
+        $map['company_id'] = $company_id;
         $data = $LowPriceGoodsModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询第一责任人名称
@@ -194,6 +199,7 @@ class LowPriceGoods extends Api
     {
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
+        $company_id = $user_info['company_id'];
         // 验证参数
         $request->scene('set_status')->validate();
         // 接收数据
@@ -201,6 +207,7 @@ class LowPriceGoods extends Api
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $where['company_id'] = $company_id;
         // 执行修改
         $result            =  $LowPriceGoodsModel->changeStatus($where, $status);
         // 提示新增失败
@@ -220,6 +227,7 @@ class LowPriceGoods extends Api
     {
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
+        $company_id = $user_info['company_id'];
         // 验证参数
         $request->scene('set_processing_status')->validate();
         // 接收数据
@@ -227,6 +235,7 @@ class LowPriceGoods extends Api
         $processing_status = request('processing_status', 0);
         // 查询用户
         $where = ['id' => $id];
+        $where['company_id'] = $company_id;
         // 执行修改
         $result            =  $LowPriceGoodsModel->changeProcessingStatus($where, $processing_status);
         // 提示新增失败

+ 11 - 3
app/Http/Controllers/Api/Process/ViolationProduct.php

@@ -30,8 +30,10 @@ class ViolationProduct extends Api
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $user_id = $user_info['uid'];
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '');
         $start_time = request('start_time', '');
@@ -55,6 +57,7 @@ class ViolationProduct extends Api
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($store_name) $map[]   = ['store_name','like',"%$store_name%"];
 
+
         //多选平台查询
         if($platform && is_string($platform)){
             $platform = explode(',', $platform);
@@ -161,9 +164,10 @@ class ViolationProduct extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('detail')->validate();
+        $company_id = $user_info['company_id'];
         // 接收参数
         $id = request('id', 0);
-        $map = ['id' => $id];
+        $map = ['id' => $id, 'company_id' => $company_id];
         $data = $ViolationProductModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
                 //查询第一责任人名称
@@ -192,13 +196,15 @@ class ViolationProduct extends Api
      */
     public function set_status(Request $request, ViolationProductModel $ViolationProductModel)
     {
+        $user_info = $this->checkLogin();
         // 验证参数
         $request->scene('set_status')->validate();
+        $company_id = $user_info['company_id'];
         // 接收数据
         $id                = request('id', 0);
         $status            = request('status', 0);
         // 查询用户
-        $where = ['id' => $id];
+        $where = ['id' => $id, 'company_id' => $company_id];
         // 执行修改
         $result            =  $ViolationProductModel->changeStatus($where, $status);
         // 提示新增失败
@@ -216,13 +222,15 @@ class ViolationProduct extends Api
      */
     public function set_processing_status(Request $request, ViolationProductModel $ViolationProductModel)
     {
+        $user_info = $this->checkLogin();
         // 验证参数
         $request->scene('set_processing_status')->validate();
+        $company_id = $user_info['company_id'];
         // 接收数据
         $id                = request('id', 0);
         $processing_status = request('processing_status', 0);
         // 查询用户
-        $where = ['id' => $id];
+        $where = ['id' => $id, 'company_id' => $company_id];
         // 执行修改
         $result            =  $ViolationProductModel->changeProcessingStatus($where, $processing_status);
         // 提示新增失败

+ 10 - 4
app/Http/Controllers/Api/Process/ViolationStore.php

@@ -29,9 +29,10 @@ class ViolationStore extends Api
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $user_id = $user_info['uid'];
         $request->scene('list')->validate();
-        // 查询条件
+        $company_id = $user_info['company_id'];
        // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '');
         $start_time = request('start_time', '');
@@ -153,9 +154,10 @@ class ViolationStore extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('detail')->validate();
+        $company_id = $user_info['company_id'];
         // 接收参数
         $id = request('id', 0);
-        $map = ['id' => $id];
+        $map = ['id' => $id,'company_id' => $company_id];
         $data = $ViolationStoreModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询第一责任人名称
@@ -184,13 +186,15 @@ class ViolationStore extends Api
      */
     public function set_status(Request $request, ViolationStoreModel $ViolationStoreModel)
     {
+        $user_info = $this->checkLogin();
         // 验证参数
         $request->scene('set_status')->validate();
+        $company_id = $user_info['company_id'];
         // 接收数据
         $id                = request('id', 0);
         $status            = request('status', 0);
         // 查询用户
-        $where = ['id' => $id];
+        $where = ['id' => $id,'company_id' => $company_id];
         // 执行修改
         $result            =  $ViolationStoreModel->changeStatus($where, $status);
         // 提示新增失败
@@ -208,13 +212,15 @@ class ViolationStore extends Api
      */
     public function set_processing_status(Request $request, ViolationStoreModel $ViolationStoreModel)
     {
+        $user_info = $this->checkLogin();
         // 验证参数
         $request->scene('set_processing_status')->validate();
+        $company_id = $user_info['company_id'];
         // 接收数据
         $id                = request('id', 0);
         $processing_status = request('processing_status', 0);
         // 查询用户
-        $where = ['id' => $id];
+        $where = ['id' => $id,'company_id' => $company_id];
         // 执行修改
         $result            =  $ViolationStoreModel->changeProcessingStatus($where, $processing_status);
         // 提示新增失败

+ 4 - 0
app/Http/Controllers/Api/WashConfig/ControlGoods.php

@@ -26,8 +26,10 @@ class ControlGoods extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');
@@ -70,8 +72,10 @@ class ControlGoods extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('spec_list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');

+ 4 - 0
app/Http/Controllers/Api/WashConfig/LowPriceGoods.php

@@ -28,8 +28,10 @@ class LowPriceGoods extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');
@@ -75,8 +77,10 @@ class LowPriceGoods extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('spec_list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');

+ 4 - 0
app/Http/Controllers/Api/WashConfig/ViolationProduct.php

@@ -27,8 +27,10 @@ class ViolationProduct extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');
@@ -71,8 +73,10 @@ class ViolationProduct extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('spec_list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');

+ 2 - 0
app/Http/Controllers/Api/WashConfig/ViolationStore.php

@@ -27,8 +27,10 @@ class ViolationStore extends Api
         $user_info = $this->checkLogin();
         if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
         $request->scene('list')->validate();
+        $company_id = $user_info['company_id'];
         // 查询条件
         $map  = [];
+        $map[] = ['company_id', '=', $company_id];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '0');
         $start_time = request('start_time', '');