1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- declare (strict_types = 1);
- namespace app\model\api;
- use app\model\api\ShowTemplate;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class UserShowTemplate extends Model
- {
- /**
- * 用户绑定名片模板
- * @param type $id
- * @param type $uid
- */
- public function userBindTemp($id,$uid){
- $count = $this->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,
- ]);
- }
- }
- }
-
-
- }
|