<?php

namespace App\Admin\Controllers;

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

/**
 * 订单
 *
 * @property OrderInfoService $service
 */
class OrderInfoController extends AdminController
{
	protected string $serviceName = OrderInfoService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('user_id', '用户编号'),
				amis()->TableColumn('coach_id', '技师编号'),
				amis()->TableColumn('service_id', '项目编号'),
				amis()->TableColumn('channel_id', '渠道编号'),
				amis()->TableColumn('shop_id', '店铺编号'),
				amis()->TableColumn('customer_service_id', '跟单客服编号'),
				amis()->TableColumn('order_type', '订单类型'),
				amis()->TableColumn('order_source', '订单来源'),
				amis()->TableColumn('total_amount', '订单金额'),
				amis()->TableColumn('service_amount', '项目金额'),
				amis()->TableColumn('traffic_amount', '路程金额'),
				amis()->TableColumn('service_snapshot', '项目快照'),
				amis()->TableColumn('service_time', '服务时间'),
				amis()->TableColumn('distance', '目的地距离(米)')->sortable(),
				amis()->TableColumn('latitude', '目的地纬度'),
				amis()->TableColumn('longitude', '目的地经度'),
				amis()->TableColumn('location', '目的地定位地址'),
				amis()->TableColumn('address', '目的地详细地址'),
				amis()->TableColumn('area_code', '目的地行政区划代码'),
				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('user_id', '用户编号'),
			amis()->TextControl('coach_id', '技师编号'),
			amis()->TextControl('service_id', '项目编号'),
			amis()->TextControl('channel_id', '渠道编号'),
			amis()->TextControl('shop_id', '店铺编号'),
			amis()->TextControl('customer_service_id', '跟单客服编号'),
			amis()->TextControl('order_type', '订单类型'),
			amis()->TextControl('order_source', '订单来源'),
			amis()->TextControl('total_amount', '订单金额'),
			amis()->TextControl('service_amount', '项目金额'),
			amis()->TextControl('traffic_amount', '路程金额'),
			amis()->TextControl('service_snapshot', '项目快照'),
			amis()->TextControl('service_time', '服务时间'),
			amis()->TextControl('distance', '目的地距离(米)'),
			amis()->TextControl('latitude', '目的地纬度'),
			amis()->TextControl('longitude', '目的地经度'),
			amis()->TextControl('location', '目的地定位地址'),
			amis()->TextControl('address', '目的地详细地址'),
			amis()->TextControl('area_code', '目的地行政区划代码'),
			amis()->TextControl('remark', '订单备注'),
			amis()->TextControl('state', '订单状态'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('user_id', '用户编号')->static(),
			amis()->TextControl('coach_id', '技师编号')->static(),
			amis()->TextControl('service_id', '项目编号')->static(),
			amis()->TextControl('channel_id', '渠道编号')->static(),
			amis()->TextControl('shop_id', '店铺编号')->static(),
			amis()->TextControl('customer_service_id', '跟单客服编号')->static(),
			amis()->TextControl('order_type', '订单类型')->static(),
			amis()->TextControl('order_source', '订单来源')->static(),
			amis()->TextControl('total_amount', '订单金额')->static(),
			amis()->TextControl('service_amount', '项目金额')->static(),
			amis()->TextControl('traffic_amount', '路程金额')->static(),
			amis()->TextControl('service_snapshot', '项目快照')->static(),
			amis()->TextControl('service_time', '服务时间')->static(),
			amis()->TextControl('distance', '目的地距离(米)')->static(),
			amis()->TextControl('latitude', '目的地纬度')->static(),
			amis()->TextControl('longitude', '目的地经度')->static(),
			amis()->TextControl('location', '目的地定位地址')->static(),
			amis()->TextControl('address', '目的地详细地址')->static(),
			amis()->TextControl('area_code', '目的地行政区划代码')->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(),
		]);
	}
}