$code, 'message' => $message, 'data' => $data]; if ($e !== false) { if ($e instanceof Exception) { $errMsg = $e->getFile().'文件第'.$e->getLine().'行错误:'.$e->getMessage(); trace([$message => $errMsg], 'error'); } else { trace([$message => $e], 'error'); } } return response()->json($out); } } //日志记录 if (!function_exists('trace')) { function trace($log = '', $level = 'info') { Log::log($level, $log); } } if (!function_exists('get_order_id')) { function get_order_id($user_id,$bus_type=1){ $userId = substr($user_id, -7); $userId = str_pad($userId, 7, "0", STR_PAD_LEFT); $u1 = substr($userId, 0, 2); $u2 = substr($userId, 2, 2); $u3 = substr($userId, 4, 2); $u4 = substr($userId, 6, 1); unset($userId); $d = date("ymd"); $timestamp = microtime(true) - strtotime(date('Y-m-d')); list($t1, $t2) = explode(".", $timestamp); unset($timestamp); $t1 = str_pad($t1, 5, "0", STR_PAD_LEFT); $t2 = intval(substr($t2, 0, 1)); $b = intval($bus_type); unset($busType); return "{$b}{$u1}{$d}{$u2}{$t1}{$u3}{$t2}{$u4}"; } }