GroupServiceWorkController.php 6.1 KB

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