|
|
@@ -186,7 +186,7 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
//多选第一责任人
|
|
|
if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
|
$first_responsible_person = explode(',', $first_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->where('duty_type',1)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->where('duty_type', 1)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
|
@@ -194,7 +194,7 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
//多选责任人
|
|
|
if ($responsible_person && is_string($responsible_person)) {
|
|
|
$responsible_person = explode(',', $responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->where('duty_type',2)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->where('duty_type', 2)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
|
@@ -202,7 +202,7 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
//多选溯源责任人
|
|
|
if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
|
$source_responsible_person = explode(',', $source_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->where('duty_type',3)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->where('duty_type', 3)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
|
@@ -244,7 +244,7 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
->where('personnel_employee.id', $user_id)->select(['personnel_employee.id', 'personnel_roles.identity'])
|
|
|
->first();
|
|
|
//角色身份1=普通2=管理员
|
|
|
- if(!empty($personnel_roles_info) && $personnel_roles_info->identity == 2){
|
|
|
+ if (!empty($personnel_roles_info) && $personnel_roles_info->identity == 2) {
|
|
|
$is_admin = 1;
|
|
|
}
|
|
|
$query = $LowPriceGoodsModel->where($map);
|
|
|
@@ -255,24 +255,24 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
->orWhere('source_responsible_person', 'like', "%,$user_id,%");
|
|
|
});
|
|
|
}
|
|
|
- $snapshot_status = $CompanyModel->where(['id'=> $low_price_goods_where['company_id']])->value('snapshot_status');
|
|
|
+ $snapshot_status = $CompanyModel->where(['id' => $low_price_goods_where['company_id']])->value('snapshot_status');
|
|
|
$query->chunkById($limit, function ($rows) use ($key_name) {
|
|
|
- $result_data = $rows->toArray();
|
|
|
- if (empty($result_data)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- $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);
|
|
|
- // 每处理完一个块,释放内存
|
|
|
- unset($result_data);
|
|
|
- gc_collect_cycles();
|
|
|
+ $result_data = $rows->toArray();
|
|
|
+ if (empty($result_data)) {
|
|
|
return true;
|
|
|
- });
|
|
|
+ }
|
|
|
+ $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);
|
|
|
+ // 每处理完一个块,释放内存
|
|
|
+ unset($result_data);
|
|
|
+ gc_collect_cycles();
|
|
|
+ return true;
|
|
|
+ });
|
|
|
|
|
|
$export_data_info = Cache::get($key_name) ?: [];
|
|
|
- $this->export_download($export_data_info, $low_price_goods_where['company_id'], $file_id,$snapshot_status);
|
|
|
+ $this->export_download($export_data_info, $low_price_goods_where['company_id'], $file_id, $snapshot_status);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -311,7 +311,7 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
* @version 1.0
|
|
|
* @date 2025-06-17
|
|
|
*/
|
|
|
- public function export_download($data, $company_id, $file_id,$snapshot_status)
|
|
|
+ public function export_download($data, $company_id, $file_id, $snapshot_status)
|
|
|
{
|
|
|
// 创建一个新的 Spreadsheet 对象
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
@@ -327,33 +327,64 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
// 然后设置行高以适应两行文本
|
|
|
$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', '销量');
|
|
|
- $sheet->setCellValue('I2', '快照URL');
|
|
|
- $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', '采集时间');
|
|
|
- $sheet->setCellValue('AA2', '清洗时间');
|
|
|
+ if ($company_id == 5) {
|
|
|
+ $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', '快照URL');
|
|
|
+ $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', '采集时间');
|
|
|
+ $sheet->setCellValue('AA2', '清洗时间');
|
|
|
+ } else {
|
|
|
+ $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', '快照URL');
|
|
|
+ $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', '采集时间');
|
|
|
+ $sheet->setCellValue('AA2', '清洗时间');
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//平台0=全部,1=淘宝,2=京东,3=拼多多,4=美团,5=药师帮,6=1药城,7=药九九,8=药易购,9=药帮忙,10=熊猫药药11=药房网
|
|
|
$platform_data = [
|
|
|
@@ -379,41 +410,80 @@ class ExportLowPriceGoodsJobs implements ShouldQueue
|
|
|
];
|
|
|
// 填充数据
|
|
|
$row = 3; // 从第2行开始
|
|
|
- foreach ($data as $item) {
|
|
|
- //关闭快照不展示数据
|
|
|
- if(!empty($snapshot_status) && $snapshot_status == 1) $item['snapshot_url'] = '';
|
|
|
- $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_brand']);
|
|
|
- $sheet->setCellValue('F' . $row, $item['product_name']);
|
|
|
- $sheet->setCellValue('G' . $row, $item['inventory']);
|
|
|
- $sheet->setCellValue('H' . $row, $item['sales']);
|
|
|
- $sheet->setCellValue('I' . $row, $item['snapshot_url'] !='' ? $item['snapshot_url'] : '暂无');
|
|
|
- $sheet->setCellValue('J' . $row, $item['product_specs']);
|
|
|
- $sheet->setCellValue('K' . $row, $item['suggested_price']);
|
|
|
- $sheet->setCellValue('L' . $row, $item['online_posting_price']);
|
|
|
- $sheet->setCellValue('M' . $row, $item['is_ultra_low_price'] == 1 ? '是' : '否');
|
|
|
- $sheet->setCellValue('N' . $row, $item['ultra_low_price']);
|
|
|
- $sheet->setCellValue('O' . $row, $item['online_posting_count']);
|
|
|
- $sheet->setCellValue('P' . $row, $item['continuous_listing_count']);
|
|
|
- $sheet->setCellValue('Q' . $row, $item['link_url']);
|
|
|
- $sheet->setCellValue('R' . $row, $item['store_name']);
|
|
|
- $sheet->setCellValue('S' . $row, $item['anonymous_store_name']);
|
|
|
- $sheet->setCellValue('T' . $row, $item['company_name']);
|
|
|
- $sheet->setCellValue('U' . $row, $item['company_category_name']);
|
|
|
- $sheet->setCellValue('V' . $row, $item['social_credit_code']);
|
|
|
- $sheet->setCellValue('W' . $row, $item['merge_province_name']);
|
|
|
- $sheet->setCellValue('X' . $row, $item['merge_city_name']);
|
|
|
- $sheet->setCellValue('Y' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
|
|
|
- $sheet->setCellValue('Z' . $row, !empty($item['collection_time']) ? date('Y-m-d H:i:s', $item['collection_time']) : '');
|
|
|
- $sheet->setCellValue('AA' . $row, date('Y-m-d H:i:s', $item['insert_time']));
|
|
|
- $row++;
|
|
|
+ if ($company_id == 5) {
|
|
|
+ foreach ($data as $item) {
|
|
|
+ //关闭快照不展示数据
|
|
|
+ if (!empty($snapshot_status) && $snapshot_status == 1) $item['snapshot_url'] = '';
|
|
|
+ $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, '');
|
|
|
+ $sheet->setCellValue('B' . $row, $responsible_person_name);
|
|
|
+ $sheet->setCellValue('C' . $row, isset($platform_data[$item['platform']]) ? $platform_data[$item['platform']] : '');
|
|
|
+ $sheet->setCellValue('D' . $row, '');
|
|
|
+ $sheet->setCellValue('E' . $row, $item['product_brand']);
|
|
|
+ $sheet->setCellValue('F' . $row, $item['product_name']);
|
|
|
+ $sheet->setCellValue('G' . $row, '');
|
|
|
+ $sheet->setCellValue('H' . $row, '');
|
|
|
+ $sheet->setCellValue('I' . $row, $item['snapshot_url'] != '' ? $item['snapshot_url'] : '暂无');
|
|
|
+ $sheet->setCellValue('J' . $row, $item['product_specs']);
|
|
|
+ $sheet->setCellValue('K' . $row, $item['suggested_price']);
|
|
|
+ $sheet->setCellValue('L' . $row, $item['online_posting_price']);
|
|
|
+ $sheet->setCellValue('M' . $row, $item['is_ultra_low_price'] == 1 ? '是' : '否');
|
|
|
+ $sheet->setCellValue('N' . $row, $item['ultra_low_price']);
|
|
|
+ $sheet->setCellValue('O' . $row, $item['online_posting_count']);
|
|
|
+ $sheet->setCellValue('P' . $row, $item['continuous_listing_count']);
|
|
|
+ $sheet->setCellValue('Q' . $row, $item['link_url']);
|
|
|
+ $sheet->setCellValue('R' . $row, $item['store_name']);
|
|
|
+ $sheet->setCellValue('S' . $row, '');
|
|
|
+ $sheet->setCellValue('T' . $row, $item['company_name']);
|
|
|
+ $sheet->setCellValue('U' . $row, '');
|
|
|
+ $sheet->setCellValue('V' . $row, '');
|
|
|
+ $sheet->setCellValue('W' . $row, $item['merge_province_name']);
|
|
|
+ $sheet->setCellValue('X' . $row, $item['merge_city_name']);
|
|
|
+ $sheet->setCellValue('Y' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
|
|
|
+ $sheet->setCellValue('Z' . $row, !empty($item['collection_time']) ? date('Y-m-d H:i:s', $item['collection_time']) : '');
|
|
|
+ $sheet->setCellValue('AA' . $row, date('Y-m-d H:i:s', $item['insert_time']));
|
|
|
+ $row++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ foreach ($data as $item) {
|
|
|
+ //关闭快照不展示数据
|
|
|
+ if (!empty($snapshot_status) && $snapshot_status == 1) $item['snapshot_url'] = '';
|
|
|
+ $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_brand']);
|
|
|
+ $sheet->setCellValue('F' . $row, $item['product_name']);
|
|
|
+ $sheet->setCellValue('G' . $row, $item['inventory']);
|
|
|
+ $sheet->setCellValue('H' . $row, $item['sales']);
|
|
|
+ $sheet->setCellValue('I' . $row, $item['snapshot_url'] != '' ? $item['snapshot_url'] : '暂无');
|
|
|
+ $sheet->setCellValue('J' . $row, $item['product_specs']);
|
|
|
+ $sheet->setCellValue('K' . $row, $item['suggested_price']);
|
|
|
+ $sheet->setCellValue('L' . $row, $item['online_posting_price']);
|
|
|
+ $sheet->setCellValue('M' . $row, $item['is_ultra_low_price'] == 1 ? '是' : '否');
|
|
|
+ $sheet->setCellValue('N' . $row, $item['ultra_low_price']);
|
|
|
+ $sheet->setCellValue('O' . $row, $item['online_posting_count']);
|
|
|
+ $sheet->setCellValue('P' . $row, $item['continuous_listing_count']);
|
|
|
+ $sheet->setCellValue('Q' . $row, $item['link_url']);
|
|
|
+ $sheet->setCellValue('R' . $row, $item['store_name']);
|
|
|
+ $sheet->setCellValue('S' . $row, $item['anonymous_store_name']);
|
|
|
+ $sheet->setCellValue('T' . $row, $item['company_name']);
|
|
|
+ $sheet->setCellValue('U' . $row, $item['company_category_name']);
|
|
|
+ $sheet->setCellValue('V' . $row, $item['social_credit_code']);
|
|
|
+ $sheet->setCellValue('W' . $row, $item['merge_province_name']);
|
|
|
+ $sheet->setCellValue('X' . $row, $item['merge_city_name']);
|
|
|
+ $sheet->setCellValue('Y' . $row, isset($processing_status_text[$item['processing_status']]) ? $processing_status_text[$item['processing_status']] : '');
|
|
|
+ $sheet->setCellValue('Z' . $row, !empty($item['collection_time']) ? date('Y-m-d H:i:s', $item['collection_time']) : '');
|
|
|
+ $sheet->setCellValue('AA' . $row, date('Y-m-d H:i:s', $item['insert_time']));
|
|
|
+ $row++;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
foreach (range('A', 'AA') as $column) {
|
|
|
$sheet->getColumnDimension($column)->setAutoSize(true);
|
|
|
}
|