'超管可见', '2' => '超管、普管、客服、运营可见', '3' => '超管、普管、渠道商、客服、运营可见', '4' => '超管、普管、渠道商、代理商、客服、运营可见','5' => '代理商、客服、运营可见']; } public function getDialogTypeList() { return ['1' => '只弹一次', '2' => '每次登陆', '3' => '每天一次', '4' => '不弹窗','5'=>'自定义']; } public function getNoticeTypeList() { return ['1' => '常规公告', '2' => '新书推荐', '3' => '活动通知']; } public function getStatusList() { return ['normal' => '显示', 'hidden' => '隐藏']; } public function getImportantTypeList(){ return ['0' => '普通', '1' => '标题标红']; } public function getShowLevelTextAttr($value, $data) { $value = $value ? $value : $data['show_level']; $list = $this->getShowLevelList(); return isset($list[$value]) ? $list[$value] : ''; } public function getDialogTypeTextAttr($value, $data) { $value = $value ? $value : $data['dialog_type']; $list = $this->getDialogTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getNoticeTypeTextAttr($value, $data) { $value = $value ? $value : $data['notice_type']; $list = $this->getNoticeTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : $data['status']; $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } /** * 获取需要弹窗的公告ID * @return int */ public function dialog($admin_id) { //级别过滤 $group = model("AuthGroupAccess")->getGroupId($admin_id); // $showlevel = []; // switch ($group){ // case 1://超管 // $showlevel = [1,2,3,4]; // break; // case 2://普管 // $showlevel = [2,3,4]; // break; // case 3://渠道商 // $showlevel = [3,4]; // break; // case 4://代理商 // $showlevel = [4,5]; // break; // case 5://客服 // $showlevel = [2,3,4,5]; // break; // case 6://运营 // $showlevel = [2,3,4,5]; // break; // } $n2Sql = $this ->alias('n') ->join('notice_log l', "n.dialog_type='1' and n.id=l.notice_id and l.admin_id='{$admin_id}'", 'left') ->field('n.id,l.admin_id') ->buildSql(); $n3Sql = $this ->alias('n') ->join('notice_log l', "n.dialog_type='3' and n.id=l.notice_id and l.admin_id='{$admin_id}' and l.createtime>" . strtotime(date('Y-m-d 00:00:00')), 'left') ->field('n.id,l.admin_id') ->buildSql(); $result = $this ->alias('n1') ->join($n2Sql . ' n2', "n1.id=n2.id and n2.admin_id IS NULL", 'inner') ->join($n3Sql . ' n3', "n1.id=n3.id and n3.admin_id IS NULL", 'inner') ->where('status', 'normal') ->where('dialog_type',"neq", '4') // ->where("show_level","in",$showlevel) ->field('n1.id,n1.groups,n1.pop_num,n1.dialog_type') ->order('id', 'desc') // ->limit(1) ->select(); //计算自定义公告当天弹窗的次数 $dialog5 = $this ->alias('n2') ->join("notice_log l2","n2.id=l2.notice_id and l2.admin_id='{$admin_id}' and l2.createtime>" . strtotime(date('Y-m-d 00:00:00')),'inner') ->where('n2.dialog_type=5') ->field('l2.notice_id,count(1) num') ->group('l2.notice_id') ->select(); if (!empty($dialog5)){ $dialog5 = array_column($dialog5,null,'notice_id'); } foreach ($result as $v){ if(strpos($v['groups'],(string)$group)!==false){ if ($v['dialog_type'] == 5 && !empty($dialog5) && isset($dialog5[$v['id']]) && $dialog5[$v['id']]['num']>=$v['pop_num']){ continue; } return $v['id']; }else{ continue; } } return null; } }