123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- namespace App\HttpController;
- use EasySwoole\Http\AbstractInterface\Controller;
- use Swoole\Coroutine\Channel;
- use App\Com\JdSdk;
- class Index extends Controller
- {
- protected $JdSdk;
- public function index()
- {
- $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
- if(!is_file($file)){
- $file = EASYSWOOLE_ROOT.'/src/Resource/Http/welcome.html';
- }
- $this->response()->write(file_get_contents($file));
- }
-
- public function skuState()
- {
- $channel = new Channel(1);
-
- go(function() use($channel){
-
- $data = $this->request()->getRequestParam();
- $skuArr = $data['skuArr'];
- $this->JdSdk = new JdSdk();
- $response = $this->JdSdk->api_product_sku_state($skuArr);
- $channel->push($response);
-
-
-
-
- });
- $responseState = $channel->pop();
- $this->response()->write($responseState . PHP_EOL);
- }
-
- public function skuStock()
- {
- $channel = new Channel(1);
- go(function() use($channel){
-
- $data = $this->request()->getRequestParam();
- $skuNums = $data['skuNums'];
- $area = $data['area'];
- $this->JdSdk = new JdSdk();
- $response = $this->JdSdk->api_stock_get_new_stock_by_id($skuNums, $area);
- $channel->push($response);
-
- });
- $responseStock = $channel->pop();
- $this->response()->write($responseStock . PHP_EOL);
- }
-
- function skuPrice()
- {
- $channel = new Channel(1);
- go(function() use($channel){
-
- $data = $this->request()->getRequestParam();
- $skuStr = $data['skuStr'];
- $this->JdSdk = new JdSdk();
- $response = $this->JdSdk->api_price_get_price($skuStr);
-
- $channel->push($response);
-
- });
- $responsePrice = $channel->pop();
- $this->response()->write($responsePrice . PHP_EOL);
- }
- function test()
- {
- $this->response()->write('this is test');
- }
- protected function actionNotFound(?string $action)
- {
- $this->response()->withStatus(404);
- $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/404.html';
- if(!is_file($file)){
- $file = EASYSWOOLE_ROOT.'/src/Resource/Http/404.html';
- }
- $this->response()->write(file_get_contents($file));
- }
- }
|