| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\workerapi\lists;
- use app\common\enum\YesNoEnum;
- use app\common\model\article\Article;
- use app\common\model\master_worker\MasterWorkerAccountLog;
- use app\common\model\works\ServiceWorkLog;
- /**
- * @author 林海涛
- * @date 2024/7/11 下午6:21
- */
- class MasterWorkerMessageLists extends BaseWorkerDataLists
- {
- public $count;
- public function queryWhere()
- {
- $where = [];
- $where[] = ['worker_id', '=', $this->userId];
- return $where;
- }
- public function lists():array
- {
- $msgType = $this->params['msg_type'];
- $where = [];
- $this->count = 0;
- $lists = [];
- switch ($msgType){
- case 1:
- $where[] = ['master_worker_id', '=', $this->userId];
- $where[] = ['show_type', '=', YesNoEnum::NO] ;
- if(ServiceWorkLog::where($where)->count() === 0){
- array_pop($where);
- }
- $lists = ServiceWorkLog::where($where)
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- $this->count = ServiceWorkLog::where($where)->count();
- break;
- case 3:
- $where[] = ['worker_id', '=', $this->userId];
- $where[] = ['show_type', '=', YesNoEnum::NO];
- if(MasterWorkerAccountLog::where($where)->count() === 0){
- array_pop($where);
- }
- $lists = MasterWorkerAccountLog::where($where)
- ->append(['action_text'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- $this->count = MasterWorkerAccountLog::where($where)->count();
- break;
- case 4:
- $where[] = ['is_show', '=', YesNoEnum::YES];
- Article::where($where)->count();
- $lists = Article::where($where)
- ->field('id,cid,title,desc,image,click_virtual,click_actual,create_time')
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- break;
- }
- return $lists;
- }
- public function count(): int
- {
- return $this->count;
- }
- }
|