<?php

namespace App\Console\Commands;

use App\Services\LogService;
use App\Services\OrderTrackingService;
use App\Services\StoreService;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;

class WasSyncWmsAsnInformation extends Command
{

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'WasSyncWmsAsnInformation';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '同步WMS的入库信息';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $this->WasSyncWmsAsn();
    }

    public function WasSyncWmsAsn(){

        /** @var StoreService $storeService */
        $storeService  = app('storeService');

        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;

        $startDate = Carbon::now()->subSeconds($dataInterval);

        $syncStartDate = data_get(config('sync'), 'asn_sync.start_at');

        if($syncStartDate ?? false){
            $syncStartDate = Carbon::parse($syncStartDate);
            if ($startDate->lt($syncStartDate)) {
                $startDate = $syncStartDate;
            }
        }
        //$storeService->syncWmsAsnData($startDate);
    }
}
