<?php

namespace Kylin\Payment\Scenarios;

use Kylin\Payment\Payment;

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

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

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

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

    /**
     * 课程报名
     */
    public function courseEnroll(array $params): mixed
    {
        // 确保参数中包含课程报名相关信息
        $params['course'] = $params['course'] ?? [];

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

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

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

    /**
     * 获取学生缴费记录
     */
    public function getStudentPaymentRecords(string $studentId): mixed
    {
        return Payment::query($this->paymentType, $studentId, $this->name);
    }

    /**
     * 批量缴费
     */
    public function batch(array $params): mixed
    {
        // 确保参数中包含批量缴费相关信息
        $params['batch'] = $params['batch'] ?? [];

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