Просмотр исходного кода

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into commission-m

liugc 1 год назад
Родитель
Сommit
c6967fc32e

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

@@ -16,6 +16,7 @@ namespace app\api\controller;
 
 
 use app\api\validate\PayValidate;
+use app\common\enum\PayEnum;
 use app\common\enum\user\UserTerminalEnum;
 use app\common\logic\PaymentLogic;
 use app\common\service\pay\AliPayService;
@@ -61,29 +62,13 @@ class PayController extends BaseApiController
         }
         //支付流程
         $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
-        $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
-        if (false === $result) {
-            return $this->fail(PaymentLogic::getError(), $params);
-        }
-        $result['sn'] = $order['sn'];
-        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);
+        if ($params['pay_way'] == PayEnum::WECHAT_NATIVE_PAY) {
+            //微信二维码预支付
+            $result = PaymentLogic::pay(2, $params['from'], $order, 4, $redirectUrl);
+        } else {
+            $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
         }
-        //支付流程
-        $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);
         }
@@ -91,7 +76,6 @@ class PayController extends BaseApiController
         return $this->success('', $result);
     }
 
-
     /**
      * @notes 获取支付状态
      * @return \think\response\Json

+ 1 - 1
app/api/validate/PayValidate.php

@@ -27,7 +27,7 @@ class PayValidate extends BaseValidate
 {
     protected $rule = [
         'from'      => 'require',
-        'pay_way'   => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY,
+        'pay_way'   => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY . ',' . PayEnum::WECHAT_NATIVE_PAY,
         'order_id'  => 'require'
     ];
 

+ 1 - 0
app/common/enum/PayEnum.php

@@ -28,6 +28,7 @@ class PayEnum
     const BALANCE_PAY   = 1; //余额支付
     const WECHAT_PAY    = 2; //微信支付
     const ALI_PAY       = 3; //支付宝支付
+    const WECHAT_NATIVE_PAY = 4; //微信扫码支付
 
     //支付状态
     const UNPAID = 0; //未支付