<?php
// +----------------------------------------------------------------------
// | [ WE CAN DO IT MORE SIMPLE  ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2020 rights reserved.
// +----------------------------------------------------------------------
// | Author: TABLE ME
// +----------------------------------------------------------------------
// | Date: 2020-08-25 17:23
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace app\api\controller\v1;

use app\BaseController;
use app\model\api\Recharge;
use app\model\api\Site;
use app\model\api\Warehouse;
use app\Request;
use library\services\UtilService;

class Pub extends BaseController
{

    /**
     * 站点信息
     */
    public function siteResouce(Request $request) {
        $stie = UtilService::getParam([
            'custom_qq',
            'custom_tel',
            'domain',
            'expire_time',
            'logo',
            'record',
            'name',
            'sub_domain',
            'sys_seo_description',
            'sys_seo_keyword',
            'sys_seo_title',
            'weixin_logo',
            'mono',
            "tag"
        ],[$request->site]);
        return app('json')->success($stie[0]);
    }


    /**
     * 获取仓库列表
     * @param Request $request
     */
    public function warehouse(Request $request) {
       [$isExp] = UtilService::getMore([
            ['isExp',''],
        ],$request,true);
        $warehouse = new Warehouse;
        $data = $warehouse->field("name,id,platform_ids")
            ->where("status",1)
            ->order("seq","desc")
            ->select()
            ->toArray();
        $platform = (new \app\model\system\Platform());
        foreach ($data as $k => $v) {
            $idsAr = explode(',',$v['platform_ids']);
            $platformAr = [];
            $data[$k]['platform']  = array_map(
                function ($item) use($platform){
                    return  $platform->getPlatformId($item,'*');
                },$idsAr);
        }

        return app('json')->success($data);
    }







}