<?php

namespace app\admin\controller;

use app\admin\logic\OrderLogic;
use app\BaseController;
use think\exception\ValidateException;
use think\facade\Config;
use think\facade\Validate;

class Order extends BaseController
{

    //列表
    public function list()
    {
        $param = $this->request->only(['page' => 1, 'size' => 10, 'orderCode' => '', 'status' => '', 'name' => '', 'username' => '', 'start_date' => '', 'end_date' => '', 'type' => ''], 'post');

        return OrderLogic::list($param);
    }

    //详情
    public function read()
    {
        $id = $this->request->post('id/d', 0);
        return OrderLogic::read($id);
    }

    //导出
    public function export()
    {
        $param = $this->request->only(['orderCode' => '', 'status' => '', 'name' => '', 'username' => '', 'start_date' => '', 'end_date' => '', 'type' => ''], 'post');

        return OrderLogic::export($param);
    }

    //发货
    public function deliver()
    {

        $list = $this->request->post('list/a', 'post');

        $val = Validate::rule(['list|发货列表' => 'require|array|length:1,100']);

        if (!$val->check(['list' => $list])) throw new ValidateException($val->getError());

        return OrderLogic::deliver($list);

    }

}