mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use App\Http\Enum\BusinessOrderShippingStatus;
|
||
|
|
use App\Models\BusinessOrder;
|
||
|
|
use App\Models\Shop;
|
||
|
|
use App\Services\Business\BusinessFactory;
|
||
|
|
use Carbon\Carbon;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class KttOrderSyncStatus extends Command
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The name and signature of the console command.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $signature = 'ktt:order_sync_status';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 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()
|
||
|
|
{
|
||
|
|
$startTime = Carbon::now()->subDays(15)->getPreciseTimestamp(3);
|
||
|
|
$shops = Shop::query()->where('plat_id', Shop::$PLAT_KTT)->where('status', Shop::$STATUS_AUTHORIZED)->get();
|
||
|
|
BusinessOrder::query()->where('confirm_at', '>=', $startTime)
|
||
|
|
->where('shipping_status',BusinessOrderShippingStatus::UNSHIP)
|
||
|
|
->where('cancel_status',0)
|
||
|
|
->chunk(200, function ($orders) use ($shops) {
|
||
|
|
foreach ($orders as $order) {
|
||
|
|
$shop = $shops->where('id',$order['shop_id'])->first();
|
||
|
|
if(!empty($shop)){
|
||
|
|
BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order);
|
||
|
|
usleep(10);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|