<?php

namespace Kylin\Payment\Scenarios;

use Kylin\Payment\Payment;

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

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

        // 调用支付方法
        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 carPurchase(array $params): mixed
    {
        // 确保参数中包含汽车购买相关信息
        $params['car_purchase'] = $params['car_purchase'] ?? [];

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

    /**
     * 汽车保养
     */
    public function carMaintenance(array $params): mixed
    {
        // 确保参数中包含汽车保养相关信息
        $params['maintenance'] = $params['maintenance'] ?? [];

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

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

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

    /**
     * 汽车加油
     */
    public function carRefueling(array $params): mixed
    {
        // 确保参数中包含汽车加油相关信息
        $params['refueling'] = $params['refueling'] ?? [];

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

    /**
     * 汽车维修
     */
    public function carRepair(array $params): mixed
    {
        // 确保参数中包含汽车维修相关信息
        $params['repair'] = $params['repair'] ?? [];

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

    /**
     * 汽车美容
     */
    public function carBeauty(array $params): mixed
    {
        // 确保参数中包含汽车美容相关信息
        $params['beauty'] = $params['beauty'] ?? [];

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

    /**
     * 获取汽车服务记录
     */
    public function getAutomotiveRecords(string $userId): mixed
    {
        return Payment::query($this->paymentType, $userId, $this->name);
    }

    /**
     * 汽车贷款还款
     */
    public function carLoanPayment(array $params): mixed
    {
        // 确保参数中包含汽车贷款还款相关信息
        $params['car_loan'] = $params['car_loan'] ?? [];

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