<?php

namespace App\Console\Commands;

use App\Models\Shop;
use App\Services\Business\BusinessFactory;
use App\Utils\DateTimeUtils;
use Illuminate\Console\Command;

class Test extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test';

    /**
     * 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()
    {
        $shop = Shop::query()->find(1);
        $business = BusinessFactory::init()->make($shop->plat_id);
        $business->setShop($shop);
        // 下载商品列表
//        $business->downloadGoodsListAndBind();

        // 下载单个商品
//        $business->downloadGoods(1);

        // 库存修改
//        $business->incrQuantity(1);

        // 订单下载
//        $beginTime =  DateTimeUtils::getMicroTime('2022-08-08');
//        $endTime = DateTimeUtils::getMicroTime('2022-08-09');
//        $business->downloadOrdersAndSave($beginTime, $endTime);

        $this->info('执行测试成功');
    }
}
