TeamServiceWorkLists.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\lists\ListsExtendInterface;
  4. use app\common\model\master_worker\MasterWorker;
  5. use app\common\model\works\ServiceWork;
  6. use app\common\lists\ListsSearchInterface;
  7. use app\workerapi\logic\MasterWorkerTeamLogic;
  8. use DateTime;
  9. /**
  10. * ServiceWork列表
  11. * Class ServiceWorkLists
  12. * @package app\workerapi\listsworks
  13. */
  14. class TeamServiceWorkLists extends BaseWorkerDataLists implements ListsExtendInterface
  15. {
  16. protected $count = 0;
  17. public function queryWhere(){
  18. $where = [
  19. 'approval'=>1,
  20. 'master_worker_id'=>['in',implode(',',MasterWorker::where('team_id', $this->userInfo['team_id'])->column('id')?:[-1])]
  21. ];
  22. // 待领单、待联系、待上门、已上门、服务中、待结算、已完结、已评价、已取消
  23. // 1=待领单,2=待联系,3=待上门,4=已上门,5=服务中,6=待结算,7=已完结,8=已评价,9=已退
  24. if(isset($this->params['work_status']) && !empty($this->params['work_status'])){
  25. $where['work_status'] = ['=', $this->params['work_status']];
  26. }
  27. if(isset($this->params['create_time']) && !empty($this->params['create_time'])){
  28. $where[] = ['create_time', 'between', [strtotime($this->params['create_time']), strtotime($this->params['create_time'])+86400-1]];
  29. }
  30. if(isset($this->params['team_work_type']) && !empty($this->params['team_work_type'])){
  31. /* 挂起订单=主管工程师未联系的工单(未分配、待领单)
  32. 超时未领单=分配给其他工程师后未领单的工单(已分配、待领单)
  33. 异常预约=其他工程师未联系的工单(已分配、待联系)
  34. 超时未服务=其他工程师未上门的工单(已分配、待上门)
  35. */
  36. switch ($this->params['team_work_type']){
  37. case 1: // 挂起订单
  38. $where['master_worker_id'] = $this->userInfo['user_id'];
  39. $where['work_status'] = ['=',1];
  40. break;
  41. case 2: // 超时未领单
  42. $where['work_status'] = ['=',1];
  43. break;
  44. case 3: // 异常预约
  45. $where['work_status'] = ['=',2];
  46. break;
  47. case 4: // 超时未服务
  48. $where['work_status'] = ['=',3];
  49. break;
  50. }
  51. }
  52. return $where;
  53. }
  54. /**
  55. * @notes 获取列表
  56. */
  57. public function lists(): array
  58. {
  59. $list = ServiceWork::where($this->queryWhere())
  60. ->field('*')
  61. ->limit($this->limitOffset, $this->limitLength)
  62. ->order(['appointment_time' => 'asc'])
  63. ->select()
  64. ->toArray();
  65. $this->count = ServiceWork::where($this->queryWhere())->count();
  66. return $list;
  67. }
  68. /**
  69. * @notes 获取数量
  70. * @return int
  71. * @author whitef
  72. * @date 2024/07/10 15:06
  73. */
  74. public function count(): int
  75. {
  76. return $this->count;
  77. }
  78. public function extend(): array
  79. {
  80. //$day_data = MasterWorkerTeamLogic::TeamOrderStatistics($this->userInfo,60);
  81. return [];
  82. }
  83. }