row('各厂家汇总', self::headers(), true); foreach ($data['dfRows'] as $row) { $fee = $data['dfFees'][$row['factory_id']]; $amounts = []; foreach (array_keys(DropshipFees::COLUMNS) as $key) { $value = (float) $fee['values'][$key]; $amounts[] = $value == 0 ? null : ($key === 'booking' ? -$value : $value); } $notes = $fee['note']; if ($fee['other'] !== []) { $other = []; foreach ($fee['other'] as $type => $amount) $other[] = $type . ' ' . number_format($amount, 2); $notes .= ($notes !== '' ? "\n" : '') . '未归类附加费(不计入合计):' . implode('、', $other); } $book->row('各厂家汇总', [$row['factory'], ...$amounts, $fee['total'], $notes, $row['warehouse'], $row['keywords'], $row['billed'], $row['bill'], $row['settle'], $row['diff'], $row['over'], $row['under'], $row['counts']['unprovided'], $row['attention'] - $row['counts']['diff'], DropshipConfirmation::label($data['dfStates'][$row['factory_id']] ?? null)]); } if ($data['dfRows'] !== []) { $totals = []; foreach (array_keys(DropshipFees::COLUMNS) as $key) { $value = (float) ($data['dfFeeTotals'][$key] ?? 0); $totals[] = $value == 0 ? null : ($key === 'booking' ? -$value : $value); } $book->row('各厂家汇总', ['合计', ...$totals, $data['dfFeeTotals']['total'], ...array_fill(0, 12, null)], true); } $book->writeTo($output); } }