HistoryWorkLists.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\model\works\ServiceWork;
  4. /**
  5. * HistoryWork列表
  6. * Class HistoryWorkLists
  7. * @package app\workerapi\listsworks
  8. */
  9. class HistoryWorkLists extends BaseWorkerDataLists
  10. {
  11. protected $count = 0;
  12. /**
  13. * @notes 获取列表
  14. * @return array
  15. * @throws \think\db\exception\DataNotFoundException
  16. * @throws \think\db\exception\DbException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. * @author whitef
  19. * @date 2024/07/10 15:06
  20. */
  21. public function lists(): array
  22. {
  23. $where = [
  24. 'master_worker_id'=>$this->userId,
  25. 'approval'=>1,//派单的时候默认审核了
  26. 'service_status'=>$this->params['service_status'] ?? 3,
  27. ];
  28. //查询月数
  29. $create_month = !empty($this->params['create_month'])?$this->params['create_month']:date('Y-m');
  30. $list = ServiceWork::where($where)
  31. ->field(['id', 'work_sn', 'address', 'title', 'work_status', 'service_status','work_pay_status','finished_time','base_service_fee','service_fee','create_time'])
  32. ->append(['work_status_text','service_status_text'])
  33. ->whereMonth('create_time', $create_month)
  34. ->limit($this->limitOffset, $this->limitLength)
  35. ->order(['id' => 'desc'])
  36. ->select()
  37. ->toArray();
  38. $this->count = ServiceWork::where($where)->whereMonth('create_time', $create_month)->count();
  39. return $list;
  40. }
  41. /**
  42. * @notes 获取数量
  43. * @return int
  44. * @author whitef
  45. * @date 2024/07/10 15:06
  46. */
  47. public function count(): int
  48. {
  49. return $this->count;
  50. }
  51. }