mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Business\BusinessFactory;
|
|
use App\Utils\DateTimeUtils;
|
|
use Illuminate\Console\Command;
|
|
use App\Models\Shop;
|
|
|
|
use Swoole\Timer;
|
|
use Swoole\Event;
|
|
|
|
class Swoole extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'swoole:timer';
|
|
|
|
/**
|
|
* 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
|
|
* @throws \Exception
|
|
*/
|
|
public function handle()
|
|
{
|
|
Timer::tick(3000, function () {
|
|
$shops = Shop::query()->where('plat_id', Shop::$PLAT_KTT)->where('status', Shop::$STATUS_AUTHORIZED)->get();
|
|
$endTime = DateTimeUtils::getMicroTime();
|
|
$beginTime = $endTime - 3000;
|
|
foreach ($shops as $shop) {
|
|
BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->downloadOrdersAndSave($beginTime, $endTime + 3000, 'increment');
|
|
}
|
|
});
|
|
Event::wait();
|
|
}
|
|
}
|