|
@@ -7,9 +7,54 @@ namespace App\HttpController;
|
|
|
use EasySwoole\Http\AbstractInterface\Controller;
|
|
|
use App\Com\JdSdk;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $index = new Index();
|
|
|
+
|
|
|
+ $index->skuState();
|
|
|
+ $index->skuStock();
|
|
|
+ $index->skuPrice();
|
|
|
+
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+go(function () {
|
|
|
+ $ret = [];
|
|
|
+
|
|
|
+ $wait = new \EasySwoole\Component\WaitGroup();
|
|
|
+
|
|
|
+ $wait->add();
|
|
|
+
|
|
|
+ go(function () use ($wait, &$ret) {
|
|
|
+
|
|
|
+ \co::sleep(0.1);
|
|
|
+ $ret[] = time();
|
|
|
+ $wait->done();
|
|
|
+ });
|
|
|
+
|
|
|
+ $wait->add();
|
|
|
+
|
|
|
+ go(function () use ($wait, &$ret) {
|
|
|
+
|
|
|
+ \co::sleep(2);
|
|
|
+ $ret[] = time();
|
|
|
+ $wait->done();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $wait->wait();
|
|
|
+
|
|
|
+
|
|
|
+ var_dump($ret);
|
|
|
+});*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
class Index extends Controller
|
|
|
{
|
|
|
protected $JdSdk;
|
|
|
+ protected $response;
|
|
|
|
|
|
public function index()
|
|
|
{
|
|
@@ -20,6 +65,7 @@ class Index extends Controller
|
|
|
$this->response()->write(file_get_contents($file));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
* 3.5 商品上下架状态接口
|
|
|
*
|
|
@@ -29,22 +75,34 @@ class Index extends Controller
|
|
|
*/
|
|
|
public function skuState()
|
|
|
{
|
|
|
-
|
|
|
- $data = $this->request()->getRequestParam();
|
|
|
|
|
|
- $skuArr = $data['skuArr'];
|
|
|
+ $wait = new \EasySwoole\Component\WaitGroup();
|
|
|
+
|
|
|
+ $wait->add();
|
|
|
+
|
|
|
+ go(function () use ($wait) {
|
|
|
|
|
|
- $this->JdSdk = new JdSdk();
|
|
|
+
|
|
|
+ $data = $this->request()->getRequestParam();
|
|
|
|
|
|
- $response = $this->JdSdk->api_product_sku_state($skuArr);
|
|
|
+ $skuArr = $data['skuArr'];
|
|
|
|
|
|
- $this->response()->write($response . PHP_EOL);
|
|
|
+ $this->JdSdk = new JdSdk();
|
|
|
|
|
|
-
|
|
|
+ $this->response = $this->JdSdk->api_product_sku_state($skuArr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ $wait->done();
|
|
|
+ });
|
|
|
+
|
|
|
+ $this->response()->write($this->response . PHP_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -58,20 +116,28 @@ class Index extends Controller
|
|
|
*/
|
|
|
public function skuStock()
|
|
|
{
|
|
|
-
|
|
|
- $data = $this->request()->getRequestParam();
|
|
|
+ $wait = new \EasySwoole\Component\WaitGroup();
|
|
|
|
|
|
- $skuArr = $data['skuArr'];
|
|
|
+ $wait->add();
|
|
|
+
|
|
|
+ go(function () use ($wait) {
|
|
|
|
|
|
- $area = $data['area'];
|
|
|
+
|
|
|
+ $data = $this->request()->getRequestParam();
|
|
|
|
|
|
- $this->JdSdk = new JdSdk();
|
|
|
+ $skuNums = $data['skuNums'];
|
|
|
|
|
|
- $response = $this->JdSdk->api_stock_get_new_stock_by_id($skuArr, $area);
|
|
|
+ $area = $data['area'];
|
|
|
|
|
|
- $this->response()->write($response . PHP_EOL);
|
|
|
+ $this->JdSdk = new JdSdk();
|
|
|
|
|
|
-
|
|
|
+ $response = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
|
|
|
+
|
|
|
+
|
|
|
+ $wait->done();
|
|
|
+ });
|
|
|
+
|
|
|
+ $this->response()->write($this->response . PHP_EOL);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -82,18 +148,27 @@ class Index extends Controller
|
|
|
*/
|
|
|
function skuPrice()
|
|
|
{
|
|
|
-
|
|
|
- $data = $this->request()->getRequestParam();
|
|
|
+ $wait = new \EasySwoole\Component\WaitGroup();
|
|
|
+
|
|
|
+ $wait->add();
|
|
|
+
|
|
|
+ go(function () use ($wait) {
|
|
|
|
|
|
- $skuArr = $data['skuArr'];
|
|
|
+
|
|
|
+ $data = $this->request()->getRequestParam();
|
|
|
|
|
|
- $this->JdSdk = new JdSdk();
|
|
|
+ $skuStr = $data['skuStr'];
|
|
|
|
|
|
- $response = $this->JdSdk->api_price_get_price($skuArr);
|
|
|
+ $this->JdSdk = new JdSdk();
|
|
|
|
|
|
- $this->response()->write($response . PHP_EOL);
|
|
|
+ $response = $this->JdSdk->api_price_get_price($skuStr);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
+ $wait->done();
|
|
|
+ });
|
|
|
+ $this->response()->write($this->response . PHP_EOL);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -111,4 +186,6 @@ class Index extends Controller
|
|
|
}
|
|
|
$this->response()->write(file_get_contents($file));
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+}
|