<?php

namespace App\Http\Controllers\Order;


use App\Exceptions\ApiException;
use App\Libs\ApiResponse;
use App\Services\Book\BookService;
use App\Services\Order\OrderService;
use App\Services\User\UserService;
use App\Transformer\Order\OrderTransformer;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;

class OrderController extends BaseController
{
    use ApiResponse;

    protected $bookService;
    protected $userService;
    protected $orderService;

    public function __construct(
        BookService  $bookService,
        UserService  $userService,
        OrderService $orderService
    )
    {
        $this->bookService  = $bookService;
        $this->userService  = $userService;
        $this->orderService = $orderService;
    }

    /**
     * 站点列表
     * @param Request $request
     * @return mixed
     * @throws ApiException
     */
    public function channelList(Request $request) {
        $data = $request->all();
        $result = $this->orderService->channelList($data);
        return $this->success($result);
    }

    /**
     * @param Request $request
     * @return mixed
     */
    public function userList(Request $request) {
        $data   = $request->all();
        $result = $this->orderService->userList($data);
        return $this->success($result, [new OrderTransformer(), 'newBuildUserList']);
    }

    /**
     * @param Request $request
     * @return mixed
     */
    public function sendOrderList(Request $request) {
        $data   = $request->all();
        $result = $this->orderService->sendOrderList($data);
        return $this->success($result, [new OrderTransformer(), 'newBuildSendOrderList']);
    }

    public function orderList(Request $request) {
        $data   = $request->all();
        $result = $this->orderService->orderList($data);
        return $this->success($result, [new OrderTransformer(), 'newBuildOrderList']);
    }
}
