HistoryWorkLists.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. $service_status = $this->params['service_status'] ?? 3;
  24. $service_status = $service_status == 4 ? '4,5':$service_status;
  25. $where = [
  26. 'master_worker_id'=>$this->userId,
  27. 'approval'=>1,//派单的时候默认审核了
  28. ];
  29. $where['service_status'] = ['in',$service_status];
  30. //查询月数
  31. $create_month = !empty($this->params['create_month'])?$this->params['create_month']:date('Y-m');
  32. $list = ServiceWork::where($where)
  33. ->field(['id', 'work_sn', 'address', 'title', 'work_status', 'service_status','work_pay_status','finished_time','base_service_fee','service_fee','work_total','create_time','work_amount'])
  34. ->append(['work_status_text','service_status_text'])
  35. ->whereMonth('create_time', $create_month)
  36. ->limit($this->limitOffset, $this->limitLength)
  37. ->order(['id' => 'desc'])
  38. ->select()
  39. ->toArray();
  40. $this->count = ServiceWork::where($where)->whereMonth('create_time', $create_month)->count();
  41. return $list;
  42. }
  43. /**
  44. * @notes 获取数量
  45. * @return int
  46. * @author whitef
  47. * @date 2024/07/10 15:06
  48. */
  49. public function count(): int
  50. {
  51. return $this->count;
  52. }
  53. }