<?php
/**
 * Created by PhpStorm.
 * User: shensong
 * Date: 2019/11/27
 * Time: 17:06
 */

namespace App;


use Illuminate\Database\Eloquent\Model;

class CustomerVip extends Model
{
    public $timestamps = false;
    protected $table = 'customer_vip';

    /**
     * 获取会员信息
     * @param $phone
     * @return mixed
     */
    public static function getCustomerInformation($phone){
        $self = new self();
        $date = date('Y-m-d');
        $info = $self->where('phone',$phone)->where('is_del',0)->where('vip_end_time','>=',$date)->first();
        return $info;
    }

    /**
     * 判断用户是否为会员
     * @param $phone
     * @return bool
     */
    public static function judgeWhetherTheUserIsAMember($phone){
        $info = CustomerVip::getCustomerInformation($phone);
        if(!$info || (strtotime($info->vip_end_time) < time())){
            return false;
        }
        return true;
    }
}