where(['id_number' => $id_number])->whereIn('status', [2, 4])->get(); return \Yz::Return(true, "弃检成功", ['list' => $list]); } public function list() { $id = request('id'); $info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first(); if (!$info) return \Yz::echoError1("查询就诊人订单失败"); $end_time = date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time) + (60 * 60 * 0.54)); $res = self::fz('time', [ 'exam_id' => $info->tj_number ?? '??????????', 'start_time' => date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time)), 'clinics' => [[ "name" => "外科诊室", "count" => 3 ], [ "name" => "内科诊室", "count" => 3 ]] ]); if (!!$res) { $time_line = $res['data']['time_line']; $check_report_status = -1; if (!!$res['data']['report']) { $report_time = date('m月d日', strtotime($res['data']['report'] . ' 00:00:00') + (60 * 60 * 24 * 5)); $report_status = false; // 这里补充 获取 出具报告 时间的逻辑 if (!$report_status) { $time_line[] = [ 'time' => '', 'name' => '出具报告', 'status' => -1, 'desc' => "预计 $report_time 出具体检报告", 'tip' => '', 'more' => 0 ]; } else { $time_line[] = [ 'time' => '', 'name' => '出具报告', 'status' => -1, 'desc' => "已出具体检报告 $report_status", 'tip' => '', 'more' => 0 ]; } $check_report_status = 0; // $check_report_status = '2024年10月11日'; // 这里补充 获取 报告解读 时间的逻辑 if ($check_report_status == 0) { $check_report_time = date('m月d日', strtotime($res['data']['report'] . ' 00:00:00') + (60 * 60 * 24 * 6)); $time_line[] = [ 'time' => '', 'name' => '报告解读', 'status' => -1, 'desc' => "预计 $check_report_time 可以预约报告解读", 'tip' => '', 'more' => 0 ]; } else { $show_date = explode('年', $check_report_status)[1]; $time_line[] = [ 'time' => '', 'name' => '报告解读', 'status' => -1, 'desc' => "已预约 $show_date 报告解读", 'tip' => '', 'more' => 0 ]; } } return \Yz::Return(true, "获取成功", [ 'info' => [ 'name' => $info->name, 'sex' => $info->sex, 'combo_name' => $info->title, 'check_date' => $info->appointment_date, 'start_time' => $res['data']['start_time'] . ':00', 'end_time' => $res['data']['end_time'], 'qrcode' => '', 'code' => $info->appointment_number, ], 'list' => $time_line, 'report' => $check_report_status, ]); } else { return \Yz::Return(true, "获取成功", [ 'info' => [ 'name' => $info->name, 'sex' => $info->sex, 'combo_name' => $info->title, 'check_date' => $info->appointment_date, 'start_time' => $info->appointment_time, 'end_time' => $end_time, 'qrcode' => '', 'code' => $info->appointment_number, ], 'list' => [], 'report' => -1, ]); } } public function info() { $id = request('id'); $clinic = request('clinic'); $info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first(); if (!$info) return \Yz::echoError1("查询就诊人订单失败"); $res = self::fz('info', [ 'exam_id' => $info->tj_number ?? '??????????', 'clinic' => $clinic, ]); if (!!$res) { if ($res['code'] == 200) { return \Yz::Return(true, "获取成功", [ 'info' => [ 'name' => $info->name, 'sex' => $info->sex, 'combo_name' => $info->title, 'check_date' => $info->appointment_date, 'start_time' => $info->appointment_time, 'end_time' => '10:25', 'qrcode' => '', 'code' => $info->appointment_number, ], 'list' => $res['data']['list'], ]); } else { return \Yz::Return(false, $res['message']); } } else { return \Yz::Return(false, "获取失败"); } } public function post($url, $data) { $data_string = json_encode($data, JSON_UNESCAPED_UNICODE); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($data_string), 'Authorization: Bearer BD30333C-CBD4-4BA3-A27C-76727FF4D8B1' ]); curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string); $r = curl_exec($curl); curl_close($curl); return $r; } public function fz($type, $content) { $date = date('Y-m-d'); self::CheckTableName(date('Y-m-d')); self::$log->date = $date; self::$log->type = $type; self::$log->content = json_encode($content, JSON_UNESCAPED_UNICODE); self::$log->callback = '{}'; self::$log->save(); $url_map = [ 'time' => '/api/Open/TiJian/get', 'info' => '/api/Open/TiJian/info', ]; $url = self::$url; $res = self::post("$url{$url_map[$type]}", $content); // /api/Open/TiJian/get self::$log->callback = $res; self::$log->save(); if (json_decode($res)) { return json_decode($res, true); } else { return false; } } public static function CheckTableName($date) { $table_name = 'zz_fenzhen_log_' . date('ym', strtotime($date)); $table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0]; if ($table_count->c === 0) { Schema::create($table_name, function (Blueprint $table) { $table->id(); $table->date('date')->index(); $table->string('type', 20)->index(); $table->longText('content'); $table->longText('callback'); $table->timestamps(); }); } self::$log = new \App\Models\FenzhenLog; self::$log->setTable($table_name); return $table_name; } }