|
|
@@ -18,7 +18,7 @@ class UserShowTemplate extends Model
|
|
|
public function userBindTemp($id,$uid){
|
|
|
$count = $this->where("uid",$uid)->where("show_template_id",$id)->count();
|
|
|
if($count<=0){
|
|
|
- $ocount = $this->where("uid",$uid)->count();
|
|
|
+ $ocount = $this->where("uid",$uid)->where("is_default",1)->count();
|
|
|
$r = $this->insert([
|
|
|
"uid" => $uid,
|
|
|
"show_template_id" => $id,
|
|
|
@@ -29,6 +29,27 @@ class UserShowTemplate extends Model
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 设置初始化模板
|
|
|
+ * @param type $uid
|
|
|
+ */
|
|
|
+ public function userBindTempInit($uid){
|
|
|
+ $count = $this->where("uid",$uid)->where("is_init",1)->count();
|
|
|
+ if($count<=0){
|
|
|
+ $initTemp = $this->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,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|