<?php

namespace App\Admin\Controllers;

use App\Services\WalletRefundRecordService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 钱包退款记录
 *
 * @property WalletRefundRecordService $service
 */
class WalletRefundRecordController extends AdminController
{
	protected string $serviceName = WalletRefundRecordService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('order_id', '订单编号'),
				amis()->TableColumn('wallet_id', '钱包编号'),
				amis()->TableColumn('trans_record_id', '交易记录编号'),
				amis()->TableColumn('external_no', '外部交易单号'),
				amis()->TableColumn('refund_method', '退款方式'),
				amis()->TableColumn('total_refund_amount', '合计退款金额'),
				amis()->TableColumn('actual_refund_amount', '实际退款金额'),
				amis()->TableColumn('wallet_balance_refund_amount', '钱包余额退款金额'),
				amis()->TableColumn('recharge_balance_refund_amount', '充值余额退款金额'),
				amis()->TableColumn('refund_time', '退款时间'),
				amis()->TableColumn('remark', '备注'),
				amis()->TableColumn('state', '状态'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('order_id', '订单编号'),
			amis()->TextControl('wallet_id', '钱包编号'),
			amis()->TextControl('trans_record_id', '交易记录编号'),
			amis()->TextControl('external_no', '外部交易单号'),
			amis()->TextControl('refund_method', '退款方式'),
			amis()->TextControl('total_refund_amount', '合计退款金额'),
			amis()->TextControl('actual_refund_amount', '实际退款金额'),
			amis()->TextControl('wallet_balance_refund_amount', '钱包余额退款金额'),
			amis()->TextControl('recharge_balance_refund_amount', '充值余额退款金额'),
			amis()->TextControl('refund_time', '退款时间'),
			amis()->TextControl('remark', '备注'),
			amis()->TextControl('state', '状态'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('order_id', '订单编号')->static(),
			amis()->TextControl('wallet_id', '钱包编号')->static(),
			amis()->TextControl('trans_record_id', '交易记录编号')->static(),
			amis()->TextControl('external_no', '外部交易单号')->static(),
			amis()->TextControl('refund_method', '退款方式')->static(),
			amis()->TextControl('total_refund_amount', '合计退款金额')->static(),
			amis()->TextControl('actual_refund_amount', '实际退款金额')->static(),
			amis()->TextControl('wallet_balance_refund_amount', '钱包余额退款金额')->static(),
			amis()->TextControl('recharge_balance_refund_amount', '充值余额退款金额')->static(),
			amis()->TextControl('refund_time', '退款时间')->static(),
			amis()->TextControl('remark', '备注')->static(),
			amis()->TextControl('state', '状态')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}