Index.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\HttpController;
  3. use EasySwoole\Http\AbstractInterface\Controller;
  4. class Index extends Controller
  5. {
  6. public function index()
  7. {
  8. $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
  9. if(!is_file($file)){
  10. $file = EASYSWOOLE_ROOT.'/src/Resource/Http/welcome.html';
  11. }
  12. $this->response()->write(file_get_contents($file));
  13. }
  14. /**
  15. * 3.5 商品上下架状态接口
  16. *
  17. * @param $skuArr
  18. *
  19. * @return array|bool
  20. */
  21. public function skuState()
  22. {
  23. // 获取 `POST` 或者 `GET` 提交的所有参数
  24. $data = $this->request()->getRequestParam();
  25. //var_dump($data);
  26. // 返回给客户端
  27. //$this->response()->write($data . PHP_EOL);
  28. $skuArr = $data['skuArr'];
  29. //$sku = implode(',', $skuArr);
  30. $this->JdSdk = new JdSdk();
  31. //var_dump($skuArr);
  32. $response = $this->JdSdk->api_product_sku_state($skuArr);
  33. print_r($response);
  34. $this->response()->write($response . PHP_EOL);
  35. //$response = json_decode($response, true);
  36. // =====$response=====
  37. // { "success": true, "resultMessage": "操作成功", "resultCode": "0000", "result": [ { "state": 0, "sku": 5729524 } ], "code": 200 }
  38. //return $response;
  39. }
  40. function test()
  41. {
  42. $this->response()->write('this is test');
  43. }
  44. protected function actionNotFound(?string $action)
  45. {
  46. $this->response()->withStatus(404);
  47. $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/404.html';
  48. if(!is_file($file)){
  49. $file = EASYSWOOLE_ROOT.'/src/Resource/Http/404.html';
  50. }
  51. $this->response()->write(file_get_contents($file));
  52. }
  53. }