WorksController.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\adminapi\logic\works\ServiceWorkLogic;
  4. use app\common\model\works\IssueWork;
  5. use app\common\model\works\ReturnWork;
  6. use app\common\model\works\ServiceWork;
  7. use app\workerapi\lists\HistoryWorkLists;
  8. use app\workerapi\lists\ServiceAssignWorkLists;
  9. use app\workerapi\lists\ServiceWorkLists;
  10. use app\workerapi\validate\ServiceWorkValidate;
  11. /**
  12. * 工单系统
  13. */
  14. class WorksController extends BaseApiController
  15. {
  16. /**
  17. * 首页数量统计
  18. * @return \think\response\Json
  19. * @throws \think\db\exception\DbException
  20. */
  21. public function statistics()
  22. {
  23. $result['service_work_count'] = ServiceWork::where(['master_worker_id'=>$this->userId])->whereIn('service_status','0,1,2')->where('work_status','<>',1)->count();
  24. $result['assign_work_count'] = ServiceWork::where(['master_worker_id'=>$this->userId,'work_status'=>1])->count();
  25. $result['pick_work_count'] = 0;
  26. $result['return_work_count'] = ReturnWork::where(['master_worker_id'=>$this->userId])->where('return_work_status','<>',2)->count();
  27. $result['issue_work_count'] = IssueWork::where(['master_worker_id'=>$this->userId])->where('issue_approval','<>',4)->count();
  28. $result['review_work_count'] = ServiceWork::where(['master_worker_id'=>$this->userId,'work_status'=>7])->count();
  29. return $this->data($result);
  30. }
  31. /**
  32. * 服务工单列表-全部
  33. * @return \think\response\Json
  34. */
  35. public function serviceWorkList()
  36. {
  37. return $this->dataLists(new ServiceWorkLists());
  38. }
  39. /**
  40. * 派单
  41. * @return \think\response\Json
  42. */
  43. public function assignWorkList()
  44. {
  45. return $this->dataLists(new ServiceAssignWorkLists());
  46. }
  47. /**
  48. * 历史工单
  49. * @return \think\response\Json
  50. */
  51. public function historyWorkList()
  52. {
  53. return $this->dataLists(new HistoryWorkLists());
  54. }
  55. /**
  56. * 领取服务单
  57. * @return \think\response\Json
  58. */
  59. public function pickWork()
  60. {
  61. $params = (new ServiceWorkValidate())->post()->goCheck('pick', [
  62. 'user_id' => $this->userId,
  63. 'user_info' => $this->userInfo
  64. ]);
  65. $result = ServiceWorkLogic::pickWork($params);
  66. if (false === $result) {
  67. return $this->fail(ServiceWorkLogic::getError());
  68. }
  69. return $this->success('领取成功', [], 1, 1);
  70. }
  71. /**
  72. * 工单详情
  73. * @return \think\response\Json
  74. */
  75. public function detail()
  76. {
  77. $params = (new ServiceWorkValidate())->goCheck('detail',[
  78. 'user_id' => $this->userId,
  79. ]);
  80. $result = ServiceWorkLogic::detail($params);
  81. if (false === $result) {
  82. return $this->fail(ServiceWorkLogic::getError());
  83. }
  84. return $this->data($result);
  85. }
  86. /**
  87. * 预约上门
  88. * @return \think\response\Json
  89. */
  90. public function appointWork()
  91. {
  92. $params = (new ServiceWorkValidate())->post()->goCheck('appoint', [
  93. 'user_id' => $this->userId,
  94. 'user_info' => $this->userInfo
  95. ]);
  96. $result = ServiceWorkLogic::appointWork($params);
  97. if (false === $result) {
  98. return $this->fail(ServiceWorkLogic::getError());
  99. }
  100. return $this->success('预约成功,等待上门', [], 1, 1);
  101. }
  102. /**
  103. * 师傅确认上门
  104. * @return \think\response\Json
  105. */
  106. public function confirmDoor()
  107. {
  108. $params = (new ServiceWorkValidate())->post()->goCheck('door', [
  109. 'user_id' => $this->userId,
  110. 'user_info' => $this->userInfo
  111. ]);
  112. $result = ServiceWorkLogic::confirmDoor($params);
  113. if (false === $result) {
  114. return $this->fail(ServiceWorkLogic::getError());
  115. }
  116. return $this->success('操作成功,师傅已上门', [], 1, 1);
  117. }
  118. /**
  119. * 师傅确认报价单
  120. * @return \think\response\Json
  121. */
  122. public function confirmPrice()
  123. {
  124. $params = (new ServiceWorkValidate())->post()->goCheck('price', [
  125. 'user_id' => $this->userId,
  126. 'user_info' => $this->userInfo
  127. ]);
  128. $result = ServiceWorkLogic::confirmPrice($params);
  129. if (false === $result) {
  130. return $this->fail(ServiceWorkLogic::getError());
  131. }
  132. return $this->success('操作成功,师傅已填写报价单,等待用户确认中', [], 1, 1);
  133. }
  134. /**
  135. * 师傅确认服务完成
  136. * @return \think\response\Json
  137. */
  138. public function confirmServiceFinish()
  139. {
  140. $params = (new ServiceWorkValidate())->post()->goCheck('finished', [
  141. 'user_id' => $this->userId,
  142. 'user_info' => $this->userInfo
  143. ]);
  144. $result = ServiceWorkLogic::confirmServiceFinish($params);
  145. if (false === $result) {
  146. return $this->fail(ServiceWorkLogic::getError());
  147. }
  148. return $this->success('操作成功,师傅已确认服务完成,等待用户确认中', [], 1, 1);
  149. }
  150. }