Sfoglia il codice sorgente

[智价云] 数据清洗配置平台修改

tangyuanwang 16 ore fa
parent
commit
4eada01f67

+ 9 - 2
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -31,7 +31,7 @@ class LowPriceGoods extends Controller
      * @date      2025-12-02
      * 
      */
-    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
+    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel,LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         $admin_company_id = request('admin_company_id', '0');
@@ -54,7 +54,6 @@ 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) $map[] = ['store_scope', '=', $store_scope];
         if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
         if ($category_id) $map[] = ['category_id', '=', $category_id];
@@ -64,6 +63,14 @@ class LowPriceGoods extends Controller
         } else {
             $map[] = ['company_id', '=', $admin_company_id];
         }
+        if ($platform != '') {
+            $platform_ids = explode(',', $platform);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query) use ($platform_ids) {
+                $query->select('platform_id')
+                    ->from('washconfig_lowprice_product_platform')
+                    ->whereIn('platform_id', $platform_ids);
+            });
+        }
         $result = $LowPriceGoodsModel->query()
             ->where($map)
             ->orderByDesc('id')

+ 9 - 2
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -31,7 +31,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationProductModel $ViolationProductModel, ViolationStoreModel $ViolationStoreModel, ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
+    public function list(Request $request, ViolationProductModel $ViolationProductModel, ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         $admin_company_id = request('admin_company_id', '0');
@@ -54,7 +54,6 @@ 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) $map[] = ['store_scope', '=', $store_scope];
         if ($company_scope) $map[] = ['company_scope', '=', $company_scope];
         if ($category_id) $map[] = ['category_id', '=', $category_id];
@@ -64,6 +63,14 @@ class ViolationProduct extends Controller
         } else {
             $map[] = ['company_id', '=', $admin_company_id];
         }
+        if ($platform != '') {
+            $platform_ids = explode(',', $platform);
+            $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query) use ($platform_ids) {
+                $query->select('platform_id')
+                    ->from('washconfig_violation_product_platform')
+                    ->whereIn('platform_id', $platform_ids);
+            });
+        }
         $result = $ViolationProductModel->query()
             ->where($map)
             ->orderByDesc('id')

+ 38 - 2
app/Models/Manager/WashConfig/LowPriceGoods.php

@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
 use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
+use App\Models\Manager\WashConfig\LowPriceGoodsPlatform as LowPriceGoodsPlatformModel;
 
 
 /**
@@ -62,7 +63,7 @@ class LowPriceGoods extends Model
     {
         DB::beginTransaction();
         try {
-            $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
+
             $insert_data = [
                 'company_id' => $data['company_id'],
                 'platform' => $data['platform'],
@@ -77,6 +78,7 @@ class LowPriceGoods extends Model
             ];
             $LowProduct_id = $this->insertGetId($insert_data);
             if ($insert_data['company_scope'] == 2) {
+                $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
                 $insert_company_data = [];
                 $company_scope = explode(',', $data['company_scope']);
                 foreach ($company_scope as $company_id) {
@@ -87,6 +89,19 @@ class LowPriceGoods extends Model
                 }
                 $LowPriceGoodsCompanyModel->insert($insert_company_data);
             }
+            if ($data['platform'] != 0) {
+                $LowPriceGoodsPlatformModel = new LowPriceGoodsPlatformModel();
+                $insert_platform_data = [];
+                $platform_scope = explode(',', $data['platform']);
+                foreach ($platform_scope as $platform_id) {
+                    $insert_platform_data[] = [
+                        'company_id' => $company_id,
+                        'product_id' => $LowProduct_id,
+                        'platform_id' => $platform_id,
+                    ];
+                }
+                $LowPriceGoodsPlatformModel->insert($insert_platform_data);
+            }
             DB::commit();
             return true;
             // 成功处理...
@@ -112,6 +127,7 @@ class LowPriceGoods extends Model
         DB::beginTransaction();
         try {
             $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
+            $LowPriceGoodsPlatformModel = new LowPriceGoodsPlatformModel();
             $store_scope = $data['store_scope'] != '' ? 2 : 1; //店铺范围1=全部店铺 2=指定店铺
             $company_scope = $data['company_scope'] != '' ? 2 : 1; //公司范围1=全部公司 2=指定公司
             $LowProduct->company_id = $data['company_id'];
@@ -126,7 +142,11 @@ class LowPriceGoods extends Model
             $LowProduct->update_time = time();
             $LowProduct->save();
 
-            $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->delete();
+            $lowPrice_goods_companycount = $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->count();
+            if ($lowPrice_goods_companycount > 0) {
+                $LowPriceGoodsCompanyModel->where('lowprice_product_logid', $LowProduct->id)->delete();
+            }
+
             if ($company_scope == 2) {
                 $insert_company_data = [];
                 $company_scope = explode(',', $data['company_scope']);
@@ -138,6 +158,22 @@ class LowPriceGoods extends Model
                 }
                 $LowPriceGoodsCompanyModel->insert($insert_company_data);
             }
+            $lowPrice_goods_platformcount = $LowPriceGoodsPlatformModel->where('product_id', $LowProduct->id)->count();
+            if ($lowPrice_goods_platformcount > 0) {
+                $LowPriceGoodsPlatformModel->where('product_id', $LowProduct->id)->delete();
+            }
+            if ($data['platform'] != 0) {
+                $insert_platform_data = [];
+                $platform_scope = explode(',', $data['platform']);
+                foreach ($platform_scope as $platform_id) {
+                    $insert_platform_data[] = [
+                        'company_id' => $company_id,
+                        'product_id' => $LowProduct->id,
+                        'platform_id' => $platform_id,
+                    ];
+                }
+                $LowPriceGoodsPlatformModel->insert($insert_platform_data);
+            }
             DB::commit();
             return true;
             // 成功处理...

+ 28 - 0
app/Models/Manager/WashConfig/LowPriceGoodsPlatform.php

@@ -0,0 +1,28 @@
+<?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: 2026-03-27
+ */
+class LowPriceGoodsPlatform extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'washconfig_lowprice_product_platform';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+
+}

