HistoryWorkLists.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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[] = ['master_worker_id','=',$this->userId];
  26. $where[] = ['approval','=',1];
  27. $where[] = ['service_status','in',$service_status];
  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','work_total','create_time','work_amount'])
  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. }