This commit is contained in:
2026-08-05 09:11:48 +08:00
parent db8774627e
commit 3ffa7ec55f
11 changed files with 141 additions and 41 deletions
+32 -9
View File
@@ -34,6 +34,7 @@ import {
updatePlatformRole,
updatePlatformTenant,
uploadPlatformTenantQualification,
uploadPlatformTenantRequiredQualificationPackage,
type PlatformPermissionResource,
type PlatformInternalUser,
type PlatformManagedUser,
@@ -271,7 +272,7 @@ describe('platform IAM roles', () => {
it('creates, updates, and changes customer status with the platform tenant contract', async () => {
const tenant = { id: '8', tenantCode: 'TEN8', tenantName: '柏悦物流', status: 'ACTIVE' }
const create = {
tenantName: '柏悦物流', legalName: '柏悦物流有限公司', legalRepresentative: '张三', unifiedSocialCreditCode: '91440300MA5ABCDE12',
tenantName: '柏悦物流', legalName: '柏悦物流有限公司', legalRepresentative: '张三',
contactName: '张三', contactPhone: '13800138000', contactEmail: 'ops@example.com', servicePackage: '标准版',
contactWechat: 'baiyue-ops', salesOwnerName: '李四', paymentTermDays: 30, enterpriseType: '有限责任公司',
establishedDate: '2020-01-01', registeredCapital: 1000, registeredCapitalCurrency: 'CNY',
@@ -281,12 +282,11 @@ describe('platform IAM roles', () => {
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: tenant })
await expect(createPlatformTenant(create)).resolves.toEqual(tenant)
const { unifiedSocialCreditCode: _creditCode, ...update } = create
await expect(updatePlatformTenant('8', update)).resolves.toEqual(tenant)
await expect(updatePlatformTenant('8', create)).resolves.toEqual(tenant)
await expect(changePlatformTenantStatus('8', 'DISABLED')).resolves.toEqual(tenant)
expect(http.post).toHaveBeenCalledWith('/platform/v1/iam/tenants', create)
expect(http.put).toHaveBeenNthCalledWith(1, '/platform/v1/iam/tenants/8', update)
expect(http.put).toHaveBeenNthCalledWith(1, '/platform/v1/iam/tenants/8', create)
expect(http.put).toHaveBeenNthCalledWith(2, '/platform/v1/iam/tenants/8/status', { status: 'DISABLED' })
})
@@ -297,26 +297,49 @@ describe('platform IAM roles', () => {
expect(http.get).toHaveBeenCalledWith('/platform/v1/orders/first-leg/tenant-counts?tenantIds=8,9')
})
it('uploads qualification metadata before explicitly submitting the customer review', async () => {
it('uploads optional qualification metadata before explicitly submitting the customer review', async () => {
const uploadResult = { qualificationId: '91', reviewId: null, tenantStatus: 'PROFILE_REQUIRED', documentUrl: '/file.pdf' }
const tenant = { id: '8', tenantCode: 'TEN8', tenantName: '柏悦物流', status: 'PENDING' }
vi.mocked(http.post).mockResolvedValueOnce({ code: '200', message: 'success', data: uploadResult })
.mockResolvedValueOnce({ code: '200', message: 'success', data: tenant })
const file = new File(['%PDF-1.4'], '营业执照.pdf', { type: 'application/pdf' })
const file = new File(['%PDF-1.4'], '开户许可证.pdf', { type: 'application/pdf' })
await expect(uploadPlatformTenantQualification('8', 'BUSINESS_LICENSE', file, '2030-12-31', '91440300MA5ABCDE12', true)).resolves.toEqual(uploadResult)
await expect(uploadPlatformTenantQualification('8', 'BANK_ACCOUNT_LICENSE', file, '2030-12-31', undefined, true)).resolves.toEqual(uploadResult)
await expect(submitPlatformTenantReview('8')).resolves.toEqual(tenant)
const form = vi.mocked(http.post).mock.calls[0]?.[1] as FormData
expect(http.post).toHaveBeenNthCalledWith(1, '/platform/v1/files/qualifications/8', expect.any(FormData))
expect(form.get('file')).toBe(file)
expect(form.get('qualificationType')).toBe('BUSINESS_LICENSE')
expect(form.get('qualificationType')).toBe('BANK_ACCOUNT_LICENSE')
expect(form.get('validTo')).toBe('2030-12-31')
expect(form.get('certificateNo')).toBe('91440300MA5ABCDE12')
expect(form.get('certificateNo')).toBeNull()
expect(form.get('replace')).toBe('true')
expect(http.post).toHaveBeenNthCalledWith(2, '/platform/v1/iam/tenants/8/submit-review', {})
})
it('uploads both required files and the credit code in one package request', async () => {
const result = {
businessLicenseQualificationId: '91', legalPersonIdQualificationId: '92',
tenantStatus: 'PROFILE_REQUIRED', businessLicenseDocumentUrl: '/license.pdf',
legalPersonIdDocumentUrl: '/legal-person.png',
}
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: result })
const businessLicense = new File(['%PDF-1.4'], '营业执照.pdf', { type: 'application/pdf' })
const legalPersonId = new File(['image'], '法人身份证.png', { type: 'image/png' })
await expect(uploadPlatformTenantRequiredQualificationPackage(
'8', businessLicense, legalPersonId, '91440300MA5ABCDE12', true, true,
)).resolves.toEqual(result)
const form = vi.mocked(http.post).mock.calls[0]?.[1] as FormData
expect(http.post).toHaveBeenCalledWith('/platform/v1/files/qualifications/8/required-package', form)
expect(form.get('businessLicense')).toBe(businessLicense)
expect(form.get('legalPersonId')).toBe(legalPersonId)
expect(form.get('unifiedSocialCreditCode')).toBe('91440300MA5ABCDE12')
expect(form.get('replaceBusinessLicense')).toBe('true')
expect(form.get('replaceLegalPersonId')).toBe('true')
})
it('preserves long review identifiers and returns one-time administrator credentials', async () => {
const reviewId = '190000000000000001'
const approval = {
+30 -2
View File
@@ -53,7 +53,6 @@ export interface CreatePlatformTenantRequest {
tenantName: string
legalName: string
legalRepresentative: string
unifiedSocialCreditCode?: string
contactName: string
contactPhone: string
contactEmail: string
@@ -69,7 +68,7 @@ export interface CreatePlatformTenantRequest {
internalRemark: string
}
export type UpdatePlatformTenantRequest = Omit<CreatePlatformTenantRequest, 'unifiedSocialCreditCode'>
export type UpdatePlatformTenantRequest = CreatePlatformTenantRequest
export interface PlatformTenantOrderCount {
tenantId: number | string
@@ -112,6 +111,14 @@ export interface PlatformQualificationUploadResponse {
replacedDocumentUrl?: string | null
}
export interface PlatformRequiredQualificationPackageUploadResponse {
businessLicenseQualificationId: number | string
legalPersonIdQualificationId: number | string
tenantStatus: PlatformTenantStatus
businessLicenseDocumentUrl: string
legalPersonIdDocumentUrl: string
}
export interface EnterpriseApprovalResponse {
tenantId: number | string
administratorCreated: boolean
@@ -341,6 +348,27 @@ export async function uploadPlatformTenantQualification(
return unwrapApiResponse(response)
}
export async function uploadPlatformTenantRequiredQualificationPackage(
tenantId: number | string,
businessLicense: File,
legalPersonId: File,
unifiedSocialCreditCode: string,
replaceBusinessLicense = false,
replaceLegalPersonId = false,
) {
const form = new FormData()
form.append('businessLicense', businessLicense)
form.append('legalPersonId', legalPersonId)
form.append('unifiedSocialCreditCode', unifiedSocialCreditCode)
if (replaceBusinessLicense) form.append('replaceBusinessLicense', 'true')
if (replaceLegalPersonId) form.append('replaceLegalPersonId', 'true')
const response = await http.post<ApiEnvelope<PlatformRequiredQualificationPackageUploadResponse>, ApiEnvelope<PlatformRequiredQualificationPackageUploadResponse>>(
`/platform/v1/files/qualifications/${tenantId}/required-package`,
form,
)
return unwrapApiResponse(response)
}
export function listPlatformTenantOrderCounts(tenantIds: Array<number | string>) {
const ids = tenantIds.map((id) => encodeURIComponent(String(id))).join(',')
return getData<PlatformTenantOrderCount[]>(`/platform/v1/orders/first-leg/tenant-counts?tenantIds=${ids}`)