CaiWuXiTong/modules/EcommerceFinance/Console/ExportShengsuanAnomalyOrders.php
renshen d79a1eedfe feat: 成本运费异常接入完整订单商品明细 (#1004)
合并 PR #1004:补全订单商品明细并按条码识别缺成本。
2026-11-09 11:02:21 +08:00

40 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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;
}
}