Преглед изворни кода

[智价云] 公司范围功能补充

tangyuanwang пре 5 дана
родитељ
комит
d3cf002cd0

+ 3 - 2
app/Http/Controllers/Manager/WashConfig/ControlGoods.php

@@ -34,6 +34,7 @@ class ControlGoods extends Controller
         $product_name = request('product_name', '');
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -41,8 +42,8 @@ class ControlGoods extends Controller
         if ($status) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($store_scope == 1) $map[] = ['store_scope', '=', ''];
-        if ($store_scope == 2) $map[] = ['store_scope', '!=', ''];
+        if ($store_scope) $map[] = ['store_scope', '=',$store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=',$company_scope];
         // 查询数据
         $result = $ControlGoodsModel->query()
             ->where($map)

+ 38 - 22
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
 use App\Http\Requests\Manager\WashConfig\LowPriceGoods as Request;
 use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
+use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
 
 
 /**
@@ -23,7 +24,7 @@ class LowPriceGoods extends Controller
      * @date      2025-12-02
      * 
      */
-    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel,ViolationStoreModel $ViolationStoreModel)
+    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -35,6 +36,7 @@ class LowPriceGoods extends Controller
         $product_name = request('product_name', '');
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -42,8 +44,8 @@ class LowPriceGoods extends Controller
         if (is_numeric($status)) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($store_scope == 1) $map[] = ['store_scope', '=', ''];
-        if ($store_scope == 2) $map[] = ['store_scope', '!=', ''];
+        if ($store_scope) $map[] = ['store_scope', '=',$store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=',$company_scope];
         // 查询数据
         $result = $LowPriceGoodsModel->query()
             ->where($map)
@@ -51,16 +53,23 @@ class LowPriceGoods extends Controller
             ->paginate($limit)->toarray();
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
-        if(isset($result['data']) && count($result['data']) > 0){
+        if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
-                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',',$value['platform']) : '';
+                $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
                 //查询店铺名称
-                if(trim($value['store_scope']) == ''){
-                    $result['data'][$key]['store_name'] =['全部店铺'];
-                }else{
-                    $store_scope = explode(',',$value['store_scope']);
-                    $store_name = $ViolationStoreModel->whereIn('id',$store_scope)->pluck('store_name');
-                    $result['data'][$key]['store_name'] = $store_name;
+                if ($value['store_scope'] == '1') {
+                    $result['data'][$key]['store_name'] = ['全部店铺'];
+                } else {
+                    $result['data'][$key]['store_name'] = '';
+                }
+                //查询公司名称
+                if ($value['company_scope'] == '1') {
+                    $result['data'][$key]['company_name'] = ['全部公司'];
+                } else {
+                    $company_data = $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $value['id'])
+                        ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_lowprice_product_company.company_id')
+                        ->select(['washconfig_violation_store.id', 'washconfig_violation_store.company_name', 'washconfig_lowprice_product_company.company_id'])->get()->toArray();
+                    $result['data'][$key]['company_name'] = !empty($company_data) ? array_column($company_data, 'company_name') : '';
                 }
             }
         }
@@ -74,7 +83,7 @@ class LowPriceGoods extends Controller
      * @version   1.0
      * @date      2025-12-02
      */
-    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel,ViolationStoreModel $ViolationStoreModel)
+    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -83,14 +92,21 @@ class LowPriceGoods extends Controller
         $data = $LowPriceGoodsModel->where($map)->first();
         if (!$data)     return json_send(['code' => 'error', 'msg' => '记录不存在']);
         //查询店铺名称
-        if(trim($data['store_scope']) == ''){
+        if (trim($data['store_scope']) == '') {
             $data['store_name'] = ['全部店铺'];
-        }else{
-            $store_scope = explode(',',$data['store_scope']);
-            $store_name = $ViolationStoreModel->whereIn('id',$store_scope)->pluck('store_name');
-            $data['store_name'] = $store_name;
+        } else {
+            $data['store_name'] = '';
+        }
+        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
+        //查询公司名称
+        if ($data->company_scope == '1') {
+            $data->company_name = ['全部公司'];
+        } else {
+            $company_data = $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $data->id)
+                ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_lowprice_product_company.company_id')
+                ->select(['washconfig_violation_store.id', 'washconfig_violation_store.company_name', 'washconfig_lowprice_product_company.company_id'])->get()->toArray();
+            $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
         }
-        $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -110,7 +126,7 @@ class LowPriceGoods extends Controller
         $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
         //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $LowPriceGoodsModel->where($map)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 写入数据表
@@ -135,10 +151,10 @@ class LowPriceGoods extends Controller
         $id         = request('id', 0);
         // 接收数据
         $all_data = request()->all();
