<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/28
 * Time: 17:20
 */
namespace app\index\model;

use think\Model;

class User extends Model
{
    public function findData($where){
        $data = $this->where($where)->find();
        if(!empty($data)){
            //判断是否为会员
            $is_vip = '2';
            if(!empty($data['vip_passtime'])){
                if($data['vip_passtime'] > time()){
                    $is_vip = "1";
                }
            }
            $is_svip = '2';
            if(!empty($data['svip_passtime'])){
                if($data['svip_passtime'] > time()){
                    $is_svip = "1";
                }
            }
            $data['is_vip'] = $is_vip;
            $data['is_svip'] = $is_svip;
        }
        return $data;
    }
    public function updateData($where,$data){
        $result = $this->where($where)->update($data);
        return $result;
    }
    public function insertData($data){
        $result = $this->insertGetId($data);
        return $result;
    }
    public function selectData($where){
        $where['status'] = ['eq',"normal"];
        $data = $this->where($where)->select();
        return $data;
    }
}