WorksController.php 5.4 KB

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