-        $store_scope = request('store_scope','');
+        $store_scope = request('store_scope', '');
         $all_data['store_scope'] = $store_scope;
-                //查询是否存在
-        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
+        //查询是否存在
+        $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $LowPriceGoodsModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);
         // 更新数据表

+ 26 - 10
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
 use App\Http\Requests\Manager\WashConfig\ViolationProduct as Request;
 use App\Models\Manager\WashConfig\ViolationProduct as ViolationProductModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
+use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
 
 
 /**
@@ -23,7 +24,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel)
+    public function list(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -35,6 +36,7 @@ class ViolationProduct extends Controller
         $product_name = request('product_name', '');
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
+        $company_scope = request('company_scope', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -42,8 +44,8 @@ class ViolationProduct extends Controller
         if (is_numeric($status)) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
         if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($store_scope == 1) $map[] = ['store_scope', '=', ''];
-        if ($store_scope == 2) $map[] = ['store_scope', '!=', ''];
+        if ($store_scope) $map[] = ['store_scope', '=',$store_scope];
+        if ($company_scope) $map[] = ['company_scope', '=',$company_scope];
         // 查询数据
         $result = $ViolationProductModel->query()
             ->where($map)
@@ -58,9 +60,16 @@ class ViolationProduct extends Controller
                 if(trim($value['store_scope']) == ''){
                     $result['data'][$key]['store_name'] =['全部店铺'];
                 }else{
-                    $store_scope = explode(',',$value['store_scope']);
-                    $store_name = $ViolationStoreModel->whereIn('id',$store_scope)->pluck('store_name');
-                    $result['data'][$key]['store_name'] = $store_name;
+                    $result['data'][$key]['store_name'] = '';
+                }
+                //查询公司名称
+                if($value['company_scope'] == '1'){
+                    $result['data'][$key]['company_name'] =['全部公司'];
+                }else{
+                    $company_data = $ViolationProductCompanyModel->where('violation_product_logid',$value['id'])
+                    ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_violation_product_company.company_id')
+                    ->select(['washconfig_violation_store.id','washconfig_violation_store.company_name','washconfig_violation_product_company.company_id'])->get()->toArray();
+                    $result['data'][$key]['company_name'] = !empty($company_data) ? array_column($company_data,'company_name') : '';
                 }
             }
         }
@@ -74,7 +83,7 @@ class ViolationProduct extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel)
+    public function detail(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -86,9 +95,16 @@ class ViolationProduct extends Controller
         if(trim($data['store_scope']) == ''){
             $data['store_name'] = ['全部店铺'];
         }else{
-            $store_scope = explode(',',$data['store_scope']);
-            $store_name = $ViolationStoreModel->whereIn('id',$store_scope)->pluck('store_name');
-            $data['store_name'] = $store_name;
+            $data['store_name'] = '';
+        }
+        //查询公司名称
+        if ($data->company_scope == '1') {
+            $data->company_name = ['全部公司'];
+        } else {
+            $company_data = $ViolationProductCompanyModel->where('violation_product_logid', $data->id)
+                ->join('washconfig_violation_store', 'washconfig_violation_store.id', '=', 'washconfig_violation_product_company.company_id')
+                ->select(['washconfig_violation_store.id', 'washconfig_violation_store.company_name', 'washconfig_violation_product_company.company_id'])->get()->toArray();
+            $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
         }
         $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
         // 加载模板

+ 11 - 2
app/Jobs/Manager/Process/LowPriceGoodsDataJobs.php

@@ -12,6 +12,7 @@ use App\Facades\Servers\Logs\Log;
 use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
 use App\Models\Manager\Personnel\Employee as EmployeeModel;
 use App\Models\Api\Process\ExecuteLog as ExecuteLogModel;
+use App\Models\Manager\Process\ScrapeData as ScrapeDataModel;
 
 /**
  * 数据清洗-低价挂网商品队列
@@ -58,6 +59,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
     {
         $EmployeeModel = new EmployeeModel();
         $LowPriceGoodsModel = new LowPriceGoodsModel();
+        $ScrapeDataModel = new ScrapeDataModel();
         $platform = $message_data['platform'];//多个平台配置
         $product_name = $message_data['product_name'];//商品名称
         $product_specs = $message_data['product_specs'];//商品规格
@@ -67,8 +69,15 @@ class LowPriceGoodsDataJobs implements ShouldQueue
         $limit = isset($message_data['limit']) ? $message_data['limit'] : 50;
         $page = isset($message_data['page']) ? $message_data['page'] : 1;
         
-
-        $product_datas = []; //商品数据
+        $where=[];
+        $where[] = ['platform', 'in', $platform];
+        $where[] = ['product_name', 'like', '%'. $product_name. '%'];
+        $where[] = ['product_specs', 'like', '%'. $product_specs. '%'];
+        $where[] = ['suggested_price', '<', $suggested_price];
+        if($store_scope){
+            $where[] = ['store_name', 'like', '%'. $store_scope. '%'];
+        }
+        $product_datas = $ScrapeDataModel->where($where)->get()->toarray(); //商品数据
         if (empty($product_datas)) {
             (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0]);
             return false;

+ 24 - 0
app/Models/Manager/Process/ScrapeData.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models\Manager\Process;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 采集原始数据表模型
+ * @author: 唐远望
+ * @version: 1.0
+ * @date: 2025-12-11
+ */
+class ScrapeData extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'scrape_data';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+}

