IssueWorkLists.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\model\works\IssueWork;
  4. use app\common\lists\ListsSearchInterface;
  5. /**
  6. * IssueWork列表
  7. * Class IssueWorkLists
  8. * @package app\workerapi\listsworks
  9. */
  10. class IssueWorkLists extends BaseWorkerDataLists implements ListsSearchInterface
  11. {
  12. /**
  13. * @notes 设置搜索条件
  14. * @return \string[][]
  15. * @author whitef
  16. * @date 2024/07/10 15:06
  17. */
  18. public function setSearch(): array
  19. {
  20. return [
  21. '=' => ['work_sn', 'service_work_id', 'complaint_status', 'responsible', 'complaint_details', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time'],
  22. ];
  23. }
  24. public function querySearch(): array
  25. {
  26. $where['master_worker_id'] = ['=',$this->userId];
  27. return $where;
  28. }
  29. /**
  30. * @notes 获取列表
  31. * @return array
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @author whitef
  36. * @date 2024/07/10 15:06
  37. */
  38. public function lists(): array
  39. {
  40. return IssueWork::with(['service_work'=>function ($query) {
  41. $query->field(['id', 'work_sn', 'address', 'title', 'work_status', 'service_status', 'work_pay_status','appointment_time','receive_time','base_service_fee','service_fee'])->append(['work_status_text','service_status_text']);
  42. }])
  43. ->where($this->searchWhere)
  44. ->where($this->querySearch())
  45. ->where('issue_approval','>',0)
  46. ->field(['id', 'work_sn', 'service_work_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'complaint_images', 'finished_time', 'create_time', 'update_time'])
  47. ->append(['issue_approval_text'])
  48. ->limit($this->limitOffset, $this->limitLength)
  49. ->order(['id' => 'desc'])
  50. ->select()
  51. ->toArray();
  52. }
  53. /**
  54. * @notes 获取数量
  55. * @return int
  56. * @author whitef
  57. * @date 2024/07/10 15:06
  58. */
  59. public function count(): int
  60. {
  61. return IssueWork::where($this->searchWhere)->where($this->querySearch())->where('issue_approval','>',0)->count();
  62. }
  63. }