MasterWorkerMessageLists.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\enum\YesNoEnum;
  4. use app\common\model\article\Article;
  5. use app\common\model\master_worker\MasterWorkerAccountLog;
  6. use app\common\model\works\ServiceWorkLog;
  7. /**
  8. * @author 林海涛
  9. * @date 2024/7/11 下午6:21
  10. */
  11. class MasterWorkerMessageLists extends BaseWorkerDataLists
  12. {
  13. public $count;
  14. public function queryWhere()
  15. {
  16. $where = [];
  17. $where[] = ['worker_id', '=', $this->userId];
  18. return $where;
  19. }
  20. public function lists():array
  21. {
  22. $msgType = $this->params['msg_type'];
  23. $where = [];
  24. $this->count = 0;
  25. $lists = [];
  26. switch ($msgType){
  27. case 1:
  28. $where[] = ['master_worker_id', '=', $this->userId];
  29. $where[] = ['show_type', '=', YesNoEnum::NO];
  30. $lists = ServiceWorkLog::where($where)
  31. ->limit($this->limitOffset, $this->limitLength)
  32. ->order(['id' => 'desc'])
  33. ->select()
  34. ->toArray();
  35. $this->count = ServiceWorkLog::where($where)->count();
  36. break;
  37. case 3:
  38. $where[] = ['worker_id', '=', $this->userId];
  39. $where[] = ['show_type', '=', YesNoEnum::NO];
  40. $lists = MasterWorkerAccountLog::where($where)
  41. ->append(['action_text'])
  42. ->limit($this->limitOffset, $this->limitLength)
  43. ->order(['id' => 'desc'])
  44. ->select()
  45. ->toArray();
  46. $this->count = MasterWorkerAccountLog::where($where)->count();
  47. break;
  48. case 4:
  49. $where[] = ['is_show', '=', YesNoEnum::YES];
  50. Article::where($where)->count();
  51. $lists = Article::where($where)
  52. ->field('id,cid,title,desc,image,click_virtual,click_actual,create_time')
  53. ->limit($this->limitOffset, $this->limitLength)
  54. ->order(['id' => 'desc'])
  55. ->select()
  56. ->toArray();
  57. break;
  58. }
  59. return $lists;
  60. }
  61. public function count(): int
  62. {
  63. return $this->count;
  64. }
  65. }