diff --git a/app/Http/Controllers/Business/CourierQuoteChanges.php b/app/Http/Controllers/Business/CourierQuoteChanges.php index e9b48d37..6af3f69c 100644 --- a/app/Http/Controllers/Business/CourierQuoteChanges.php +++ b/app/Http/Controllers/Business/CourierQuoteChanges.php @@ -364,6 +364,8 @@ class CourierQuoteChanges extends Controller 'change_type' => ['required', 'in:费率调整,面单调整,规则备注,执行日期,其他'], 'effective_date' => ['required', 'date_format:Y-m-d'], 'summary' => ['required', 'string', 'min:2', 'max:2000'], + 'quote_notes' => ['sometimes', 'array', 'max:500'], + 'quote_notes.*' => ['nullable', 'string', 'max:10000'], 'items' => ['required', 'array', 'min:1', 'max:500'], 'items.*.source_cell' => ['required', 'regex:/^[A-Z]+[1-9][0-9]*$/'], 'items.*.source_row' => ['required', 'integer', 'min:0'], @@ -393,6 +395,7 @@ class CourierQuoteChanges extends Controller 'quotes' => $quotes, 'source' => $source, 'editableCells' => $this->editableCells($source, $existingItems), + 'editableNotes' => \App\Support\CourierQuoteNotes::cells($source, $change?->quote_payload['quote_notes'] ?? []), ]; } diff --git a/app/Http/Controllers/Business/CourierQuoteSignatures.php b/app/Http/Controllers/Business/CourierQuoteSignatures.php index 89154983..ca78ad3d 100644 --- a/app/Http/Controllers/Business/CourierQuoteSignatures.php +++ b/app/Http/Controllers/Business/CourierQuoteSignatures.php @@ -140,10 +140,9 @@ class CourierQuoteSignatures extends Controller */ public function sheet(CourierQuoteVersion $quoteVersion): StreamedResponse { - $values = json_decode((string) $quoteVersion->values_json, true); - $layout = self::quoteLayout(is_array($values) ? $values : []); + $confirmation = app(\App\Support\CourierQuoteConfirmation::class)->data($quoteVersion); + $layout = self::quoteLayout($confirmation['values']); if ($quoteVersion->isTemporary()) { - $confirmation = app(\App\Support\CourierQuoteConfirmation::class)->data($quoteVersion); array_unshift($layout['notes'], $confirmation['temporary_note']); } $table = self::quoteTableWithNotes($layout)['rows']; @@ -155,8 +154,9 @@ class CourierQuoteSignatures extends Controller foreach ($table as $rowIndex => $row) { foreach ($row as $columnIndex => $value) { $cell = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($columnIndex + 1) . ($rowIndex + 1); - if (is_int($value) || is_float($value)) { - $sheet->setCellValue($cell, $value); + if ($rowIndex > 0 && $columnIndex > 0 && $columnIndex < count($table[0]) - 1 && is_numeric($value)) { + $sheet->setCellValue($cell, (float) $value); + $sheet->getStyle($cell)->getNumberFormat()->setFormatCode('0.00'); } elseif ($value !== null && $value !== '') { $sheet->setCellValueExplicit($cell, (string) $value, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); } diff --git a/app/Models/Business/CourierQuoteChange.php b/app/Models/Business/CourierQuoteChange.php index 200e32ef..16f37d1c 100644 --- a/app/Models/Business/CourierQuoteChange.php +++ b/app/Models/Business/CourierQuoteChange.php @@ -71,7 +71,7 @@ class CourierQuoteChange extends Model public function hasQuotePayload(): bool { - return is_array($this->quote_payload) && array_diff_key($this->quote_payload, ['execution_periods' => true]) !== []; + return is_array($this->quote_payload) && array_diff_key($this->quote_payload, ['execution_periods' => true, 'quote_notes' => true]) !== []; } public function isStockQuote(): bool diff --git a/app/Support/CourierQuoteChangeExport.php b/app/Support/CourierQuoteChangeExport.php index f9aeb04a..9927be3d 100644 --- a/app/Support/CourierQuoteChangeExport.php +++ b/app/Support/CourierQuoteChangeExport.php @@ -84,6 +84,17 @@ final class CourierQuoteChangeExport } } $this->style($details, 8, max(7, count($cells) + 7), 7); + if ($change->quote_payload['quote_notes'] ?? []) { + $notes = $this->sheet($book, $change, '报价备注变更'); + foreach (['地区', '原备注', '新备注'] as $index => $label) $this->text($notes, Coordinate::stringFromColumnIndex($index + 1) . '7', $label); + foreach (array_values($change->quote_payload['quote_notes']) as $index => $note) { + foreach ([$note['region'], $note['original'], $note['text']] as $column => $text) $this->text($notes, Coordinate::stringFromColumnIndex($column + 1) . ($index + 8), $text); + } + $this->style($notes, 3, 7 + count($change->quote_payload['quote_notes']), 7); + $notes->getColumnDimension('B')->setWidth(60); + $notes->getColumnDimension('C')->setWidth(60); + $notes->getStyle('B8:C' . (7 + count($change->quote_payload['quote_notes'])))->getAlignment()->setWrapText(true); + } $details->getColumnDimension('B')->setWidth(30); $details->getColumnDimension('G')->setWidth(48); $details->getStyle('G8:G' . max(8, count($cells) + 7))->getAlignment()->setWrapText(true); diff --git a/app/Support/CourierQuoteChangeService.php b/app/Support/CourierQuoteChangeService.php index 553dd777..2ebd3e0f 100644 --- a/app/Support/CourierQuoteChangeService.php +++ b/app/Support/CourierQuoteChangeService.php @@ -28,6 +28,7 @@ final class CourierQuoteChangeService if (($data['change_type'] ?? '') !== '存量报价') { $data = CourierQuotePeriods::normalize($data); $data['quote_payload'] = CourierQuotePeriods::payload($data['quote_payload'] ?? null, $data['execution_periods']); + $data['quote_payload'] = CourierQuoteNotes::payload($data['quote_payload'], $data, $source); } return DB::transaction(function () use ($data, $userId, $source): CourierQuoteChange { @@ -70,6 +71,7 @@ final class CourierQuoteChangeService if (!$change->isStockQuote()) { $data = CourierQuotePeriods::normalize($data + ['end_date' => $change->end_date?->toDateString()]); $data['quote_payload'] = CourierQuotePeriods::payload($change->quote_payload, $data['execution_periods']); + $data['quote_payload'] = CourierQuoteNotes::payload($data['quote_payload'], $data, $source); } return DB::transaction(function () use ($change, $data, $userId, $source): CourierQuoteChange { @@ -101,7 +103,7 @@ final class CourierQuoteChangeService { $this->ensureEditableBy($change, $userId); - if (! ($change->isStockQuote() && filled($change->proposed_values_json)) && $change->items()->count() === 0) { + if (! ($change->isStockQuote() && filled($change->proposed_values_json)) && $change->items()->count() === 0 && empty($change->quote_payload['quote_notes'])) { throw ValidationException::withMessages(['items' => '至少需要一条发生变化的报价明细。']); } @@ -198,6 +200,7 @@ final class CourierQuoteChangeService throw ValidationException::withMessages(['stock_signature_verified' => '尚未上传历史签署资料,请补充资料或取消历史资料核验;不影响存量报价审核生效。']); } $historicalSigned = $hasHistoricalFiles && $historicalDocumentsConfirmed; + $source = CourierQuoteNotes::apply($source, $change->quote_payload['quote_notes'] ?? []); $values = $source['values']; $formulas = $source['formulas']; @@ -335,7 +338,7 @@ final class CourierQuoteChangeService ]); } - if ($change->items()->count() === 0) { + if ($change->items()->count() === 0 && empty($change->quote_payload['quote_notes'])) { throw ValidationException::withMessages(['items' => '至少需要一条原价格与新价格不同的变价明细。']); } } @@ -382,6 +385,7 @@ final class CourierQuoteChangeService 'effective_date' => $change->effective_date->toDateString(), 'end_date' => $change->end_date?->toDateString(), 'execution_periods' => $change->executionPeriods(), + 'quote_notes' => $change->quote_payload['quote_notes'] ?? [], 'is_retrospective' => $change->isRetrospective(), 'recalculation_status' => $change->recalculation_status, 'recalculation_note' => $change->recalculation_note, diff --git a/app/Support/CourierQuoteConfirmation.php b/app/Support/CourierQuoteConfirmation.php index 42ec1841..dc2290d7 100644 --- a/app/Support/CourierQuoteConfirmation.php +++ b/app/Support/CourierQuoteConfirmation.php @@ -56,7 +56,8 @@ final class CourierQuoteConfirmation : null, 'face_fee' => $this->matrixMetric($values, ['面单费', '面单费用', '面单']), 'bubble_coefficient' => $this->matrixMetric($values, ['计泡系数', '泡系数', '计泡']), - 'values' => $values, + 'billing_rules' => CourierQuoteDocument::executionText($version->billing_rules, $version->periodLabel()), + 'values' => CourierQuoteDocument::values($values, $version->periodLabel()), 'formulas' => $this->decodeMatrix($version->formulas_json), ]; } diff --git a/app/Support/CourierQuoteDocument.php b/app/Support/CourierQuoteDocument.php new file mode 100644 index 00000000..b0ae290e --- /dev/null +++ b/app/Support/CourierQuoteDocument.php @@ -0,0 +1,33 @@ + $row, 'source_column' => $column, 'original' => $original, + 'text' => $saved[$row]['text'] ?? $original, 'region' => (string) ($source['values'][$row][0] ?? '')]; + } + + return $cells; + } + + public static function payload(?array $payload, array $data, array $source): ?array + { + if (! array_key_exists('quote_notes', $data)) return $payload; + $cells = self::cells($source); + $changes = []; + foreach ($data['quote_notes'] as $row => $value) { + if (! isset($cells[$row])) throw ValidationException::withMessages(['quote_notes' => '报价备注位置已变化,请重新载入后修改。']); + $text = (string) ($value ?? ''); + if ($text !== $cells[$row]['original']) $changes[$row] = [...$cells[$row], 'text' => $text]; + } + $payload = $payload ?? []; + unset($payload['quote_notes']); + if ($changes !== []) $payload['quote_notes'] = $changes; + + return $payload ?: null; + } + + public static function apply(array $source, array $notes): array + { + $cells = self::cells($source); + foreach ($notes as $row => $note) { + if (! isset($cells[$row]) || $cells[$row]['original'] !== $note['original']) { + throw ValidationException::withMessages(['quote_notes' => '原报价备注已变化,请退回后重新核对。']); + } + $source['values'][$row][$cells[$row]['source_column']] = $note['text']; + // The legacy import also stores the same general remarks above the matrix. + if (filled($source['billing_rules'] ?? null) && trim($source['billing_rules']) === trim($note['original'])) { + $source['billing_rules'] = $note['text']; + } + } + + return $source; + } +} diff --git a/app/Support/CourierQuotePdf.php b/app/Support/CourierQuotePdf.php index 624d5363..8f0a0753 100644 --- a/app/Support/CourierQuotePdf.php +++ b/app/Support/CourierQuotePdf.php @@ -24,7 +24,7 @@ final class CourierQuotePdf 'partyA' => $data['party_a'], 'expiryDate' => $data['expiry_date'], 'temporaryNote' => $data['temporary_note'] ?? null, - 'billingRules' => $version->billing_rules, + 'billingRules' => $data['billing_rules'], 'faceFee' => $data['face_fee'], 'bubbleCoefficient' => $data['bubble_coefficient'], 'signatureDate' => $signatureDate, diff --git a/resources/views/business/pages/courier-payables/quote-change-editor.blade.php b/resources/views/business/pages/courier-payables/quote-change-editor.blade.php index dbf54568..ce581605 100644 --- a/resources/views/business/pages/courier-payables/quote-change-editor.blade.php +++ b/resources/views/business/pages/courier-payables/quote-change-editor.blade.php @@ -74,6 +74,8 @@ .quote-change-cell-note summary { cursor: pointer; } .quote-change-cell-note summary:focus-visible { outline: 2px solid var(--qc-gold); } .quote-change-note-input { width: 100%; height: 30px; margin-top: 5px; border: 1px solid var(--qc-border); border-radius: 6px; padding: 0 8px; color: var(--qc-ink); font: inherit; } + .quote-change-table .quote-change-remarks { min-width: 360px; width: 360px; } + .quote-change-remarks textarea { min-height: 90px; font-size: 12px; line-height: 1.6; } .quote-change-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border: 1px solid var(--qc-border); border-radius: 12px; background: #fff; } .quote-change-footer__summary { color: var(--qc-muted); font-size: 12px; } .quote-change-footer__summary strong { color: var(--qc-ink); font-variant-numeric: tabular-nums; } @@ -86,6 +88,9 @@ .quote-change-footer { align-items: stretch; flex-direction: column; } .quote-change-footer__actions { justify-content: flex-end; } } + @media (max-width: 600px) { + .quote-change-table .quote-change-remarks { min-width: 160px; width: 160px; } + }
@@ -139,7 +144,7 @@
-
{{ $change ? '变价明细' : '第三步:编辑新价格' }}
仅新价格可编辑;系统会再次核对原价格,防止过期数据覆盖。
+
{{ $change ? '变价明细' : '第三步:编辑新价格' }}
可修改新价格和报价备注;系统会再次核对原价格和原备注。
保存草稿不会让报价生效。提交后由指定审核人员审核并生成新版本;待审核单可在详情页撤回修改后重提。本人单据的审核权限以指定授权为准。
@@ -147,7 +152,7 @@
-

每个地区一行,各重量区间横向填写新价;下方对照原价和差额。勾选地区、区间列或单个价格可批量调整。

+

每个地区一行,各重量区间横向填写新价;下方对照原价和差额。勾选地区、区间列或单个价格可批量调整。右侧报价备注可重新粘贴或清空;备注中的报价执行日期按本单执行区间显示。

@php $priceRows = collect($editableCells)->groupBy('source_row', true); $priceColumns = collect($editableCells)->unique('source_column')->sortBy('source_column'); @@ -159,6 +164,7 @@ @foreach ($priceColumns as $column) @endforeach + @if($editableNotes)报价备注@endif @foreach ($priceRows as $rowIndex => $rowCells) @@ -184,6 +190,13 @@ — @endif @endforeach + @if($editableNotes) + + @if(isset($editableNotes[$rowIndex])) + + @endif + + @endif @endforeach diff --git a/resources/views/business/pages/courier-payables/quote-change-show.blade.php b/resources/views/business/pages/courier-payables/quote-change-show.blade.php index 99a75ed2..d5416456 100644 --- a/resources/views/business/pages/courier-payables/quote-change-show.blade.php +++ b/resources/views/business/pages/courier-payables/quote-change-show.blade.php @@ -100,6 +100,13 @@
签署状态
{{ $change->version?->signatureLabel() ?? '未进入签署' }}
变更依据与说明
{{ $change->summary }}
+ @if($change->quote_payload['quote_notes'] ?? []) +
报价备注修改 + @foreach($change->quote_payload['quote_notes'] as $note) +
{{ $note['region'] }}
原备注:{{ $note['original'] ?: '空白' }}
新备注:{{ $note['text'] ?: '已清空' }}
+ @endforeach +
+ @endif @if(!$stockEntry && $change->end_date)
临时执行区间(均含开始和截止当天) @foreach($change->executionPeriods() as $period)
{{ $period['effective_date'] }} 至 {{ $period['end_date'] }}
@endforeach diff --git a/resources/views/business/pdf/courier-quote.blade.php b/resources/views/business/pdf/courier-quote.blade.php index 3c6c33f4..ca358c1e 100644 --- a/resources/views/business/pdf/courier-quote.blade.php +++ b/resources/views/business/pdf/courier-quote.blade.php @@ -120,7 +120,7 @@ @foreach($row as $columnIndex => $cell) @php($formula = $rowKey !== null && $columnIndex < $lastColumn ? ($formulas[$rowKey][$columnIndex] ?? null) : null) <{{ $rowIndex === 0 ? 'th' : 'td' }} @if($columnIndex === $lastColumn)class="matrix__note"@endif> - {!! $mixedText(is_bool($cell) ? ($cell ? '是' : '否') : ($cell ?? '')) !!} + {!! $mixedText($rowIndex > 0 && $columnIndex > 0 && $columnIndex < $lastColumn && is_numeric($cell) ? number_format((float) $cell, 2, '.', '') : (is_bool($cell) ? ($cell ? '是' : '否') : ($cell ?? ''))) !!} @if(is_string($formula) && trim($formula) !== '')
公式:{!! $mixedText($formula) !!}
@endif @endforeach diff --git a/tests/Feature/Business/CourierQuoteChangeWorkflowTest.php b/tests/Feature/Business/CourierQuoteChangeWorkflowTest.php index b51096b6..cdf92234 100644 --- a/tests/Feature/Business/CourierQuoteChangeWorkflowTest.php +++ b/tests/Feature/Business/CourierQuoteChangeWorkflowTest.php @@ -616,6 +616,68 @@ class CourierQuoteChangeWorkflowTest extends FeatureTestCase } } + public function test_quote_remarks_can_be_replaced_cleared_reviewed_and_exported_without_price_changes(): void + { + \Illuminate\Support\Facades\Storage::fake('uploads'); + \Illuminate\Support\Facades\Http::preventStrayRequests(); + config(['courier_onboarding.allow_same_reviewer' => true]); + $this->loginAs()->get(route('business.courier-quote-changes.create', ['source_quote_id' => 'QB-001'])) + ->assertOk()->assertSee('name="quote_notes[1]"', false)->assertSeeText('报价备注'); + $payload = $this->validPayload(); + $payload['items'][0]['new_amount'] = $payload['items'][0]['original_amount']; + $payload['quote_notes'] = [1 => "包丢不包损\n面单预充6元/单", 2 => '江苏另行说明']; + $this->post(route('business.courier-quote-changes.store'), $payload)->assertSessionHasNoErrors(); + $change = CourierQuoteChange::firstOrFail(); + $this->assertFalse($change->hasQuotePayload()); + $this->assertCount(0, $change->items); + $this->get(route('business.courier-quote-changes.edit', $change))->assertOk()->assertSeeText('面单预充6元/单'); + $payload['quote_notes'][2] = ''; + $this->patch(route('business.courier-quote-changes.update', $change), $payload)->assertSessionHasNoErrors(); + $change->refresh(); + $this->assertArrayNotHasKey(2, $change->quote_payload['quote_notes']); + $book = app(\App\Support\CourierQuoteChangeExport::class)->build($change); + $this->assertSame($payload['quote_notes'][1], $book->getSheetByName('报价备注变更')->getCell('C8')->getValue()); + $book->disconnectWorksheets(); + $this->post(route('business.courier-quote-changes.submit', $change))->assertSessionHasNoErrors(); + $this->get(route('business.courier-quote-changes.show', $change))->assertOk()->assertSeeText('报价备注修改')->assertSeeText('面单预充6元/单'); + $this->post(route('business.courier-quote-changes.approve', $change))->assertSessionHasNoErrors(); + $values = json_decode($change->fresh()->version->values_json, true); + $this->assertSame($payload['quote_notes'][1], $values[1][3]); + $this->assertSame(5, $values[1][1]); + $this->assertSame(1.2, $values[1][2]); + $this->assertNull($values[2][3]); + $this->assertSame($payload['quote_notes'][1], json_decode($change->events()->where('event_type', 'approved')->sole()->details_json, true)['quote_notes'][1]['text']); + $this->assertNull(app(\App\Support\CourierQuoteChangeService::class)->findSourceQuote('QB-001')['values'][1][3]); + } + + public function test_quote_remarks_reject_unknown_cells_and_pending_or_other_users_edits(): void + { + $payload = [...$this->validPayload(), 'quote_notes' => [999 => '不能写入任意单元格']]; + $this->withExceptionHandling()->loginAs()->post(route('business.courier-quote-changes.store'), $payload)->assertSessionHasErrors('quote_notes'); + $this->assertDatabaseCount('business_courier_quote_changes', 0); + $payload['quote_notes'] = [1 => '财务核对后确认']; + $this->post(route('business.courier-quote-changes.store'), $payload)->assertSessionHasNoErrors(); + $change = CourierQuoteChange::firstOrFail(); + $this->loginAs($this->createReviewer())->patch(route('business.courier-quote-changes.update', $change), $payload)->assertForbidden(); + $this->loginAs()->post(route('business.courier-quote-changes.submit', $change))->assertSessionHasNoErrors(); + $this->patch(route('business.courier-quote-changes.update', $change), $payload)->assertSessionHasErrors('status'); + $this->assertSame('财务核对后确认', $change->fresh()->quote_payload['quote_notes'][1]['text']); + } + + public function test_clearing_existing_quote_remarks_clears_matching_general_rules_and_stale_sources_are_rejected(): void + { + $source = ['values' => [['省份', '费用', '备注'], ['江苏', 1.2345, "第一行\n第二行"]], + 'formulas' => [], 'billing_rules' => "第一行\n第二行"]; + $payload = \App\Support\CourierQuoteNotes::payload(null, ['quote_notes' => [1 => null]], $source); + $updated = \App\Support\CourierQuoteNotes::apply($source, $payload['quote_notes']); + $this->assertSame('', $updated['values'][1][2]); + $this->assertSame('', $updated['billing_rules']); + $this->assertSame(1.2345, $updated['values'][1][1]); + $source['values'][1][2] = '已经变更的来源'; + $this->expectException(\Illuminate\Validation\ValidationException::class); + \App\Support\CourierQuoteNotes::apply($source, $payload['quote_notes']); + } + private function validPayload(): array { return [ diff --git a/tests/Feature/Business/CourierQuoteSignatureWorkflowTest.php b/tests/Feature/Business/CourierQuoteSignatureWorkflowTest.php index f2040414..417593cd 100644 --- a/tests/Feature/Business/CourierQuoteSignatureWorkflowTest.php +++ b/tests/Feature/Business/CourierQuoteSignatureWorkflowTest.php @@ -116,7 +116,7 @@ class CourierQuoteSignatureWorkflowTest extends FeatureTestCase app()->instance('dompdf.wrapper', $pdf); $signature = app(CourierQuoteSignatureService::class)->prepareVersion($version, $this->user->id); $rendered = implode('', $text); - foreach (['0-3公斤', '3-35公斤', '江苏', '安徽', '0.5000', '0.5300', '0.6300', '元/公斤', '按实际重量计费', '计泡系数:1.2'] as $expected) { + foreach (['0-3公斤', '3-35公斤', '江苏', '安徽', '0.50', '0.53', '0.63', '元/公斤', '按实际重量计费', '计泡系数:1.2'] as $expected) { $this->assertStringContainsString($expected, $rendered); } foreach (['新旧价格差异', '原价格', '差额', '单元格', '987.6543', '内部审核备注', '内部差额核对'] as $internal) { @@ -132,6 +132,50 @@ class CourierQuoteSignatureWorkflowTest extends FeatureTestCase $this->assertSame(0, $table['rows'][2][1]); } + public function test_signature_and_sheet_use_actual_periods_in_rules_and_remarks_without_changing_saved_values(): void + { + $version = $this->createVersion(); + $periods = [['effective_date' => '2026-10-20', 'end_date' => '2026-10-24'], ['effective_date' => '2026-11-11', 'end_date' => '2026-11-14']]; + $version->change->update(['quote_payload' => ['execution_periods' => $periods]]); + $version->update(['effective_date' => '2026-10-20', 'end_date' => '2026-11-14', + 'billing_rules' => '7、此价格于2026年9月20日起 8、以下城市主发', + 'values_json' => json_encode([['省份', '0-3公斤', '备注'], ['江苏', '0.5350', "本价格2026.9.20开始执行\n包丢不包损"]], JSON_UNESCAPED_UNICODE)]); + $original = $version->values_json; + $data = app(\App\Support\CourierQuoteConfirmation::class)->data($version->fresh()); + foreach ([$data['billing_rules'], $data['values'][1][2]] as $text) { + $this->assertStringContainsString('2026-10-20 至 2026-10-24;2026-11-11 至 2026-11-14', $text); + $this->assertStringNotContainsString('9月20', $text); + $this->assertStringNotContainsString('2026.9.20', $text); + } + $frames = []; + $pdf = app('dompdf.wrapper'); + $pdf->getDomPDF()->setCallbacks([['event' => 'end_frame', 'f' => static function ($frame) use (&$frames): void { + if ($frame instanceof \Dompdf\FrameDecorator\Text) $frames[] = $frame->get_text(); + }]]); + app()->instance('dompdf.wrapper', $pdf); + app(CourierQuoteSignatureService::class)->prepareVersion($version->fresh(), $this->user->id); + $rendered = implode('', $frames); + $this->assertStringContainsString('0.54', $rendered); + $this->assertStringNotContainsString('0.5350', $rendered); + $this->assertStringNotContainsString('2026年9月20', $rendered); + $this->assertStringContainsString('8、以下城市主发', $rendered); + $this->assertStringContainsString('包丢不包损', $rendered); + + $response = $this->loginAs()->get(route('business.courier-quote-signatures.sheet', $version))->assertOk(); + ob_start(); $response->baseResponse->sendContent(); $bytes = ob_get_clean(); + $path = tempnam(sys_get_temp_dir(), 'quote-period-sheet'); file_put_contents($path, $bytes); + try { + $book = \PhpOffice\PhpSpreadsheet\IOFactory::load($path); + $sheet = $book->getActiveSheet(); + $this->assertSame(0.535, $sheet->getCell('B2')->getValue()); + $this->assertSame('0.54', $sheet->getCell('B2')->getFormattedValue()); + $this->assertStringContainsString('2026-11-11 至 2026-11-14', $sheet->getCell('C2')->getValue()); + $this->assertStringNotContainsString('2026.9.20', $sheet->getCell('C2')->getValue()); + $book->disconnectWorksheets(); + } finally { unlink($path); } + $this->assertSame($original, $version->fresh()->values_json); + } + public function test_admin_can_push_the_exact_pdf_to_esign_sandbox(): void { $signature = $this->createPreparedSignature(); diff --git a/tests/Unit/CourierQuoteDocumentTest.php b/tests/Unit/CourierQuoteDocumentTest.php new file mode 100644 index 00000000..07877de9 --- /dev/null +++ b/tests/Unit/CourierQuoteDocumentTest.php @@ -0,0 +1,22 @@ +assertSame("7、本报价执行期间:{$label}。 8、以下城市主发\n协议签署日期:2026-09-20\n原报价 QB-108(2026-09-20 起执行)", $actual); + $this->assertSame($actual, CourierQuoteDocument::executionText($actual, $label)); + } + $this->assertSame('本报价执行期间:2026-12-01 起。', CourierQuoteDocument::executionText('生效时间:2026/9/20起', '2026-12-01 起')); + } +}