panel('基本信息', function (Show $show) { $show->field('id', '订单ID'); $show->field('out_order_id', '外部订单ID'); $show->field('transfer_app_id', '划转应用ID'); $show->field('transferApp.title', '划转应用名称'); $show->field('transferApp.keyname', '应用标识'); }); // 用户信息面板 $show->panel('用户信息', function (Show $show) { $show->field('user_id', '内部用户ID'); $show->field('out_user_id', '外部用户ID'); $show->field('out_id', '外部应用ID'); }); // 订单信息面板 $show->panel('订单信息', function (Show $show) { $show->field('type', '订单类型')->using([ 1 => '转入', 2 => '转出' ])->label([ 1 => 'success', 2 => 'warning' ]); $show->field('status', '订单状态')->using([ 1 => '已创建', 20 => '处理中', 30 => '已回调', 100 => '已完成', -1 => '失败' ])->label([ 1 => 'info', 20 => 'warning', 30 => 'primary', 100 => 'success', -1 => 'danger' ]); }); // 金额信息面板 $show->panel('金额信息', function (Show $show) { $show->field('amount', '内部金额')->as(function ($value) { return number_format($value, 10); }); $show->field('out_amount', '外部金额')->as(function ($value) { return number_format($value, 10); }); $show->field('exchange_rate', '汇率')->as(function ($value) { return number_format($value, 4); }); $show->field('currency_id', '货币类型ID'); $show->field('fund_id', '资金账户类型ID'); }); // 时间信息面板 $show->panel('时间信息', function (Show $show) { $show->field('created_at', '创建时间'); $show->field('processed_at', '处理时间'); $show->field('callback_at', '回调时间'); $show->field('completed_at', '完成时间'); $show->field('updated_at', '更新时间'); }); // 附加信息面板 $show->panel('附加信息', function (Show $show) { $show->field('remark', '备注'); $show->field('error_message', '错误信息')->unescape(); $show->field('callback_data', '回调数据')->json(); }); } /** * 配置应用详情显示 * * @param Show $show * @return void */ public static function appShow(Show $show): void { // 基本信息面板 $show->panel('基本信息', function (Show $show) { $show->field('id', '应用ID'); $show->field('keyname', '应用标识'); $show->field('title', '应用名称'); $show->field('description', '描述')->unescape(); }); // 外部应用信息面板 $show->panel('外部应用信息', function (Show $show) { $show->field('out_id', '外部应用ID'); $show->field('out_id2', '外部应用ID2'); $show->field('out_id3', '外部应用ID3'); }); // 配置信息面板 $show->panel('配置信息', function (Show $show) { $show->field('currency_id', '货币类型ID'); $show->field('fund_id', '资金账户类型ID'); $show->field('fund_to_uid', '转入目标账户UID'); $show->field('fund_in_uid', '转入来源账户UID'); $show->field('exchange_rate', '汇率')->as(function ($value) { return number_format($value, 4); }); }); // 状态信息面板 $show->panel('状态信息', function (Show $show) { $show->field('is_enabled', '启用状态')->using([ 1 => '启用', 0 => '禁用' ])->label([ 1 => 'success', 0 => 'danger' ]); }); // API配置面板 $show->panel('API配置', function (Show $show) { $show->field('order_callback_url', '回调通知URL'); $show->field('order_in_info_url', '转入查询URL'); $show->field('order_out_create_url', '转出创建URL'); $show->field('order_out_info_url', '转出查询URL'); }); // 时间信息面板 $show->panel('时间信息', function (Show $show) { $show->field('created_at', '创建时间'); $show->field('updated_at', '更新时间'); $show->field('deleted_at', '删除时间'); }); // 统计信息面板 $show->panel('统计信息', function (Show $show) { $show->field('orders_count', '总订单数')->as(function () { return $this->orders()->count(); }); $show->field('completed_orders_count', '已完成订单数')->as(function () { return $this->orders()->where('status', 100)->count(); }); $show->field('failed_orders_count', '失败订单数')->as(function () { return $this->orders()->where('status', -1)->count(); }); $show->field('total_amount', '总金额')->as(function () { return number_format($this->orders()->sum('amount'), 2); }); }); } /** * 配置详情页工具栏 * * @param Show $show * @return void */ public static function configureTools(Show $show): void { $show->tools(function (Show\Tools $tools) { // 添加自定义按钮 $tools->append(' 返回 '); }); } /** * 配置关联数据显示 * * @param Show $show * @param string $relation * @param string $title * @param callable $callback * @return void */ public static function configureRelation(Show $show, string $relation, string $title, callable $callback): void { $show->relation($relation, $title, $callback); } /** * 添加自定义字段显示 * * @param Show $show * @param string $field * @param string $label * @param callable|null $callback * @return void */ public static function addCustomField(Show $show, string $field, string $label, ?callable $callback = null): void { $fieldObj = $show->field($field, $label); if ($callback) { $fieldObj->as($callback); } } }