Kaynağa Gözat

[智价云] 清洗配置数据隔离

tangyuanwang 1 ay önce
ebeveyn
işleme
92ef6d73b4

+ 37 - 26
app/Http/Controllers/Manager/External/Company.php

@@ -50,6 +50,41 @@ class Company extends Controller
         return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
     }
 
+    /**
+     * 全部
+     * @author    唐远望
+     * @version   1.0
+     * @date      2026-02-03
+     * 
+     */
+    public function all(Request $request, CompanyModel $CompanyModel)
+    {
+        $request->scene('all')->validate();
+        // 查询条件
+        $map  = [];
+        $status    = request('status', '');
+        $start_time = request('start_time', '');
+        $end_time = request('end_time', '');
+        $company_name = request('company_name', '');
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
+        // 其他条件
+        if (is_numeric($status)) $map[] = ['status', '=', $status];
+        if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
+        // 查询数据
+        $result = $CompanyModel->query()
+            ->where($map)
+            ->orderByDesc('id')
+            ->get();
+        // 分配数据
+        if (!$result)  return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
+        // 加载模板
+        return        json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
+    }
+
+
+
     /**
      * 详情
      * @author    唐远望
@@ -65,8 +100,6 @@ class Company extends Controller
         // 权限判断
         $data = $CompanyModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
-
-        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -82,19 +115,8 @@ class Company extends Controller
     {
         $request->scene('add')->validate();
         $all_data = request()->all();
-        //采集信息配置
-        $minimum_order_quantity = request('minimum_order_quantity', 1);
-        $sampling_cycle = request('sampling_cycle', '0');
-        $sampling_start_time = request('sampling_start_time', '');
-        $sampling_end_time = request('sampling_end_time', '');
-        $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
-        $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
-        $all_data['minimum_order_quantity'] = $minimum_order_quantity;
-        $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp(); // 明天的开始时间(允许开始采集时间校验)
-        if ($all_data['sampling_start_time']  && $all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
         //查询是否存在
-        $map = ['company_name' => $all_data['company_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
+        $map = ['social_credit_code' => $all_data['social_credit_code']];
         $data = $CompanyModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -125,17 +147,8 @@ class Company extends Controller
         $id         = request('id', 0);
         // 接收数据
         $all_data = request()->all();
-        //采集信息配置
-        $minimum_order_quantity = request('minimum_order_quantity', 1);
-        $sampling_cycle = request('sampling_cycle', '0');
-        $sampling_start_time = request('sampling_start_time', '');
-        $sampling_end_time = request('sampling_end_time', '');
-        $all_data['sampling_cycle'] = $sampling_cycle;
-        $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
-        $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
-        $all_data['minimum_order_quantity'] = $minimum_order_quantity;
         //查询是否存在
-        $map = ['company_name' => $all_data['company_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
+        $map = ['social_credit_code' => $all_data['social_credit_code']];
         $data = $CompanyModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
@@ -143,8 +156,6 @@ class Company extends Controller
         $Company = $CompanyModel->where($where)->first();
         if (!$Company) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         $oldData = $Company->toarray();
-        $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp(); // 明天的开始时间(允许开始采集时间校验)
-        if ($all_data['sampling_start_time']  && $all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
         $result =  $CompanyModel->editCompany_content($Company, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);

+ 1 - 0
app/Http/Controllers/Manager/WashConfig/CompanyCategory.php

@@ -171,6 +171,7 @@ class CompanyCategory extends Controller
         $CompanyCategory = $CompanyCategoryModel->where($where)->first();
         if (!$CompanyCategory) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         $oldData = $CompanyCategory->toArray();
+        $all_data['company_id'] = $company_id;
         $result =  $CompanyCategoryModel->editCompanyCategory_content($CompanyCategory, $all_data);
         // 如果操作失败
         if (!$result)     return json_send(['code' => 'error', 'msg' => '修改失败']);

+ 0 - 7
app/Http/Controllers/Manager/WashConfig/PlatForm.php

@@ -41,7 +41,6 @@ class PlatForm extends Controller
         if (is_numeric($status)) $map[] = ['status', '=', $status];
         if ($name) $map[] = ['name', 'like', "%$name%"];
         // 查询数据
-        if ($is_admin != 1 && $company_id != 0) $map[] = ['company_id', '=', $company_id];
         $result = $PlatFormModel->query()
             ->where($map)
             ->orderByDesc('id')
@@ -81,7 +80,6 @@ class PlatForm extends Controller
         // 其他条件
         if ($name) $map[] = ['name', 'like', "%$name%"];
         if (is_numeric($status)) $map[] = ['status', '=', $status];
-        if ($is_admin != 1 && $company_id != 0) $map[] = ['company_id', '=', $company_id];
         $result = $PlatFormModel->query()
             ->where($map)
             ->select(['id', 'name'])
@@ -107,7 +105,6 @@ class PlatForm extends Controller
         // 接收参数
         $id = request('id', 0);
         $map = ['id' => $id];
-        if ($is_admin != 1 && $company_id != 0) $map[] = ['company_id', '=', $company_id];
         $data = $PlatFormModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         $employee_ids = $data->employee_ids != '' ? explode(',', $data->employee_ids) : '';
@@ -135,7 +132,6 @@ class PlatForm extends Controller
         $all_data['employee_ids'] = $employee_ids;
         //查询是否存在
         $map = ['name' => $all_data['name']];
-        if ($is_admin != 1 && $company_id != 0) $map['company_id'] = $company_id;
         $data = $PlatFormModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -176,7 +172,6 @@ class PlatForm extends Controller
         // if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表
         $where = ['id' => $id];
-        if ($is_admin != 1 && $company_id != 0) $where['company_id'] = $company_id;
         $PlatForm = $PlatFormModel->where($where)->first();
         if (!$PlatForm) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         $oldData = $PlatForm->toArray();
@@ -211,7 +206,6 @@ class PlatForm extends Controller
         $status            = request('status', 0);
         // 查询用户
         $where = ['id' => $id];
-        if ($is_admin != 1 && $company_id != 0) $where['company_id'] = $company_id;
         $PlatForm = $PlatFormModel->where($where)->first();
         if (!$PlatForm) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         // 执行修改
@@ -246,7 +240,6 @@ class PlatForm extends Controller
         // 查询用户
         $where = ['id' => $id];
         // 执行删除
-        if ($is_admin != 1 && $company_id != 0) $where['company_id'] = $company_id;
         $PlatForm = $PlatFormModel->where($where)->first();
         if (!$PlatForm) return json_send(['code' => 'error', 'msg' => '记录不存在']);
         $result = $PlatForm->delete();

+ 1 - 0
app/Http/Requests/Manager/External/Company.php

@@ -37,6 +37,7 @@ class Company extends BaseRequest
     // 场景列表
     protected   $scenes         = [
         'detail'             => ['id'],
+        'all'               => [],
         'list'               => ['page', 'limit'],
         'add'                      => ['company_name','social_credit_code'],
         'edit'                  => ['id','company_name','social_credit_code'],

+ 0 - 2
app/Models/Manager/WashConfig/PlatForm.php

@@ -58,7 +58,6 @@ class PlatForm extends Model
         try {
             $PlatFormMemberModel = new PlatFormMemberModel();
             $insert_data = [
-                'company_id' => $data['company_id'],
                 'platform' => $data['platform'],
                 'employee_ids'  => $data['employee_ids'],
                 'insert_time' => time(),
@@ -123,7 +122,6 @@ class PlatForm extends Model
         DB::beginTransaction();
         try {
             // $PlatForm->name = $data['name'];
-            $PlatForm->company_id = $data['company_id'];
             $PlatForm->employee_ids = $data['employee_ids'];
             $PlatForm->update_time = time();
             $PlatForm->save();

+ 2 - 1
app/Models/Manager/WashConfig/ProductCategory.php

@@ -33,6 +33,7 @@ class ProductCategory extends Model
     public function addProductCategory_content($data)
     {
         $insert_data = [
+            'company_id' => $data['company_id'],
             'name' => $data['name'],
             'insert_time' => time(),
         ];
@@ -75,8 +76,8 @@ class ProductCategory extends Model
      */
     public function editProductCategory_content($ProductCategory, $data)
     {
-        
         $ProductCategory->name = $data['name'];
+        $ProductCategory->company_id = $data['company_id'];
         $ProductCategory->update_time = time();
         $ProductCategory->save();
         return true;

+ 1 - 0
app/Models/Manager/WashConfig/ViolationProduct.php

@@ -35,6 +35,7 @@ class ViolationProduct extends Model
     public function addViolationProduct_content($data)
     {
         $insert_data = [
+            'company_id' => $data['company_id'],
             'platform' => $data['platform'],
             'product_name' => $data['product_name'],
             'product_specs' => $data['product_specs'],

+ 3 - 1
routes/manager.php

@@ -317,4 +317,6 @@ Route::any('external/company/edit', [App\Http\Controllers\Manager\External\Compa
 //外部-公司管理-删除
 Route::any('external/company/delete', [App\Http\Controllers\Manager\External\Company::class, 'delete']);
 //外部-公司管理-状态修改
-Route::any('external/company/set_status', [App\Http\Controllers\Manager\External\Company::class,'set_status']);
+Route::any('external/company/set_status', [App\Http\Controllers\Manager\External\Company::class,'set_status']);
+//外部-公司管理-全部
+Route::any('external/company/all', [App\Http\Controllers\Manager\External\Company::class, 'all']);