Преглед на файлове

[智价云] 公司责任人信息展示补充

tangyuanwang преди 12 часа
родител
ревизия
7841bb4f2c
променени са 2 файла, в които са добавени 18 реда и са изтрити 7 реда
  1. 16 5
      app/Http/Controllers/Manager/WashConfig/ViolationStore.php
  2. 2 2
      app/Models/Manager/WashConfig/ViolationStore.php

+ 16 - 5
app/Http/Controllers/Manager/WashConfig/ViolationStore.php

@@ -7,10 +7,10 @@ use App\Http\Requests\Manager\WashConfig\ViolationStore as Request;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
 use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
-
+use App\Models\Manager\Personnel\Employee as EmployeeModel;
 
 /**
- * 数据清洗-违规店铺配置
+ * 数据清洗-违规店铺(公司)配置
  * @author    唐远望
  * @version   1.0
  * @date      2025-12-03
@@ -24,7 +24,7 @@ class ViolationStore extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationStoreModel $ViolationStoreModel)
+    public function list(Request $request, ViolationStoreModel $ViolationStoreModel,EmployeeModel $EmployeeModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -50,9 +50,17 @@ class ViolationStore extends Controller
         $result = $ViolationStoreModel->query()
             ->where($map)
             ->orderByDesc('id')
-            ->paginate($limit);
+            ->paginate($limit)->toarray();
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
+        if (isset($result['data']) && count($result['data']) > 0) {
+            foreach ($result['data'] as $key => $value) {
+                $employee_ids = $value['employee_ids'] !='' ? explode(',', $value['employee_ids']) : '';
+                $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
+                $result['data'][$key]['employee_ids'] = $employee_ids;
+                $result['data'][$key]['employee_name'] = $employee_ids ? $EmployeeModel->whereIn('id', $employee_ids)->pluck('name')->toArray() : '';
+            }
+        }
         // 加载模板
         return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
     }
@@ -100,7 +108,7 @@ class ViolationStore extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ViolationStoreModel $ViolationStoreModel)
+    public function detail(Request $request, ViolationStoreModel $ViolationStoreModel,EmployeeModel $EmployeeModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -108,6 +116,9 @@ class ViolationStore extends Controller
         $map = ['id' => $id];
         $data = $ViolationStoreModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
+        $employee_ids = $data->employee_ids !='' ? explode(',', $data->employee_ids) : '';
+        $data->employee_ids = $employee_ids;
+        $data->employee_name = $employee_ids ? $EmployeeModel->whereIn('id', $employee_ids)->pluck('name')->toArray() : '';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }

+ 2 - 2
app/Models/Manager/WashConfig/ViolationStore.php

@@ -74,7 +74,7 @@ class ViolationStore extends Model
                 foreach ($employee_ids as $employee_id) {
                     $insert_company_data[] = [
                         'company_logid' => $ViolationStore_id,
-                        'company_id' => $employee_id,
+                        'employee_id' => $employee_id,
                     ];
                 }
                 $ViolationCompanyMemberModel->insert($insert_company_data);
@@ -145,7 +145,7 @@ class ViolationStore extends Model
                 foreach ($employee_ids as $employee_id) {
                     $insert_company_data[] = [
                         'company_logid' => $ViolationStore->id,
-                        'company_id' => $employee_id,
+                        'employee_id' => $employee_id,
                     ];
                 }
                 $ViolationCompanyMemberModel->insert($insert_company_data);