diff --git a/app/command/TbCommand.php b/app/command/TbCommand.php new file mode 100644 index 0000000..3618b40 --- /dev/null +++ b/app/command/TbCommand.php @@ -0,0 +1,49 @@ +all(); + + foreach ($list as $item) { + // UserSn::where('user_sn', $item->sn)->update(['user_id' => $item->id]); + } + return self::SUCCESS; + } +} + + +function replaceRichTextUrls($input) { + // 匹配旧域名及其引号包裹情况(包含http/https协议) + $pattern = '#(https?://server\.xyh\.hnzhwlkj\.club|["\']https?://server\.xyh\.hnzhwlkj\.club)(/[^\s"\'<>]*)?#iu'; + + $replacement = function ($matches) { + $originalQuote = ''; + $path = $matches[2] ?? ''; + + // 检测是否以引号开头 + if (isset($matches[0][0]) && in_array($matches[0][0], ['"', "'"])) { + $originalQuote = $matches[0][0]; + } + + // 构建新URL(强制使用http协议) + return $originalQuote . 'http://219.157.255.213:25326' . $path; + }; + + return preg_replace_callback($pattern, $replacement, $input); +} \ No newline at end of file diff --git a/app/inquiry/controller/InquiryLogController.php b/app/inquiry/controller/InquiryLogController.php index 8bc6761..82f5667 100644 --- a/app/inquiry/controller/InquiryLogController.php +++ b/app/inquiry/controller/InquiryLogController.php @@ -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'); + // } } \ No newline at end of file diff --git a/app/inquiry/service/InquiryLogService.php b/app/inquiry/service/InquiryLogService.php index 8f40a0e..7a935b4 100644 --- a/app/inquiry/service/InquiryLogService.php +++ b/app/inquiry/service/InquiryLogService.php @@ -127,6 +127,22 @@ class InquiryLogService $data['email'] = trim($data["email"]); $data['tel'] = trim($data['tel']); $data['whatsapp'] = trim($data['whatsapp']); + + // 将OSS直连地址替换为代理地址 + $ossDomain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com/'; + $proxyPath = getenv('MAIN_DOMAIN').'/proxy/ossurl?file='; + + $data['content'] = str_replace( + '?Expires=', + '&Expires=', + $data['content'] + ); + $data['content'] = str_replace( + $ossDomain, + $proxyPath, + $data['content'] + ); + return $data; } @@ -219,7 +235,7 @@ class InquiryLogService $quality = [ 1 => '💛 金牌商机', 2 => '🤍 银牌商机', - 3 => '🤍 银牌商机' + 3 => '🧡 银牌商机' ]; return $quality[$id]; } diff --git a/config/route.php b/config/route.php index 8d12177..303c4aa 100644 --- a/config/route.php +++ b/config/route.php @@ -33,6 +33,8 @@ Route::any('/perm', [app\controller\IndexController::class, 'perm']); Route::any('/feishu/event', [app\common\controller\NotifyController::class, 'feishuEvent']); // 飞书回调 Route::any('/feishu/callback', [app\common\controller\NotifyController::class, 'feishuCallback']); +// 代理oss文件地址 +Route::any('/proxy/ossurl', [app\common\controller\UploadController::class, 'proxy']); // 公共 Route::group('/common', function () {