<?php

namespace App\Console\Commands;

use App\Models\MessageStock;
use App\Models\Shop;
use App\Models\StockNotice;
use App\Services\Business\BusinessFactory;
use App\Utils\DateTimeUtils;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Pool\Core\Redis;
class ChkOrderServer extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'check:orderServer';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '快团团根据更新时间获取增量售后单';

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

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $shops = Shop::query()->where('plat_id', Shop::$PLAT_KTT)->where('status', Shop::$STATUS_AUTHORIZED)->get();
        $endTime = DateTimeUtils::getMicroTime();
        $beginTime = $endTime-(24*60*60*1000);
        foreach ($shops as $shop) {
            BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSaveServer($beginTime, $endTime);
        }

        Log::info('任务完成:快团团根据更新时间获取增量售后单');
    }
}
