GroupServiceWorkLists.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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[] = ['work_status','=',3];
  40. $where[] = ['appointment_time','between',[$startOfDayTimestamp, $endOfDayTimestamp]];
  41. break;
  42. case 1:
  43. //待完成
  44. $where[] = ['work_status','<>',1];
  45. $where[] = ['service_status','in','0,1,2'];
  46. break;
  47. case 2:
  48. //已完成
  49. $where[] = ['service_status','=','3'];
  50. break;
  51. }
  52. $list = GroupServiceWork::where($where)
  53. ->field(['id', 'work_sn', 'address', 'title', 'work_status', 'service_status','appointment_time'])
  54. ->append(['work_status_text','service_status_text'])
  55. ->limit($this->limitOffset, $this->limitLength)
  56. ->order(['appointment_time' => 'asc'])//上门时间排序
  57. ->select()
  58. ->toArray();
  59. $this->count = GroupServiceWork::where($where)->count();
  60. return $list;
  61. }
  62. /**
  63. * @notes 获取数量
  64. * @return int
  65. * @author whitef
  66. * @date 2024/07/10 15:06
  67. */
  68. public function count(): int
  69. {
  70. return $this->count;
  71. }
  72. }