<?php
namespace app\service\model;

use think\Model;

class Services extends Model
{
    //检测token
    function checktoken($token){
        $user = db('users')->where('token', $token)->find();
        if(!empty($user)){
            $time = time()-$user['expire_time'];
            if($time<3600){
                db('users')->where('id', $user['id'])->update(['expire_time' => time()]);
                $user_id = explode('/',base64_decode($token))['2'];
                return $user_id;
            }else{
                return -1;
            }
        }
        return -1;
    }

}
