fix(快递入驻): 公司代码支持英文句点 #1679
@ -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']));
|
||||
|
||||
@ -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']));
|
||||
|
||||
@ -105,7 +105,7 @@
|
||||
<div class="co-field">
|
||||
<label for="co-expcode">快递公司代码 *</label>
|
||||
<input id="co-expcode" name="workplatform_expcode" type="text" maxlength="64" required value="{{ old('workplatform_expcode', request('expcode')) }}" placeholder="如:SQZTKY" autocomplete="off">
|
||||
<span class="co-help">与快递资料「快递公司代码」一致,入驻信息按这个代码对齐到快递资料。</span>
|
||||
<span class="co-help">与快递资料「快递公司代码」一致,入驻信息按这个代码对齐到快递资料。支持字母、数字、英文句点(.)、下划线和短横线。</span>
|
||||
@error('workplatform_expcode')<span class="co-error">{{ $message }}</span>@enderror
|
||||
</div>
|
||||
<div class="co-field">
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user