40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
||
|
||
namespace Modules\EcommerceFinance\Console;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Modules\EcommerceFinance\Repositories\CostFreightAnomalyRepository;
|
||
|
||
class ExportShengsuanAnomalyOrders extends Command
|
||
{
|
||
protected $signature = 'order-profit:shengsuan-anomaly-orders
|
||
{--from= : 发货开始日期}
|
||
{--to= : 发货结束日期}
|
||
{--missing-details : 只输出尚未同步商品明细的订单}
|
||
{--limit=0 : 最多输出多少单,0 表示不限制}';
|
||
|
||
protected $description = '输出聚胜算成本/运费异常订单编号,供本机明细抓取脚本使用';
|
||
|
||
public function handle(CostFreightAnomalyRepository $repository): int
|
||
{
|
||
$from = trim((string) $this->option('from')) ?: now()->subDays(6)->toDateString();
|
||
$to = trim((string) $this->option('to')) ?: now()->toDateString();
|
||
$limit = max((int) $this->option('limit'), 0);
|
||
$orders = $repository->references([
|
||
'from' => $from,
|
||
'to' => $to,
|
||
'shop_names' => [],
|
||
'order_no' => '',
|
||
], (bool) $this->option('missing-details'), $limit);
|
||
|
||
$this->line(json_encode([
|
||
'from' => $from,
|
||
'to' => $to,
|
||
'count' => count($orders),
|
||
'orders' => $orders,
|
||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|