Ver código fonte

php7.4兼容问题,协程变量未及时获取问题

reloadnike 2 anos atrás
pai
commit
1a55d3b1fa
2 arquivos alterados com 10 adições e 8 exclusões
  1. 1 1
      App/Com/JdSdk.php
  2. 9 7
      App/HttpController/Index.php

+ 1 - 1
App/Com/JdSdk.php

@@ -524,7 +524,7 @@ class JdSdk
 
         foreach ($params as $parameter => $value) {
 
-            if (in_array($parameter, array('pic', 'image', 'Filedata')) && $value{0} == '@') {
+            if (in_array($parameter, array('pic', 'image', 'Filedata')) && $value[0] == '@') {
                 $url      = ltrim($value, '@');
                 $content  = file_get_contents($url);
                 $array    = explode('?', basename($url));

+ 9 - 7
App/HttpController/Index.php

@@ -54,7 +54,9 @@ go(function () {
 class Index extends Controller
 {
     protected $JdSdk;
-    protected $response;
+    protected $responseState;
+    protected $responseStock;
+    protected $responsePrice;
 
     public function index()
     {
@@ -89,7 +91,7 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $this->response = $this->JdSdk->api_product_sku_state($skuArr);
+            $this->responseState = $this->JdSdk->api_product_sku_state($skuArr);
 
 
 
@@ -102,7 +104,7 @@ class Index extends Controller
             $wait->done();
         });
 
-        $this->response()->write($this->response . PHP_EOL);
+        $this->response()->write($this->responseState . PHP_EOL);
 
     }
 
@@ -131,13 +133,13 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $response = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
+            $this->responseStock = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
 
             //return $response;
             $wait->done();
         });
 
-        $this->response()->write($this->response . PHP_EOL);
+        $this->response()->write($this->responseStock . PHP_EOL);
     }
 
     /**
@@ -161,14 +163,14 @@ class Index extends Controller
 
             $this->JdSdk = new JdSdk();
 
-            $response = $this->JdSdk->api_price_get_price($skuStr);
+            $this->responsePrice = $this->JdSdk->api_price_get_price($skuStr);
 
             //$this->response()->write($response . PHP_EOL);
 
         //return $response;
             $wait->done();
         });
-        $this->response()->write($this->response . PHP_EOL);
+        $this->response()->write($this->responsePrice . PHP_EOL);
     }