1
0

ServiceOrderController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\lists\recharge\ServiceOrderLists;
  4. use app\api\logic\ServiceOrderLogic;
  5. use app\api\validate\ServiceOrderValidate;
  6. use think\facade\Log;
  7. /**
  8. * 订单类
  9. */
  10. class ServiceOrderController extends BaseApiController
  11. {
  12. /**
  13. * 订单列表
  14. * @return \think\response\Json
  15. */
  16. public function lists()
  17. {
  18. return $this->dataLists(new ServiceOrderLists());
  19. }
  20. /**
  21. * 订单详情
  22. * @return \think\response\Json
  23. */
  24. public function detail()
  25. {
  26. $params = (new ServiceOrderValidate())->goCheck('detail',[
  27. 'user_id' => $this->userId,
  28. ]);
  29. $result = ServiceOrderLogic::detail($params);
  30. if (false === $result) {
  31. return $this->fail(ServiceOrderLogic::getError());
  32. }
  33. return $this->data($result);
  34. }
  35. public function getMasterWorker()
  36. {
  37. $params = (new ServiceOrderValidate())->goCheck('worker',[
  38. 'user_id' => $this->userId,
  39. ]);
  40. $result = ServiceOrderLogic::getMasterWorker($params);
  41. if (false === $result) {
  42. return $this->fail(ServiceOrderLogic::getError());
  43. }
  44. return $this->data($result);
  45. }
  46. /**
  47. * 提交订单
  48. * @return \think\response\Json
  49. */
  50. public function submitOrder()
  51. {
  52. $params = (new ServiceOrderValidate())->post()->goCheck('add', [
  53. 'user_id' => $this->userId,
  54. 'terminal' => $this->userInfo['terminal'],
  55. 'user_info' => $this->userInfo
  56. ]);
  57. Log::write(json_encode($params,JSON_UNESCAPED_UNICODE));
  58. $result = ServiceOrderLogic::submitOrder($params);
  59. if (false === $result) {
  60. return $this->fail(ServiceOrderLogic::getError());
  61. }
  62. return $this->data($result);
  63. }
  64. /**
  65. * 取消订单
  66. * @return \think\response\Json
  67. */
  68. public function cancelOrder()
  69. {
  70. $params = (new ServiceOrderValidate())->post()->goCheck('cancel', [
  71. 'user_id' => $this->userId,
  72. 'terminal' => $this->userInfo['terminal'],
  73. 'user_info' => $this->userInfo
  74. ]);
  75. $result = ServiceOrderLogic::cancelOrder($params);
  76. if (false === $result) {
  77. return $this->fail(ServiceOrderLogic::getError());
  78. }
  79. return $this->success('取消成功', [], 1, 1);
  80. }
  81. /**
  82. * 确认报价订单
  83. * @return \think\response\Json
  84. */
  85. public function confirmOrder()
  86. {
  87. $params = (new ServiceOrderValidate())->post()->goCheck('price', [
  88. 'user_id' => $this->userId,
  89. 'user_info' => $this->userInfo
  90. ]);
  91. $result = ServiceOrderLogic::confirmOrder($params);
  92. if (false === $result) {
  93. return $this->fail(ServiceOrderLogic::getError());
  94. }
  95. return $this->success('已确认报价,师傅即将开始服务', [], 1, 1);
  96. }
  97. /**
  98. * 用户确认服务完成
  99. * @return \think\response\Json
  100. */
  101. public function confirmServiceFinish()
  102. {
  103. $params = (new ServiceOrderValidate())->post()->goCheck('finished', [
  104. 'user_id' => $this->userId,
  105. 'user_info' => $this->userInfo
  106. ]);
  107. $result = ServiceOrderLogic::confirmServiceFinish($params);
  108. if (false === $result) {
  109. return $this->fail(ServiceOrderLogic::getError());
  110. }
  111. // 服务完成 - 后续分成事件
  112. event('PropertyCommission',$params);
  113. return $this->success('已确认服务完成', [], 1, 1);
  114. }
  115. /**
  116. * 提交尾款订单
  117. * @return \think\response\Json
  118. */
  119. public function submitFinalOrder()
  120. {
  121. $params = (new ServiceOrderValidate())->post()->goCheck('final', [
  122. 'user_id' => $this->userId,
  123. 'terminal' => $this->userInfo['terminal'],
  124. 'user_info' => $this->userInfo
  125. ]);
  126. Log::write(json_encode($params,JSON_UNESCAPED_UNICODE));
  127. $result = ServiceOrderLogic::submitFinalOrder($params);
  128. if (false === $result) {
  129. return $this->fail(ServiceOrderLogic::getError());
  130. }
  131. return $this->success('已确认支付尾款', [], 1, 1);
  132. }
  133. public function firmOrderLists()
  134. {
  135. return $this->dataLists(new ServiceOrderLists());
  136. }
  137. public function firmOrderSave()
  138. {
  139. $params = (new ServiceOrderValidate())->post()->goCheck('firmOrderSave', [
  140. 'user_id' => $this->userId,
  141. 'user_info' => $this->userInfo
  142. ]);
  143. $result = ServiceOrderLogic::firmOrderSave($params);
  144. if (false === $result) {
  145. return $this->fail(ServiceOrderLogic::getError());
  146. }
  147. return $this->success('保存成功', [], 1, 1);
  148. }
  149. }