<?php

namespace Kylin\Payment\Scenarios;

use Kylin\Payment\Payment;

/**
 * 政府服务支付场景类
 */
class GovernmentPayment
{
    /**
     * 构造函数
     */
    public function __construct(
        protected readonly string $paymentType,
        protected readonly string $name = 'default'
    ) {}

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

        // 调用支付方法
        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 taxPayment(array $params): mixed
    {
        // 确保参数中包含税费缴纳相关信息
        $params['tax'] = $params['tax'] ?? [];

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

    /**
     * 罚款缴纳
     */
    public function finePayment(array $params): mixed
    {
        // 确保参数中包含罚款缴纳相关信息
        $params['fine'] = $params['fine'] ?? [];

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

    /**
     * 证件办理费用缴纳
     */
    public function certificateFee(array $params): mixed
    {
        // 确保参数中包含证件办理费用缴纳相关信息
        $params['certificate'] = $params['certificate'] ?? [];

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

    /**
     * 社保费用缴纳
     */
    public function socialSecurityPayment(array $params): mixed
    {
        // 确保参数中包含社保费用缴纳相关信息
        $params['social_security'] = $params['social_security'] ?? [];

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

    /**
     * 医保费用缴纳
     */
    public function medicalInsurancePayment(array $params): mixed
    {
        // 确保参数中包含医保费用缴纳相关信息
        $params['medical_insurance'] = $params['medical_insurance'] ?? [];

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

    /**
     * 获取政府服务支付记录
     */
    public function getGovernmentRecords(string $userId): mixed
    {
        return Payment::query($this->paymentType, $userId, $this->name);
    }

    /**
     * 公共事业费用缴纳
     */
    public function utilityPayment(array $params): mixed
    {
        // 确保参数中包含公共事业费用缴纳相关信息
        $params['utility'] = $params['utility'] ?? [];

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