瀏覽代碼

[智价云] 文件任务式导出功能

tangyuanwang 5 天之前
父節點
當前提交
3385d3cf18

+ 57 - 0
app/Http/Controllers/Manager/Other/DownloadTask.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace App\Http\Controllers\Manager\Other;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\Manager\Other\DownloadTask as Request;
+use App\Models\Manager\Other\DownloadTask as DownloadTaskModel;
+
+
+/**
+ * 文件下载任务
+ * @author 唐远望
+ * @version 2.0
+ * @date 2026-04-01
+ */
+class DownloadTask extends Controller
+{
+    /**
+     * 列表
+     * @author 唐远望
+     * @version 2.0
+     * @date 2026-04-01
+     */
+    public function list(Request $request, DownloadTaskModel $DownloadTaskModel)
+    {
+        $request->scene('list')->validate();
+        $admin_company_id = request('admin_company_id', '0');
+        $company_id = request('access_token.company_id', '0');
+        $is_admin = request('access_token.is_admin', '0');
+        $user_id = request('access_token.uid', 0);
+        // 查询条件
+        $limit = request('limit', config('page_num', 10));
+        $map[]              = ['operator_userid', '=', $user_id];
+        // 权限判断
+        if ($is_admin != 1 && $company_id != 0) {
+            $map['company_id'] = $company_id;
+        } else {
+            $map['company_id']  = $admin_company_id;
+        }
+        // 查询数据
+        $result             = $DownloadTaskModel->where($map)->orderByDesc('id')->paginate($limit);
+        // 循环数据
+        foreach ($result as $key => $value) {
+            // 如果状态为 0。且时间超过30分钟
+            if ($value->status == 0 && $value->create_time + 1800  < time()) {
+                // 更新数据
+                $DownloadTaskModel->edit($value->id, ['status' => 2]);
+                // 更改状态
+                $value->status = 2;
+            }
+            // 获取文件名称
+            $result[$key]   = $value;
+        }
+        // 加载模板
+        return              json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
+    }
+}

+ 56 - 331
app/Http/Controllers/Manager/Process/LowPriceGoods.php

@@ -15,6 +15,10 @@ use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
 use App\Models\manager\Process\LowPriceGoodsRecord as LowPriceGoodsRecordModel;
 use Illuminate\Support\Facades\DB;
 use App\Models\Manager\Citys as CitysModel;
+use App\Servers\Aliyun\Oss;
+use App\Jobs\Manager\Other\ExportLowPriceGoodsJobs;
+use App\Models\Manager\Other\DownloadTask as DownloadTaskModel;
+use Illuminate\Support\Facades\Cache;
 
 /**
  * 违规处理-低价商品
@@ -214,347 +218,68 @@ class LowPriceGoods extends Controller
      * @version 1.0
      * @date 2025-06-17
      */
