request->isAjax()) { return JsonServer::success('', DeliveryBatchLogic::lists(input())); } return view(); } /** * @notes 批量发货详情 * @return \think\response\Json * @author lbzy * @datetime 2025-03-06 18:10:39 */ function detail() { return JsonServer::success('', [ 'detail' => DeliveryBatchLogic::detail(input('id/d')) ]); } /** * @notes 下载默认文件等 * @return string|\think\response\File * @author lbzy * @datetime 2025-03-06 17:35:44 */ function down() { $filename = pathinfo(input('file/s'), PATHINFO_FILENAME); $path = app()->getRootPath() . 'public/static/excel/' . $filename . '.xls'; if (! file_exists($path)) { return '文件不存在'; } return download($path, $filename); } /** * @notes 下载导入失败的 * @return void * @author lbzy * @datetime 2025-03-06 18:20:45 */ function down2() { $lists = DeliveryBatchLogic::getFailInfoLists(input('id/d')); Excel::out($lists, [ [ 'field' => 'sn', 'title' => '订单编号', 'excel_data_type' => DataType::TYPE_STRING ], [ 'field' => 'express_name', 'title' => '快递公司名称' ], [ 'field' => 'express_no', 'title' => '快递单号' ], [ 'field' => 'fail_content', 'title' => '失败原因' ], ], '','', '导入失败订单'); exit; } /** * @notes 立即导入 * @return \think\response\Json * @author lbzy * @datetime 2025-03-06 17:56:34 */ function import() { $sheet = IOFactory::load($_FILES['file']['tmp_name'])->getActiveSheet(); $sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT); $sheet->getStyle('B')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT); $sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT); $lists = $sheet->toArray(null, true, true, true); (new DeliveryBatchImportValidate())->goCheck('', [ 'lists' => $lists ]); $result = DeliveryBatchLogic::importLists($lists, $_FILES['file']['name']); return is_array($result) ? JsonServer::success('', $result) : JsonServer::error($result); } /** * @notes 执行导入页面 * @return \think\response\Json|\think\response\View * @author lbzy * @datetime 2025-03-06 18:08:52 */ function delivery() { $detail = DeliveryBatchLogic::detail(input('id/d')); if ($this->request->isAjax()) { DeliveryBatchLogic::delivery($detail); return JsonServer::success(''); } return view('', [ 'detail' => $detail ]); } }