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

[智价云] 违规处理数据导出功能

tangyuanwang преди 1 ден
родител
ревизия
7b0c96ae74

+ 88 - 32
app/Http/Controllers/Manager/Process/LowPriceGoods.php

@@ -28,7 +28,7 @@ class LowPriceGoods extends Controller
      * @date      2025-12-08
      * 
      */
-    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel,LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
+    public function list(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel, LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -54,47 +54,47 @@ class LowPriceGoods extends Controller
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         // 其他条件
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
-        if ($store_name) $map[]   = ['store_name','like',"%$store_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
         //多选平台查询
-        if($platform && is_string($platform)){
+        if ($platform && is_string($platform)) {
             $platform = explode(',', $platform);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('platform', $platform);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('platform', $platform);
         }
         //多选处理状态查询
-        if($processing_status && is_string($processing_status)){
+        if ($processing_status && is_string($processing_status)) {
             $processing_status = explode(',', $processing_status);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('processing_status', $processing_status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('processing_status', $processing_status);
         }
         //多选状态查询
-        if($status && is_string($status)){
+        if ($status && is_string($status)) {
             $status = explode(',', $status);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('status', $status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('status', $status);
         }
         //多选店铺名称查询
-        if($store_names && is_string($store_names)){
+        if ($store_names && is_string($store_names)) {
             $store_names = explode(',', $store_names);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('store_name', $store_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('store_name', $store_names);
         }
         //多选违规挂网次数查询
-        if($online_posting_cunt && is_string($online_posting_cunt)){
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
             $online_posting_cunt = explode(',', $online_posting_cunt);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('online_posting_cunt', $online_posting_cunt);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('online_posting_cunt', $online_posting_cunt);
         }
         //多选规格查询
-        if($product_specs && is_string($product_specs)){
+        if ($product_specs && is_string($product_specs)) {
             $product_specs = explode(',', $product_specs);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('product_specs', $product_specs);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_specs', $product_specs);
         }
         //多选商品查询
         if ($product_names && is_string($product_names)) {
             $product_names = explode(',', $product_names);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('product_name', $product_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_name', $product_names);
         }
         //多选公司查询
         if ($company_name && is_string($company_name)) {
             $company_name = explode(',', $company_name);
-            $LowPriceGoodsModel=$LowPriceGoodsModel->whereIn('company_name', $company_name);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('company_name', $company_name);
         }
         //多选第一责任人
         if ($first_responsible_person && is_string($first_responsible_person)) {
@@ -153,46 +153,102 @@ class LowPriceGoods extends Controller
      * @version 1.0
      * @date 2025-06-17
      */
-    public function export_excel(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel)
+    public function export_excel(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel, LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
     {
         $request->scene('export_excel')->validate();
         // 查询条件
         $map  = [];
+        $limit = request('limit', config('page_num', 10));
         $status    = request('status', '');
         $start_time = request('start_time', '');
         $end_time = request('end_time', '');
         $product_name = request('product_name', '');
+        $product_names = request('product_names', '');
         $first_responsible_person = request('first_responsible_person', '');
         $responsible_person = request('responsible_person', '');
         $platform = request('platform', '');
         $company_name = request('company_name', '');
         $store_name = request('store_name', '');
+        $store_names = request('store_names', '');
         $source_responsible_person = request('source_responsible_person', '');
         $processing_status = request('processing_status', '');
-        $product_name = request('product_name', '');
         $product_specs = request('product_specs', '');
         $online_posting_cunt = request('online_posting_cunt', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         // 其他条件
-        if ($status) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
-        if ($first_responsible_person) $map[] = ['first_responsible_person', 'like', "%,$first_responsible_person,%"];
-        if ($responsible_person) $map[] = ['responsible_person', 'like', "%,$responsible_person,%"];
-        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
-        if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
-        if ($source_responsible_person) $map[] = ['source_responsible_person', 'like', "%,$source_responsible_person,%"];
-        if ($processing_status) $map[] = ['processing_status', '=', $processing_status];
-        if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
-        if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
-        if ($online_posting_cunt) $map[] = ['online_posting_cunt', '=', $online_posting_cunt];
-        // 查询数据
-        $result = $LowPriceGoodsModel->query()
+        //多选平台查询
+        if ($platform && is_string($platform)) {
+            $platform = explode(',', $platform);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('platform', $platform);
+        }
+        //多选处理状态查询
+        if ($processing_status && is_string($processing_status)) {
+            $processing_status = explode(',', $processing_status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('processing_status', $processing_status);
+        }
+        //多选状态查询
+        if ($status && is_string($status)) {
+            $status = explode(',', $status);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('status', $status);
+        }
+        //多选店铺名称查询
+        if ($store_names && is_string($store_names)) {
+            $store_names = explode(',', $store_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('store_name', $store_names);
+        }
+        //多选违规挂网次数查询
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
+            $online_posting_cunt = explode(',', $online_posting_cunt);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('online_posting_cunt', $online_posting_cunt);
+        }
+        //多选规格查询
+        if ($product_specs && is_string($product_specs)) {
+            $product_specs = explode(',', $product_specs);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_specs', $product_specs);
+        }
+        //多选商品查询
+        if ($product_names && is_string($product_names)) {
+            $product_names = explode(',', $product_names);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('product_name', $product_names);
+        }
+        //多选公司查询
+        if ($company_name && is_string($company_name)) {
+            $company_name = explode(',', $company_name);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('company_name', $company_name);
+        }
+        //多选第一责任人
+        if ($first_responsible_person && is_string($first_responsible_person)) {
+            $first_responsible_person = explode(',', $first_responsible_person);
+            $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选责任人
+        if ($responsible_person && is_string($responsible_person)) {
+            $responsible_person = explode(',', $responsible_person);
+            $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选溯源责任人
+        if ($source_responsible_person && is_string($source_responsible_person)) {
+            $source_responsible_person = explode(',', $source_responsible_person);
+            $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        $result = $LowPriceGoodsModel
             ->where($map)
-            ->orderByDesc('id')->get()->toarray();
+            ->orderByDesc('id')
+            ->get()->toarray();
         // 分配数据
         if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
         // 处理责任人展示信息

+ 85 - 31
app/Http/Controllers/Manager/Process/ViolationProduct.php

@@ -28,7 +28,7 @@ class ViolationProduct extends Controller
      * @date      2025-12-08
      * 
      */
-    public function list(Request $request, ViolationProductModel $ViolationProductModel,EmployeeModel $EmployeeModel,ViolationProductMemberModel $ViolationProductMemberModel)
+    public function list(Request $request, ViolationProductModel $ViolationProductModel, EmployeeModel $EmployeeModel, ViolationProductMemberModel $ViolationProductMemberModel)
     {
         $request->scene('list')->validate();
         // 查询条件
@@ -54,47 +54,47 @@ class ViolationProduct extends Controller
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         // 其他条件
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
-        if ($store_name) $map[]   = ['store_name','like',"%$store_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
         //多选平台查询
-        if($platform && is_string($platform)){
+        if ($platform && is_string($platform)) {
             $platform = explode(',', $platform);
-            $ViolationProductModel=$ViolationProductModel->whereIn('platform', $platform);
+            $ViolationProductModel = $ViolationProductModel->whereIn('platform', $platform);
         }
         //多选处理状态查询
-        if($processing_status && is_string($processing_status)){
+        if ($processing_status && is_string($processing_status)) {
             $processing_status = explode(',', $processing_status);
-            $ViolationProductModel=$ViolationProductModel->whereIn('processing_status', $processing_status);
+            $ViolationProductModel = $ViolationProductModel->whereIn('processing_status', $processing_status);
         }
         //多选状态查询
-        if($status && is_string($status)){
+        if ($status && is_string($status)) {
             $status = explode(',', $status);
-            $ViolationProductModel=$ViolationProductModel->whereIn('status', $status);
+            $ViolationProductModel = $ViolationProductModel->whereIn('status', $status);
         }
         //多选店铺名称查询
-        if($store_names && is_string($store_names)){
+        if ($store_names && is_string($store_names)) {
             $store_names = explode(',', $store_names);
-            $ViolationProductModel=$ViolationProductModel->whereIn('store_name', $store_names);
+            $ViolationProductModel = $ViolationProductModel->whereIn('store_name', $store_names);
         }
         //多选违规挂网次数查询
-        if($online_posting_cunt && is_string($online_posting_cunt)){
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
             $online_posting_cunt = explode(',', $online_posting_cunt);
-            $ViolationProductModel=$ViolationProductModel->whereIn('online_posting_cunt', $online_posting_cunt);
+            $ViolationProductModel = $ViolationProductModel->whereIn('online_posting_cunt', $online_posting_cunt);
         }
         //多选规格查询
-        if($product_specs && is_string($product_specs)){
+        if ($product_specs && is_string($product_specs)) {
             $product_specs = explode(',', $product_specs);
-            $ViolationProductModel=$ViolationProductModel->whereIn('product_specs', $product_specs);
+            $ViolationProductModel = $ViolationProductModel->whereIn('product_specs', $product_specs);
         }
         //多选商品查询
         if ($product_names && is_string($product_names)) {
             $product_names = explode(',', $product_names);
-            $ViolationProductModel=$ViolationProductModel->whereIn('product_name', $product_names);
+            $ViolationProductModel = $ViolationProductModel->whereIn('product_name', $product_names);
         }
         //多选公司查询
         if ($company_name && is_string($company_name)) {
             $company_name = explode(',', $company_name);
-            $ViolationProductModel=$ViolationProductModel->whereIn('company_name', $company_name);
+            $ViolationProductModel = $ViolationProductModel->whereIn('company_name', $company_name);
         }
         //多选第一责任人
         if ($first_responsible_person && is_string($first_responsible_person)) {
@@ -152,7 +152,7 @@ class ViolationProduct extends Controller
      * @version 1.0
      * @date 2025-06-17
      */
-    public function export_excel(Request $request, ViolationProductModel $ViolationProductModel, EmployeeModel $EmployeeModel)
+    public function export_excel(Request $request, ViolationProductModel $ViolationProductModel, EmployeeModel $EmployeeModel, ViolationProductMemberModel $ViolationProductMemberModel)
     {
         $request->scene('export_excel')->validate();
         // 查询条件
@@ -162,35 +162,89 @@ class ViolationProduct extends Controller
         $start_time = request('start_time', '');
         $end_time = request('end_time', '');
         $product_name = request('product_name', '');
+        $product_names = request('product_names', '');
         $first_responsible_person = request('first_responsible_person', '');
         $responsible_person = request('responsible_person', '');
         $platform = request('platform', '');
         $company_name = request('company_name', '');
         $store_name = request('store_name', '');
+        $store_names = request('store_names', '');
         $source_responsible_person = request('source_responsible_person', '');
         $processing_status = request('processing_status', '');
-        $product_name = request('product_name', '');
         $product_specs = request('product_specs', '');
         $online_posting_cunt = request('online_posting_cunt', '');
         // 时间条件
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         // 其他条件
-        if ($status) $map[] = ['status', '=', $status];
         if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
-        if ($first_responsible_person) $map[] = ['first_responsible_person', 'like', "%,$first_responsible_person,%"];
-        if ($responsible_person) $map[] = ['responsible_person', 'like', "%,$responsible_person,%"];
-        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
-        if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
-        if ($source_responsible_person) $map[] = ['source_responsible_person', 'like', "%,$source_responsible_person,%"];
-        if ($processing_status) $map[] = ['processing_status', '=', $processing_status];
-        if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
-        if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
-        if ($online_posting_cunt) $map[] = ['online_posting_cunt', '=', $online_posting_cunt];
-        // 查询数据
-        $result = $ViolationProductModel->query()
+        //多选平台查询
+        if ($platform && is_string($platform)) {
+            $platform = explode(',', $platform);
+            $ViolationProductModel = $ViolationProductModel->whereIn('platform', $platform);
+        }
+        //多选处理状态查询
+        if ($processing_status && is_string($processing_status)) {
+            $processing_status = explode(',', $processing_status);
+            $ViolationProductModel = $ViolationProductModel->whereIn('processing_status', $processing_status);
+        }
+        //多选状态查询
+        if ($status && is_string($status)) {
+            $status = explode(',', $status);
+            $ViolationProductModel = $ViolationProductModel->whereIn('status', $status);
+        }
+        //多选店铺名称查询
+        if ($store_names && is_string($store_names)) {
+            $store_names = explode(',', $store_names);
+            $ViolationProductModel = $ViolationProductModel->whereIn('store_name', $store_names);
+        }
+        //多选违规挂网次数查询
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
+            $online_posting_cunt = explode(',', $online_posting_cunt);
+            $ViolationProductModel = $ViolationProductModel->whereIn('online_posting_cunt', $online_posting_cunt);
+        }
+        //多选规格查询
+        if ($product_specs && is_string($product_specs)) {
+            $product_specs = explode(',', $product_specs);
+            $ViolationProductModel = $ViolationProductModel->whereIn('product_specs', $product_specs);
+        }
+        //多选商品查询
+        if ($product_names && is_string($product_names)) {
+            $product_names = explode(',', $product_names);
+            $ViolationProductModel = $ViolationProductModel->whereIn('product_name', $product_names);
+        }
+        //多选公司查询
+        if ($company_name && is_string($company_name)) {
+            $company_name = explode(',', $company_name);
+            $ViolationProductModel = $ViolationProductModel->whereIn('company_name', $company_name);
+        }
+        //多选第一责任人
+        if ($first_responsible_person && is_string($first_responsible_person)) {
+            $first_responsible_person = explode(',', $first_responsible_person);
+            $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('violation_product_logid')->select('violation_product_logid');
+            $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选责任人
+        if ($responsible_person && is_string($responsible_person)) {
+            $responsible_person = explode(',', $responsible_person);
+            $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $responsible_person)->distinct('violation_product_logid')->select('violation_product_logid');
+            $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选溯源责任人
+        if ($source_responsible_person && is_string($source_responsible_person)) {
+            $source_responsible_person = explode(',', $source_responsible_person);
+            $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('violation_product_logid')->select('violation_product_logid');
+            $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        $result = $ViolationProductModel
             ->where($map)
             ->orderByDesc('id')
             ->get()->toarray();

+ 103 - 55
app/Http/Controllers/Manager/Process/ViolationStore.php

@@ -27,11 +27,10 @@ class ViolationStore extends Controller
      * @date      2025-12-08
      * 
      */
-    public function list(Request $request, ViolationStoreModel $ViolationStoreModel,EmployeeModel $EmployeeModel,ViolationStoreMemberModel $ViolationStoreMemberModel)
+    public function list(Request $request, ViolationStoreModel $ViolationStoreModel, EmployeeModel $EmployeeModel, ViolationStoreMemberModel $ViolationStoreMemberModel)
     {
         $request->scene('list')->validate();
         // 查询条件
-       // 查询条件
         $map  = [];
         $limit = request('limit', config('page_num', 10));
         $status    = request('status', '');
@@ -51,42 +50,42 @@ class ViolationStore extends Controller
         if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
         if ($end_time) $map[]   = ['insert_time', '<=', strtotime($end_time)];
         //其它条件
-        if ($store_name) $map[]   = ['store_name','like',"%$store_name%"];
+        if ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
         //多选平台查询
-        if($platform && is_string($platform)){
+        if ($platform && is_string($platform)) {
             $platform = explode(',', $platform);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('platform', $platform);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('platform', $platform);
         }
         //多选处理状态查询
-        if($processing_status && is_string($processing_status)){
+        if ($processing_status && is_string($processing_status)) {
             $processing_status = explode(',', $processing_status);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('processing_status', $processing_status);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('processing_status', $processing_status);
         }
         //多选状态查询
-        if($status && is_string($status)){
+        if ($status && is_string($status)) {
             $status = explode(',', $status);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('status', $status);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('status', $status);
         }
         //多选店铺名称查询
-        if($store_names && is_string($store_names)){
+        if ($store_names && is_string($store_names)) {
             $store_names = explode(',', $store_names);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('store_name', $store_names);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('store_name', $store_names);
         }
         //多选违规挂网次数查询
-        if($online_posting_cunt && is_string($online_posting_cunt)){
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
             $online_posting_cunt = explode(',', $online_posting_cunt);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('online_posting_cunt', $online_posting_cunt);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('online_posting_cunt', $online_posting_cunt);
         }
         //多选规格查询
-        if($product_specs && is_string($product_specs)){
+        if ($product_specs && is_string($product_specs)) {
             $product_specs = explode(',', $product_specs);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('product_specs', $product_specs);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('product_specs', $product_specs);
         }
         //多选公司查询
         if ($company_name && is_string($company_name)) {
             $company_name = explode(',', $company_name);
-            $ViolationStoreModel=$ViolationStoreModel->whereIn('company_name', $company_name);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('company_name', $company_name);
         }
         //多选第一责任人
         if ($first_responsible_person && is_string($first_responsible_person)) {
@@ -145,7 +144,7 @@ class ViolationStore extends Controller
      * @version 1.0
      * @date 2025-06-17
      */
-    public function export_excel(Request $request, ViolationStoreModel $ViolationStoreModel, EmployeeModel $EmployeeModel)
+    public function export_excel(Request $request,  ViolationStoreModel $ViolationStoreModel, EmployeeModel $EmployeeModel, ViolationStoreMemberModel $ViolationStoreMemberModel)
     {
         $request->scene('export_excel')->validate();
         // 查询条件
@@ -159,23 +158,78 @@ class ViolationStore extends Controller
         $platform = request('platform', '');
         $company_name = request('company_name', '');
         $store_name = request('store_name', '');
+        $store_names = request('store_names', '');
         $source_responsible_person = request('source_responsible_person', '');
         $processing_status = request('processing_status', '');
+        $product_specs = request('product_specs', '');
+        $online_posting_cunt = request('online_posting_cunt', '');
         // 时间条件
         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 ($store_name) $map[]   = ['store_name', 'like', "%$store_name%"];
 
-        if ($first_responsible_person) $map[] = ['first_responsible_person', 'like', "%,$first_responsible_person,%"];
-        if ($responsible_person) $map[] = ['responsible_person', 'like', "%,$responsible_person,%"];
-        if ($platform) $map[] = ['platform', 'like', "%$platform%"];
-        if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
-        if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
-        if ($source_responsible_person) $map[] = ['source_responsible_person', 'like', "%,$source_responsible_person,%"];
-        if ($processing_status) $map[] = ['processing_status', '=', $processing_status];
+        //多选平台查询
+        if ($platform && is_string($platform)) {
+            $platform = explode(',', $platform);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('platform', $platform);
+        }
+        //多选处理状态查询
+        if ($processing_status && is_string($processing_status)) {
+            $processing_status = explode(',', $processing_status);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('processing_status', $processing_status);
+        }
+        //多选状态查询
+        if ($status && is_string($status)) {
+            $status = explode(',', $status);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('status', $status);
+        }
+        //多选店铺名称查询
+        if ($store_names && is_string($store_names)) {
+            $store_names = explode(',', $store_names);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('store_name', $store_names);
+        }
+        //多选违规挂网次数查询
+        if ($online_posting_cunt && is_string($online_posting_cunt)) {
+            $online_posting_cunt = explode(',', $online_posting_cunt);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('online_posting_cunt', $online_posting_cunt);
+        }
+        //多选规格查询
+        if ($product_specs && is_string($product_specs)) {
+            $product_specs = explode(',', $product_specs);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('product_specs', $product_specs);
+        }
+        //多选公司查询
+        if ($company_name && is_string($company_name)) {
+            $company_name = explode(',', $company_name);
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('company_name', $company_name);
+        }
+        //多选第一责任人
+        if ($first_responsible_person && is_string($first_responsible_person)) {
+            $first_responsible_person = explode(',', $first_responsible_person);
+            $subQuery = $ViolationStoreMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('violation_store_logid')->select('violation_store_logid');
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_store_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选责任人
+        if ($responsible_person && is_string($responsible_person)) {
+            $responsible_person = explode(',', $responsible_person);
+            $subQuery = $ViolationStoreMemberModel->whereIn('employee_id', $responsible_person)->distinct('violation_store_logid')->select('violation_store_logid');
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_store_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选溯源责任人
+        if ($source_responsible_person && is_string($source_responsible_person)) {
+            $source_responsible_person = explode(',', $source_responsible_person);
+            $subQuery = $ViolationStoreMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('violation_store_logid')->select('violation_store_logid');
+            $ViolationStoreModel = $ViolationStoreModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('violation_store_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
         // 查询数据
-        $result = $ViolationStoreModel->query()
+        $result = $ViolationStoreModel
             ->where($map)
             ->orderByDesc('id')
             ->get()->toarray();
@@ -259,7 +313,7 @@ class ViolationStore extends Controller
 
         //合并单元格
         $sheet->mergeCells('A1:P1');
-        $sheet->setCellValue('A1', '违规挂网商品导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
+        $sheet->setCellValue('A1', '违规店铺导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
         // 获取合并后的单元格样式对象
         $style = $sheet->getStyle('A1');
         // 设置水平居中和垂直居中
@@ -270,19 +324,16 @@ class ViolationStore extends Controller
         $sheet->setCellValue('A2', '第一责任人');
         $sheet->setCellValue('B2', '责任人');
         $sheet->setCellValue('C2', '平台');
-        $sheet->setCellValue('D2', '商品名称');
-        $sheet->setCellValue('E2', '商品规格');
-        $sheet->setCellValue('F2', '挂网次数');
-        $sheet->setCellValue('G2', '链接地址');
-        $sheet->setCellValue('H2', '店铺名称');
-        $sheet->setCellValue('I2', '公司名称');
-        $sheet->setCellValue('J2', '信用代码');
-        $sheet->setCellValue('K2', '省份');
-        $sheet->setCellValue('L2', '城市');
-        $sheet->setCellValue('M2', '溯源责任人');
-        $sheet->setCellValue('N2', '处理状态');
-        $sheet->setCellValue('O2', '任务状态');
-        $sheet->setCellValue('P2', '记录时间');
+        $sheet->setCellValue('D2', '链接地址');
+        $sheet->setCellValue('E2', '店铺名称');
+        $sheet->setCellValue('F2', '公司名称');
+        $sheet->setCellValue('G2', '信用代码');
+        $sheet->setCellValue('H2', '省份');
+        $sheet->setCellValue('I2', '城市');
+        $sheet->setCellValue('J2', '溯源责任人');
+        $sheet->setCellValue('K2', '处理状态');
+        $sheet->setCellValue('L2', '任务状态');
+        $sheet->setCellValue('M2', '记录时间');
 
         $platform_data = [
             '0' => '全部',
@@ -310,19 +361,16 @@ class ViolationStore extends Controller
             $sheet->setCellValue('A' . $row, $first_responsible_person_name);
             $sheet->setCellValue('B' . $row, $responsible_person_name);
             $sheet->setCellValue('C' . $row, isset($platform_data[$item['platform']]) ? $platform_data[$item['platform']] : '');
-            $sheet->setCellValue('D' . $row, $item['product_name']);
-            $sheet->setCellValue('E' . $row, $item['product_specs']);
-            $sheet->setCellValue('F' . $row, $item['online_posting_cunt']);
-            $sheet->setCellValue('G' . $row, $item['link_url']);
-            $sheet->setCellValue('H' . $row, $item['store_name']);
-            $sheet->setCellValue('I' . $row, $item['company_name']);
-            $sheet->setCellValue('J' . $row, $item['social_credit_code']);
-            $sheet->setCellValue('K' . $row, $item['province_name']);
-            $sheet->setCellValue('L' . $row, $item['city_name']);
-            $sheet->setCellValue('M' . $row, $source_responsible_person_name);
-            $sheet->setCellValue('N' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
-            $sheet->setCellValue('O' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
-            $sheet->setCellValue('P' . $row, date('Y-m-d H:i:s', $item['insert_time']));
+            $sheet->setCellValue('D' . $row, $item['link_url']);
+            $sheet->setCellValue('E' . $row, $item['store_name']);
+            $sheet->setCellValue('F' . $row, $item['company_name']);
+            $sheet->setCellValue('G' . $row, $item['social_credit_code']);
+            $sheet->setCellValue('H' . $row, $item['province_name']);
+            $sheet->setCellValue('I' . $row, $item['city_name']);
+            $sheet->setCellValue('J' . $row, $source_responsible_person_name);
+            $sheet->setCellValue('K' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
+            $sheet->setCellValue('L' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
+            $sheet->setCellValue('M' . $row, date('Y-m-d H:i:s', $item['insert_time']));
             $row++;
         }
         foreach (range('A', 'P') as $column) {
@@ -332,7 +380,7 @@ class ViolationStore extends Controller
         $writer = new Xlsx($spreadsheet);
 
         // 直接输出到浏览器(下载)
-        $filename = '违规挂网商品数据' . date('YmdHis') . '.xlsx';
+        $filename = '违规店铺数据' . date('YmdHis') . '.xlsx';
         header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
         header('Content-Disposition: attachment;filename="' . $filename . '"');
         header('Cache-Control: max-age=0');

+ 1 - 0
app/Http/Requests/Manager/Process/ControlGoods.php

@@ -80,6 +80,7 @@ class ControlGoods extends BaseRequest
         'set_processing_status'   => ['id', 'processing_status'],
         'delete'                  => ['id'],
         'data_cleaning'           => [''],
+        'export_excel'            => ['']
     ];
 
     /**

+ 1 - 0
app/Http/Requests/Manager/Process/LowPriceGoods.php

@@ -80,6 +80,7 @@ class LowPriceGoods extends BaseRequest
         'set_processing_status'   => ['id', 'processing_status'],
         'delete'                  => ['id'],
         'data_cleaning'           => [''],
+        'export_excel'            => ['']
     ];
 
     /**

+ 1 - 0
app/Http/Requests/Manager/Process/ViolationProduct.php

@@ -76,6 +76,7 @@ class ViolationProduct extends BaseRequest
         'set_processing_status'   => ['id', 'processing_status'],
         'delete'                  => ['id'],
         'data_cleaning'           => [''],
+        'export_excel'            => ['']
     ];
 
     /**

+ 1 - 0
app/Http/Requests/Manager/Process/ViolationStore.php

@@ -72,6 +72,7 @@ class ViolationStore extends BaseRequest
         'set_processing_status'   => ['id', 'processing_status'],
         'delete'                  => ['id'],
         'data_cleaning'           => [''],
+        'export_excel'            => ['']
     ];
 
     /**