fly 5 年 前
コミット
3b2f4787db

+ 11 - 6
app/Http/Controllers/QuickApp/Order/OrdersController.php

@@ -443,7 +443,7 @@ class OrdersController extends BaseController
     /**
      * @apiVersion 1.0.0
      * @apiDescription 支付
-     * @api {get} goToPay 支付
+     * @api {get} goToPay 微信APP支付
      * @apiGroup pay
      * @apiName wxindex
      * @apiParam {Int}  product_id   product_id
@@ -486,14 +486,20 @@ class OrdersController extends BaseController
 
     /**
      * @apiVersion 1.0.0
-     * @apiDescription 支付宝支付
-     * @api {get} goToAliPay 支付宝支付
+     * @apiDescription 支付宝APP支付
+     * @api {get} goToAliPay 支付宝APP支付
      * @apiGroup pay
      * @apiName aliIndex
      * @apiParam {Int}  product_id   product_id
      * @apiParam {Int}  send_order_id   send_order_id
      * @apiParam {String}  bid   bid
      * @apiHeader {String} [Authorization]  token
+     * @apiSuccessExample {json} Success-Response:
+     *     HTTP/1.1 200 OK
+     *     {
+     *       code: 0,
+     *       msg: "",
+     *       data:""
      * 
      */
     public function aliIndex(Request $request)
@@ -504,8 +510,8 @@ class OrdersController extends BaseController
         } else {
             return response()->error('QAPP_PARAM_ERROR');
         }
