TestController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Batch;
  4. use App\CommodityBarcode;
  5. use App\Components\AsyncResponse;
  6. use App\Components\Database;
  7. use App\Components\ErrorPush;
  8. use App\Exceptions\Exception;
  9. use App\OracleDOCWaveDetails;
  10. use App\Order;
  11. use App\OrderBin;
  12. use App\OrderCommodity;
  13. use App\Rejected;
  14. use App\RejectedBill;
  15. use App\RejectedBillItem;
  16. use App\Services\LogService;
  17. use App\Services\OracleDocAsnHerderService;
  18. use App\Services\OracleDOCOrderHeaderService;
  19. use App\Services\OrderCommodityService;
  20. use App\Services\OrderService;
  21. use App\Services\OwnerService;
  22. use App\Services\RejectedBillService;
  23. use App\Services\StoreItemService;
  24. use App\Services\StoreService;
  25. use App\Services\WaveService;
  26. use App\Services\WaybillService;
  27. use App\SortingStation;
  28. use App\Store;
  29. use App\User;
  30. use App\UserToken;
  31. use App\ValueStore;
  32. use App\Warehouse;
  33. use App\Waybill;
  34. use Carbon\Carbon;
  35. use Illuminate\Database\Eloquent\Collection;
  36. use Illuminate\Http\Request;
  37. use Illuminate\Support\Facades\Auth;
  38. use Illuminate\Support\Facades\DB;
  39. use Illuminate\Support\Facades\Hash;
  40. use Illuminate\Support\Facades\Http;
  41. use Illuminate\Support\Str;
  42. use Zttp\Zttp;
  43. class TestController extends Controller
  44. {
  45. use AsyncResponse, ErrorPush, Database;
  46. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  47. public function __construct()
  48. {
  49. $this->data["active_test"] = "active";
  50. }
  51. public function method(Request $request, $method)
  52. {
  53. try {
  54. return call_user_func([$this, $method], $request);
  55. }catch (\BadMethodCallException $e){
  56. dd("方法不存在");
  57. }
  58. }
  59. public function test(Request $request)
  60. {
  61. $waybill = Waybill::query()->where("waybill_number","BSZX2209079840")->first();
  62. $json="
  63. {
  64. \"request\": [
  65. {
  66. \"OrderNo\": \"{$waybill['wms_bill_number']}\",
  67. \"DELIVERYNO\": \"{$waybill['waybill_number']}\"
  68. }
  69. ]
  70. }
  71. ";
  72. $sendingJson = json_decode($json,true);
  73. $url=url(config('api.flux.waybill.new'));
  74. try{
  75. $response = Zttp::post($url, $sendingJson);
  76. }catch (\Exception $exception){
  77. dd('CURL请求异常:'.$exception->getMessage());
  78. return false;
  79. }
  80. $responseJson = $response->json();
  81. if(!$responseJson||!isset($responseJson['Response'])||!$responseJson['Response']['return']['returnFlag']=='1'){
  82. dd("向WMS提交运单失败!!SO单号:{$waybill['wms_bill_number']}。提交:{$json},返回:{$response->body()}, URL:{$url}");
  83. return false;
  84. }
  85. Controller::logS(__METHOD__,''.__FUNCTION__,"向WMS提交运单成功,SO单号:{$waybill['wms_bill_number']}。返回:{$response->body()}",0);
  86. return true;
  87. }
  88. }