ServiceWorkController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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\controller\works;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\works\ServiceWorkLists;
  17. use app\adminapi\logic\works\ServiceWorkLogic;
  18. use app\adminapi\validate\works\ServiceWorkValidate;
  19. /**
  20. * ServiceWork控制器
  21. * Class WorksController
  22. * @package app\adminapi\controller\works
  23. */
  24. class ServiceWorkController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 获取列表
  28. * @return \think\response\Json
  29. * @author likeadmin
  30. * @date 2024/07/10 15:06
  31. */
  32. public function lists()
  33. {
  34. return $this->dataLists(new ServiceWorkLists());
  35. }
  36. /**
  37. * @notes 添加
  38. * @return \think\response\Json
  39. * @author likeadmin
  40. * @date 2024/07/10 15:06
  41. */
  42. public function add()
  43. {
  44. $params = (new ServiceWorkValidate())->post()->goCheck('add');
  45. $result = ServiceWorkLogic::add($params);
  46. if (true === $result) {
  47. return $this->success('添加成功', [], 1, 1);
  48. }
  49. return $this->fail(ServiceWorkLogic::getError());
  50. }
  51. /**
  52. * @notes 编辑
  53. * @return \think\response\Json
  54. * @author likeadmin
  55. * @date 2024/07/10 15:06
  56. */
  57. public function edit()
  58. {
  59. $params = (new ServiceWorkValidate())->post()->goCheck('edit');
  60. $workDetail = ServiceWorkLogic::detail($params);
  61. $result = ServiceWorkLogic::edit($params);
  62. if (true === $result) {
  63. if(strtotime($workDetail['appointment_time']) !== strtotime($params['appointment_time'])){
  64. // 修改预约时间通知【给用户的通知】
  65. $res = event('Notice', [
  66. 'scene_id' => 117,
  67. 'params' => [
  68. 'user_id' => $workDetail['user_id']
  69. ]
  70. ]);
  71. // 修改预约时间通知【给工程师的通知,仅限公众号】
  72. $res = event('Notice', [
  73. 'scene_id' => 118,
  74. 'params' => [
  75. 'user_id' => $workDetail['master_worker_id'],
  76. 'thing4' => $workDetail['title'],
  77. 'time5' => $workDetail['appointment_time'],
  78. 'time6' => $params['appointment_time'],
  79. 'thing11' => $workDetail['address'],
  80. 'phone_number8' => $workDetail['mobile'],
  81. ]
  82. ]);
  83. }
  84. return $this->success('编辑成功', [], 1, 1);
  85. }
  86. return $this->fail(ServiceWorkLogic::getError());
  87. }
  88. /**
  89. * @notes 删除
  90. * @return \think\response\Json
  91. * @author likeadmin
  92. * @date 2024/07/10 15:06
  93. */
  94. public function delete()
  95. {
  96. $params = (new ServiceWorkValidate())->post()->goCheck('delete');
  97. $result = ServiceWorkLogic::edit($params);
  98. if (true === $result) {
  99. return $this->success('编辑成功', [], 1, 1);
  100. }
  101. return $this->success('分配成功', [], 1, 1);
  102. }
  103. /**
  104. * @notes 获取详情
  105. * @return \think\response\Json
  106. * @author likeadmin
  107. * @date 2024/07/10 15:06
  108. */
  109. public function detail()
  110. {
  111. $params = (new ServiceWorkValidate())->goCheck('detail');
  112. $result = ServiceWorkLogic::detail($params);
  113. return $this->data($result);
  114. }
  115. public function allocateWorker()
  116. {
  117. $params = (new ServiceWorkValidate())->post()->goCheck('allocateWorker');
  118. $result = ServiceWorkLogic::allocateWorker($params,$this->adminInfo);
  119. if (true === $result) {
  120. // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
  121. $workDetail = ServiceWorkLogic::detail($params);
  122. $res = event('Notice', [
  123. 'scene_id' => 113,
  124. 'params' => [
  125. 'user_id' => $params['master_worker_id'],
  126. 'thing9' => $workDetail['title'],
  127. 'time7' => $workDetail['appointment_time'],
  128. 'thing8' => $workDetail['address'],
  129. 'phone_number6' => $workDetail['mobile'],
  130. ]
  131. ]);
  132. return $this->success('分配工程师成功', [], 1, 1);
  133. }
  134. return $this->fail(ServiceWorkLogic::getError());
  135. }
  136. public function cancelWorker()
  137. {
  138. $params = (new ServiceWorkValidate())->post()->goCheck('detail');
  139. $result = ServiceWorkLogic::cancel($params);
  140. if (true === $result) {
  141. return $this->success('取消工单成功!', [], 1, 1);
  142. }
  143. return $this->fail(ServiceWorkLogic::getError());
  144. }
  145. public function settlementMaster()
  146. {
  147. $params = (new ServiceWorkValidate())->post()->goCheck('detail');
  148. $result = ServiceWorkLogic::settlement($params);
  149. if (true === $result) {
  150. return $this->success('操作成功!', [], 1, 1);
  151. }
  152. return $this->fail(ServiceWorkLogic::getError());
  153. }
  154. }