<?php

namespace Kylin\Payment\Scenarios;

use Kylin\Payment\Payment;

/**
 * 旅游支付场景类
 */
class TourismPayment
{
    /**
     * 构造函数
     */
    public function __construct(
        protected readonly string $paymentType,
        protected readonly string $name = 'default'
    ) {}

    /**
     * 创建旅游支付订单
     */
    public function create(array $params): mixed
    {
        // 确保参数中包含旅游支付相关信息
        $params['tourism'] = $params['tourism'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }

    /**
     * 支付旅游订单
     */
    public function pay(string $orderId, array $params): mixed
    {
        return Payment::pay($this->paymentType, array_merge($params, ['order_id' => $orderId]), $this->name);
    }

    /**
     * 取消旅游订单
     */
    public function cancel(string $orderId): mixed
    {
        return Payment::close($this->paymentType, $orderId, $this->name);
    }

    /**
     * 查询旅游订单状态
     */
    public function status(string $orderId): mixed
    {
        return Payment::query($this->paymentType, $orderId, $this->name);
    }

    /**
     * 旅游退款
     */
    public function refund(string $orderId, array $params): mixed
    {
        return Payment::refund($this->paymentType, array_merge($params, ['order_id' => $orderId]), $this->name);
    }

    /**
     * 酒店预订
     */
    public function hotelBooking(array $params): mixed
    {
        // 确保参数中包含酒店预订相关信息
        $params['hotel'] = $params['hotel'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }

    /**
     * 机票预订
     */
    public function flightBooking(array $params): mixed
    {
        // 确保参数中包含机票预订相关信息
        $params['flight'] = $params['flight'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }

    /**
     * 旅游套餐预订
     */
    public function packageBooking(array $params): mixed
    {
        // 确保参数中包含旅游套餐预订相关信息
        $params['package'] = $params['package'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }

    /**
     * 景点门票预订
     */
    public function ticketBooking(array $params): mixed
    {
        // 确保参数中包含景点门票预订相关信息
        $params['ticket'] = $params['ticket'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }

    /**
     * 获取旅游订单记录
     */
    public function getTourismRecords(string $userId): mixed
    {
        return Payment::query($this->paymentType, $userId, $this->name);
    }

    /**
     * 旅游保险购买
     */
    public function insurance(array $params): mixed
    {
        // 确保参数中包含旅游保险相关信息
        $params['insurance'] = $params['insurance'] ?? [];

        // 调用支付方法
        return Payment::pay($this->paymentType, $params, $this->name);
    }
}