+ 52 - 8
app/Models/Manager/WashConfig/ControlGoods.php

@@ -5,6 +5,7 @@ namespace App\Models\Manager\WashConfig;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
+use App\Models\Manager\WashConfig\ControlGoodsCompany as ControlGoodsCompanyModel;
 
 
 /**
@@ -57,7 +58,27 @@ class ControlGoods extends Model
     {
         DB::beginTransaction();
         try {
-            $this->addControlGoods_content($data);
+            $ControlGoodsCompanyModel = new ControlGoodsCompanyModel();
+            $insert_data = [
+                'platform' => $data['platform'],
+                'product_name' => $data['product_name'],
+                'product_specs' => $data['product_specs'],
+                'store_scope'    => $data['store_scope'] ? 2 : 1, //店铺范围1=全部店铺 2=指定店铺
+                'company_scope'    => $data['company_scope'] ? 2 : 1, //公司范围1=全部公司 2=指定公司
+                'insert_time' => time(),
+            ];
+            $ControlGoods_id = $this->insertGetId($insert_data);
+            if ($insert_data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'control_product_logid' => $ControlGoods_id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $ControlGoodsCompanyModel->insert($insert_company_data);
+            }
             DB::commit();
             return true;
             // 成功处理...
@@ -83,13 +104,36 @@ class ControlGoods extends Model
         if (!$ControlGoods) {
             return false;
         }
-        $ControlGoods->platform = $data['platform'];
-        $ControlGoods->product_name = $data['product_name'];
-        $ControlGoods->product_specs = $data['product_specs'];
-        $ControlGoods->store_scope = $data['store_scope'];
-        $ControlGoods->update_time = time();
-        $ControlGoods->save();
-        return true;
+        DB::beginTransaction();
+        try {
+            $ControlGoodsCompanyModel = new ControlGoodsCompanyModel();
+            $ControlGoods->platform = $data['platform'];
+            $ControlGoods->product_name = $data['product_name'];
+            $ControlGoods->product_specs = $data['product_specs'];
+            $ControlGoods->store_scope = $data['store_scope'];
+            $ControlGoods->update_time = time();
+            $ControlGoods->save();
+
+            $ControlGoodsCompanyModel->where('control_product_logid', $ControlGoods->id)->delete();
+            if ($data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'control_product_logid' => $ControlGoods->id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $ControlGoodsCompanyModel->insert($insert_company_data);
+            }
+            DB::commit();
+            return true;
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return false;
+        }
     }
 
 

+ 26 - 0
app/Models/Manager/WashConfig/ControlGoodsCompany.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models\Manager\WashConfig;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * 清洗配置-强管控商品公司关系模型
+ * @author: 唐远望
+ * @version: 1.0
+ * @date: 2025-12-11
+ */
+class ControlGoodsCompany extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'washconfig_control_product_company';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+}

+ 55 - 9
app/Models/Manager/WashConfig/LowPriceGoods.php

