<?php
// +----------------------------------------------------------------------
// | onezan-admin 快速开发的管理平台
// +----------------------------------------------------------------------
// | 官方网址：https://www.onezan.cn
// +----------------------------------------------------------------------
// | onezan团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: 543885307@qq.com
// +----------------------------------------------------------------------
namespace Applications\sample\modules\order\service\admin;

use app\service\admin\BaseAdminService;
use app\service\RequestHelper;
use Applications\sample\modules\order\repository\OrderRepository;
use think\Request;

/**
 * Order Service
 * @package Applications\sample\modules\order\service\admin
 */
class OrderService extends BaseAdminService
{
    /**
     * 后台订单列表
     */
    public function list(Request $request): array
    {
        $page = $this->repository()->paginateForAdmin([
            'order_no' => $request->get('order_no', ''),
            'created_from' => $request->get('created_from', ''),
            'created_to' => $request->get('created_to', ''),
        ], RequestHelper::parseLimit($request, 'limit', 10, 100));

        return ['code' => 0, 'data' => $page];
    }

    /**
     * 获取订单仓库实例
     * @return OrderRepository
     */
    private function repository(): OrderRepository
    {
        return $this->app->make(OrderRepository::class);
    }
}
