<?php

namespace App\Admin\Controllers;

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

/**
 * 钱包分账记录
 *
 * @property WalletSplitRecordService $service
 */
class WalletSplitRecordController extends AdminController
{
	protected string $serviceName = WalletSplitRecordService::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('rule_id', '分账规则配置编号'),
				amis()->TableColumn('split_type', '分账类型(服务佣金、平台分成、邀请奖励、团队邀请奖励、推荐奖励)'),
				amis()->TableColumn('amount', '参与分账金额'),
				amis()->TableColumn('split_ratio', '分账比例'),
				amis()->TableColumn('split_amount', '分账金额'),
				amis()->TableColumn('entry_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('rule_id', '分账规则配置编号'),
			amis()->TextControl('split_type', '分账类型(服务佣金、平台分成、邀请奖励、团队邀请奖励、推荐奖励)'),
			amis()->TextControl('amount', '参与分账金额'),
			amis()->TextControl('split_ratio', '分账比例'),
			amis()->TextControl('split_amount', '分账金额'),
			amis()->TextControl('entry_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('rule_id', '分账规则配置编号')->static(),
			amis()->TextControl('split_type', '分账类型(服务佣金、平台分成、邀请奖励、团队邀请奖励、推荐奖励)')->static(),
			amis()->TextControl('amount', '参与分账金额')->static(),
			amis()->TextControl('split_ratio', '分账比例')->static(),
			amis()->TextControl('split_amount', '分账金额')->static(),
			amis()->TextControl('entry_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(),
		]);
	}
}