From 315f724e14cea52edd6fd78cdad221a7d8330f12 Mon Sep 17 00:00:00 2001
From: limeng <1131177064@qq.com>
Date: Thu, 3 Dec 2026 10:45:33 +0800
Subject: [PATCH] =?UTF-8?q?fix(=E5=BF=AB=E9=80=92=E5=85=A5=E9=A9=BB):=20?=
=?UTF-8?q?=E5=85=AC=E5=8F=B8=E4=BB=A3=E7=A0=81=E6=94=AF=E6=8C=81=E8=8B=B1?=
=?UTF-8?q?=E6=96=87=E5=8F=A5=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Business/CourierOnboardings.php | 4 +--
.../Controllers/Business/CourierProfiles.php | 4 +--
.../courier-onboarding.blade.php | 2 +-
routes/admin.php | 4 +--
.../CourierOnboardingWorkflowTest.php | 13 ++++++--
.../Business/CourierProfileEditingTest.php | 31 +++++++++++++++++--
6 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/app/Http/Controllers/Business/CourierOnboardings.php b/app/Http/Controllers/Business/CourierOnboardings.php
index 487795bfa..eb57596d9 100644
--- a/app/Http/Controllers/Business/CourierOnboardings.php
+++ b/app/Http/Controllers/Business/CourierOnboardings.php
@@ -31,13 +31,13 @@ class CourierOnboardings extends Controller
'courier_name' => ['required', 'string', 'max:100'],
'invite_label' => ['nullable', 'string', 'max:100'],
'valid_days' => ['nullable', 'integer', 'min:1', 'max:180'],
- 'workplatform_expcode' => ['required', 'string', 'max:64', 'regex:/^[0-9A-Za-z_\-]+$/'],
+ 'workplatform_expcode' => ['required', 'string', 'max:64', 'regex:/^[0-9A-Za-z_.-]+$/'],
// 资料由内部人员在钉钉后续节点补充;兼容旧请求中明确提交的字段。
...CourierOnboarding::profileRules(true),
], [
'courier_name.required' => '请先定好系统快递名称(需与报价名、发货数据里的快递名称一致)。',
'workplatform_expcode.required' => '请填写快递公司代码(与快递资料「快递公司代码」一致)。',
- 'workplatform_expcode.regex' => '快递公司代码只能包含字母、数字、下划线和短横线。',
+ 'workplatform_expcode.regex' => '快递公司代码只能包含字母、数字、英文句点(.)、下划线和短横线。',
...CourierOnboarding::profileMessages(),
], CourierOnboarding::profileAttributes());
$code = strtoupper(trim((string) $data['workplatform_expcode']));
diff --git a/app/Http/Controllers/Business/CourierProfiles.php b/app/Http/Controllers/Business/CourierProfiles.php
index 26607f4d3..3f3d76a43 100644
--- a/app/Http/Controllers/Business/CourierProfiles.php
+++ b/app/Http/Controllers/Business/CourierProfiles.php
@@ -47,8 +47,8 @@ class CourierProfiles extends Controller
public function storePaymentAccountForCode(Request $request): RedirectResponse
{
$data = $request->validate(
- ['expcode' => ['required', 'string', 'max:64', 'regex:/^[0-9A-Za-z_\-]+$/']],
- ['expcode.required' => '请填写快递公司代码。', 'expcode.regex' => '快递公司代码只能是字母、数字、下划线或短横线。'],
+ ['expcode' => ['required', 'string', 'max:64', 'regex:/^[0-9A-Za-z_.-]+$/']],
+ ['expcode.required' => '请填写快递公司代码。', 'expcode.regex' => '快递公司代码只能包含字母、数字、英文句点(.)、下划线和短横线。'],
);
return $this->storePaymentAccount($request, trim($data['expcode']));
diff --git a/resources/views/business/pages/courier-payables/courier-onboarding.blade.php b/resources/views/business/pages/courier-payables/courier-onboarding.blade.php
index 608af14b5..98cde3884 100644
--- a/resources/views/business/pages/courier-payables/courier-onboarding.blade.php
+++ b/resources/views/business/pages/courier-payables/courier-onboarding.blade.php
@@ -105,7 +105,7 @@
- 与快递资料「快递公司代码」一致,入驻信息按这个代码对齐到快递资料。
+ 与快递资料「快递公司代码」一致,入驻信息按这个代码对齐到快递资料。支持字母、数字、英文句点(.)、下划线和短横线。
@error('workplatform_expcode'){{ $message }}@enderror
diff --git a/routes/admin.php b/routes/admin.php
index 9acfe7d57..6663a8323 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -708,8 +708,8 @@ Route::prefix('workspace/courier-payables/courier-information/profiles')
->middleware('business.page:courier-payables,courier-information')
->group(function (): void {
Route::post('payment-accounts', [CourierProfiles::class, 'storePaymentAccountForCode'])->name('payment-accounts.store-any');
- Route::post('{expcode}', [CourierProfiles::class, 'update'])->name('update')->where('expcode', '[0-9A-Za-z_\\-]+');
- Route::post('{expcode}/payment-accounts', [CourierProfiles::class, 'storePaymentAccount'])->name('payment-accounts.store')->where('expcode', '[0-9A-Za-z_\\-]+');
+ Route::post('{expcode}', [CourierProfiles::class, 'update'])->name('update')->where('expcode', '[0-9A-Za-z_.-]+');
+ Route::post('{expcode}/payment-accounts', [CourierProfiles::class, 'storePaymentAccount'])->name('payment-accounts.store')->where('expcode', '[0-9A-Za-z_.-]+');
});
Route::get('workspace/courier-payables/courier-information/export', 'Business\Pages@exportCourierInformation')
diff --git a/tests/Feature/Business/CourierOnboardingWorkflowTest.php b/tests/Feature/Business/CourierOnboardingWorkflowTest.php
index 72af0a653..29c901610 100644
--- a/tests/Feature/Business/CourierOnboardingWorkflowTest.php
+++ b/tests/Feature/Business/CourierOnboardingWorkflowTest.php
@@ -48,6 +48,7 @@ class CourierOnboardingWorkflowTest extends FeatureTestCase
->assertOk()
->assertSee('aria-label="快递入驻"', false)
->assertSeeText('生成入驻二维码')
+ ->assertSeeText('支持字母、数字、英文句点(.)、下划线和短横线。')
->assertSeeText('入驻流程')
->assertDontSee('id="co-profile-title"', false)
->assertDontSee('name="courier_category"', false)
@@ -60,7 +61,7 @@ class CourierOnboardingWorkflowTest extends FeatureTestCase
$response = $this->loginAs()->post(route('business.courier-onboardings.store'), [
...self::profile(),
'courier_name' => '新北中通',
- 'workplatform_expcode' => 'xbzt',
+ 'workplatform_expcode' => 'yto.sbsyyt',
'invite_label' => '新北中通 · 张经理',
'valid_days' => 15,
]);
@@ -75,13 +76,19 @@ class CourierOnboardingWorkflowTest extends FeatureTestCase
->assertSessionHasErrors('courier_name');
// 快递公司代码必填、自动转大写、不能和其他入驻重复。
- $this->assertSame('XBZT', $onboarding->workplatform_expcode);
+ $this->assertSame('YTO.SBSYYT', $onboarding->workplatform_expcode);
$this->withExceptionHandling()->loginAs()
->post(route('business.courier-onboardings.store'), [...self::profile(), 'courier_name' => '另一家'])
->assertSessionHasErrors('workplatform_expcode');
$this->withExceptionHandling()->loginAs()
- ->post(route('business.courier-onboardings.store'), [...self::profile(), 'courier_name' => '另一家', 'workplatform_expcode' => 'XBZT'])
+ ->post(route('business.courier-onboardings.store'), [...self::profile(), 'courier_name' => '另一家', 'workplatform_expcode' => 'yto.sbsyyt'])
->assertSessionHasErrors('workplatform_expcode');
+ foreach (['YTO/SBSYYT', 'YTO SBSYYT', 'YTO。SBSYYT', str_repeat('A', 65)] as $invalidCode) {
+ $this->withExceptionHandling()->loginAs()
+ ->post(route('business.courier-onboardings.store'), [...self::profile(), 'courier_name' => '另一家', 'workplatform_expcode' => $invalidCode])
+ ->assertSessionHasErrors('workplatform_expcode');
+ }
+ $this->assertSame(1, CourierOnboarding::query()->count());
$this->assertSame(CourierOnboarding::STATUS_INVITED, $onboarding->status);
$this->assertSame(40, strlen($onboarding->token));
$this->assertMatchesRegularExpression('/^RZ-\d{8}-001$/', $onboarding->number);
diff --git a/tests/Feature/Business/CourierProfileEditingTest.php b/tests/Feature/Business/CourierProfileEditingTest.php
index 0ed23f14d..e3a2c347a 100644
--- a/tests/Feature/Business/CourierProfileEditingTest.php
+++ b/tests/Feature/Business/CourierProfileEditingTest.php
@@ -6,6 +6,7 @@ use App\Business\CourierProfileData;
use App\Models\Auth\Permission;
use App\Models\Auth\Role;
use App\Models\Business\CourierOnboarding;
+use App\Models\Business\CourierPaymentAccount;
use App\Models\Business\CourierProfile;
use App\Models\Business\CourierProfileEvent;
use App\Utilities\CourierProfilePermissions;
@@ -16,6 +17,8 @@ use Tests\Feature\FeatureTestCase;
class CourierProfileEditingTest extends FeatureTestCase
{
+ private string $courierCode = 'TEST-EDIT';
+
protected function setUp(): void
{
parent::setUp();
@@ -27,7 +30,7 @@ class CourierProfileEditingTest extends FeatureTestCase
$mirror->shouldReceive('relatedAvailability')->andReturn([]);
$mirror->shouldReceive('state')->andReturn(['status' => 'succeeded', 'mirror_row_count' => 1902]);
$mirror->shouldReceive('syncStatus')->andReturn(['code' => 'healthy']);
- $mirror->shouldReceive('paginate')->andReturn(['data' => [$this->row()], 'total' => 1902]);
+ $mirror->shouldReceive('paginate')->andReturnUsing(fn () => ['data' => [$this->row()], 'total' => 1902]);
$mirror->shouldReceive('exportRows')->andReturnUsing(function (): \Generator { yield $this->row(); });
$this->app->instance(CourierInformationMirrorRepository::class, $mirror);
}
@@ -102,6 +105,30 @@ class CourierProfileEditingTest extends FeatureTestCase
$this->get(route('system-settings.users.index'))->assertForbidden();
}
+ public function test_dotted_company_code_can_save_profile_and_payment_accounts(): void
+ {
+ $this->courierCode = 'YTO.SBSYYT';
+ $this->grant();
+ $this->loginAs()->get($this->page(['selected' => $this->courierCode, 'edit' => 1]))
+ ->assertOk()->assertSee('aria-label="编辑快递资料"', false);
+ $this->post(route('business.courier-profiles.update', $this->courierCode), ['expname' => '句点代码测试快递'])
+ ->assertSessionHasNoErrors()->assertRedirect();
+ $this->assertSame($this->courierCode, CourierProfile::sole()->expcode);
+
+ foreach ([
+ route('business.courier-profiles.payment-accounts.store', $this->courierCode),
+ route('business.courier-profiles.payment-accounts.store-any'),
+ ] as $url) {
+ $this->post($url, [
+ 'expcode' => $this->courierCode,
+ 'action' => 'add', 'account_type' => '对公', 'account_name' => '测试公司',
+ 'bank_name' => '测试银行', 'account_number' => '6222000012345678', 'effective_date' => '2026-12-03',
+ ])->assertSessionHasNoErrors()->assertRedirect();
+ }
+ $this->assertSame([$this->courierCode, $this->courierCode], CourierPaymentAccount::query()->pluck('expcode')->all());
+ Http::assertNothingSent();
+ }
+
public function test_disabled_or_non_member_editor_is_denied(): void
{
$this->grant();
@@ -146,7 +173,7 @@ class CourierProfileEditingTest extends FeatureTestCase
private function row(): object
{
- return (object) ['Id' => 1, 'expcode' => 'TEST-EDIT', 'expname' => '测试快递', 'outcode' => 'EXT-OLD', 'status' => '1'];
+ return (object) ['Id' => 1, 'expcode' => $this->courierCode, 'expname' => '测试快递', 'outcode' => 'EXT-OLD', 'status' => '1'];
}
private function page(array $query = []): string
--
2.47.2