TestController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\Components\Database;
  5. use App\Components\ErrorPush;
  6. use App\Exceptions\Exception;
  7. use App\Services\WaybillService;
  8. use App\User;
  9. use App\Waybill;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Facades\Auth;
  12. use Illuminate\Support\Facades\DB;
  13. use Illuminate\Support\Facades\Hash;
  14. use Illuminate\Support\Facades\Http;
  15. use Zttp\Zttp;
  16. class TestController extends Controller
  17. {
  18. use AsyncResponse, ErrorPush, Database;
  19. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  20. public function __construct()
  21. {
  22. $this->data["active_test"] = "active";
  23. }
  24. public function method(Request $request, $method)
  25. {
  26. try {
  27. return call_user_func([$this, $method], $request);
  28. }catch (\BadMethodCallException $e){
  29. dd("方法不存在");
  30. }
  31. }
  32. public function test()
  33. {
  34. $json = <<<json
  35. {
  36. "request": [
  37. {
  38. "ORDERNUMBERCODE": "ASN2205270586",
  39. "CUSTOMERID": "JIANSHANG",
  40. "ASNTYPE": "THRK",
  41. "ASNREFERENCE1": "92052644969",
  42. "ADDWHO": "WCS",
  43. "USERDEFINE1": "",
  44. "USERDEFINE2": "",
  45. "USERDEFINE3": "",
  46. "SKU_LIST": [
  47. {
  48. "ORDERNUMBERCODE": "ASN2205270586",
  49. "ASNLINENO": "1",
  50. "SKUCODE": "6213100205402",
  51. "QUANTITY": "1",
  52. "LOTATT04": "",
  53. "LOTATT05": "MJ-CP",
  54. "STATUS": "CC",
  55. "PRODUCTION DATE": "",
  56. "EXPIRATION DATE": "",
  57. "USERDEFINE1": "JIANSHANG02",
  58. "USERDEFINE2": "",
  59. "USERDEFINE3": "",
  60. "UNIQUE_CODE_LIST": []
  61. }
  62. ]
  63. }
  64. ]
  65. }
  66. json;
  67. $sendingJson = json_decode($json,true);
  68. $url=url(config('api.flux.receive.new'));
  69. try{
  70. $response = Zttp::post($url, $sendingJson);
  71. dd($response->json());
  72. }catch (\Exception $exception){
  73. Controller::logS(__METHOD__,'Exception_'.__FUNCTION__,'CURL请求异常:'.$exception->getMessage(),null);
  74. dd($exception);
  75. }
  76. }
  77. }