-    public function export_excel(Request $request, LowPriceGoodsModel $LowPriceGoodsModel, EmployeeModel $EmployeeModel, LowPriceGoodsMemberModel $LowPriceGoodsMemberModel)
+    public function export_excel(Request $request,DownloadTaskModel $DownloadTaskModel)
     {
         $request->scene('export_excel')->validate();
-        $admin_company_id = request('admin_company_id', '0');
-        $company_id = request('access_token.company_id', '0');
-        $is_admin = request('access_token.is_admin', '0'); //是否管理员操作 0=是1=否
-        $user_id = request('access_token.uid', 0);
+        $message_data['admin_company_id'] = request('admin_company_id', '0');
+        $message_data['company_id'] = request('access_token.company_id', '0');
+        $message_data['is_admin'] = request('access_token.is_admin', '0'); //是否管理员操作 0=是1=否
+        $message_data['user_id'] = request('access_token.uid', 0);
         // 查询条件
-        $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_specs = request('product_specs', '');
-        $online_posting_count = request('online_posting_count', '');
-        $category_name = request('category_name', '');
-        $province_ids = request('province_ids', '');
-        $city_ids = request('city_ids', '');
-        $shipment_province_ids = request('shipment_province_ids', '');
-        $shipment_city_ids = request('shipment_city_ids', '');
-        // 时间条件
-        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
-        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 ($category_name) $map[] = ['category_name', 'like', "%$category_name%"];
+        $message_data['status'] = request('status', '');
+        $message_data['start_time'] = request('start_time', '');
+        $message_data['end_time'] = request('end_time', '');
+        $message_data['product_name'] = request('product_name', '');
+        $message_data['product_names'] = request('product_names', '');
+        $message_data['first_responsible_person'] = request('first_responsible_person', '');
+        $message_data['responsible_person'] = request('responsible_person', '');
+        $message_data['platform'] = request('platform', '');
+        $message_data['company_name'] = request('company_name', '');
+        $message_data['company_names'] = request('company_names', '');
+        $message_data['store_name'] = request('store_name', '');
+        $message_data['store_names'] = request('store_names', '');
+        $message_data['source_responsible_person'] = request('source_responsible_person', '');
+        $message_data['processing_status'] = request('processing_status', '');
+        $message_data['product_specs'] = request('product_specs', '');
+        $message_data['online_posting_count'] = request('online_posting_count', '');
+        $message_data['category_name'] = request('category_name', '');
+        $message_data['id'] = request('id', '');
+        $message_data['online_posting_cunt'] = request('online_posting_cunt', '');
+        $message_data['continuous_listing_count'] = request('continuous_listing_count', '');
+        $message_data['province_ids'] = request('province_ids', '');
+        $message_data['city_ids'] = request('city_ids', '');
+        $message_data['shipment_province_ids'] = request('shipment_province_ids', '');
+        $message_data['shipment_city_ids'] = request('shipment_city_ids', '');
 
         $low_price_goods_where = [];
         // 权限判断
-        if ($is_admin != 1 && $company_id != 0) {
-            $low_price_goods_where['company_id'] = $company_id;
-        } else {
-            $low_price_goods_where['company_id']  = $admin_company_id;
-        }
-        $LowPriceGoodsModel = $LowPriceGoodsModel->where($low_price_goods_where);
-        //多选平台查询
-        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_count && is_string($online_posting_count)) {
-            $online_posting_count = explode(',', $online_posting_count);
-            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('online_posting_count', $online_posting_count);
-        }
-        //多选规格查询
-        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');
-            });
-        }
-        //多选省份
-        if ($province_ids && is_string($province_ids)) {
-            $province_ids = explode(',', $province_ids);
-            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('province_id', $province_ids);
-        }
-        //多选城市
-        if ($city_ids && is_string($city_ids)) {
-            $city_ids = explode(',', $city_ids);
-            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
-        }
-        //多选发货省份
-        if ($shipment_province_ids && is_string($shipment_province_ids)) {
-            $shipment_province_ids = explode(',', $shipment_province_ids);
-            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
-        }
-        //多选发货城市
-        if ($shipment_city_ids && is_string($shipment_city_ids)) {
-            $shipment_city_ids = explode(',', $shipment_city_ids);
-            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
-        }
-
-        if ($is_admin != 1 && $company_id != 0) {
-            $result_totle = $LowPriceGoodsModel->where(function ($q) use ($user_id) {
-                $q->where('first_responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
-            })
-                ->where($map)
-                ->orderByDesc('id')
-                ->count();
+        if ($message_data['is_admin'] != 1 && $message_data['company_id'] != 0) {
+            $low_price_goods_where['company_id'] = $message_data['company_id'];
         } else {
-            $result_totle = $LowPriceGoodsModel->where($map)
-                ->orderByDesc('id')
-                ->count();
-        }
-        // 数量过多时,限制导出
-        if ($result_totle > 100000) {
-            return json_send(['code' => 'error', 'msg' => '导出数据过多,请缩小查询条件']);
-        }
-
-        if ($is_admin != 1 && $company_id != 0) {
-            $result = $LowPriceGoodsModel->where(function ($q) use ($user_id) {
-                $q->where('first_responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
-            })
-                ->where($map)
-                ->orderByDesc('id')
-                ->get()->toarray();
-        } else {
-            $result = $LowPriceGoodsModel
-                ->where($map)
-                ->orderByDesc('id')
-                ->get()->toarray();
-        }
-        // 分配数据
-        if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
-        // 处理责任人展示信息
-        $list_data = $this->processing_responsible_person($result);
-        // 导出数据
-        $this->export_download($list_data);
-    }
-
-
-    /**
-     * 处理责任人展示信息
-     * @author 唐远望
-     * @version 1.0
-     * @date 2025-12-17
-     */
-    public function processing_responsible_person($result)
-    {
-        $EmployeeModel = new EmployeeModel();
-        //获取所有员工
-        $employeee_data = $EmployeeModel->select(['id', 'name'])->get()->toarray();
-        $employeee_list = [];
-        if (!empty($employeee_data)) {
-            foreach ($employeee_data as $key => $value) {
-                $employeee_list[$value['id']] = $value['name'];
-            }
-        }
-        if (isset($result) && count($result) > 0) {
-            foreach ($result as $key => $value) {
-                //查询第一责任人名称
-                $first_responsible_person = $value['first_responsible_person'] != '' ? explode(',', $value['first_responsible_person']) : [];
-                $first_responsible_person_name = [];
-                if (!empty($first_responsible_person)) {
-                    foreach ($first_responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $first_responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['first_responsible_person_name'] = $first_responsible_person_name;
-                //查询责任人名称
-                $responsible_person = $value['responsible_person'] != '' ? explode(',', $value['responsible_person']) : [];
-                $responsible_person_name = [];
-                if (!empty($responsible_person)) {
-                    foreach ($responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['responsible_person_name'] = $responsible_person_name;
-                //查询来源责任人名称
-                $source_responsible_person = $value['source_responsible_person'] != '' ? explode(',', $value['source_responsible_person']) : [];
-                $source_responsible_person_name = [];
-                if (!empty($source_responsible_person)) {
-                    foreach ($source_responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $source_responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['source_responsible_person_name'] = $source_responsible_person_name;
-            }
+            $low_price_goods_where['company_id']  = $message_data['admin_company_id'];
         }
-        return $result;
-    }
-
-    /**
-     * 导出下载
-     * @author 唐远望
-     * @version 1.0
-     * @date 2025-06-17
-     */
-    public function export_download($data)
-    {
-        // 创建一个新的 Spreadsheet 对象
-        $spreadsheet = new Spreadsheet();
-        $sheet = $spreadsheet->getActiveSheet();
+        $key_name = 'ExportLowPriceGoodsJobs_' . $low_price_goods_where['company_id'];
+        $export_data_info = Cache::get($key_name);
+        if ($export_data_info) return json_send(['code' => 'fail', 'msg' => '导出任务正在执行中,请稍后再试', 'data' => '']);
 
-        //合并单元格
-        $sheet->mergeCells('A1:U1');
-        $sheet->setCellValue('A1', '低价挂网商品导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
-        // 获取合并后的单元格样式对象
-        $style = $sheet->getStyle('A1');
-        // 设置水平居中和垂直居中
-        $style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
-        // 然后设置行高以适应两行文本
-        $sheet->getRowDimension(1)->setRowHeight(40); // 设置行高,单位是磅(point)
-        // 设置表头
-        $sheet->setCellValue('A2', '第一责任人');
-        $sheet->setCellValue('B2', '责任人');
-        $sheet->setCellValue('C2', '平台');
-        $sheet->setCellValue('D2', '商品分类');
-        $sheet->setCellValue('E2', '商品名称');
-        $sheet->setCellValue('F2', '库存');
-        $sheet->setCellValue('G2', '销量');
-        $sheet->setCellValue('H2', '快照URL');
-        $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('Q2', '公司分类');
-        $sheet->setCellValue('R2', '信用代码');
-        $sheet->setCellValue('S2', '省份');
-        $sheet->setCellValue('T2', '城市');
-        $sheet->setCellValue('U2', '溯源责任人');
-        $sheet->setCellValue('V2', '处理状态');
-        $sheet->setCellValue('W2', '任务状态');
-        $sheet->setCellValue('X2', '记录时间');
-        $sheet->setCellValue('Y2', '发货省份');
-        $sheet->setCellValue('Z2', '发货城市');
-
-        $platform_data = [
-            '0' => '全部',
-            '1' => '淘宝',
-            '2' => '京东',
-            '3' => '拼多多',
-            '4' => '美团',
-            '5' => '药师帮',
-            '6' => '1药城',
-            '7' => '药久久',
-        ];
-        $processing_status_text = [
-            '1' => '待处理',
+        // 生成唯一文件ID
+        $fileId                     = make_snow_flake();
+        $message_data['file_id']    = $fileId;
+        $fileName = '低价挂网商品导出_' . date('Y-m-d H:i:s', time()) . '.xlsx';
+        $downloadLog                 = [
+            'insert_time' => time(),
+            'company_id' => $low_price_goods_where['company_id'],
+            'operator_userid' => $message_data['user_id'],
+            'file_name' => $fileName,
+            'file_id' => $fileId,
+            'url' => '',
         ];
-        $status_text = [
-            '0' => '有效',
-            '1' => '无效',
-        ];
-        // 填充数据
-        $row = 3; // 从第2行开始
-        foreach ($data as $item) {
-            $first_responsible_person_name = !empty($item['first_responsible_person_name']) ? implode(',', $item['first_responsible_person_name']) : '';
-            $responsible_person_name = !empty($item['responsible_person_name']) ? implode(',', $item['responsible_person_name']) : '';
-            $source_responsible_person_name = !empty($item['source_responsible_person_name']) ? implode(',', $item['source_responsible_person_name']) : '';
-            $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['category_name']);
-            $sheet->setCellValue('E' . $row, $item['product_name']);
-            $sheet->setCellValue('F' . $row, $item['inventory']);
-            $sheet->setCellValue('G' . $row, $item['sales']);
-            $sheet->setCellValue('H' . $row, $item['snapshot_url']);
-            $sheet->setCellValue('I' . $row, $item['product_specs']);
-            $sheet->setCellValue('J' . $row, $item['suggested_price']);
-            $sheet->setCellValue('K' . $row, $item['online_posting_price']);
-            $sheet->setCellValue('L' . $row, $item['online_posting_count']);
-            $sheet->setCellValue('M' . $row, $item['continuous_listing_count']);
-            $sheet->setCellValue('N' . $row, $item['link_url']);
-            $sheet->setCellValue('O' . $row, $item['store_name']);
-            $sheet->setCellValue('P' . $row, $item['company_name']);
-            $sheet->setCellValue('Q' . $row, $item['company_category_name']);
-            $sheet->setCellValue('R' . $row, $item['social_credit_code']);
-            $sheet->setCellValue('S' . $row, $item['province_name']);
-            $sheet->setCellValue('T' . $row, $item['city_name']);
-            $sheet->setCellValue('U' . $row, $source_responsible_person_name);
-            $sheet->setCellValue('V' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
-            $sheet->setCellValue('W' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
-            $sheet->setCellValue('X' . $row, date('Y-m-d H:i:s', $item['insert_time']));
-            $sheet->setCellValue('Y' . $row, $item['shipment_city_name']);
-            $sheet->setCellValue('Z' . $row, $item['shipment_city_name']);
-            $row++;
-        }
-        // 生成 Excel 文件
-        $writer = new Xlsx($spreadsheet);
-
-        // 直接输出到浏览器(下载)
-        $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');
-        $writer->save('php://output');
-        exit;
+        // 写入数据表
+        $result = $DownloadTaskModel->insertGetId($downloadLog);
+        if(!$result) return json_send(['code' => 'fail', 'msg' => '导出任务添加失败', 'data' => '']);
+        // ExportLowPriceGoodsJobs::dispatch($message_data);
+        ExportLowPriceGoodsJobs::dispatchSync($message_data);
+        return json_send(['code' => 'success', 'msg' => '导出任务添加成功', 'data' => '']);
     }
 
 

+ 64 - 337
app/Http/Controllers/Manager/Process/ViolationProduct.php

@@ -14,6 +14,10 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
 use App\Models\Manager\Process\ViolationProductMember as ViolationProductMemberModel;
 use App\Models\Manager\Citys as CitysModel;
 use Illuminate\Support\Facades\DB;
+use App\Servers\Aliyun\Oss;
+use App\Jobs\Manager\Other\ExportViolationProductJobs;
+use App\Models\Manager\Other\DownloadTask as DownloadTaskModel;
+use Illuminate\Support\Facades\Cache;
 
 /**
  * 违规处理-违规商品
@@ -214,346 +218,69 @@ class ViolationProduct extends Controller
      * @version 1.0
      * @date 2025-06-17
      */
-    public function export_excel(Request $request, ViolationProductModel $ViolationProductModel, EmployeeModel $EmployeeModel, ViolationProductMemberModel $ViolationProductMemberModel)
+    public function export_excel(Request $request, DownloadTaskModel $DownloadTaskModel)
     {
         $request->scene('export_excel')->validate();
-        $admin_company_id = request('admin_company_id', '0');
-        $company_id = request('access_token.company_id', '0');
-        $is_admin = request('access_token.is_admin', '0'); //是否管理员操作 0=是1=否
-        $user_id = request('access_token.uid', 0);
+        $message_data['admin_company_id'] = request('admin_company_id', '0');
+        $message_data['company_id'] = request('access_token.company_id', '0');
+        $message_data['is_admin'] = request('access_token.is_admin', '0'); //是否管理员操作 0=是1=否
+        $message_data['user_id'] = request('access_token.uid', 0);
         // 查询条件
-        $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_specs = request('product_specs', '');
-        $online_posting_count = request('online_posting_count', '');
-        $category_name = request('category_name', '');
-        $province_ids = request('province_ids', '');
-        $city_ids = request('city_ids', '');
-        $shipment_province_ids = request('shipment_province_ids', '');
-        $shipment_city_ids = request('shipment_city_ids', '');
-        // 时间条件
-        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
-        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 ($category_name) $map[] = ['category_name', 'like', "%$category_name%"];
+        $message_data['status'] = request('status', '');
+        $message_data['start_time'] = request('start_time', '');
+        $message_data['end_time'] = request('end_time', '');
+        $message_data['product_name'] = request('product_name', '');
+        $message_data['product_names'] = request('product_names', '');
+        $message_data['first_responsible_person'] = request('first_responsible_person', '');
+        $message_data['responsible_person'] = request('responsible_person', '');
+        $message_data['platform'] = request('platform', '');
+        $message_data['company_name'] = request('company_name', '');
+        $message_data['company_names'] = request('company_names', '');
+        $message_data['store_name'] = request('store_name', '');
+        $message_data['store_names'] = request('store_names', '');
+        $message_data['source_responsible_person'] = request('source_responsible_person', '');
+        $message_data['processing_status'] = request('processing_status', '');
+        $message_data['product_specs'] = request('product_specs', '');
+        $message_data['online_posting_count'] = request('online_posting_count', '');
+        $message_data['category_name'] = request('category_name', '');
+        $message_data['id'] = request('id', '');
+        $message_data['online_posting_cunt'] = request('online_posting_cunt', '');
+        $message_data['continuous_listing_count'] = request('continuous_listing_count', '');
+        $message_data['province_ids'] = request('province_ids', '');
+        $message_data['city_ids'] = request('city_ids', '');
+        $message_data['shipment_province_ids'] = request('shipment_province_ids', '');
+        $message_data['shipment_city_ids'] = request('shipment_city_ids', '');
 
         $violation_product_where = [];
         // 权限判断
-        if ($is_admin != 1 && $company_id != 0) {
-            $violation_product_where['company_id'] = $company_id;
+        if ($message_data['is_admin'] != 1 && $message_data['company_id'] != 0) {
+            $violation_product_where['company_id'] = $message_data['company_id'];
         } else {
-            $violation_product_where['company_id']  = $admin_company_id;
-        }
-        $ViolationProductModel = $ViolationProductModel->where($violation_product_where);
-
-        //多选平台查询
-        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_count && is_string($online_posting_count)) {
-            $online_posting_count = explode(',', $online_posting_count);
-            $ViolationProductModel = $ViolationProductModel->whereIn('online_posting_count', $online_posting_count);
-        }
-        //多选规格查询
-        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');
-            });
-        }
-        //多选省份
-        if ($province_ids && is_string($province_ids)) {
-            $province_ids = explode(',', $province_ids);
-            $ViolationProductModel = $ViolationProductModel->whereIn('province_id', $province_ids);
-        }
-        //多选城市
-        if ($city_ids && is_string($city_ids)) {
-            $city_ids = explode(',', $city_ids);
-            $ViolationProductModel = $ViolationProductModel->whereIn('city_id', $city_ids);
-        }
-        //多选发货省份
-        if ($shipment_province_ids && is_string($shipment_province_ids)) {
-            $shipment_province_ids = explode(',', $shipment_province_ids);
-            $ViolationProductModel = $ViolationProductModel->whereIn('shipment_province_id', $shipment_province_ids);
-        }
-        //多选发货城市
-        if ($shipment_city_ids && is_string($shipment_city_ids)) {
-            $shipment_city_ids = explode(',', $shipment_city_ids);
-            $ViolationProductModel = $ViolationProductModel->whereIn('shipment_city_id', $shipment_city_ids);
-        }
-
-        if ($is_admin != 1 && $company_id != 0) {
-            $result_totle = $ViolationProductModel->where(function ($q) use ($user_id) {
-                $q->where('first_responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
-            })
-                ->where($map)
-                ->orderByDesc('id')
-                ->count();
-        } else {
-            $result_totle = $ViolationProductModel->where($map)
-                ->orderByDesc('id')
-                ->count();
-        }
-
-        // 数量过多时,限制导出
-        if ($result_totle > 100000) {
-            return json_send(['code' => 'error', 'msg' => '导出数据过多,请缩小查询条件']);
-        }
-        if ($is_admin != 1 && $company_id != 0) {
-            $result = $ViolationProductModel->where(function ($q) use ($user_id) {
-                $q->where('first_responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
-                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
-            })
-                ->where($map)
-                ->orderByDesc('id')
-                ->get()->toarray();
-        } else {
-            $result = $ViolationProductModel->where($map)
-                ->orderByDesc('id')
-                ->get()->toarray();
-        }
-        // 分配数据
-        if (!$result)  return json_send(['code' => 'error', 'msg' => '暂无数据']);
-        // 处理责任人展示信息
-        $list_data = $this->processing_responsible_person($result);
-        // 导出数据
-        $this->export_download($list_data);
-    }
-
-
-    /**
-     * 处理责任人展示信息
-     * @author 唐远望
-     * @version 1.0
-     * @date 2025-12-17
-     */
-    public function processing_responsible_person($result)
-    {
-        $EmployeeModel = new EmployeeModel();
-        //获取所有员工
-        $employeee_data = $EmployeeModel->select(['id', 'name'])->get()->toarray();
-        $employeee_list = [];
-        if (!empty($employeee_data)) {
-            foreach ($employeee_data as $key => $value) {
-                $employeee_list[$value['id']] = $value['name'];
-            }
-        }
-        if (isset($result) && count($result) > 0) {
-            foreach ($result as $key => $value) {
-                //查询第一责任人名称
-                $first_responsible_person = $value['first_responsible_person'] != '' ? explode(',', $value['first_responsible_person']) : [];
-                $first_responsible_person_name = [];
-                if (!empty($first_responsible_person)) {
-                    foreach ($first_responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $first_responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['first_responsible_person_name'] = $first_responsible_person_name;
-                //查询责任人名称
-                $responsible_person = $value['responsible_person'] != '' ? explode(',', $value['responsible_person']) : [];
-                $responsible_person_name = [];
-                if (!empty($responsible_person)) {
-                    foreach ($responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['responsible_person_name'] = $responsible_person_name;
-                //查询来源责任人名称
-                $source_responsible_person = $value['source_responsible_person'] != '' ? explode(',', $value['source_responsible_person']) : [];
-                $source_responsible_person_name = [];
-                if (!empty($source_responsible_person)) {
-                    foreach ($source_responsible_person as $k => $v) {
-                        if (isset($employeee_list[$v])) {
-                            $source_responsible_person_name[] = $employeee_list[$v];
-                        }
-                    }
-                }
-                $result[$key]['source_responsible_person_name'] = $source_responsible_person_name;
-            }
-        }
-        return $result;
-    }
-
-    /**
-     * 导出下载
-     * @author 唐远望
-     * @version 1.0
-     * @date 2025-06-17
-     */
-    public function export_download($data)
-    {
-        // 创建一个新的 Spreadsheet 对象
-        $spreadsheet = new Spreadsheet();
-        $sheet = $spreadsheet->getActiveSheet();
-
-        //合并单元格
-        $sheet->mergeCells('A1:Q1');
-        $sheet->setCellValue('A1', '禁止挂网商品导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
-        // 获取合并后的单元格样式对象
-        $style = $sheet->getStyle('A1');
-        // 设置水平居中和垂直居中
-        $style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
-        // 然后设置行高以适应两行文本
-        $sheet->getRowDimension(1)->setRowHeight(40); // 设置行高,单位是磅(point)
-        // 设置表头
-        $sheet->setCellValue('A2', '第一责任人');
-        $sheet->setCellValue('B2', '责任人');
-        $sheet->setCellValue('C2', '平台');
-        $sheet->setCellValue('D2', '商品分类');
-        $sheet->setCellValue('E2', '商品名称');
-        $sheet->setCellValue('F2', '库存');
-        $sheet->setCellValue('G2', '销量');
-        $sheet->setCellValue('H2', '快照URL');
-        $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('Q2', '省份');
-        $sheet->setCellValue('R2', '城市');
-        $sheet->setCellValue('S2', '溯源责任人');
-        $sheet->setCellValue('T2', '处理状态');
-        $sheet->setCellValue('U2', '任务状态');
-        $sheet->setCellValue('V2', '记录时间');
-        $sheet->setCellValue('W2', '发货省份');
-        $sheet->setCellValue('X2', '发货城市');
-
-        $platform_data = [
-            '0' => '全部',
-            '1' => '淘宝',
-            '2' => '京东',
-            '3' => '拼多多',
-            '4' => '美团',
-            '5' => '药师帮',
-            '6' => '1药城',
-            '7' => '药久久',
-        ];
-        $processing_status_text = [
-            '1' => '待处理',
+            $violation_product_where['company_id']  = $message_data['admin_company_id'];
+        }
+        $key_name = 'ExportViolationProductJobs_' . $violation_product_where['company_id'];
+        $export_data_info = Cache::get($key_name);
+        if ($export_data_info) return json_send(['code' => 'fail', 'msg' => '导出任务正在执行中,请稍后再试', 'data' => '']);
+
+
+        // 生成唯一文件ID
+        $fileId                     = make_snow_flake();
+        $message_data['file_id']    = $fileId;
+        $fileName = '违规挂网商品导出_' . date('Y-m-d H:i:s', time()) . '.xlsx';
+        $downloadLog                 = [
+            'insert_time' => time(),
+            'company_id' => $violation_product_where['company_id'],
+            'operator_userid' => $message_data['user_id'],
+            'file_name' => $fileName,
+            'file_id' => $fileId,
+            'url' => '',
         ];
-        $status_text = [
-            '0' => '有效',
-            '1' => '无效',
-        ];
-        // 填充数据
-        $row = 3; // 从第2行开始
-        foreach ($data as $item) {
-            $first_responsible_person_name = !empty($item['first_responsible_person_name']) ? implode(',', $item['first_responsible_person_name']) : '';
-            $responsible_person_name = !empty($item['responsible_person_name']) ? implode(',', $item['responsible_person_name']) : '';
-            $source_responsible_person_name = !empty($item['source_responsible_person_name']) ? implode(',', $item['source_responsible_person_name']) : '';
-            $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['category_name']);
-            $sheet->setCellValue('E' . $row, $item['product_name']);
-            $sheet->setCellValue('F' . $row, $item['inventory']);
-            $sheet->setCellValue('G' . $row, $item['sales']);
-            $sheet->setCellValue('H' . $row, $item['snapshot_url']);
-            $sheet->setCellValue('I' . $row, $item['product_specs']);
-            $sheet->setCellValue('J' . $row, $item['online_posting_count']);
-            $sheet->setCellValue('K' . $row, $item['continuous_listing_count']);
-            $sheet->setCellValue('L' . $row, $item['link_url']);
-            $sheet->setCellValue('M' . $row, $item['store_name']);
-            $sheet->setCellValue('N' . $row, $item['company_name']);
-            $sheet->setCellValue('O' . $row, $item['company_category_name']);
-            $sheet->setCellValue('P' . $row, $item['social_credit_code']);
-            $sheet->setCellValue('Q' . $row, $item['province_name']);
-            $sheet->setCellValue('R' . $row, $item['city_name']);
-            $sheet->setCellValue('S' . $row, $source_responsible_person_name);
-            $sheet->setCellValue('T' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
-            $sheet->setCellValue('U' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
-            $sheet->setCellValue('V' . $row, date('Y-m-d H:i:s', $item['insert_time']));
-            $sheet->setCellValue('W' . $row, $item['shipment_city_name']);
-            $sheet->setCellValue('X' . $row, $item['shipment_city_name']);
-            $row++;
-        }
-        foreach (range('A', 'P') as $column) {
-            $sheet->getColumnDimension($column)->setAutoSize(true);
-        }
-        // 生成 Excel 文件
-        $writer = new Xlsx($spreadsheet);
-
-        // 直接输出到浏览器(下载)
-        $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');
-        $writer->save('php://output');
-        exit;
+        // 写入数据表
+        $result = $DownloadTaskModel->insertGetId($downloadLog);
+        if(!$result) return json_send(['code' => 'fail', 'msg' => '导出任务添加失败', 'data' => '']);
+        ExportViolationProductJobs::dispatch($message_data);
+        // ExportViolationProductJobs::dispatchSync($message_data);
+        return json_send(['code' => 'success', 'msg' => '导出任务添加成功', 'data' => '']);
     }
 
 
@@ -1008,17 +735,17 @@ class ViolationProduct extends Controller
                         $shipment_province_name = $shipment_province_name . '省';
                     }
                 }
-                $shipment_province_id ='0';
-                if (!isset($province_id_data[$shipment_province_name])){
+                $shipment_province_id = '0';
+                if (!isset($province_id_data[$shipment_province_name])) {
                     $shipment_province_name = '';
-                }else{
+                } else {
                     $shipment_province_id = $province_id_data[$shipment_province_name]['id'];
                 }
                 $shipment_city_id = '0';
                 $shipment_city_name = isset($item[21]) ? $item[21] : '';
-                if (!isset($city_id_data[$shipment_city_name])){
+                if (!isset($city_id_data[$shipment_city_name])) {
                     $shipment_city_name = '';
-                }else{
+                } else {
                     $shipment_city_id = $city_id_data[$shipment_city_name]['id'];
                 }
 

+ 64 - 0
app/Http/Requests/Manager/Other/DownloadTask.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace App\Http\Requests\Manager\Other;
+
+use App\Http\Requests\BaseRequest;
+
+/**
+ * 文件下载任务-接口验证
+ * @author 唐远望
+ * @version 1.0
+ * @date 2026-04-01
+ * 
+ */
+class DownloadTask extends BaseRequest
+{
+    /**
+     * 获取应用于请求的规则
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        // 返回结果
+        return      [
+            'name'                 => 'required',
+            'id'                => 'required|integer|gt:0',
+            'status'            => 'required|integer|in:0,1',
+            'page'              => 'integer|min:1',
+            'limit'             => 'integer|min:1',
+        ];
+    }
+
+
+    // 场景列表
+    protected   $scenes         = [
+        'detail'             => ['id'],
+        'list'               => ['page', 'limit'],
+        'add'                      => [''],
+        'edit'                  => [''],
+        'detail'                  => [''],
+    ];
+
+    /**
+     * 获取已定义验证规则的错误消息
+     *
+     * @return array
+     */
+    public function messages()
+    {
+        return [
+            'name.required'     => '公司分类名称必填',
+            'id.required'       => 'ID未知',
+            'id.integer'        => 'ID格式错误',
+            'id.gt'               => 'ID格式错误',
+            'status.required'   => '状态未知',
+            'status.integer'    => '状态格式错误',
+            'status.in'         => '状态格式错误',
+            'page.integer'      => '页码格式错误',
+            'page.min'          => '页码格式错误',
+            'limit.integer'     => '每页数量格式错误',
+            'limit.min'         => '每页数量格式错误',
+        ];
+    }
+}

+ 430 - 0
app/Jobs/Manager/Other/ExportLowPriceGoodsJobs.php

@@ -0,0 +1,430 @@
+<?php
+
+namespace App\Jobs\Manager\Other;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use App\Http\Requests\Manager\Process\LowPriceGoods as Request;
+use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
+use App\Models\Manager\Personnel\Employee as EmployeeModel;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
+use App\Servers\Aliyun\Oss;
+use App\Facades\Servers\Logs\Log;
+use App\Models\Manager\Other\DownloadTask as DownloadTaskModel;
+use Illuminate\Support\Facades\Cache;
+
+
+/**
+ * 违规处理-导出低价挂网数据处理队列
+ * @author    唐远望
+ * @version   1.0
+ * @date      2026-04-01
+ */
+class ExportLowPriceGoodsJobs implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+    protected $message_data;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(array $message_data)
+    {
+        $this->message_data = $message_data;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        try {
+            $this->export_excel($this->message_data);
+        } catch (\Exception $e) {
+            Log::info('job_error', '违规数据-导出低价挂网数据处理队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
+        }
+    }
+
+
+    /**
+     * 列表导出
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-06-17
+     */
+    public function export_excel($message_data)
+    {
+        $LowPriceGoodsModel = new LowPriceGoodsModel();
+        $LowPriceGoodsMemberModel = new LowPriceGoodsMemberModel();
+        $admin_company_id = $message_data['admin_company_id'] ?? '0';
+        $company_id = $message_data['access_token']['company_id'] ?? '0';
+        $is_admin = $message_data['access_token']['is_admin'] ?? '0'; //是否管理员操作 0=是1=否
+        $user_id = $message_data['access_token']['uid'] ?? 0;
+        $file_id = $message_data['file_id'];
+        // 查询条件
+        $map  = [];
+        $job_page = isset($message_data['job_page']) ? $message_data['job_page'] : 1;
+        $limit = 5000; //每次处理1000条
+        $status    = $message_data['status'] ?? '';
+        $start_time = $message_data['start_time'] ?? '';
+        $end_time = $message_data['end_time'] ?? '';
+        $product_name = $message_data['product_name'] ?? '';
+        $product_names = $message_data['product_names'] ?? '';
+        $first_responsible_person = $message_data['first_responsible_person'] ?? '';
+        $responsible_person = $message_data['responsible_person'] ?? '';
+        $platform = $message_data['platform'] ?? '';
+        $company_name = $message_data['company_name'] ?? '';
+        $store_name = $message_data['store_name'] ?? '';
+        $store_names = $message_data['store_names'] ?? '';
+        $source_responsible_person = $message_data['source_responsible_person'] ?? '';
+        $processing_status = $message_data['processing_status'] ?? '';
+        $product_specs = $message_data['product_specs'] ?? '';
+        $online_posting_count = $message_data['online_posting_count'] ?? '';
+        $category_name = $message_data['category_name'] ?? '';
+        $province_ids = $message_data['province_ids'] ?? '';
+        $city_ids = $message_data['city_ids'] ?? '';
+        $shipment_province_ids = $message_data['shipment_province_ids'] ?? '';
+        $shipment_city_ids = $message_data['shipment_city_ids'] ?? '';
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        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 ($category_name) $map[] = ['category_name', 'like', "%$category_name%"];
+
+        $low_price_goods_where = [];
+        // 权限判断
+        if ($is_admin != 1 && $company_id != 0) {
+            $low_price_goods_where['company_id'] = $company_id;
+        } else {
+            $low_price_goods_where['company_id']  = $admin_company_id;
+        }
+        $LowPriceGoodsModel = $LowPriceGoodsModel->where($low_price_goods_where);
+        //多选平台查询
+        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_count && is_string($online_posting_count)) {
+            $online_posting_count = explode(',', $online_posting_count);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('online_posting_count', $online_posting_count);
+        }
+        //多选规格查询
+        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');
+            });
+        }
+        //多选省份
+        if ($province_ids && is_string($province_ids)) {
+            $province_ids = explode(',', $province_ids);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('province_id', $province_ids);
+        }
+        //多选城市
+        if ($city_ids && is_string($city_ids)) {
+            $city_ids = explode(',', $city_ids);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
+        }
+        //多选发货省份
+        if ($shipment_province_ids && is_string($shipment_province_ids)) {
+            $shipment_province_ids = explode(',', $shipment_province_ids);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
+        }
+        //多选发货城市
+        if ($shipment_city_ids && is_string($shipment_city_ids)) {
+            $shipment_city_ids = explode(',', $shipment_city_ids);
+            $LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
+        }
+        if ($is_admin != 1 && $company_id != 0) {
+            $result = $LowPriceGoodsModel->where(function ($q) use ($user_id) {
+                $q->where('first_responsible_person', 'like', "%,$user_id,%")
+                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
+                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
+            })
+                ->where($map)
+                ->orderByDesc('id')
+                ->paginate($limit, ['*'], 'page', $job_page)
+                ->toarray();
+        } else {
+            $result = $LowPriceGoodsModel
+                ->where($map)
+                ->orderByDesc('id')
+                ->paginate($limit, ['*'], 'page', $job_page)
+                ->toarray();
+        }
+        $key_name = 'ExportLowPriceGoodsJobs_' . $low_price_goods_where['company_id'];
+        if ($job_page == 1) {
+            //创建缓存
+            Cache::put($key_name, [], 60 * 60 * 24);
+        }
+        // 分配数据
+        $result_data = $result['data'];
+        if (count($result_data) < 1) {
+            $export_data_info = Cache::get($key_name);
+            $this->export_download($export_data_info, $low_price_goods_where['company_id'], $file_id);
+        } else {
+            // 处理责任人展示信息
+            $list_data = $this->processing_responsible_person($result_data);
+            $list_data_info = Cache::get($key_name);
+            $list_new_data = !empty($list_data_info) ? array_merge($list_data_info, $list_data) : $list_data;
+            // 更新缓存
+            Cache::put($key_name, $list_new_data, 60 * 60 * 24);
+            // //继续执行下一页
+            $message_data['job_page'] = $job_page + 1;
+            // ExportLowPriceGoodsJobs::dispatch($message_data);
+            ExportLowPriceGoodsJobs::dispatchSync($message_data);
+        }
+    }
+
+
+    /**
+     * 处理责任人展示信息
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-12-17
+     */
+    public function processing_responsible_person($result)
+    {
+        $EmployeeModel = new EmployeeModel();
+        //获取所有员工
+        $employeee_data = $EmployeeModel->select(['id', 'name'])->get()->toarray();
+        $employeee_list = [];
+        if (!empty($employeee_data)) {
+            foreach ($employeee_data as $key => $value) {
+                $employeee_list[$value['id']] = $value['name'];
+            }
+        }
+        if (isset($result) && count($result) > 0) {
+            foreach ($result as $key => $value) {
+                //查询第一责任人名称
+                $first_responsible_person = $value['first_responsible_person'] != '' ? explode(',', $value['first_responsible_person']) : [];
+                $first_responsible_person_name = [];
+                if (!empty($first_responsible_person)) {
+                    foreach ($first_responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $first_responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['first_responsible_person_name'] = $first_responsible_person_name;
+                //查询责任人名称
+                $responsible_person = $value['responsible_person'] != '' ? explode(',', $value['responsible_person']) : [];
+                $responsible_person_name = [];
+                if (!empty($responsible_person)) {
+                    foreach ($responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['responsible_person_name'] = $responsible_person_name;
+                //查询来源责任人名称
+                $source_responsible_person = $value['source_responsible_person'] != '' ? explode(',', $value['source_responsible_person']) : [];
+                $source_responsible_person_name = [];
+                if (!empty($source_responsible_person)) {
+                    foreach ($source_responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $source_responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['source_responsible_person_name'] = $source_responsible_person_name;
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 导出下载
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-06-17
+     */
+    public function export_download($data, $company_id, $file_id)
+    {
+        // 创建一个新的 Spreadsheet 对象
+        $spreadsheet = new Spreadsheet();
+        $sheet = $spreadsheet->getActiveSheet();
+
+        //合并单元格
+        $sheet->mergeCells('A1:U1');
+        $sheet->setCellValue('A1', '低价挂网商品导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
+        // 获取合并后的单元格样式对象
+        $style = $sheet->getStyle('A1');
+        // 设置水平居中和垂直居中
+        $style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
+        // 然后设置行高以适应两行文本
+        $sheet->getRowDimension(1)->setRowHeight(40); // 设置行高,单位是磅(point)
+        // 设置表头
+        $sheet->setCellValue('A2', '第一责任人');
+        $sheet->setCellValue('B2', '责任人');
+        $sheet->setCellValue('C2', '平台');
+        $sheet->setCellValue('D2', '商品分类');
+        $sheet->setCellValue('E2', '商品名称');
+        $sheet->setCellValue('F2', '库存');
+        $sheet->setCellValue('G2', '销量');
+        $sheet->setCellValue('H2', '快照URL');
+        $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('Q2', '公司分类');
+        $sheet->setCellValue('R2', '信用代码');
+        $sheet->setCellValue('S2', '省份');
+        $sheet->setCellValue('T2', '城市');
+        $sheet->setCellValue('U2', '溯源责任人');
+        $sheet->setCellValue('V2', '处理状态');
+        $sheet->setCellValue('W2', '任务状态');
+        $sheet->setCellValue('X2', '记录时间');
+        $sheet->setCellValue('Y2', '发货省份');
+        $sheet->setCellValue('Z2', '发货城市');
+
+        $platform_data = [
+            '0' => '全部',
+            '1' => '淘宝',
+            '2' => '京东',
+            '3' => '拼多多',
+            '4' => '美团',
+            '5' => '药师帮',
+            '6' => '1药城',
+            '7' => '药久久',
+        ];
+        $processing_status_text = [
+            '1' => '待处理',
+        ];
+        $status_text = [
+            '0' => '有效',
+            '1' => '无效',
+        ];
+        // 填充数据
+        $row = 3; // 从第2行开始
+        foreach ($data as $item) {
+            $first_responsible_person_name = !empty($item['first_responsible_person_name']) ? implode(',', $item['first_responsible_person_name']) : '';
+            $responsible_person_name = !empty($item['responsible_person_name']) ? implode(',', $item['responsible_person_name']) : '';
+            $source_responsible_person_name = !empty($item['source_responsible_person_name']) ? implode(',', $item['source_responsible_person_name']) : '';
+            $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['category_name']);
+            $sheet->setCellValue('E' . $row, $item['product_name']);
+            $sheet->setCellValue('F' . $row, $item['inventory']);
+            $sheet->setCellValue('G' . $row, $item['sales']);
+            $sheet->setCellValue('H' . $row, $item['snapshot_url']);
+            $sheet->setCellValue('I' . $row, $item['product_specs']);
+            $sheet->setCellValue('J' . $row, $item['suggested_price']);
+            $sheet->setCellValue('K' . $row, $item['online_posting_price']);
+            $sheet->setCellValue('L' . $row, $item['online_posting_count']);
+            $sheet->setCellValue('M' . $row, $item['continuous_listing_count']);
+            $sheet->setCellValue('N' . $row, $item['link_url']);
+            $sheet->setCellValue('O' . $row, $item['store_name']);
+            $sheet->setCellValue('P' . $row, $item['company_name']);
+            $sheet->setCellValue('Q' . $row, $item['company_category_name']);
+            $sheet->setCellValue('R' . $row, $item['social_credit_code']);
+            $sheet->setCellValue('S' . $row, $item['province_name']);
+            $sheet->setCellValue('T' . $row, $item['city_name']);
+            $sheet->setCellValue('U' . $row, $source_responsible_person_name);
+            $sheet->setCellValue('V' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
+            $sheet->setCellValue('W' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
+            $sheet->setCellValue('X' . $row, date('Y-m-d H:i:s', $item['insert_time']));
+            $sheet->setCellValue('Y' . $row, $item['shipment_city_name']);
+            $sheet->setCellValue('Z' . $row, $item['shipment_city_name']);
+            $row++;
+        }
+        // 创建Excel文件
+        $filename = '低价挂网商品数据' . $file_id . '.xlsx';
+        $path = public_path('uploads/exports/');
+        $fullPath = $path . $filename;
+        if (!is_dir($path))         mkdir($path, 0777, true);
+
+        // 生成 Excel 文件
+        $writer = new Xlsx($spreadsheet);
+        $writer->save($fullPath);
+        // 清理
+        $spreadsheet->disconnectWorksheets();
+        unset($spreadsheet, $writer);
+        //释放redis缓存
+        Cache::forget('ExportLowPriceGoodsJobs_' . $company_id);
+        $Oss                = new Oss();
+        $oss_url                = $Oss->uploadFile($filename, $fullPath);
+        if ($oss_url)           @unlink($fullPath);
+        // 记录下载任务
+        $downloadTask = DownloadTaskModel::where(['file_id' => $file_id, 'company_id' => $company_id])->first();
+        if ($downloadTask) {
+            $downloadTask->url = $oss_url;
+            $downloadTask->file_dir_name = $filename;
+            $downloadTask->update_time = time();
+            $downloadTask->status = 1;
+            $downloadTask->save();
+        }
+        return $oss_url;
+    }
+
+
+    public function failed(\Throwable $exception)
+    {
+        Log::info('job_error', '违规数据-导出低价挂网数据队列完全失败', ['data' => $this->message_data, 'error' => $exception]);
+    }
+}

+ 426 - 0
app/Jobs/Manager/Other/ExportViolationProductJobs.php

@@ -0,0 +1,426 @@
+<?php
+
+namespace App\Jobs\Manager\Other;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use App\Models\Manager\Process\LowPriceGoods as ViolationProductModel;
+use App\Models\Manager\Personnel\Employee as EmployeeModel;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use App\Servers\Aliyun\Oss;
+use App\Facades\Servers\Logs\Log;
+use App\Models\Manager\Other\DownloadTask as DownloadTaskModel;
+use Illuminate\Support\Facades\Cache;
+
+
+/**
+ * 违规处理-导出违规商品数据处理队列
+ * @author    唐远望
+ * @version   1.0
+ * @date      2026-04-01
+ */
+class ExportViolationProductJobs implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+    protected $message_data;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(array $message_data)
+    {
+        $this->message_data = $message_data;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        try {
+            $this->export_excel($this->message_data);
+        } catch (\Exception $e) {
+            Log::info('job_error', '违规数据-导出禁止挂网数据处理队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
+        }
+    }
+
+
+    /**
+     * 列表导出
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-06-17
+     */
+    public function export_excel($message_data)
+    {
+        $ViolationProductModel = new ViolationProductModel();
+        $ViolationProductModel = new ViolationProductModel();
+        $admin_company_id = $message_data['admin_company_id'] ?? '0';
+        $company_id = $message_data['access_token']['company_id'] ?? '0';
+        $is_admin = $message_data['access_token']['is_admin'] ?? '0'; //是否管理员操作 0=是1=否
+        $user_id = $message_data['access_token']['uid'] ?? 0;
+        $file_id = $message_data['file_id'];
+        // 查询条件
+        $map  = [];
+        $job_page = isset($message_data['job_page']) ? $message_data['job_page'] : 1;
+        $limit = 5000; //每次处理1000条
+        $status    = $message_data['status'] ?? '';
+        $start_time = $message_data['start_time'] ?? '';
+        $end_time = $message_data['end_time'] ?? '';
+        $product_name = $message_data['product_name'] ?? '';
+        $product_names = $message_data['product_names'] ?? '';
+        $first_responsible_person = $message_data['first_responsible_person'] ?? '';
+        $responsible_person = $message_data['responsible_person'] ?? '';
+        $platform = $message_data['platform'] ?? '';
+        $company_name = $message_data['company_name'] ?? '';
+        $store_name = $message_data['store_name'] ?? '';
+        $store_names = $message_data['store_names'] ?? '';
+        $source_responsible_person = $message_data['source_responsible_person'] ?? '';
+        $processing_status = $message_data['processing_status'] ?? '';
+        $product_specs = $message_data['product_specs'] ?? '';
+        $online_posting_count = $message_data['online_posting_count'] ?? '';
+        $category_name = $message_data['category_name'] ?? '';
+        $province_ids = $message_data['province_ids'] ?? '';
+        $city_ids = $message_data['city_ids'] ?? '';
+        $shipment_province_ids = $message_data['shipment_province_ids'] ?? '';
+        $shipment_city_ids = $message_data['shipment_city_ids'] ?? '';
+        // 时间条件
+        if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
+        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 ($category_name) $map[] = ['category_name', 'like', "%$category_name%"];
+
+        $violation_product_where = [];
+        // 权限判断
+        if ($is_admin != 1 && $company_id != 0) {
+            $violation_product_where['company_id'] = $company_id;
+        } else {
+            $violation_product_where['company_id']  = $admin_company_id;
+        }
+        $ViolationProductModel = $ViolationProductModel->where($violation_product_where);
+        //多选平台查询
+        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_count && is_string($online_posting_count)) {
+            $online_posting_count = explode(',', $online_posting_count);
+            $ViolationProductModel = $ViolationProductModel->whereIn('online_posting_count', $online_posting_count);
+        }
+        //多选规格查询
+        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 = $ViolationProductModel->whereIn('employee_id', $first_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $ViolationProductModel = $ViolationProductModel->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 = $ViolationProductModel->whereIn('employee_id', $responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $ViolationProductModel = $ViolationProductModel->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 = $ViolationProductModel->whereIn('employee_id', $source_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
+            $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
+                $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
+            });
+        }
+        //多选省份
+        if ($province_ids && is_string($province_ids)) {
+            $province_ids = explode(',', $province_ids);
+            $ViolationProductModel = $ViolationProductModel->whereIn('province_id', $province_ids);
+        }
+        //多选城市
+        if ($city_ids && is_string($city_ids)) {
+            $city_ids = explode(',', $city_ids);
+            $ViolationProductModel = $ViolationProductModel->whereIn('city_id', $city_ids);
+        }
+        //多选发货省份
+        if ($shipment_province_ids && is_string($shipment_province_ids)) {
+            $shipment_province_ids = explode(',', $shipment_province_ids);
+            $ViolationProductModel = $ViolationProductModel->whereIn('shipment_province_id', $shipment_province_ids);
+        }
+        //多选发货城市
+        if ($shipment_city_ids && is_string($shipment_city_ids)) {
+            $shipment_city_ids = explode(',', $shipment_city_ids);
+            $ViolationProductModel = $ViolationProductModel->whereIn('shipment_city_id', $shipment_city_ids);
+        }
+        if ($is_admin != 1 && $company_id != 0) {
+            $result = $ViolationProductModel->where(function ($q) use ($user_id) {
+                $q->where('first_responsible_person', 'like', "%,$user_id,%")
+                    ->orWhere('responsible_person', 'like', "%,$user_id,%")
+                    ->orWhere('source_responsible_person', 'like', "%,$user_id,%");
+            })
+                ->where($map)
+                ->orderByDesc('id')
+                ->paginate($limit, ['*'], 'page', $job_page)
+                ->toarray();
+        } else {
+            $result = $ViolationProductModel
+                ->where($map)
+                ->orderByDesc('id')
+                ->paginate($limit, ['*'], 'page', $job_page)
+                ->toarray();
+        }
+        $key_name = 'ExportViolationProductJobs_' . $violation_product_where['company_id'];
+        if ($job_page == 1) {
+            //创建缓存
+            Cache::put($key_name, [], 60 * 60 * 24);
+        }
+        // 分配数据
+        $result_data = $result['data'];
+        if (count($result_data) < 1) {
+            $export_data_info = Cache::get($key_name);
+            $this->export_download($export_data_info, $violation_product_where['company_id'], $file_id);
+        } else {
+            // 处理责任人展示信息
+            $list_data = $this->processing_responsible_person($result_data);
+            $list_data_info = Cache::get($key_name);
+            $list_new_data = !empty($list_data_info) ? array_merge($list_data_info, $list_data) : $list_data;
+            // 更新缓存
+            Cache::put($key_name, $list_new_data, 60 * 60 * 24);
+            // //继续执行下一页
+            $message_data['job_page'] = $job_page + 1;
+            ExportViolationProductJobs::dispatch($message_data);
+            // ExportViolationProductJobs::dispatchSync($message_data);
+        }
+    }
+
+
+    /**
+     * 处理责任人展示信息
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-12-17
+     */
+    public function processing_responsible_person($result)
+    {
+        $EmployeeModel = new EmployeeModel();
+        //获取所有员工
+        $employeee_data = $EmployeeModel->select(['id', 'name'])->get()->toarray();
+        $employeee_list = [];
+        if (!empty($employeee_data)) {
+            foreach ($employeee_data as $key => $value) {
+                $employeee_list[$value['id']] = $value['name'];
+            }
+        }
+        if (isset($result) && count($result) > 0) {
+            foreach ($result as $key => $value) {
+                //查询第一责任人名称
+                $first_responsible_person = $value['first_responsible_person'] != '' ? explode(',', $value['first_responsible_person']) : [];
+                $first_responsible_person_name = [];
+                if (!empty($first_responsible_person)) {
+                    foreach ($first_responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $first_responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['first_responsible_person_name'] = $first_responsible_person_name;
+                //查询责任人名称
+                $responsible_person = $value['responsible_person'] != '' ? explode(',', $value['responsible_person']) : [];
+                $responsible_person_name = [];
+                if (!empty($responsible_person)) {
+                    foreach ($responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['responsible_person_name'] = $responsible_person_name;
+                //查询来源责任人名称
+                $source_responsible_person = $value['source_responsible_person'] != '' ? explode(',', $value['source_responsible_person']) : [];
+                $source_responsible_person_name = [];
+                if (!empty($source_responsible_person)) {
+                    foreach ($source_responsible_person as $k => $v) {
+                        if (isset($employeee_list[$v])) {
+                            $source_responsible_person_name[] = $employeee_list[$v];
+                        }
+                    }
+                }
+                $result[$key]['source_responsible_person_name'] = $source_responsible_person_name;
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 导出下载
+     * @author 唐远望
+     * @version 1.0
+     * @date 2025-06-17
+     */
+    public function export_download($data, $company_id, $file_id)
+    {
+        // 创建一个新的 Spreadsheet 对象
+        $spreadsheet = new Spreadsheet();
+        $sheet = $spreadsheet->getActiveSheet();
+
+        //合并单元格
+        $sheet->mergeCells('A1:Q1');
+        $sheet->setCellValue('A1', '禁止挂网商品导出(导出时间:' . date('Y-m-d H:i:s', time()) . ')'); // 设置合并后的单元格内容
+        // 获取合并后的单元格样式对象
+        $style = $sheet->getStyle('A1');
+        // 设置水平居中和垂直居中
+        $style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
+        // 然后设置行高以适应两行文本
+        $sheet->getRowDimension(1)->setRowHeight(40); // 设置行高,单位是磅(point)
+        // 设置表头
+        $sheet->setCellValue('A2', '第一责任人');
+        $sheet->setCellValue('B2', '责任人');
+        $sheet->setCellValue('C2', '平台');
+        $sheet->setCellValue('D2', '商品分类');
+        $sheet->setCellValue('E2', '商品名称');
+        $sheet->setCellValue('F2', '库存');
+        $sheet->setCellValue('G2', '销量');
+        $sheet->setCellValue('H2', '快照URL');
+        $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('Q2', '省份');
+        $sheet->setCellValue('R2', '城市');
+        $sheet->setCellValue('S2', '溯源责任人');
+        $sheet->setCellValue('T2', '处理状态');
+        $sheet->setCellValue('U2', '任务状态');
+        $sheet->setCellValue('V2', '记录时间');
+        $sheet->setCellValue('W2', '发货省份');
+        $sheet->setCellValue('X2', '发货城市');
+
+        $platform_data = [
+            '0' => '全部',
+            '1' => '淘宝',
+            '2' => '京东',
+            '3' => '拼多多',
+            '4' => '美团',
+            '5' => '药师帮',
+            '6' => '1药城',
+            '7' => '药久久',
+        ];
+        $processing_status_text = [
+            '1' => '待处理',
+        ];
+        $status_text = [
+            '0' => '有效',
+            '1' => '无效',
+        ];
+        // 填充数据
+        $row = 3; // 从第2行开始
+        foreach ($data as $item) {
+            $first_responsible_person_name = !empty($item['first_responsible_person_name']) ? implode(',', $item['first_responsible_person_name']) : '';
+            $responsible_person_name = !empty($item['responsible_person_name']) ? implode(',', $item['responsible_person_name']) : '';
+            $source_responsible_person_name = !empty($item['source_responsible_person_name']) ? implode(',', $item['source_responsible_person_name']) : '';
+            $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['category_name']);
+            $sheet->setCellValue('E' . $row, $item['product_name']);
+            $sheet->setCellValue('F' . $row, $item['inventory']);
+            $sheet->setCellValue('G' . $row, $item['sales']);
+            $sheet->setCellValue('H' . $row, $item['snapshot_url']);
+            $sheet->setCellValue('I' . $row, $item['product_specs']);
+            $sheet->setCellValue('J' . $row, $item['online_posting_count']);
+            $sheet->setCellValue('K' . $row, $item['continuous_listing_count']);
+            $sheet->setCellValue('L' . $row, $item['link_url']);
+            $sheet->setCellValue('M' . $row, $item['store_name']);
+            $sheet->setCellValue('N' . $row, $item['company_name']);
+            $sheet->setCellValue('O' . $row, $item['company_category_name']);
+            $sheet->setCellValue('P' . $row, $item['social_credit_code']);
+            $sheet->setCellValue('Q' . $row, $item['province_name']);
+            $sheet->setCellValue('R' . $row, $item['city_name']);
+            $sheet->setCellValue('S' . $row, $source_responsible_person_name);
+            $sheet->setCellValue('T' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
+            $sheet->setCellValue('U' . $row, isset($status_text[$item['status']]) ? $status_text[$item['status']] : '');
+            $sheet->setCellValue('V' . $row, date('Y-m-d H:i:s', $item['insert_time']));
+            $sheet->setCellValue('W' . $row, $item['shipment_city_name']);
+            $sheet->setCellValue('X' . $row, $item['shipment_city_name']);
+            $row++;
+        }
+        foreach (range('A', 'P') as $column) {
+            $sheet->getColumnDimension($column)->setAutoSize(true);
+        }
+        // 创建Excel文件
+        $filename = '禁止挂网商品数据' . $file_id . '.xlsx';
+        $path = public_path('uploads/exports/');
+        $fullPath = $path . $filename;
+        if (!is_dir($path))         mkdir($path, 0777, true);
+
+        // 生成 Excel 文件
+        $writer = new Xlsx($spreadsheet);
+        $writer->save($fullPath);
+        // 清理
+        $spreadsheet->disconnectWorksheets();
+        unset($spreadsheet, $writer);
+        //释放redis缓存
+        Cache::forget('ExportViolationProductJobs_' . $company_id);
+        $Oss                = new Oss();
+        $oss_url                = $Oss->uploadFile($filename, $fullPath);
+        if ($oss_url)           @unlink($fullPath);
+        // 记录下载任务
+        $downloadTask = DownloadTaskModel::where(['file_id' => $file_id, 'company_id' => $company_id])->first();
+        if ($downloadTask) {
+            $downloadTask->url = $oss_url;
+            $downloadTask->file_dir_name = $filename;
+            $downloadTask->update_time = time();
+            $downloadTask->status = 1;
+            $downloadTask->save();
+        }
+        return $oss_url;
+    }
+
+    public function failed(\Throwable $exception)
+    {
+        Log::info('job_error', '违规数据-导出违规商品数据队列完全失败', ['data' => $this->message_data, 'error' => $exception]);
+    }
+}

+ 25 - 0
app/Models/Manager/Other/DownloadTask.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models\Manager\Other;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+
+/**
+ * 文件下载任务-模型
+ * @author 唐远望
+ * @version 2.0
+ * @date 2026-04-01
+ */
+class DownloadTask extends Model
+{
+    use HasFactory;
+    // 与模型关联的表名
+    protected $table = 'other_download_task';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+}

+ 4 - 1
routes/manager.php

@@ -399,4 +399,7 @@ Route::any('website/lead_message/set_status', [App\Http\Controllers\Manager\Webs
 //表格配置-编辑
 Route::any('user/table_config/edit', [App\Http\Controllers\Manager\User\TableConfig::class, 'edit']);
 //表格配置-详情
-Route::any('user/table_config/detail', [App\Http\Controllers\Manager\User\TableConfig::class, 'detail']);
+Route::any('user/table_config/detail', [App\Http\Controllers\Manager\User\TableConfig::class, 'detail']);
+
+//文件下载任务-列表
+Route::any('download_task/list',[\App\Http\Controllers\Manager\Other\DownloadTask::class,'list']);