whitefang 1 год назад
Родитель
Сommit
952a6b556e
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      app/api/controller/PayController.php

+ 22 - 0
app/api/controller/PayController.php

@@ -69,6 +69,28 @@ class PayController extends BaseApiController
         return $this->success('', $result);
     }
 
+    /**
+     * 微信二维码预支付
+     * @return \think\response\Json
+     */
+    public function preNativePay()
+    {
+        $params = (new PayValidate())->post()->goCheck();
+        //订单信息
+        $order = PaymentLogic::getPayOrderInfo($params);
+        if (false === $order) {
+            return $this->fail(PaymentLogic::getError(), $params);
+        }
+        //支付流程
+        $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
+        $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, 4, $redirectUrl);
+        if (false === $result) {
+            return $this->fail(PaymentLogic::getError(), $params);
+        }
+        $result['sn'] = $order['sn'];
+        return $this->success('', $result);
+    }
+
 
     /**
      * @notes 获取支付状态