询单url调整
This commit is contained in:
@@ -38,7 +38,7 @@ class InquiryLogController extends BaseController
|
||||
$data['r_time'] = $data['r_time'] > 0 ? date('Y-m-d H:i:s', $data['r_time']) : 0;
|
||||
if (isset($data['t_time']))
|
||||
$data['t_time'] = $data['t_time'] > 0 ? date('Y-m-d H:i:s', $data['t_time']) : 0;
|
||||
|
||||
// var_dump($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -77,131 +77,131 @@ class InquiryLogController extends BaseController
|
||||
}
|
||||
|
||||
// 导出
|
||||
public function export(Request $request)
|
||||
{
|
||||
if ($request->method() == "POST") {
|
||||
$data = $request->all();
|
||||
// public function export(Request $request)
|
||||
// {
|
||||
// if ($request->method() == "POST") {
|
||||
// $data = $request->all();
|
||||
|
||||
$where = [];
|
||||
if (isset($data['log_lusers']) && $data['log_lusers']) {
|
||||
$where[] = ['enter_user_id', '=', $data['log_lusers']];
|
||||
}
|
||||
if (isset($data['log_gusers']) && $data['log_gusers']) {
|
||||
$where[] = ['recipient', '=', $data['log_gusers']];
|
||||
}
|
||||
if (isset($data['log_country']) && $data['log_country']) {
|
||||
$where[] = ['log_country', '=', $data['log_country']];
|
||||
}
|
||||
if (isset($data['log_channel']) && $data['log_channel']) {
|
||||
$where[] = ['log_type', '=', $data['log_channel']];
|
||||
}
|
||||
if (isset($data['log_times']) && $data['log_times']) {
|
||||
$times = explode(' - ', $data["log_times"]);
|
||||
$specificDayStart = trim($times[0]);
|
||||
$specificDayEnd = trim($times[1]);
|
||||
$where[] = [
|
||||
"c_time", ">", strtotime($specificDayStart)
|
||||
];
|
||||
$where[] = [
|
||||
"c_time", "<=", strtotime($specificDayEnd)
|
||||
];
|
||||
}
|
||||
// $where = [];
|
||||
// if (isset($data['log_lusers']) && $data['log_lusers']) {
|
||||
// $where[] = ['enter_user_id', '=', $data['log_lusers']];
|
||||
// }
|
||||
// if (isset($data['log_gusers']) && $data['log_gusers']) {
|
||||
// $where[] = ['recipient', '=', $data['log_gusers']];
|
||||
// }
|
||||
// if (isset($data['log_country']) && $data['log_country']) {
|
||||
// $where[] = ['log_country', '=', $data['log_country']];
|
||||
// }
|
||||
// if (isset($data['log_channel']) && $data['log_channel']) {
|
||||
// $where[] = ['log_type', '=', $data['log_channel']];
|
||||
// }
|
||||
// if (isset($data['log_times']) && $data['log_times']) {
|
||||
// $times = explode(' - ', $data["log_times"]);
|
||||
// $specificDayStart = trim($times[0]);
|
||||
// $specificDayEnd = trim($times[1]);
|
||||
// $where[] = [
|
||||
// "c_time", ">", strtotime($specificDayStart)
|
||||
// ];
|
||||
// $where[] = [
|
||||
// "c_time", "<=", strtotime($specificDayEnd)
|
||||
// ];
|
||||
// }
|
||||
|
||||
// 查询
|
||||
$results = InquiryLogModel::with(['enterUser', 'recipientUser', 'country'])
|
||||
->where($where)
|
||||
->get()
|
||||
->map(function ($log) use($data) {
|
||||
$arr = [];
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['订单号'] = $log->order_no;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['录入人'] = $log->enterUser->name ?? null;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['接单人'] = $log->recipientUser->name ?? null;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['等级'] = $log->log_quality;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['邮箱'] = $log->log_contact_type;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['电话'] = $log->log_contact_tel;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['WhatsApp'] = $log->log_contact_whatsapp;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['联系人'] = $log->log_contacts;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['国家(中文)'] = $log->country->cn_addr ?? null;
|
||||
}
|
||||
if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
$arr['国家(英文)'] = $log->country->en_full_name ?? null;
|
||||
}
|
||||
if (isset($data['hsl_r_time']) && $data['hsl_r_time']) {
|
||||
$arr['发单时间'] = $log->r_time ? date('Y-m-d H:i:s', $log->r_time) : null;
|
||||
}
|
||||
if (isset($data['hsl_t_time']) && $data['hsl_t_time']) {
|
||||
$arr['跟单时间'] = $log->t_time ? date('Y-m-d H:i:s', $log->t_time) : null;
|
||||
}
|
||||
return $arr;
|
||||
});
|
||||
// 创建一个新的 Spreadsheet 对象
|
||||
$spreadsheet = new Spreadsheet();
|
||||
// 设置当前活动的工作表
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
// 设置工作表的标题
|
||||
$sheet->setCellValue('A1', '订单号');
|
||||
$sheet->setCellValue('B1', '录入人');
|
||||
$sheet->setCellValue('C1', '接单人');
|
||||
$sheet->setCellValue('D1', '等级');
|
||||
$sheet->setCellValue('E1', '邮箱');
|
||||
$sheet->setCellValue('F1', '电话');
|
||||
$sheet->setCellValue('G1', 'WhatsApp');
|
||||
$sheet->setCellValue('H1', '联系人');
|
||||
$sheet->setCellValue('I1', '国家(中文)');
|
||||
$sheet->setCellValue('J1', '国家(英文)');
|
||||
$sheet->setCellValue('K1', '发单时间');
|
||||
$sheet->setCellValue('L1', '跟单时间');
|
||||
$data = $results->toArray();
|
||||
// // 查询
|
||||
// $results = InquiryLogModel::with(['enterUser', 'recipientUser', 'country'])
|
||||
// ->where($where)
|
||||
// ->get()
|
||||
// ->map(function ($log) use($data) {
|
||||
// $arr = [];
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['订单号'] = $log->order_no;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['录入人'] = $log->enterUser->name ?? null;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['接单人'] = $log->recipientUser->name ?? null;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['等级'] = $log->log_quality;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['邮箱'] = $log->log_contact_type;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['电话'] = $log->log_contact_tel;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['WhatsApp'] = $log->log_contact_whatsapp;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['联系人'] = $log->log_contacts;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['国家(中文)'] = $log->country->cn_addr ?? null;
|
||||
// }
|
||||
// if (isset($data['hsl_order_no']) && $data['hsl_order_no']) {
|
||||
// $arr['国家(英文)'] = $log->country->en_full_name ?? null;
|
||||
// }
|
||||
// if (isset($data['hsl_r_time']) && $data['hsl_r_time']) {
|
||||
// $arr['发单时间'] = $log->r_time ? date('Y-m-d H:i:s', $log->r_time) : null;
|
||||
// }
|
||||
// if (isset($data['hsl_t_time']) && $data['hsl_t_time']) {
|
||||
// $arr['跟单时间'] = $log->t_time ? date('Y-m-d H:i:s', $log->t_time) : null;
|
||||
// }
|
||||
// return $arr;
|
||||
// });
|
||||
// // 创建一个新的 Spreadsheet 对象
|
||||
// $spreadsheet = new Spreadsheet();
|
||||
// // 设置当前活动的工作表
|
||||
// $sheet = $spreadsheet->getActiveSheet();
|
||||
// // 设置工作表的标题
|
||||
// $sheet->setCellValue('A1', '订单号');
|
||||
// $sheet->setCellValue('B1', '录入人');
|
||||
// $sheet->setCellValue('C1', '接单人');
|
||||
// $sheet->setCellValue('D1', '等级');
|
||||
// $sheet->setCellValue('E1', '邮箱');
|
||||
// $sheet->setCellValue('F1', '电话');
|
||||
// $sheet->setCellValue('G1', 'WhatsApp');
|
||||
// $sheet->setCellValue('H1', '联系人');
|
||||
// $sheet->setCellValue('I1', '国家(中文)');
|
||||
// $sheet->setCellValue('J1', '国家(英文)');
|
||||
// $sheet->setCellValue('K1', '发单时间');
|
||||
// $sheet->setCellValue('L1', '跟单时间');
|
||||
// $data = $results->toArray();
|
||||
|
||||
// 将数据填充到工作表中
|
||||
$row = 2; // 从第2行开始填充
|
||||
foreach ($data as $item) {
|
||||
$sheet->setCellValue('A' . $row, $item['订单号']);
|
||||
$sheet->setCellValue('B' . $row, $item['录入人']);
|
||||
$sheet->setCellValue('C' . $row, $item['接单人']);
|
||||
// // 将数据填充到工作表中
|
||||
// $row = 2; // 从第2行开始填充
|
||||
// foreach ($data as $item) {
|
||||
// $sheet->setCellValue('A' . $row, $item['订单号']);
|
||||
// $sheet->setCellValue('B' . $row, $item['录入人']);
|
||||
// $sheet->setCellValue('C' . $row, $item['接单人']);
|
||||
|
||||
$sheet->setCellValue('D' . $row, $item['等级']);
|
||||
$sheet->setCellValue('E' . $row, $item['邮箱']);
|
||||
$sheet->setCellValue('F' . $row, $item['电话']);
|
||||
// $sheet->setCellValue('D' . $row, $item['等级']);
|
||||
// $sheet->setCellValue('E' . $row, $item['邮箱']);
|
||||
// $sheet->setCellValue('F' . $row, $item['电话']);
|
||||
|
||||
$sheet->setCellValue('G' . $row, $item['WhatsApp']);
|
||||
$sheet->setCellValue('H' . $row, $item['联系人']);
|
||||
$sheet->setCellValue('I' . $row, $item['国家(中文)']);
|
||||
// $sheet->setCellValue('G' . $row, $item['WhatsApp']);
|
||||
// $sheet->setCellValue('H' . $row, $item['联系人']);
|
||||
// $sheet->setCellValue('I' . $row, $item['国家(中文)']);
|
||||
|
||||
$sheet->setCellValue('J' . $row, $item['国家(英文)']);
|
||||
$sheet->setCellValue('K' . $row, $item['发单时间']);
|
||||
$sheet->setCellValue('L' . $row, $item['跟单时间']);
|
||||
$row++;
|
||||
}
|
||||
// $sheet->setCellValue('J' . $row, $item['国家(英文)']);
|
||||
// $sheet->setCellValue('K' . $row, $item['发单时间']);
|
||||
// $sheet->setCellValue('L' . $row, $item['跟单时间']);
|
||||
// $row++;
|
||||
// }
|
||||
|
||||
// 创建 Excel 文件的写入器
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
// 名称
|
||||
$fileName = $request->user->name.'_'.date('Ymd').'_'.uniqid().'.xlsx';
|
||||
// 路径
|
||||
$filePath = '/export/'.$fileName;
|
||||
// 将文件保存到本地
|
||||
$writer->save(public_path().$filePath);
|
||||
// // 创建 Excel 文件的写入器
|
||||
// $writer = new Xlsx($spreadsheet);
|
||||
// // 名称
|
||||
// $fileName = $request->user->name.'_'.date('Ymd').'_'.uniqid().'.xlsx';
|
||||
// // 路径
|
||||
// $filePath = '/export/'.$fileName;
|
||||
// // 将文件保存到本地
|
||||
// $writer->save(public_path().$filePath);
|
||||
|
||||
return $this->successResponse(['url'=>$filePath, 'name'=>$fileName]);
|
||||
}
|
||||
return view('inquiry-log/export');
|
||||
}
|
||||
// return $this->successResponse(['url'=>$filePath, 'name'=>$fileName]);
|
||||
// }
|
||||
// return view('inquiry-log/export');
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user