MasterWorkerScheduleLists.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. foreach ($list as &$item) {
  60. $stopList = [];
  61. foreach( $item['stopList'] as $v ) {
  62. $min = (int)date("d",strtotime($v['start_time']));
  63. $max = (int)date("d",strtotime($v['end_time']));
  64. $stopList = array_merge($stopList,range($min,$max));
  65. }
  66. $item['stopList'] = array_values(array_unique($stopList));
  67. }
  68. return $list;
  69. }
  70. /**
  71. * @notes 获取数量
  72. * @return int
  73. * @author likeadmin
  74. * @date 2024/07/10 18:17
  75. */
  76. public function count(): int
  77. {
  78. return MasterWorker::where($this->searchWhere)
  79. ->where($this->queryWhere())
  80. ->count();
  81. }
  82. }