| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- /**
- * 订单详情
- * Created by PhpStorm.
- * Author: 芸众商城 www.yunzshop.com
- * Date: 2017/3/4
- * Time: 上午11:16
- */
- namespace app\backend\modules\order\controllers;
- use app\backend\modules\order\models\Order;
- use app\common\components\BaseController;
- use app\common\models\OrderPay;
- use app\common\models\PayCallbackException;
- class OrderPayController extends BaseController
- {
- /**
- * @return string
- * @throws \Throwable
- */
- public function index()
- {
- $orderId = request()->query('order_id');
- $order = Order::with(['orderPays' => function ($query) {
- $query->with('orders');
- }])->find($orderId);
- return view('order.orderPay', [
- 'orderPays' => json_encode($order->orderPays)
- ])->render();
- }
- public function vue()
- {
- $orderId = intval(request()->input('order_id'));
- $order = Order::with(['orderPays' => function ($query) {
- $query->with('orders');
- }])->find($orderId);
- return $this->successJson('orderPay', $order->orderPays);
- }
- public function callbackException()
- {
- //回调失败退款记录
- $data = [];
- return view('order.pay_error_refund', [
- 'orderPays' => json_encode($data)
- ])->render();
- }
- public function exceptionList()
- {
- $search = request()->input('search');
- $page = PayCallbackException::getList($search)->orderBy('id','desc')->paginate(15);
- if ($page->isNotEmpty()) {
- $page->map(function (PayCallbackException $payException) {
- $orders = $payException->orderPay->orders;
- $payException->orders = $orders;
- });
- }
- return $this->successJson('exceptionList', $page);
- }
- public function payErrorRefund()
- {
- $id = intval(request()->input('id'));
- if (empty($id)) {
- return $this->errorJson('参数错误');
- }
- $payException = PayCallbackException::find($id);
- if (!$payException || $payException->error_code != PayCallbackException::ORDER_CLOSE) {
- return $this->errorJson('异常类型不支持操作退款');
- }
- if ( $payException->status == PayCallbackException::STATUS_SUCCESS) {
- return $this->successJson('支付已退款');
- }
- $result = $payException->refund();
- if (!$result['status']) {
- return $this->errorJson($result['msg']);
- }
- return $this->successJson('操作退款成功');
- }
- }
|