<?php

namespace App\Admin\Controllers;

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

/**
 * 钱包
 *
 * @property WalletService $service
 */
class WalletController extends AdminController
{
	protected string $serviceName = WalletService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('owner_id', '所属主体编号'),
				amis()->TableColumn('owner_type', '钱包类型'),
				amis()->TableColumn('total_balance', '总余额'),
				amis()->TableColumn('available_balance', '可用余额'),
				amis()->TableColumn('frozen_amount', '冻结金额'),
				amis()->TableColumn('total_income', '累计收入'),
				amis()->TableColumn('total_expense', '累计支出'),
				amis()->TableColumn('state', '状态：ENABLE-启用，DISABLE-禁用'),
				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('owner_id', '所属主体编号'),
			amis()->TextControl('owner_type', '钱包类型'),
			amis()->TextControl('total_balance', '总余额'),
			amis()->TextControl('available_balance', '可用余额'),
			amis()->TextControl('frozen_amount', '冻结金额'),
			amis()->TextControl('total_income', '累计收入'),
			amis()->TextControl('total_expense', '累计支出'),
			amis()->TextControl('state', '状态：ENABLE-启用，DISABLE-禁用'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('owner_id', '所属主体编号')->static(),
			amis()->TextControl('owner_type', '钱包类型')->static(),
			amis()->TextControl('total_balance', '总余额')->static(),
			amis()->TextControl('available_balance', '可用余额')->static(),
			amis()->TextControl('frozen_amount', '冻结金额')->static(),
			amis()->TextControl('total_income', '累计收入')->static(),
			amis()->TextControl('total_expense', '累计支出')->static(),
			amis()->TextControl('state', '状态：ENABLE-启用，DISABLE-禁用')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}