<?php

namespace Kylin\Payment\Scenarios;

use Kylin\Payment\Payment;

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

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

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

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

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

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

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

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

    /**
     * 装修押金支付
     */
    public function decorationDeposit(array $params): mixed
    {
        // 确保参数中包含装修押金相关信息
        $params['decoration_deposit'] = $params['decoration_deposit'] ?? [];

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

    /**
     * 获取房产缴费记录
     */
    public function getRealEstateRecords(string $userId): mixed
    {
        return Payment::query($this->paymentType, $userId, $this->name);
    }

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

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