<?php

namespace App\Models\Log;

use App\Models\Model;

/**
 * *
 *  * Class VipLogModel
 *  * @package App\Models\Log
 *  * @method renewalSupvip(int $uid, int $day)
 *  * @method openSupvip(int $uid, int $day)
 *  * @method openVip(int $uid)
 *  * @method closeVip(int $uid)
 *
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Log\VipLogModel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Log\VipLogModel newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Log\VipLogModel query()
 * @mixin \Eloquent
 */
class VipLogModel extends Model
{
    protected $connection = "mysql_datalog";

    protected $table = "kdgx_vip_logs";

    public $timestamps = false;

    protected $fillable = ['id', 'created_at', 'uid', 'log', 'day'];

    /**
     * @param  string  $method
     * @param  array  $params
     * @return mixed
     */
    public static function __callStatic($method, $params)
    {
        return call_user_func_array([new VipLogModel(), "p{$method}"], $params);
    }

    /**
     * 记录激活普通会籍
     * @param  int  $uid
     */
    private function popenVip(int $uid)
    {
        $this->fill([
            'created_at' => time(),
            'uid' => $uid,
            'log' => "激活会籍"
        ])->save();
    }

    /**
     * 记录取消普通会籍
     * @param  int  $uid
     */
    private function pcloseVip(int $uid)
    {
        $this->fill([
            'created_at' => time(),
            'uid' => $uid,
            'log' => "取消会籍"
        ])->save();
    }

    /**
     * 记录开通超级会员
     * @param  int  $uid
     * @param  int  $day
     */
    private function popenSupvip(int $uid, int $day)
    {
        $this->fill([
            'created_at' => time(),
            'uid' => $uid,
            'log' => "开通超级会员",
            'day' => $day
        ])->save();
    }

    /**
     * 记录续费超级会员
     * @param  int  $uid
     * @param  int  $day
     */
    private function prenewalSupvip(int $uid, int $day)
    {
        $this->fill([
            'created_at' => time(),
            'uid' => $uid,
            'log' => "续费超级会员",
            'day' => $day
        ])->save();
    }
}
