limeng 2a1b663da2 feat(发货数据): 合并/明细双模式,还原工作平台 导出/导出明细
- 同步改为"一个发货单×每件商品一行"(明细底座);新增 pkg_count 列存"1/N"件数
- 体积=数量×长×宽×高;包裹级(实称重量/运费)仅落首件,合并求和不重复
- 仓储 paginate/exportRows 支持 mode:
  合并=按 source_id 归并(条码/商品ID逗号拼接、数量/重量/体积/金额/运费求和、长宽高取最大、其余取值);
  明细=每件一行
- 页面加"合并/明细"切换 + 两个导出(导出/导出明细) + 件数列
- 同步内存加固(1.5G、关本地查询日志、每批释放+gc),避免全量 OOM

实测:包裹199602/明细222311,多件包裹11667,补差0;
7件样例合并体积=各件求和、运费不重复、明细每行1/7。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhRy6EiUwf
2026-09-21 07:49:26 +00:00

40 lines
2.0 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 App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class JstCount extends Command
{
protected $signature = 'jst:count';
protected $description = '发货数据本地表统计';
public function handle(): int
{
$c = DB::connection((string) config('jushuitan.connection', 'jushuitan_local'));
$t = fn () => $c->table('jst_oms_shipping');
$this->line('明细行数 total='.$t()->count());
$this->line('包裹数(distinct source_id)='.$t()->distinct()->count('source_id'));
$this->line('自动发货仓行(source>=1e9)='.$t()->where('source_id', '>=', 1000000000)->count());
$this->line('补差残留='.$t()->where('product_name', 'like', '%补收差价%')->count());
$this->line('快递单号非空='.$t()->whereNotNull('express_no')->where('express_no', '<>', '')->count());
$this->line('件数pkg_count非空='.$t()->whereNotNull('pkg_count')->where('pkg_count', '<>', '')->count());
// 多件包裹数(pkg_count 不是 1/1)
$multi = $t()->where('pkg_count', 'not like', '1/1')->where('pkg_count', 'like', '1/%')->distinct()->count('source_id');
$this->line('多件包裹数(件数≠1/1)='.$multi);
// 一个多件包裹样例
$sample = $t()->where('pkg_count', 'like', '1/%')->where('pkg_count', '<>', '1/1')->orderByDesc('source_id')->first();
if ($sample) {
$rows = $t()->where('source_id', $sample->source_id)->get(['barcode', 'product_name', 'qty', 'pkg_count', 'actual_weight', 'freight', 'volume_cm3']);
$this->line('--- 样例多件包裹 source_id='.$sample->source_id.' 快递单号='.$sample->express_no.' ---');
foreach ($rows as $r) {
$this->line(sprintf(' 条码=%s 名称=%s 数量=%s 件数=%s 实称=%s 运费=%s 体积=%s',
$r->barcode, mb_substr((string) $r->product_name, 0, 12), $r->qty, $r->pkg_count, $r->actual_weight, $r->freight, $r->volume_cm3));
}
}
return self::SUCCESS;
}
}