59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\common\dao\system\notice;
|
|
|
|
|
|
use app\common\dao\BaseDao;
|
|
use app\common\model\system\notice\SystemNoticeConfig;
|
|
|
|
class SystemNoticeConfigDao extends BaseDao
|
|
{
|
|
|
|
protected function getModel(): string
|
|
{
|
|
return SystemNoticeConfig::class;
|
|
}
|
|
|
|
|
|
public function getNoticeStatusByKey(string $key, string $field)
|
|
{
|
|
$value = $this->getModel()::getDb()->where('notice_key',$key)->value($field);
|
|
return $value == 1 ? true : false;
|
|
}
|
|
|
|
public function getNoticeStatusByConstKey(string $key)
|
|
{
|
|
$value = $this->getModel()::getDb()->where('const_key',$key)->field('notice_sys,notice_wechat,notice_routine,notice_sms')->find();
|
|
return $value;
|
|
}
|
|
|
|
public function search($where)
|
|
{
|
|
$query = $this->getModel()::getDb()
|
|
->when(isset($where['is_sms']) && $where['is_sms'] != '', function($query){
|
|
$query->whereIn('notice_sms',[0,1]);
|
|
})
|
|
->when(isset($where['is_routine']) && $where['is_routine'] != '', function($query){
|
|
$query->whereIn('notice_routine',[0,1]);
|
|
})
|
|
->when(isset($where['is_wechat']) && $where['is_wechat'] != '', function($query){
|
|
$query->whereIn('notice_wechat',[0,1]);
|
|
})
|
|
;
|
|
return $query;
|
|
}
|
|
|
|
public function getSubscribe()
|
|
{
|
|
$arr = [];
|
|
$res = $this->search([])->where(['notice_routine' => 1])->with(['routineTemplate'])->select()->toArray();
|
|
foreach ($res as $re) {
|
|
$arr[$re['const_key']] = $re['routineTemplate']['tempid'] ?? '';
|
|
}
|
|
return $arr;
|
|
}
|
|
}
|