+ 38 - 2
app/Models/Manager/WashConfig/ViolationProduct.php

@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
 use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
+use App\Models\Manager\WashConfig\ViolationProductPlatform as ViolationProductPlatformModel;
 
 
 /**
@@ -62,7 +63,8 @@ class ViolationProduct extends Model
     {
         DB::beginTransaction();
         try {
-            $ViolationProductCompanyModel = new ViolationProductCompanyModel();
+
+
             $insert_data = [
                 'company_id' => $data['company_id'],
                 'platform' => $data['platform'],
@@ -76,6 +78,7 @@ class ViolationProduct extends Model
             ];
             $ViolationProduct_id = $this->insertGetId($insert_data);
             if ($insert_data['company_scope'] == 2) {
+                $ViolationProductCompanyModel = new ViolationProductCompanyModel();
                 $insert_company_data = [];
                 $company_scope = explode(',', $data['company_scope']);
                 foreach ($company_scope as $company_id) {
@@ -86,6 +89,19 @@ class ViolationProduct extends Model
                 }
                 $ViolationProductCompanyModel->insert($insert_company_data);
             }
+            if ($data['platform'] != 0) {
+                $ViolationProductPlatformModel = new ViolationProductPlatformModel();
+                $insert_platform_data = [];
+                $platform_scope = explode(',', $data['platform']);
+                foreach ($platform_scope as $platform_id) {
+                    $insert_platform_data[] = [
+                        'company_id' => $company_id,
+                        'product_id' => $ViolationProduct_id,
+                        'platform_id' => $platform_id,
+                    ];
+                }
+                $ViolationProductPlatformModel->insert($insert_platform_data);
+            }
             DB::commit();
             return true;
             // 成功处理...
@@ -110,6 +126,7 @@ class ViolationProduct extends Model
         DB::beginTransaction();
         try {
             $ViolationProductCompanyModel = new ViolationProductCompanyModel();
+            $ViolationProductPlatformModel = new ViolationProductPlatformModel();
             $store_scope = $data['store_scope'] != '' ? 2 : 1; //店铺范围1=全部店铺 2=指定店铺
             $company_scope = $data['company_scope'] != '' ? 2 : 1; //公司范围1=全部公司 2=指定公司
             $ViolationProduct->company_id = $data['company_id'];
@@ -123,7 +140,10 @@ class ViolationProduct extends Model
             $ViolationProduct->update_time = time();
             $ViolationProduct->save();
 
-            $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->delete();
+            $violation_product_companycount = $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->count();
+            if ($violation_product_companycount > 0) {
+                $ViolationProductCompanyModel->where('violation_product_logid', $ViolationProduct->id)->delete();
+            }
             if ($company_scope == 2) {
                 $insert_company_data = [];
                 $company_scope = explode(',', $data['company_scope']);
@@ -135,6 +155,22 @@ class ViolationProduct extends Model
                 }
                 $ViolationProductCompanyModel->insert($insert_company_data);
             }
+            $violation_product_platformcount = $ViolationProductPlatformModel->where('product_id', $ViolationProduct->id)->count();
+            if ($violation_product_platformcount > 0) {
+                $ViolationProductPlatformModel->where('product_id', $ViolationProduct->id)->delete();
+            }
+            if ($data['platform'] != 0) {
+                $insert_platform_data = [];
+                $platform_scope = explode(',', $data['platform']);
+                foreach ($platform_scope as $platform_id) {
+                    $insert_platform_data[] = [
+                        'company_id' => $company_id,
+                        'product_id' => $ViolationProduct->id,
+                        'platform_id' => $platform_id,
+                    ];
+                }
+                $ViolationProductPlatformModel->insert($insert_platform_data);
+            }
             DB::commit();
             return true;
             // 成功处理...

+ 28 - 0
app/Models/Manager/WashConfig/ViolationProductPlatform.php

@@ -0,0 +1,28 @@
+<?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: 2026-03-27
+ */
+class ViolationProductPlatform extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'washconfig_violation_product_platform';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+    
+
+}