WASSyncWMSOrderInformation.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\LogService;
  4. use App\Services\OrderTrackingService;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Carbon;
  7. use Illuminate\Support\Facades\Auth;
  8. class WASSyncWMSOrderInformation extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'WASSyncWMSOrderInformation';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = '同步WMS的订单信息';
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. *
  34. * @return int
  35. */
  36. public function handle()
  37. {
  38. sleep(rand(15,30));
  39. $this->WasSyncWmsOrder();
  40. }
  41. public function WasSyncWmsOrder(){
  42. /** @var OrderTrackingService $orderTrackingService */
  43. $orderTrackingService = app('OrderTrackingService');
  44. $dataInterval = intval(data_get(config('sync'), 'order_tracking_import.interval')) * 60 + 5;
  45. $startDate = Carbon::now()->subSeconds($dataInterval);
  46. $syncStartDate = data_get(config('sync'), 'order_tracking_import.start_at');
  47. if($syncStartDate ?? false){
  48. $syncStartDate = Carbon::parse($syncStartDate);
  49. if ($startDate->lt($syncStartDate)) {
  50. $startDate = $syncStartDate;
  51. }
  52. }
  53. // $startDate = Carbon::parse('2020-05-06 13:16:51')->toDateTimeString();
  54. // $orderTrackingService->根据设置从WMS同步追踪货主的订单($startDate);
  55. $orderTrackingService->trackingWmsOrder($startDate);
  56. }
  57. }