ServiceOrderController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. /**
  36. * 订单支付详情
  37. * @return \think\response\Json
  38. */
  39. public function orderPayInfo()
  40. {
  41. $params = (new ServiceOrderValidate())->goCheck('detail',[
  42. 'user_id' => $this->userId,
  43. ]);
  44. $result = ServiceOrderLogic::orderPayInfo($params);
  45. if (false === $result) {
  46. return $this->fail(ServiceOrderLogic::getError());
  47. }
  48. return $this->data($result);
  49. }
  50. public function getMasterWorker()
  51. {
  52. $params = (new ServiceOrderValidate())->goCheck('worker',[
  53. 'user_id' => $this->userId,
  54. ]);
  55. $result = ServiceOrderLogic::getMasterWorker($params);
  56. if (false === $result) {
  57. return $this->fail(ServiceOrderLogic::getError());
  58. }
  59. return $this->data($result);
  60. }
  61. /**
  62. * 提交订单
  63. * @return \think\response\Json
  64. */
  65. public function submitOrder()
  66. {
  67. $params = (new ServiceOrderValidate())->post()->goCheck('add', [
  68. 'user_id' => $this->userId,
  69. 'terminal' => $this->userInfo['terminal'],
  70. 'user_info' => $this->userInfo
  71. ]);
  72. Log::write(json_encode($params,JSON_UNESCAPED_UNICODE));
  73. $result = ServiceOrderLogic::submitOrder($params);
  74. if (false === $result) {
  75. return $this->fail(ServiceOrderLogic::getError());
  76. }
  77. return $this->data($result);
  78. }
  79. /**
  80. * 取消订单
  81. * @return \think\response\Json
  82. */
  83. public function cancelOrder()
  84. {
  85. $params = (new ServiceOrderValidate())->post()->goCheck('cancel', [
  86. 'user_id' => $this->userId,
  87. 'terminal' => $this->userInfo['terminal'],
  88. 'user_info' => $this->userInfo
  89. ]);
  90. $result = ServiceOrderLogic::cancelOrder($params);
  91. if (false === $result) {
  92. return $this->fail(ServiceOrderLogic::getError());
  93. }
  94. return $this->success('取消成功', [], 1, 1);
  95. }
  96. /**
  97. * 确认报价订单
  98. * @return \think\response\Json
  99. */
  100. public function confirmOrder()
  101. {
  102. $params = (new ServiceOrderValidate())->post()->goCheck('price', [
  103. 'user_id' => $this->userId,
  104. 'user_info' => $this->userInfo
  105. ]);
  106. $result = ServiceOrderLogic::confirmOrder($params);
  107. if (false === $result) {
  108. return $this->fail(ServiceOrderLogic::getError());
  109. }
  110. return $this->success('已确认报价,师傅即将开始服务', [], 1, 1);
  111. }
  112. /**
  113. * 用户确认服务完成
  114. * @return \think\response\Json
  115. */
  116. public function confirmServiceFinish()
  117. {
  118. $params = (new ServiceOrderValidate())->post()->goCheck('finished', [
  119. 'user_id' => $this->userId,
  120. 'user_info' => $this->userInfo
  121. ]);
  122. $result = ServiceOrderLogic::confirmServiceFinish($params);
  123. if (false === $result) {
  124. return $this->fail(ServiceOrderLogic::getError());
  125. }
  126. return $this->success('已确认服务完成', [], 1, 1);
  127. }
  128. /**
  129. * 提交尾款订单
  130. * @return \think\response\Json
  131. */
  132. public function submitFinalOrder()
  133. {
  134. $params = (new ServiceOrderValidate())->post()->goCheck('final', [
  135. 'user_id' => $this->userId,
  136. 'terminal' => $this->userInfo['terminal'],
  137. 'user_info' => $this->userInfo
  138. ]);
  139. Log::write(json_encode($params,JSON_UNESCAPED_UNICODE));
  140. $result = ServiceOrderLogic::submitFinalOrder($params);
  141. if (false === $result) {
  142. return $this->fail(ServiceOrderLogic::getError());
  143. }
  144. return $this->data($result);
  145. }
  146. /**
  147. * 重置订单优惠券
  148. * @return \think\response\Json
  149. */
  150. public function cancelOrderCoupon()
  151. {
  152. $params = (new ServiceOrderValidate())->post()->goCheck('cancelOrderCoupon', [
  153. 'user_id' => $this->userId,
  154. 'user_info' => $this->userInfo
  155. ]);
  156. $result = ServiceOrderLogic::cancelOrderCoupon($params);
  157. if (false === $result) {
  158. return $this->fail(ServiceOrderLogic::getError());
  159. }
  160. return $this->success('保存成功', [], 1, 1);
  161. }
  162. public function firmOrderLists()
  163. {
  164. return $this->dataLists(new ServiceOrderLists());
  165. }
  166. public function firmOrderSave()
  167. {
  168. $params = (new ServiceOrderValidate())->post()->goCheck('firmOrderSave', [
  169. 'user_id' => $this->userId,
  170. 'user_info' => $this->userInfo
  171. ]);
  172. $result = ServiceOrderLogic::firmOrderSave($params);
  173. if (false === $result) {
  174. return $this->fail(ServiceOrderLogic::getError());
  175. }
  176. return $this->success('保存成功', [], 1, 1);
  177. }
  178. }