ServiceOrderController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /**
  7. * 订单类
  8. */
  9. class ServiceOrderController extends BaseApiController
  10. {
  11. /**
  12. * 订单列表
  13. * @return \think\response\Json
  14. */
  15. public function lists()
  16. {
  17. return $this->dataLists(new ServiceOrderLists());
  18. }
  19. /**
  20. * 订单详情
  21. * @return \think\response\Json
  22. */
  23. public function detail()
  24. {
  25. $params = (new ServiceOrderValidate())->goCheck('detail',[
  26. 'user_id' => $this->userId,
  27. ]);
  28. $result = ServiceOrderLogic::detail($params);
  29. if (false === $result) {
  30. return $this->fail(ServiceOrderLogic::getError());
  31. }
  32. return $this->data($result);
  33. }
  34. public function getMasterWorker()
  35. {
  36. $params = (new ServiceOrderValidate())->goCheck('worker',[
  37. 'user_id' => $this->userId,
  38. ]);
  39. $result = ServiceOrderLogic::getMasterWorker($params);
  40. if (false === $result) {
  41. return $this->fail(ServiceOrderLogic::getError());
  42. }
  43. return $this->data($result);
  44. }
  45. /**
  46. * 提交订单
  47. * @return \think\response\Json
  48. */
  49. public function submitOrder()
  50. {
  51. $params = (new ServiceOrderValidate())->post()->goCheck('add', [
  52. 'user_id' => $this->userId,
  53. 'terminal' => $this->userInfo['terminal'],
  54. 'user_info' => $this->userInfo
  55. ]);
  56. $result = ServiceOrderLogic::submitOrder($params);
  57. if (false === $result) {
  58. return $this->fail(ServiceOrderLogic::getError());
  59. }
  60. return $this->data($result);
  61. }
  62. /**
  63. * 取消订单
  64. * @return \think\response\Json
  65. */
  66. public function cancelOrder()
  67. {
  68. $params = (new ServiceOrderValidate())->post()->goCheck('cancel', [
  69. 'user_id' => $this->userId,
  70. 'terminal' => $this->userInfo['terminal'],
  71. 'user_info' => $this->userInfo
  72. ]);
  73. $result = ServiceOrderLogic::cancelOrder($params);
  74. if (false === $result) {
  75. return $this->fail(ServiceOrderLogic::getError());
  76. }
  77. return $this->success('取消成功', [], 1, 1);
  78. }
  79. /**
  80. * 确认报价订单
  81. * @return \think\response\Json
  82. */
  83. public function confirmOrder()
  84. {
  85. $params = (new ServiceOrderValidate())->post()->goCheck('price', [
  86. 'user_id' => $this->userId,
  87. 'user_info' => $this->userInfo
  88. ]);
  89. $result = ServiceOrderLogic::confirmOrder($params);
  90. if (false === $result) {
  91. return $this->fail(ServiceOrderLogic::getError());
  92. }
  93. return $this->success('已确认报价,师傅即将开始服务', [], 1, 1);
  94. }
  95. /**
  96. * 用户确认服务完成
  97. * @return \think\response\Json
  98. */
  99. public function confirmServiceFinish()
  100. {
  101. $params = (new ServiceOrderValidate())->post()->goCheck('finished', [
  102. 'user_id' => $this->userId,
  103. 'user_info' => $this->userInfo
  104. ]);
  105. $result = ServiceOrderLogic::confirmServiceFinish($params);
  106. if (false === $result) {
  107. return $this->fail(ServiceOrderLogic::getError());
  108. }
  109. return $this->success('已确认服务完成', [], 1, 1);
  110. }
  111. }