<?php
namespace app\api\server\travel;

use app\api\model\TravelLine;
use app\api\model\TravelDate;
use app\api\model\MerchantShop;
use support\Redis;

class LineServer
{
    /**
     * Notes:获取店铺信息
     * @param int $shop_id
     * @return array
     * User: YCP
     * Date: 2022/10/27
     */
    public static function getShop(int $shop_id)
    {
        $info = MerchantShop::getShopInfo($shop_id);
        $info['shop_label'] = explode('|',$info['shop_label']);
        return $info;
    }

    /**
     * Notes:获取线路列表
     * @param string $keywords
     * @param int $page
     * @param int $limit
     * @return array
     * User: YCP
     * Date: 2023/05/16
     */
    public static function getLineList()
    {
        [$list, $count] =  TravelLine::getLineList();
        return compact('list', 'count');
    }

    /**
     * Notes:查询线路
     * @param int $line_id
     * @return int
     * User: YCP
     * Date: 2023/05/16
     */
    public static function lineInfo($line_id)
    {
        $where = [];
        $where['line_id'] = $line_id;
        $result = TravelLine::where($where)->with(['LineDate','Shop'])->first();
        if(empty($result) || $result === false)
        {
            throw new \Exception('线路信息不存在');
        }
        $result['line_images'] = explode(",",$result['line_images']);
        $result['line_tags'] = explode(",",$result['line_tags']);
        $result['line_trip'] = explode(",",$result['line_trip']);

        return $result;
    }


}
