reloadnike 2 tahun lalu
induk
melakukan
c7b1cb552e
1 mengubah file dengan 8 tambahan dan 30 penghapusan
  1. 8 30
      App/HttpController/Index.php

+ 8 - 30
App/HttpController/Index.php

@@ -54,9 +54,6 @@ go(function () {
 class Index extends Controller
 {
     protected $JdSdk;
-    protected $responseState;
-    protected $responseStock;
-    protected $responsePrice;
 
     public function index()
     {
@@ -78,11 +75,6 @@ class Index extends Controller
     public function skuState()
     {
 
-        $wait = new \EasySwoole\Component\WaitGroup();
-
-        $wait->add();
-        // 启动第 1 个协程
-        go(function () use ($wait) {
 
             // 获取 `POST` 或者 `GET` 提交的所有参数
             $data = $this->request()->getRequestParam();
@@ -91,7 +83,7 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $this->responseState = $this->JdSdk->api_product_sku_state($skuArr);
+            $responseState = $this->JdSdk->api_product_sku_state($skuArr);
 
 
 
@@ -101,10 +93,8 @@ class Index extends Controller
 
             //return $response;
 
-            $wait->done();
-        });
 
-        $this->response()->write($this->responseState . PHP_EOL);
+        $this->response()->write($responseState . PHP_EOL);
 
     }
 
@@ -118,11 +108,6 @@ class Index extends Controller
      */
     public function skuStock()
     {
-        $wait = new \EasySwoole\Component\WaitGroup();
-
-        $wait->add();
-        // 启动第 1 个协程
-        go(function () use ($wait) {
 
             // 获取 `POST` 或者 `GET` 提交的所有参数
             $data = $this->request()->getRequestParam();
@@ -133,13 +118,12 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $this->responseStock = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
+            $responseStock = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
 
             //return $response;
-            $wait->done();
-        });
 
-        $this->response()->write($this->responseStock . PHP_EOL);
+
+        $this->response()->write($responseStock . PHP_EOL);
     }
 
     /**
@@ -150,11 +134,6 @@ class Index extends Controller
      */
     function skuPrice()
     {
-        $wait = new \EasySwoole\Component\WaitGroup();
-
-        $wait->add();
-        // 启动第 1 个协程
-        go(function () use ($wait) {
 
             // 获取 `POST` 或者 `GET` 提交的所有参数
             $data = $this->request()->getRequestParam();
@@ -163,14 +142,13 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $this->responsePrice = $this->JdSdk->api_price_get_price($skuStr);
+            $responsePrice = $this->JdSdk->api_price_get_price($skuStr);
 
             //$this->response()->write($response . PHP_EOL);
 
         //return $response;
-            $wait->done();
-        });
-        $this->response()->write($this->responsePrice . PHP_EOL);
+
+        $this->response()->write($responsePrice . PHP_EOL);
     }