OperationController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/3
  6. * Time: 下午2:30
  7. */
  8. namespace app\frontend\modules\order\controllers;
  9. use app\common\components\ApiController;
  10. use app\common\models\Order;
  11. use app\frontend\modules\order\services\OrderService;
  12. use app\frontend\modules\order\services\MiniMessageService;
  13. class OperationController extends ApiController
  14. {
  15. public $transactionActions = ['*'];
  16. protected $params;
  17. protected $order;
  18. /**
  19. * @return \Illuminate\Http\JsonResponse|void
  20. * @throws \app\common\exceptions\ShopException
  21. */
  22. public function __construct()
  23. {
  24. parent::__construct(); // TODO: Change the autogenerated stub
  25. }
  26. public function preAction()
  27. {
  28. parent::preAction(); // TODO: Change the autogenerated stub
  29. $this->params = request()->input();
  30. if (!isset($this->params['order_id'])) {
  31. return $this->errorJson('order_id 不能为空!');
  32. }
  33. $this->order = app('OrderManager')->make('Order')->find($this->params['order_id']);
  34. if (!isset($this->order)) {
  35. return $this->errorJson('未找到该订单!');
  36. }
  37. }
  38. /**
  39. * @return \Illuminate\Http\JsonResponse
  40. * @throws \app\common\exceptions\AppException
  41. */
  42. public function pay()
  43. {
  44. OrderService::orderPay($this->params);
  45. return $this->successJson();
  46. }
  47. /**
  48. * @return \Illuminate\Http\JsonResponse
  49. * @throws \app\common\exceptions\AppException
  50. */
  51. public function cancelPay()
  52. {
  53. OrderService::orderCancelPay($this->params);
  54. return $this->successJson();
  55. }
  56. /**
  57. * @return \Illuminate\Http\JsonResponse
  58. * @throws \app\common\exceptions\AppException
  59. */
  60. public function send()
  61. {
  62. OrderService::orderSend($this->params);
  63. return $this->successJson();
  64. }
  65. /**
  66. * @return \Illuminate\Http\JsonResponse
  67. * @throws \app\common\exceptions\AppException
  68. */
  69. public function cancelSend()
  70. {
  71. OrderService::orderCancelSend($this->params);
  72. return $this->successJson();
  73. }
  74. /**
  75. * @return \Illuminate\Http\JsonResponse
  76. * @throws \app\common\exceptions\AppException
  77. */
  78. public function Receive()
  79. {
  80. OrderService::orderReceive($this->params);
  81. return $this->successJson();
  82. }
  83. /**
  84. * @return \Illuminate\Http\JsonResponse
  85. * @throws \app\common\exceptions\AppException
  86. */
  87. public function Delete()
  88. {
  89. OrderService::orderDelete($this->params);
  90. return $this->successJson();
  91. }
  92. /**
  93. * @return \Illuminate\Http\JsonResponse
  94. * @throws \app\common\exceptions\AppException
  95. */
  96. public function Close()
  97. {
  98. OrderService::orderClose($this->params);
  99. $ingress = \Yunshop::request()->ingress;
  100. $type = \Yunshop::request()->type;
  101. // if ($ingress == 'weChatApplet' && $type == 2){
  102. // $order = Order::find(\Yunshop::request()->orderId);
  103. // (new MiniMessageService($order,'',2,'订单取消通知'))->received();
  104. // }
  105. return $this->successJson();
  106. }
  107. }