<?php

namespace App\Admin\Controllers;

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

/**
 * 钱包交易记录
 *
 * @property WalletTransRecordService $service
 */
class WalletTransRecordController extends AdminController
{
	protected string $serviceName = WalletTransRecordService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('wallet_id', '钱包编号'),
				amis()->TableColumn('owner_id', '业务类型编号'),
				amis()->TableColumn('owner_type', '业务类型(profit:分账 recharge:充值 withdraw:提现 refund:退款 payment:支付 gift:赠送 breach:违约 compensation:补偿)'),
				amis()->TableColumn('trans_type', '交易类型(income:收入 expense:支出)'),
				amis()->TableColumn('storage_type', '存储类型(balance:余额 recharge:充值)'),
				amis()->TableColumn('amount', '交易金额'),
				amis()->TableColumn('before_balance', '交易前余额'),
				amis()->TableColumn('after_balance', '交易后余额'),
				amis()->TableColumn('before_recharge_balance', '交易前充值余额'),
				amis()->TableColumn('after_recharge_balance', '交易后充值余额'),
				amis()->TableColumn('trans_time', '交易时间'),
				amis()->TableColumn('remark', '备注'),
				amis()->TableColumn('state', '交易状态(processing:进行中 success:成功 fail:失败 cancel:取消)'),
				amis()->TableColumn('create_time', '创建时间'),
				amis()->TableColumn('update_time', '更新时间'),
				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('wallet_id', '钱包编号'),
			amis()->TextControl('owner_id', '业务类型编号'),
			amis()->TextControl('owner_type', '业务类型(profit:分账 recharge:充值 withdraw:提现 refund:退款 payment:支付 gift:赠送 breach:违约 compensation:补偿)'),
			amis()->TextControl('trans_type', '交易类型(income:收入 expense:支出)'),
			amis()->TextControl('storage_type', '存储类型(balance:余额 recharge:充值)'),
			amis()->TextControl('amount', '交易金额'),
			amis()->TextControl('before_balance', '交易前余额'),
			amis()->TextControl('after_balance', '交易后余额'),
			amis()->TextControl('before_recharge_balance', '交易前充值余额'),
			amis()->TextControl('after_recharge_balance', '交易后充值余额'),
			amis()->TextControl('trans_time', '交易时间'),
			amis()->TextControl('remark', '备注'),
			amis()->TextControl('state', '交易状态(processing:进行中 success:成功 fail:失败 cancel:取消)'),
			amis()->TextControl('create_time', '创建时间'),
			amis()->TextControl('update_time', '更新时间'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('wallet_id', '钱包编号')->static(),
			amis()->TextControl('owner_id', '业务类型编号')->static(),
			amis()->TextControl('owner_type', '业务类型(profit:分账 recharge:充值 withdraw:提现 refund:退款 payment:支付 gift:赠送 breach:违约 compensation:补偿)')->static(),
			amis()->TextControl('trans_type', '交易类型(income:收入 expense:支出)')->static(),
			amis()->TextControl('storage_type', '存储类型(balance:余额 recharge:充值)')->static(),
			amis()->TextControl('amount', '交易金额')->static(),
			amis()->TextControl('before_balance', '交易前余额')->static(),
			amis()->TextControl('after_balance', '交易后余额')->static(),
			amis()->TextControl('before_recharge_balance', '交易前充值余额')->static(),
			amis()->TextControl('after_recharge_balance', '交易后充值余额')->static(),
			amis()->TextControl('trans_time', '交易时间')->static(),
			amis()->TextControl('remark', '备注')->static(),
			amis()->TextControl('state', '交易状态(processing:进行中 success:成功 fail:失败 cancel:取消)')->static(),
			amis()->TextControl('create_time', '创建时间')->static(),
			amis()->TextControl('update_time', '更新时间')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}