fix: 商标国际分类只显示数字 #1017
@ -1131,6 +1131,7 @@ SQL);
|
||||
$row = $this->toUtf8($row);
|
||||
$row['registration_date'] = $this->date($row['registration_date'] ?? null);
|
||||
$row['expiry_date'] = $this->date($row['expiry_date'] ?? null);
|
||||
$row['trademark_type'] = $this->trademarkClassification($row['trademark_type'] ?? null);
|
||||
$row['trademark_status'] = match ((string) ($row['trademark_status'] ?? '')) {
|
||||
'0' => '未启用',
|
||||
'1' => '有效',
|
||||
@ -1140,6 +1141,14 @@ SQL);
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function trademarkClassification(mixed $value): ?string
|
||||
{
|
||||
preg_match_all('/\d+/u', (string) ($value ?? ''), $matches);
|
||||
$classes = array_values(array_unique($matches[0]));
|
||||
|
||||
return $classes === [] ? null : implode(',', $classes);
|
||||
}
|
||||
|
||||
private function toUtf8(array $row): array
|
||||
{
|
||||
foreach ($row as &$value) {
|
||||
|
||||
@ -163,6 +163,30 @@ class UpstreamBusinessInformationTest extends TestCase
|
||||
$this->assertSame([], $summaryCards->all());
|
||||
}
|
||||
|
||||
public function test_trademark_classification_is_normalized_to_digits_only(): void
|
||||
{
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->once()->with('trademark-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('paginate')->once()->with('trademark-information.read', 1, 50, [])->andReturn([
|
||||
'data' => [
|
||||
['id' => 1, 'trademark_type' => '第20'],
|
||||
['id' => 2, 'trademark_type' => '第20类;第35类'],
|
||||
['id' => 3, 'trademark_type' => null],
|
||||
],
|
||||
'total' => 3,
|
||||
]);
|
||||
|
||||
$paginator = (new UpstreamBusinessInformation(
|
||||
Mockery::mock(UpstreamQueryCacheFactory::class),
|
||||
$mirror,
|
||||
null,
|
||||
))->paginate('trademark-management', 'information', 50);
|
||||
|
||||
$this->assertSame('20', $paginator->items()[0]->trademark_type);
|
||||
$this->assertSame('20,35', $paginator->items()[1]->trademark_type);
|
||||
$this->assertNull($paginator->items()[2]->trademark_type);
|
||||
}
|
||||
|
||||
public function test_base_information_pages_do_not_render_summary_cards(): void
|
||||
{
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user