Bladeren bron

[智价云] 数据清洗配置商品分类功能

tangyuanwang 1 dag geleden
bovenliggende
commit
9ff6d33018

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

@@ -7,6 +7,7 @@ use App\Http\Requests\Manager\WashConfig\ControlGoods as Request;
 use App\Models\Manager\WashConfig\ControlGoods as ControlGoodsModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\WashConfig\ControlGoodsCompany as ControlGoodsCompanyModel;
+use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
 
 /**
  * 数据清洗-强管控商品配置
@@ -23,7 +24,7 @@ class ControlGoods extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ControlGoodsModel $ControlGoodsModel, ViolationStoreModel $ViolationStoreModel, ControlGoodsCompanyModel $ControlGoodsCompanyModel)
+    public function list(Request $request, ControlGoodsModel $ControlGoodsModel, ViolationStoreModel $ViolationStoreModel, ControlGoodsCompanyModel $ControlGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -36,6 +37,7 @@ class ControlGoods extends Controller
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
         $company_scope = request('company_scope', '');
+        $category_id = request('category_id', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -45,6 +47,7 @@ class ControlGoods extends Controller
         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];
         // 查询数据
         $result = $ControlGoodsModel->query()
             ->where($map)
@@ -55,6 +58,8 @@ class ControlGoods extends Controller
         if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
+                $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name'):'';
+                $result['data'][$key]['category_name'] = $category_name;
                 //查询店铺名称
                 if (trim($value['store_scope']) == '') {
                     $result['data'][$key]['store_name'] = ['全部店铺'];
@@ -82,7 +87,7 @@ class ControlGoods extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ControlGoodsModel $ControlGoodsModel, ViolationStoreModel $ViolationStoreModel, ControlGoodsCompanyModel $ControlGoodsCompanyModel)
+    public function detail(Request $request, ControlGoodsModel $ControlGoodsModel,ControlGoodsCompanyModel $ControlGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -107,7 +112,8 @@ class ControlGoods extends Controller
             $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
             $data->company_ids = !empty($company_data) ? array_column($company_data, 'company_id') : '';
         }
-        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
+        $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
+        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name'):'';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -128,6 +134,8 @@ class ControlGoods extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $ControlGoodsModel->where($map)->first();
@@ -158,6 +166,8 @@ class ControlGoods extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $ControlGoodsModel->where($map)->where('id', '!=', $id)->first();

+ 13 - 3
app/Http/Controllers/Manager/WashConfig/LowPriceGoods.php

@@ -7,6 +7,7 @@ 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;
+use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
 
 
 /**
@@ -24,7 +25,7 @@ class LowPriceGoods extends Controller
      * @date      2025-12-02
      * 
      */
-    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel)
+    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -37,6 +38,7 @@ class LowPriceGoods extends Controller
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
         $company_scope = request('company_scope', '');
+        $category_id = request('category_id', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -46,6 +48,7 @@ class LowPriceGoods extends Controller
         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];
         // 查询数据
         $result = $LowPriceGoodsModel->query()
             ->where($map)
@@ -56,6 +59,8 @@ class LowPriceGoods extends Controller
         if (isset($result['data']) && count($result['data']) > 0) {
             foreach ($result['data'] as $key => $value) {
                 $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',', $value['platform']) : '';
+                $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name'):'';
+                $result['data'][$key]['category_name'] = $category_name;
                 //查询店铺名称
                 if ($value['store_scope'] == '1') {
                     $result['data'][$key]['store_name'] = ['全部店铺'];
@@ -83,7 +88,7 @@ class LowPriceGoods extends Controller
      * @version   1.0
      * @date      2025-12-02
      */
-    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, ViolationStoreModel $ViolationStoreModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel)
+    public function detail(Request $request, LowPriceGoodsModel $LowPriceGoodsModel,LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -97,7 +102,6 @@ class LowPriceGoods extends Controller
         } else {
             $data['store_name'] = '';
         }
-        $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
         //查询公司名称
         if ($data->company_scope == '1') {
             $data->company_name = ['全部公司'];
@@ -109,6 +113,8 @@ class LowPriceGoods extends Controller
             $data->company_name = !empty($company_data) ? array_column($company_data, 'company_name') : '';
             $data->company_ids = !empty($company_data) ? array_column($company_data, 'company_id') : '';
         }
+        $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
+        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name'):'';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -129,6 +135,8 @@ class LowPriceGoods extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
         $data = $LowPriceGoodsModel->where($map)->first();
@@ -159,6 +167,8 @@ class LowPriceGoods extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
         //查询是否存在
         $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();

+ 13 - 4
app/Http/Controllers/Manager/WashConfig/ViolationProduct.php

@@ -7,7 +7,7 @@ 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;
-
+use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
 
 /**
  * 数据清洗-违规产品配置
@@ -24,7 +24,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-03
      * 
      */
-    public function list(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel)
+    public function list(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -37,6 +37,7 @@ class ViolationProduct extends Controller
         $platform = request('platform', '');
         $store_scope = request('store_scope', '');
         $company_scope = request('company_scope', '');
+        $category_id = request('category_id', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
@@ -46,6 +47,7 @@ class ViolationProduct extends Controller
         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];
         // 查询数据
         $result = $ViolationProductModel->query()
             ->where($map)
@@ -56,6 +58,8 @@ class ViolationProduct extends Controller
         if(isset($result['data']) && count($result['data']) > 0){
             foreach ($result['data'] as $key => $value) {
                  $result['data'][$key]['platform'] = isset($value['platform']) ? explode(',',$value['platform']) : '';
+                 $category_name = $value['category_id'] > 0 ? $ProductCategoryModel->where('id', $value['category_id'])->value('name'):'';
+                 $result['data'][$key]['category_name'] = $category_name;
                 //查询店铺名称
                 if(trim($value['store_scope']) == ''){
                     $result['data'][$key]['store_name'] =['全部店铺'];
@@ -83,7 +87,7 @@ class ViolationProduct extends Controller
      * @version   1.0
      * @date      2025-12-03
      */
-    public function detail(Request $request, ViolationProductModel $ViolationProductModel,ViolationStoreModel $ViolationStoreModel,ViolationProductCompanyModel $ViolationProductCompanyModel)
+    public function detail(Request $request, ViolationProductModel $ViolationProductModel,ViolationProductCompanyModel $ViolationProductCompanyModel, ProductCategoryModel $ProductCategoryModel)
     {
         $request->scene('detail')->validate();
         // 接收参数
@@ -109,6 +113,7 @@ class ViolationProduct extends Controller
             $data->company_ids = !empty($company_data) ? array_column($company_data, 'company_id') : '';
         }
         $data->platform = isset($data->platform) ? explode(',',$data->platform) : '';
+        $data->category_name = $data->category_id > 0 ? $ProductCategoryModel->where('id', $data->category_id)->value('name'):'';
         // 加载模板
         return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
     }
@@ -129,6 +134,8 @@ class ViolationProduct extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
         //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
         $data = $ViolationProductModel->where($map)->first();
@@ -159,7 +166,9 @@ class ViolationProduct extends Controller
         $all_data['store_scope'] = $store_scope;
         $company_scope = request('company_scope', '');
         $all_data['company_scope'] = $company_scope;
-                //查询是否存在
+        $category_id = request('category_id', '');
+        $all_data['category_id'] = $category_id;
+        //查询是否存在
         $map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'],'platform'=> $all_data['platform']];
         $data = $ViolationProductModel->where($map)->where('id', '!=', $id)->first();
         if ($data)     return json_send(['code' => 'error', 'msg' => '记录已存在']);