@@ -5,6 +5,7 @@ namespace App\Models\Manager\WashConfig;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
+use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
 
 
 /**
@@ -58,7 +59,28 @@ class LowPriceGoods extends Model
     {
         DB::beginTransaction();
         try {
-            $this->addLowProduct_content($data);
+            $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
+            $insert_data = [
+                'platform' => $data['platform'],
+                'product_name' => $data['product_name'],
+                'product_specs' => $data['product_specs'],
+                'suggested_price' => $data['suggested_price'],
+                'store_scope'    => $data['store_scope'] ? 2 : 1, //店铺范围1=全部店铺 2=指定店铺
+                'company_scope'    => $data['company_scope'] ? 2 : 1, //公司范围1=全部公司 2=指定公司
+                'insert_time' => time(),
+            ];
+            $LowProduct_id = $this->insertGetId($insert_data);
+            if ($insert_data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'lowprice_product_logid' => $LowProduct_id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $LowPriceGoodsCompanyModel->insert($insert_company_data);
+            }
             DB::commit();
             return true;
             // 成功处理...
@@ -84,14 +106,38 @@ class LowPriceGoods extends Model
         if (!$LowProduct) {
             return false;
         }
-        $LowProduct->platform = $data['platform'];
-        $LowProduct->product_name = $data['product_name'];
-        $LowProduct->product_specs = $data['product_specs'];
-        $LowProduct->suggested_price = $data['suggested_price'];
-        $LowProduct->store_scope = $data['store_scope'];
-        $LowProduct->update_time = time();
-        $LowProduct->save();
-        return true;
+        DB::beginTransaction();
+        try {
+            $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
+            $LowProduct->platform = $data['platform'];
+            $LowProduct->product_name = $data['product_name'];
+            $LowProduct->product_specs = $data['product_specs'];
+            $LowProduct->suggested_price = $data['suggested_price'];
+            $LowProduct->store_scope = $data['store_scope'] ? 2 : 1; //店铺范围1=全部店铺 2=指定店铺
+            $LowProduct->company_scope = $data['company_scope'] ? 2 : 1; //公司范围1=全部公司 2=指定公司
+            $LowProduct->update_time = time();
+            $LowProduct->save();
+
+            $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->delete();
+            if ($data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'lowprice_product_logid' => $LowProduct->id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $LowPriceGoodsCompanyModel->insert($insert_company_data);
+            }
+            DB::commit();
+            return true;
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return false;
+        }
     }
 
 

+ 26 - 0
app/Models/Manager/WashConfig/LowPriceGoodsCompany.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models\Manager\WashConfig;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * 清洗配置-低价商品公司关系模型
+ * @author: 唐远望
+ * @version: 1.0
+ * @date: 2025-12-11
+ */
+class LowPriceGoodsCompany extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'washconfig_lowprice_product_company';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+}

+ 52 - 8
app/Models/Manager/WashConfig/ViolationProduct.php

@@ -5,6 +5,7 @@ namespace App\Models\Manager\WashConfig;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
+use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
 
 
 /**
@@ -57,7 +58,27 @@ class ViolationProduct extends Model
     {
         DB::beginTransaction();
         try {
-            $this->addViolationProduct_content($data);
+            $ViolationProductCompanyModel = new ViolationProductCompanyModel();
+            $insert_data = [
+                'platform' => $data['platform'],
+                'product_name' => $data['product_name'],
+                'product_specs' => $data['product_specs'],
+                'store_scope'    => $data['store_scope'] ? 2 : 1, //店铺范围1=全部店铺 2=指定店铺
+                'company_scope'    => $data['company_scope'] ? 2 : 1, //公司范围1=全部公司 2=指定公司
+                'insert_time' => time(),
+            ];
+            $ViolationProduct_id = $this->insertGetId($insert_data);
+            if ($insert_data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'violation_product_logid' => $ViolationProduct_id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $ViolationProductCompanyModel->insert($insert_company_data);
+            }
             DB::commit();
             return true;
             // 成功处理...
@@ -83,13 +104,36 @@ class ViolationProduct extends Model
         if (!$ViolationProduct) {
             return false;
         }
-        $ViolationProduct->platform = $data['platform'];
-        $ViolationProduct->product_name = $data['product_name'];
-        $ViolationProduct->product_specs = $data['product_specs'];
-        $ViolationProduct->store_scope = $data['store_scope'];
-        $ViolationProduct->update_time = time();
-        $ViolationProduct->save();
-        return true;
+        DB::beginTransaction();
+        try {
+            $ViolationProductCompanyModel = new ViolationProductCompanyModel();
+            $ViolationProduct->platform = $data['platform'];
+            $ViolationProduct->product_name = $data['product_name'];
+            $ViolationProduct->product_specs = $data['product_specs'];
+            $ViolationProduct->store_scope = $data['store_scope'];
+            $ViolationProduct->update_time = time();
+            $ViolationProduct->save();
+            DB::commit();
+
+            $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->delete();
+            if ($data['company_scope'] == 2) {
+                $insert_company_data = [];
+                $company_scope = $data['company_scope'];
+                foreach ($company_scope as $company_id) {
+                    $insert_company_data[] = [
+                        'violation_product_logid' => $ViolationProduct->id,
+                        'company_id' => $company_id,
+                    ];
+                }
+                $ViolationProductCompanyModel->insert($insert_company_data);
+            }
+            return true;
+            // 成功处理...
+        } catch (\Exception $e) {
+            DB::rollBack();
+            // 错误处理...
+            return false;
+        }
     }
 
 

+ 27 - 0
app/Models/Manager/WashConfig/ViolationProductCompany.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Models\Manager\WashConfig;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\DB;
+
+
+/**
+ * 清洗配置-违规商品公司关系模型
+ * @author: 唐远望
+ * @version: 1.0
+ * @date: 2025-12-11
+ */
+class ViolationProductCompany extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'washconfig_violation_product_company';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+}