Order.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\controller;
  10. use app\common\exception\BaseException;
  11. use think\facade\Request;
  12. use app\api\service\Order as OrderService;
  13. use app\api\service\PaymentOrder as PaymentOrderService;
  14. class Order extends Base {
  15. /**
  16. * 确认订单
  17. * @return \think\response\Json
  18. */
  19. public function confirm(){
  20. try{
  21. return $this->returnAjax("ok",1,PaymentOrderService::confirm(Request::param()));
  22. }catch (\Exception $ex){
  23. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  24. }
  25. }
  26. /**
  27. * 创建订单并支付
  28. * @return \think\response\Json
  29. */
  30. public function create(){
  31. try{
  32. return $this->returnAjax("ok",1,PaymentOrderService::create(Request::param()));
  33. }catch (\Exception $ex){
  34. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  35. }
  36. }
  37. /**
  38. * 订单列表
  39. * @return \think\response\Json
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\DbException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. */
  44. public function get_list(){
  45. try{
  46. return $this->returnAjax("ok",1,OrderService::getList(Request::param()));
  47. }catch (BaseException $ex){
  48. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  49. }
  50. }
  51. /**
  52. * 订单详情
  53. * @return \think\response\Json
  54. */
  55. public function detail(){
  56. try{
  57. return $this->returnAjax("ok",1,OrderService::detail(Request::post("id","0","intval")));
  58. }catch (\Exception $ex){
  59. return $this->returnAjax("服务器繁忙,请稍后在试",$ex->getCode());
  60. }
  61. }
  62. /**
  63. * 申请退款
  64. * @return \think\response\Json
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. */
  69. public function refund(){
  70. try{
  71. return $this->returnAjax("ok",1,OrderService::refund(Request::post("id","0","intval")));
  72. }catch (\Exception $ex){
  73. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  74. }
  75. }
  76. /**
  77. * 提交退款申请
  78. * @return \think\response\Json
  79. */
  80. public function apply_refund(){
  81. try{
  82. OrderService::applyRefund(Request::param());
  83. return $this->returnAjax("您的退款申请已提交,请等待管理员审核");
  84. }catch (\Exception $ex){
  85. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  86. }
  87. }
  88. /**
  89. * 确认收货详情
  90. * @return \think\response\Json
  91. */
  92. public function delivery(){
  93. try{
  94. return $this->returnAjax("ok",1,OrderService::delivery(Request::post("id","0","intval")));
  95. }catch (\Exception $ex){
  96. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  97. }
  98. }
  99. /**
  100. * 确认收货
  101. * @return \think\response\Json
  102. */
  103. public function confirm_delivery(){
  104. try{
  105. OrderService::confirmDelivery(Request::post("id","0","intval"));
  106. return $this->returnAjax("确认收货成功");
  107. }catch (\Exception $ex){
  108. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  109. }
  110. }
  111. /**
  112. * 评价详情
  113. * @return \think\response\Json
  114. */
  115. public function evaluate(){
  116. try{
  117. return $this->returnAjax("ok",1,OrderService::evaluate(Request::post("id","0","intval")));
  118. }catch (\Exception $ex){
  119. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  120. }
  121. }
  122. /**
  123. * 提交评价
  124. * @return \think\response\Json
  125. */
  126. public function do_evaluate(){
  127. try{
  128. OrderService::applyEvaluate(Request::param());
  129. return $this->returnAjax("评价成功");
  130. }catch (\Exception $ex){
  131. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  132. }
  133. }
  134. /**
  135. * 重新发起订单支付
  136. * @return \think\response\Json
  137. */
  138. public function payment(){
  139. try{
  140. return $this->returnAjax("ok",1,PaymentOrderService::payment(Request::param()));
  141. }catch (\Exception $ex){
  142. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  143. }
  144. }
  145. /**
  146. * 取消订单
  147. * @return \think\response\Json
  148. */
  149. public function cancel(){
  150. try{
  151. OrderService::cancel(Request::get("order_id","","intval"));
  152. return $this->returnAjax("取消订单成功");
  153. }catch (\Exception $ex){
  154. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  155. }
  156. }
  157. /**
  158. * 售后列表
  159. * @return \think\response\Json
  160. */
  161. public function service(){
  162. try{
  163. return $this->returnAjax("ok",1,OrderService::service(Request::param()));
  164. }catch (BaseException $ex){
  165. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  166. }
  167. }
  168. /**
  169. * 获取物流信息
  170. * @return \think\response\Json
  171. */
  172. public function express(){
  173. try{
  174. return $this->returnAjax("ok",1,OrderService::getExpressData(Request::post("id","0","intval")));
  175. }catch (\Exception $ex){
  176. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  177. }
  178. }
  179. /**
  180. * 获取订单信息
  181. * @return \think\response\Json
  182. */
  183. public function info(){
  184. try{
  185. return $this->returnAjax("ok",1,OrderService::getOrderInfo(Request::param("order_id","0","intval")));
  186. }catch (\Exception $ex){
  187. return $this->returnAjax($ex->getMessage(),$ex->getCode());
  188. }
  189. }
  190. }