MasterWorkerScheduleLists.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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\master_worker;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\master_worker\MasterWorker;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * MasterWorkerSchedule列表
  20. * Class MasterWorkerScheduleLists
  21. * @package app\adminapi\listsmaster_worker
  22. */
  23. class MasterWorkerScheduleLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. public $count = 0;
  26. /**
  27. * @notes 设置搜索条件
  28. * @return \string[][]
  29. * @author likeadmin
  30. * @date 2024/07/10 18:17
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '=' => ['mobile'],
  36. '%like%' => ['real_name']
  37. ];
  38. }
  39. public function queryWhere(){
  40. $where[] = ['type','=',2];
  41. return $where;
  42. }
  43. /**
  44. * @notes 获取列表
  45. * @return array
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\DbException
  48. * @throws \think\db\exception\ModelNotFoundException
  49. */
  50. public function lists(): array
  51. {
  52. $list = MasterWorker::with(['stopList'])->where($this->searchWhere)
  53. ->where($this->queryWhere())
  54. ->field(['id','real_name','mobile','avatar'])
  55. ->limit($this->limitOffset, $this->limitLength)
  56. ->order("id","desc")
  57. ->select()
  58. ->toArray();
  59. $stopList = [];
  60. foreach ($list as &$item) {
  61. foreach( $item['stopList'] as $v ) {
  62. $stopList[] = (int)date("d",strtotime($v['start_time']));
  63. $stopList[] = (int)date("d",strtotime($v['end_time']));
  64. }
  65. $item['stopList'] = array_values(array_unique($stopList));
  66. }
  67. return $list;
  68. }
  69. /**
  70. * @notes 获取数量
  71. * @return int
  72. * @author likeadmin
  73. * @date 2024/07/10 18:17
  74. */
  75. public function count(): int
  76. {
  77. return MasterWorker::where($this->searchWhere)
  78. ->where($this->queryWhere())
  79. ->count();
  80. }
  81. }