<?php


namespace app\shared\model;

use think\Model as ThinkModel;

class UserUv extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $name = 'shared_user_uv';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    static public function todayUv($acid=1,$type=1,$store_id=0,$user_id=0,$form_id=0){

    	if($user_id!=0){
    		$is_uv=self::where(['acid'=>$acid,'type'=>$type,'form_id'=>$form_id,'user_id'=>$user_id])->whereDay('create_time')->cache(10)->count();
    		if(!$is_uv){
    			(new self)->save([
    				'acid'=>$acid,
    				'type'=>$type,
                    'store_id'=>$store_id,
    				'user_id'=>$user_id,
    				'form_id'=>$form_id
    			]);
    		}
    	}
    }
}