<?php

namespace app\store\controller;

use app\common\controller\Definitions;
use app\common\lists\DeliveryServiceLists;
use app\common\logic\DeliveryServiceLogic;

class DeliveryController extends BaseAdminController
{

    // #[
    //     ApiDoc\Title('列表'),
    //     ApiDoc\url('/store/delivery/lists'),
    //     ApiDoc\Method('GET'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '名称/手机号'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Query(ref: [Definitions::class, "page"]),
    //     ApiDoc\ResponseSuccess("data", type: "array"),
    // ]
    public function lists()
    {
        return $this->dataLists(new DeliveryServiceLists());
    }

    // #[
    //     ApiDoc\Title('添加'),
    //     ApiDoc\url('/store/delivery/add'),
    //     ApiDoc\Method('POST'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'),
    //     ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'),
    //     ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'),
    //     ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'),
    //     ApiDoc\ResponseSuccess("data", type: "array"),
    // ]
    public function add(DeliveryServiceLogic $logic)
    {
        $params = $this->request->post();
        $logic->add($params);
        return $this->success('操作成功', [], 1, 1);
    }

    // #[
    //     ApiDoc\Title('编辑'),
    //     ApiDoc\url('/store/delivery/edit'),
    //     ApiDoc\Method('POST'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'),
    //     ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'),
    //     ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'),
    //     ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'),
    //     ApiDoc\ResponseSuccess("data", type: "array"),
    // ]
    public function edit(DeliveryServiceLogic $logic)
    {
        $id = $this->request->post('id');
        $params = $this->request->post();
        $logic->edit($id, $params);
        return $this->success('操作成功', [], 1, 1);
    }

    // #[
    //     ApiDoc\Title('删除'),
    //     ApiDoc\url('/store/delivery/delete'),
    //     ApiDoc\Method('POST'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
    //     ApiDoc\ResponseSuccess("data", type: "array"),
    // ]
    public function delete(DeliveryServiceLogic $logic)
    {
        $id = $this->request->post('id');
        $logic->delete($id);
        return $this->success('操作成功', [], 1, 1);
    }

    // #[
    //     ApiDoc\Title('详情'),
    //     ApiDoc\url('/store/delivery/detail'),
    //     ApiDoc\Method('GET'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'),
    //     ApiDoc\ResponseSuccess("data", type: "array", children: [
    //         ['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
    //         ['name' => 'account', 'desc' => '账号', 'type' => 'string'],
    //         ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'],
    //         ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'],
    //         ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'],
    //         ['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'],
    //         ['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'],
    //         ['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'],
    //         ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'],
    //         ['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'],
    //     ]),
    // ]
    public function detail(DeliveryServiceLogic $logic)
    {
        $id = $this->request->get('id');
        $data = $logic->detail($id);
        return $this->data($data);
    }

    // #[
    //     ApiDoc\Title('开启/关闭'),
    //     ApiDoc\url('/store/delivery/status'),
    //     ApiDoc\Method('POST'),
    //     ApiDoc\NotHeaders(),
    //     ApiDoc\Author('中国队长'),
    //     ApiDoc\Header(ref: [Definitions::class, "token"]),
    //     ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
    //     ApiDoc\ResponseSuccess("data", type: "array"),
    // ]
    public function status(DeliveryServiceLogic $logic)
    {
        $id = $this->request->post('id');
        $logic->status($id);
        return $this->success('操作成功', [], 1, 1);
    }

}