MasterWorkerMessageLists.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. if(ServiceWorkLog::where($where)->count() === 0){
  31. array_pop($where);
  32. }
  33. $lists = ServiceWorkLog::where($where)
  34. ->limit($this->limitOffset, $this->limitLength)
  35. ->order(['id' => 'desc'])
  36. ->select()
  37. ->toArray();
  38. $this->count = ServiceWorkLog::where($where)->count();
  39. break;
  40. case 3:
  41. $where[] = ['worker_id', '=', $this->userId];
  42. $where[] = ['show_type', '=', YesNoEnum::NO];
  43. if(MasterWorkerAccountLog::where($where)->count() === 0){
  44. array_pop($where);
  45. }
  46. $lists = MasterWorkerAccountLog::where($where)
  47. ->append(['action_text'])
  48. ->limit($this->limitOffset, $this->limitLength)
  49. ->order(['id' => 'desc'])
  50. ->select()
  51. ->toArray();
  52. $this->count = MasterWorkerAccountLog::where($where)->count();
  53. break;
  54. case 4:
  55. $where[] = ['is_show', '=', YesNoEnum::YES];
  56. Article::where($where)->count();
  57. $lists = Article::where($where)
  58. ->field('id,cid,title,desc,image,click_virtual,click_actual,create_time')
  59. ->limit($this->limitOffset, $this->limitLength)
  60. ->order(['id' => 'desc'])
  61. ->select()
  62. ->toArray();
  63. break;
  64. }
  65. return $lists;
  66. }
  67. public function count(): int
  68. {
  69. return $this->count;
  70. }
  71. }