Browse Source

先让接口在index下都跑起来,不独立开

reloadnike 2 years ago
parent
commit
f13ba92fb6
2 changed files with 55 additions and 8 deletions
  1. 54 7
      App/HttpController/Index.php
  2. 1 1
      App/HttpController/Router.php

+ 54 - 7
App/HttpController/Index.php

@@ -5,9 +5,11 @@ namespace App\HttpController;
 
 
 use EasySwoole\Http\AbstractInterface\Controller;
+use App\Com\JdSdk;
 
 class Index extends Controller
 {
+    protected $JdSdk;
 
     public function index()
     {
@@ -29,19 +31,15 @@ class Index extends Controller
     {
         // 获取 `POST` 或者 `GET` 提交的所有参数
         $data = $this->request()->getRequestParam();
-//var_dump($data);
-
-        // 返回给客户端
-        //$this->response()->write($data . PHP_EOL);
 
         $skuArr = $data['skuArr'];
 
-        //$sku = implode(',', $skuArr);
         $this->JdSdk = new JdSdk();
-//var_dump($skuArr);
+
         $response = $this->JdSdk->api_product_sku_state($skuArr);
-        print_r($response);
+
         $this->response()->write($response . PHP_EOL);
+
         //$response = json_decode($response, true);
 //        =====$response=====
 //        { "success": true, "resultMessage": "操作成功", "resultCode": "0000", "result": [ { "state": 0, "sku": 5729524 } ], "code": 200 }
@@ -50,6 +48,55 @@ class Index extends Controller
 
     }
 
+    /**
+     * 6.2  批量获取库存接口(建议订单详情页、下单使用)
+     *
+     * @param $skuNums
+     * @param $area
+     * $skuNums商品和数量 此是个String 再重构吧  [{skuId: 569172,num:101}], $area格式:1_0_0 (分别代表1、2、3级地址)
+     * @return mixed
+     */
+    public function skuStock()
+    {
+        // 获取 `POST` 或者 `GET` 提交的所有参数
+        $data = $this->request()->getRequestParam();
+
+        $skuArr = $data['skuArr'];
+
+        $area = $data['area'];
+
+        $this->JdSdk = new JdSdk();
+
+        $response = $this->JdSdk->api_stock_get_new_stock_by_id($skuArr, $area);
+
+        $this->response()->write($response . PHP_EOL);
+
+        //return $response;
+    }
+
+    /**
+     * TODO 待测 5.2  批量查询协议价价格
+     * HTTPS请求方式:POST
+     *
+     * @return string
+     */
+    function skuPrice()
+    {
+        // 获取 `POST` 或者 `GET` 提交的所有参数
+        $data = $this->request()->getRequestParam();
+
+        $skuArr = $data['skuArr'];
+
+        $this->JdSdk = new JdSdk();
+
+        $response = $this->JdSdk->api_price_get_price($skuArr);
+
+        $this->response()->write($response . PHP_EOL);
+
+        //return $response;
+    }
+
+
     function test()
     {
         $this->response()->write('this is test');

+ 1 - 1
App/HttpController/Router.php

@@ -27,7 +27,7 @@ class Router extends AbstractRouter
         });
 
         /*商品上下架状态接口*/
-        $routeCollector->get('/ProductService','/skuState');
+        $routeCollector->get('/skuState','/ProductService/skuState');
 
     }
 }