<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Relations\HasOne;
use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $order_coupon_id 主键id
 * @property int $order_inquiry_id 订单-问诊id
 * @property int $user_coupon_id 用户优惠卷表
 * @property string $coupon_name 优惠卷名称
 * @property string $coupon_use_price 优惠卷使用金额
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class OrderInquiryCoupon extends Model
{
    use Snowflake;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'order_inquiry_coupon';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['order_coupon_id', 'order_inquiry_id', 'user_coupon_id', 'coupon_name', 'coupon_use_price', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['order_coupon_id' => 'string', 'order_inquiry_id' => 'string', 'user_coupon_id' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected string $primaryKey = "order_coupon_id";

    /**
     * 获取信息-单条
     * @param array $params
     * @param array $fields
     * @return object|null
     */
    public static function getOne(array $params, array $fields = ['*']): object|null
    {
        return self::where($params)->first($fields);
    }

    /**
     * 获取信息-多条
     * @param array $params
     * @param array $fields
     * @return object|null
     */
    public static function getList(array $params, array $fields = ['*']): object|null
    {
        return self::where($params)->get($fields);
    }

    /**
     * 新增
     * @param array $data
     * @return OrderInquiryCoupon|\Hyperf\Database\Model\Model
     */
    public static function addOrderInquiryCoupon(array $data): \Hyperf\Database\Model\Model|OrderInquiryCoupon
    {
        return self::create($data);
    }
}