-        $app = OrderArousePayFactory::aliApp($this->uid);
-        return $app->handle($params);
+        $app = OrderArousePayFactory::ali($this->uid);
+        return response()->success($app->handle($params));
     }
 
     /**
@@ -599,5 +605,4 @@ class OrdersController extends BaseController
             return response('fail');
         }
     }
-
 }

+ 3 - 18
app/Libs/Pay/Merchants/AliPay.php

@@ -30,6 +30,8 @@ class AliPay implements PayMerchantInterface
         $this->app->alipayrsaPublicKey = self::ALIPAYRSAPUBLICKEY;
         $this->app->signType = self::SIGN_TYPE;
         $this->app->gatewayUrl = self::GATE_WAY_URL;
+        $this->app->postCharset = 'GBK';
+        $this->app->format = 'json';
     }
 
     public function send(array $data)
@@ -65,27 +67,10 @@ class AliPay implements PayMerchantInterface
 
     private function AlipayTradeAppPayRequest(array $data)
     {
-        $this->app->postCharset = 'GBK';
-        $this->app->format = 'json';
         $request = new \AlipayTradeAppPayRequest();
         $request->setBizContent(json_encode($data));
         $request->setNotifyUrl(env('ALI_PAY_CALL_BACK'));
-        $result = $this->app->sdkExecute($request);
-        dd($result);
-        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
-        $resultCode = $result->$responseNode->code;
-        if (!empty($resultCode) && $resultCode == 10000) {
-            return [
-                'out_trade_no' => $result->$responseNode->out_trade_no,
-                'trade_no' => $result->$responseNode->trade_no,
-                'total_amount' => $result->$responseNode->total_amount,
-                'seller_id' => $result->$responseNode->seller_id,
-                'merchant_order_no' => $result->$responseNode->merchant_order_no,
-                'sign' => $result->sign,
-            ];
-        } else {
-            return false;
-        }
+        return $this->app->sdkExecute($request);
     }
 
 

+ 1 - 1
app/Modules/Trade/Pay/AliAppOrderArousePay.php

@@ -6,7 +6,7 @@ use App\Libs\Pay\PayFactory;
 use Exception;
 use Log;
 
-class AliAppOrderArousePay extends OrderArousePayAbstract
+class AliOrderArousePay extends OrderArousePayAbstract
 {
     public function arouse(array $data)
     {

+ 0 - 30
app/Modules/Trade/Pay/AliWapOrderArousePay.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Modules\Trade\Pay;
-
-use App\Libs\Pay\PayFactory;
-use Exception;
-use Log;
-
-class AliWapOrderArousePay extends OrderArousePayAbstract
-{
-    public function arouse(array $data)
-    {
-        $ali_param = [
-            'body' => '小说阅读',
-            'subject' => '追书云',
-            'out_trade_no' => $data['trade_no'],
-            'timeout_express' => '90m',
-            'total_amount' => $data['price'] / 100,
-            'product_code' => 'QUICK_WAP_WAY',
-            'return_url' => '',
-        ];
-        try {
-            $pay = PayFactory::aliPay();
-            $result = $pay->send($ali_param);
-            return $result;
-        } catch (Exception $e) {
-            Log::error("创建支付宝订单失败," . $e->getMessage());
-        }
-    }
-}

+ 2 - 3
app/Modules/Trade/Pay/OrderArousePayFactory.php

@@ -4,9 +4,8 @@ namespace App\Modules\Trade\Pay;
 
 /**
  * 
- * @method static \App\Modules\Trade\Pay\WxAppOrderArousePay wxApp(array $data)
- * @method static \App\Modules\Trade\Pay\AliWapOrderArousePay aliWap(array $data)
- * @method static \App\Modules\Trade\Pay\AliAppOrderArousePay aliApp(array $data)
+ * @method static \App\Modules\Trade\Pay\WxAppOrderArousePay wxApp(int uid)
+ * @method static \App\Modules\Trade\Pay\AliOrderArousePay ali(int uid)
  */
 class OrderArousePayFactory
 {

+ 12 - 3
public/kyydoc/api_data.js

@@ -3855,10 +3855,10 @@ define({ "api": [
   },
   {
     "version": "1.0.0",
-    "description": "<p>支付宝支付</p>",
+    "description": "<p>支付宝APP支付</p>",
     "type": "get",
     "url": "goToAliPay",
-    "title": "支付宝支付",
+    "title": "支付宝APP支付",
     "group": "pay",
     "name": "aliIndex",
     "parameter": {
@@ -3901,6 +3901,15 @@ define({ "api": [
         ]
       }
     },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n  code: 0,\n  msg: \"\",\n  data:\"\"",
+          "type": "json"
+        }
+      ]
+    },
     "filename": "app/Http/Controllers/QuickApp/Order/OrdersController.php",
     "groupTitle": "pay"
   },
@@ -3987,7 +3996,7 @@ define({ "api": [
     "description": "<p>支付</p>",
     "type": "get",
     "url": "goToPay",
-    "title": "支付",
+    "title": "微信APP支付",
     "group": "pay",
     "name": "wxindex",
     "parameter": {

+ 12 - 3
public/kyydoc/api_data.json

@@ -3855,10 +3855,10 @@
   },
   {
     "version": "1.0.0",
-    "description": "<p>支付宝支付</p>",
+    "description": "<p>支付宝APP支付</p>",
     "type": "get",
     "url": "goToAliPay",
-    "title": "支付宝支付",
+    "title": "支付宝APP支付",
     "group": "pay",
     "name": "aliIndex",
     "parameter": {
@@ -3901,6 +3901,15 @@
         ]
       }
     },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n  code: 0,\n  msg: \"\",\n  data:\"\"",
+          "type": "json"
+        }
+      ]
+    },
     "filename": "app/Http/Controllers/QuickApp/Order/OrdersController.php",
     "groupTitle": "pay"
   },
@@ -3987,7 +3996,7 @@
     "description": "<p>支付</p>",
     "type": "get",
     "url": "goToPay",
-    "title": "支付",
+    "title": "微信APP支付",
     "group": "pay",
     "name": "wxindex",
     "parameter": {

+ 1 - 1
public/kyydoc/api_project.js

@@ -17,7 +17,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-10-30T07:54:52.567Z",
+    "time": "2019-10-30T09:08:34.305Z",
     "url": "http://apidocjs.com",
     "version": "0.17.7"
   }

+ 1 - 1
public/kyydoc/api_project.json

@@ -17,7 +17,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-10-30T07:54:52.567Z",
+    "time": "2019-10-30T09:08:34.305Z",
     "url": "http://apidocjs.com",
     "version": "0.17.7"
   }