option('mode') === 'detail' ? 'detail' : 'merged'; $filters = [ 'ship_from' => (string) $this->option('from'), 'ship_to' => (string) $this->option('to'), ]; $cols = [ ['express_no', '快递单号'], ['trade_no', '交易单号'], ['item_id', '商品ID'], ['barcode', '条形码'], ['product_name', '商品名称'], ['qty', '数量'], ['pkg_count', '件数'], ['warehouse_name', '仓库'], ['supplier_name', '供应商'], ['platform', '平台'], ['shop_name', '店铺名称'], ['volume_cm3', '体积'], ['length_cm', '长'], ['width_cm', '宽'], ['height_cm', '高'], ['actual_weight', '实称重量'], ['online_weight', '线上重量'], ['freight', '运费'], ['ship_time', '发货时间'], ['pay_time', '付款时间'], ['product_code', '货号'], ['receiver_state', '省'], ['receiver_city', '市'], ['receiver_district', '区'], ['package_no', '配货单号'], ['amount', '金额'], ['express_name1', '快递名称'], ]; $fh = fopen('php://output', 'w'); fwrite($fh, chr(0xEF).chr(0xBB).chr(0xBF)); fputcsv($fh, array_map(fn ($c) => $c[1], $cols)); $n = 0; foreach ($repo->exportRows($filters, 2000, $mode) as $row) { fputcsv($fh, array_map(fn ($c) => (string) ($row[$c[0]] ?? ''), $cols)); $n++; } fflush($fh); fwrite(STDERR, 'wrote '.$n.' rows ('.$mode.')'.PHP_EOL); return self::SUCCESS; } }