where("uid",$uid)->where("show_template_id",$id)->count(); if($count<=0){ $ocount = $this->where("uid",$uid)->where("is_default",1)->count(); $r = $this->insert([ "uid" => $uid, "show_template_id" => $id, "start_time" => time(), "end_time" => time()+100*365*24*60*60,//100年 "is_default" => $ocount>0 ? 0 : 1, ]); } return true; } /** * 设置初始化模板 * @param type $uid */ public function userBindTempInit($uid){ $count = $this->where("uid",$uid)->where("is_init",1)->count(); if($count<=0){ $initTemp = (new ShowTemplate)->where("is_init",1)->find(); if(!empty($initTemp)){ $ocount = $this->where("uid",$uid)->where("is_default",1)->count(); $r = $this->insert([ "uid" => $uid, "show_template_id" => $initTemp->id, "start_time" => time(), "end_time" => time()+1000*365*24*60*60,//100年 "is_default" => $ocount>0 ? 0 : 1, "is_init" => 1, ]); } } } }