GroupServiceWorkLists.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\model\works\GroupServiceWork;
  4. use app\common\lists\ListsSearchInterface;
  5. use DateTime;
  6. /**
  7. * GroupServiceWork列表
  8. * Class GroupServiceWorkLists
  9. * @package app\workerapi\listsworks
  10. */
  11. class GroupServiceWorkLists extends BaseWorkerDataLists implements ListsSearchInterface
  12. {
  13. protected $count = 0;
  14. public function setSearch(): array
  15. {
  16. return [];
  17. }
  18. /**
  19. * @notes 获取列表
  20. * @return array
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\DbException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. * @author whitef
  25. * @date 2024/07/10 15:06
  26. */
  27. public function lists(): array
  28. {
  29. $where = [
  30. 'master_worker_id'=>$this->userId,
  31. ];
  32. //条件搜索
  33. $status = $this->params['status'] ?? 0;
  34. switch ($status){
  35. case 0:
  36. //今日上门
  37. $startOfDayTimestamp = strtotime(date("Y-m-d"));
  38. $endOfDayTimestamp = strtotime(date("Y-m-d 23:59:59"));
  39. $where[] = ['appointment_time','between',[$startOfDayTimestamp, $endOfDayTimestamp]];
  40. break;
  41. case 1:
  42. //待完成
  43. $where[] = ['work_status','<>',1];
  44. $where[] = ['service_status','in','0,1,2'];
  45. break;
  46. case 2:
  47. //已完成
  48. $where[] = ['service_status','=','3'];
  49. break;
  50. }
  51. $list = GroupServiceWork::where($where)
  52. ->field(['id', 'work_sn', 'address', 'title', 'work_status', 'service_status','appointment_time','remark'])
  53. ->append(['work_status_text','service_status_text'])
  54. ->limit($this->limitOffset, $this->limitLength)
  55. ->order(['appointment_time' => 'asc'])//上门时间排序
  56. ->select()
  57. ->toArray();
  58. $this->count = GroupServiceWork::where($where)->count();
  59. return $list;
  60. }
  61. /**
  62. * @notes 获取数量
  63. * @return int
  64. * @author whitef
  65. * @date 2024/07/10 15:06
  66. */
  67. public function count(): int
  68. {
  69. return $this->count;
  70. }
  71. }