ServiceWorkAppointmentLists.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\works;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\works\ServiceWorkAppointmentLog;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * ServiceWorkAppointment列表
  20. * Class ServiceWorkAppointmentLists
  21. * @package app\adminapi\lists
  22. */
  23. class ServiceWorkAppointmentLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2025/05/04 15:41
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['work_id'],
  35. ];
  36. }
  37. public function queryWhere(){
  38. $where = [];
  39. if (isset($this->params['status']) ) {
  40. if ($this->params['status'] == 0) {
  41. $where[] = ["a.status", "=", 0];
  42. } else {
  43. $where[] = ["a.status", "<>", 1];
  44. }
  45. }
  46. if (!empty($this->params['real_name'])) {
  47. $where[] = ["b.real_name", "like", '%' . $this->params['real_name'] . '%'];
  48. }
  49. return $where;
  50. }
  51. /**
  52. * @notes 获取列表
  53. * @return array
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\DbException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. * @author likeadmin
  58. * @date 2025/05/04 15:41
  59. */
  60. public function lists(): array
  61. {
  62. return ServiceWorkAppointmentLog::alias("a")
  63. ->leftJoin("master_worker b","a.worker_id = b.id")
  64. ->where($this->searchWhere)
  65. ->where($this->queryWhere())
  66. ->field(['a.id', 'a.work_id', 'a.worker_id', 'a.last_appointment_time', 'a.this_appointment_time', 'a.status', 'a.create_time','b.real_name'])
  67. ->limit($this->limitOffset, $this->limitLength)
  68. ->order(['a.id' => 'desc'])
  69. ->select()
  70. ->toArray();
  71. }
  72. /**
  73. * @notes 获取数量
  74. * @return int
  75. * @author likeadmin
  76. * @date 2025/05/04 15:41
  77. */
  78. public function count(): int
  79. {
  80. return ServiceWorkAppointmentLog::alias("a")
  81. ->leftJoin("master_worker b","a.worker_id = b.id")
  82. ->where($this->searchWhere)
  83. ->where($this->queryWhere())
  84. ->count();
  85. }
  86. }