功能(订单服务): 将未成年提示和底部引导图并入分类配置

This commit is contained in:
2026-11-27 15:53:09 +08:00
parent 5e45b69720
commit c3a13c5f36
25 changed files with 619 additions and 384 deletions
@@ -6,8 +6,6 @@ export const APP_CONFIG_KEYS = {
workerPlatformNotifications: 'worker_platform_notifications', workerPlatformNotifications: 'worker_platform_notifications',
workerProductMatch: 'worker_product_match', workerProductMatch: 'worker_product_match',
workerAnnouncement: 'worker_announcement', workerAnnouncement: 'worker_announcement',
/** 工单补资料页未成年提示:全局配置,默认关闭 */
orderServiceAgeGate: 'order_service_age_gate',
workerSupportContact: 'worker_support_contact', workerSupportContact: 'worker_support_contact',
workerHall: 'worker_hall', workerHall: 'worker_hall',
/** 商品名来源后缀:按 material.source.provider 在商品名后追加(文字),仅展示用 */ /** 商品名来源后缀:按 material.source.provider 在商品名后追加(文字),仅展示用 */
@@ -0,0 +1,12 @@
-- 183_order_service_content_config_fields.sql
-- 未成年提示与底部引导图并入分类级订单服务配置。
-- 不新增独立配置表;草稿、发布版本、父子分类继承和工单快照继续复用订单服务配置链路。
ALTER TABLE order_service_profiles
ADD COLUMN IF NOT EXISTS age_gate_json JSONB NOT NULL DEFAULT '{}'::jsonb,
ADD COLUMN IF NOT EXISTS bottom_guide_image_json JSONB NOT NULL DEFAULT '{}'::jsonb;
COMMENT ON COLUMN order_service_profiles.age_gate_json IS
'分类级未成年提示配置:enabled/title/warningText/content/importantNotice/按钮与拦截文案';
COMMENT ON COLUMN order_service_profiles.bottom_guide_image_json IS
'分类级填写资料页底部引导图:enabled/image';
@@ -9,6 +9,8 @@ export type OrderServiceProfileRow = {
title: string title: string
description: string description: string
guide_image_json: Record<string, unknown> guide_image_json: Record<string, unknown>
age_gate_json: Record<string, unknown>
bottom_guide_image_json: Record<string, unknown>
fields_json: Array<Record<string, unknown>> fields_json: Array<Record<string, unknown>>
screenshots_json: Record<string, unknown> screenshots_json: Record<string, unknown>
auto_publish_json: Record<string, unknown> auto_publish_json: Record<string, unknown>
@@ -99,6 +101,8 @@ export async function upsertOrderServiceProfile(input: {
title: string title: string
description: string description: string
guideImage: Record<string, unknown> guideImage: Record<string, unknown>
ageGate: Record<string, unknown>
bottomGuideImage: Record<string, unknown>
fields: Array<Record<string, unknown>> fields: Array<Record<string, unknown>>
screenshots: Record<string, unknown> screenshots: Record<string, unknown>
autoPublish: Record<string, unknown> autoPublish: Record<string, unknown>
@@ -113,19 +117,24 @@ export async function upsertOrderServiceProfile(input: {
` `
INSERT INTO order_service_profiles ( INSERT INTO order_service_profiles (
category_id, name, title, description, category_id, name, title, description,
guide_image_json, fields_json, screenshots_json, auto_publish_json, guide_image_json, age_gate_json, bottom_guide_image_json,
fields_json, screenshots_json, auto_publish_json,
material_confirmation_json, status_steps_json, material_confirmation_json, status_steps_json,
submit_text, success_text, post_submit_text, status, created_by_admin_user_id submit_text, success_text, post_submit_text, status, created_by_admin_user_id
) VALUES ( ) VALUES (
$1, $2, $3, $4, $1, $2, $3, $4,
$5::jsonb, $6::jsonb, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb, $5::jsonb, $6::jsonb, $7::jsonb,
$11, $12, $13, 'draft', $14 $8::jsonb, $9::jsonb, $10::jsonb,
$11::jsonb, $12::jsonb,
$13, $14, $15, 'draft', $16
) )
ON CONFLICT (category_id) DO UPDATE SET ON CONFLICT (category_id) DO UPDATE SET
name = EXCLUDED.name, name = EXCLUDED.name,
title = EXCLUDED.title, title = EXCLUDED.title,
description = EXCLUDED.description, description = EXCLUDED.description,
guide_image_json = EXCLUDED.guide_image_json, guide_image_json = EXCLUDED.guide_image_json,
age_gate_json = EXCLUDED.age_gate_json,
bottom_guide_image_json = EXCLUDED.bottom_guide_image_json,
fields_json = EXCLUDED.fields_json, fields_json = EXCLUDED.fields_json,
screenshots_json = EXCLUDED.screenshots_json, screenshots_json = EXCLUDED.screenshots_json,
auto_publish_json = EXCLUDED.auto_publish_json, auto_publish_json = EXCLUDED.auto_publish_json,
@@ -148,6 +157,8 @@ export async function upsertOrderServiceProfile(input: {
input.title, input.title,
input.description, input.description,
JSON.stringify(input.guideImage), JSON.stringify(input.guideImage),
JSON.stringify(input.ageGate),
JSON.stringify(input.bottomGuideImage),
JSON.stringify(input.fields), JSON.stringify(input.fields),
JSON.stringify(input.screenshots), JSON.stringify(input.screenshots),
JSON.stringify(input.autoPublish), JSON.stringify(input.autoPublish),
@@ -163,7 +174,6 @@ export async function upsertOrderServiceProfile(input: {
if (!row) throw new Error('order service profile upsert returned no row') if (!row) throw new Error('order service profile upsert returned no row')
return mapProfile(row) return mapProfile(row)
} }
export async function archiveOrderServiceProfile( export async function archiveOrderServiceProfile(
profileId: number | string, profileId: number | string,
): Promise<OrderServiceProfileRow | null> { ): Promise<OrderServiceProfileRow | null> {
@@ -6,7 +6,6 @@ import {
deleteAdminWorkProductRule, deleteAdminWorkProductRule,
deleteAdminWorkProductRuleMapping, deleteAdminWorkProductRuleMapping,
deleteAdminWorkerLevel, deleteAdminWorkerLevel,
getAdminOrderServiceAgeGateConfig,
getAdminWorkerAnnouncementConfig, getAdminWorkerAnnouncementConfig,
getAdminWorkerFinanceConfig, getAdminWorkerFinanceConfig,
getAdminWorkerHallConfig, getAdminWorkerHallConfig,
@@ -26,7 +25,6 @@ import {
saveAdminWorkCategory, saveAdminWorkCategory,
saveAdminWorkProductRule, saveAdminWorkProductRule,
saveAdminWorkProductRuleMapping, saveAdminWorkProductRuleMapping,
saveAdminOrderServiceAgeGateConfig,
saveAdminWorkerAnnouncementConfig, saveAdminWorkerAnnouncementConfig,
archiveAdminOrderServiceProfile, archiveAdminOrderServiceProfile,
listAdminOrderServiceAutoPublishJobs, listAdminOrderServiceAutoPublishJobs,
@@ -426,33 +424,6 @@ router.post(
}), }),
) )
router.get(
'/worker-platform/order-service-age-gate',
requireAdminPermission('worker_platform.misc_config'),
setHttpCache(0),
createJsonHandler(() => getAdminOrderServiceAgeGateConfig(), {
successMessage: 'ok',
errorMessage: '读取工单补资料页未成年提示失败',
scope: '[admin/worker-platform/order-service-age-gate]',
}),
)
router.post(
'/worker-platform/order-service-age-gate',
requireAdminPermission('worker_platform.misc_config'),
createJsonHandler((req) => saveAdminOrderServiceAgeGateConfig(req.body || {}), {
successMessage: '工单补资料页未成年提示已保存',
errorMessage: '保存工单补资料页未成年提示失败',
scope: '[admin/worker-platform/order-service-age-gate]',
audit: (_req, data) => ({
action: 'order_service_age_gate_saved',
targetType: 'order_service_age_gate',
targetId: 'order_service_age_gate',
data: data && typeof data === 'object' ? (data as Record<string, unknown>) : {},
}),
}),
)
router.get( router.get(
'/worker-platform/support-contact', '/worker-platform/support-contact',
requireAdminPermission('worker_platform.misc_config'), requireAdminPermission('worker_platform.misc_config'),
@@ -303,7 +303,13 @@ export function refreshUploadedFileUrls(value: unknown) {
} }
} }
export const PUBLIC_SCENES = new Set(['category_icon', 'hall_icon', 'public', 'announcement']) export const PUBLIC_SCENES = new Set([
'category_icon',
'hall_icon',
'public',
'announcement',
'order-service-guide',
])
export function isPublicObjectKey(objectKey: string) { export function isPublicObjectKey(objectKey: string) {
const normalized = normalizeObjectKey(objectKey) const normalized = normalizeObjectKey(objectKey)
@@ -4,10 +4,6 @@ import {
getWorkerAnnouncementConfig, getWorkerAnnouncementConfig,
saveWorkerAnnouncementConfig, saveWorkerAnnouncementConfig,
} from './worker-announcement-config-service.js' } from './worker-announcement-config-service.js'
import {
getOrderServiceAgeGateConfig,
saveOrderServiceAgeGateConfig,
} from './order-service-age-gate-config-service.js'
import { import {
getWorkerPlatformNotificationConfig, getWorkerPlatformNotificationConfig,
saveWorkerPlatformNotificationConfig, saveWorkerPlatformNotificationConfig,
@@ -45,14 +41,6 @@ export async function saveAdminWorkerAnnouncementConfig(payload: JsonObject = {}
return saveWorkerAnnouncementConfig(payload) return saveWorkerAnnouncementConfig(payload)
} }
export async function getAdminOrderServiceAgeGateConfig() {
return getOrderServiceAgeGateConfig()
}
export async function saveAdminOrderServiceAgeGateConfig(payload: JsonObject = {}) {
return saveOrderServiceAgeGateConfig(payload)
}
export async function saveAdminWorkerProductMatchConfig(payload: JsonObject = {}) { export async function saveAdminWorkerProductMatchConfig(payload: JsonObject = {}) {
return saveWorkerProductMatchConfig(payload) return saveWorkerProductMatchConfig(payload)
} }
@@ -3,6 +3,8 @@ import test from 'node:test'
import { import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT, DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT,
DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
normalizeOrderServiceBottomGuideImageConfig,
normalizeOrderServiceAgeGateConfig, normalizeOrderServiceAgeGateConfig,
} from './order-service-age-gate-config-service.js' } from './order-service-age-gate-config-service.js'
@@ -74,3 +76,20 @@ test('非布尔启用值和超长文本不会穿透配置边界', () => {
assert.equal(config.minorBlockedTitle.length, 40) assert.equal(config.minorBlockedTitle.length, 40)
assert.equal(config.minorBlockedContent.length, 500) assert.equal(config.minorBlockedContent.length, 500)
}) })
test('底部引导图默认关闭,启用后保留上传图片对象', () => {
assert.deepEqual(DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG, {
enabled: false,
image: {},
})
const config = normalizeOrderServiceBottomGuideImageConfig({
enabled: true,
image: {
objectKey: 'order-service-guide/2026/11/27/demo.png',
url: '/api/v1/files/object?key=order-service-guide%2F2026%2F11%2F27%2Fdemo.png',
contentType: 'image/png',
},
})
assert.equal(config.enabled, true)
assert.equal(config.image.objectKey, 'order-service-guide/2026/11/27/demo.png')
})
@@ -1,6 +1,5 @@
import { APP_CONFIG_KEYS } from '../../config/app-config-keys.js'
import type { JsonObject } from '../../types/json.js' import type { JsonObject } from '../../types/json.js'
import { readAppConfigEntry, saveAppConfigEntry } from '../config/app-config-store.js' import { normalizeUploadedFiles } from './worker-input-normalizers.js'
export type OrderServiceAgeGateConfig = { export type OrderServiceAgeGateConfig = {
enabled: boolean enabled: boolean
@@ -14,6 +13,11 @@ export type OrderServiceAgeGateConfig = {
minorBlockedContent: string minorBlockedContent: string
} }
export type OrderServiceBottomGuideImageConfig = {
enabled: boolean
image: Record<string, unknown>
}
export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT = `1. 购买商品和角色信息有没有错误 export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT = `1. 购买商品和角色信息有没有错误
角色名/系统/区服有无遗漏 角色名/系统/区服有无遗漏
如未核对导致送错,本店概不负责哦~ 如未核对导致送错,本店概不负责哦~
@@ -42,26 +46,9 @@ export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG: OrderServiceAgeGateConfig =
'根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。', '根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。',
} }
export function createDefaultOrderServiceAgeGateConfig(): OrderServiceAgeGateConfig { export const DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG: OrderServiceBottomGuideImageConfig = {
return { ...DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG } enabled: false,
} image: {},
export function getOrderServiceAgeGateConfig(): OrderServiceAgeGateConfig {
return readAppConfigEntry({
configKey: APP_CONFIG_KEYS.orderServiceAgeGate,
fallback: createDefaultOrderServiceAgeGateConfig,
normalize: normalizeOrderServiceAgeGateConfig,
})
}
export async function saveOrderServiceAgeGateConfig(
rawValue: unknown,
): Promise<OrderServiceAgeGateConfig> {
return saveAppConfigEntry({
configKey: APP_CONFIG_KEYS.orderServiceAgeGate,
value: rawValue,
normalize: normalizeOrderServiceAgeGateConfig,
})
} }
export function normalizeOrderServiceAgeGateConfig(rawValue: unknown): OrderServiceAgeGateConfig { export function normalizeOrderServiceAgeGateConfig(rawValue: unknown): OrderServiceAgeGateConfig {
@@ -84,6 +71,17 @@ export function normalizeOrderServiceAgeGateConfig(rawValue: unknown): OrderServ
} }
} }
export function normalizeOrderServiceBottomGuideImageConfig(
rawValue: unknown,
): OrderServiceBottomGuideImageConfig {
const source = isPlainObject(rawValue) ? rawValue : {}
const image = normalizeUploadedFiles([source.image])[0] || {}
return {
enabled: source.enabled === true,
image,
}
}
function textOrDefault(value: unknown, fallback: string, maxLength: number) { function textOrDefault(value: unknown, fallback: string, maxLength: number) {
const normalized = String(value ?? '') const normalized = String(value ?? '')
.trim() .trim()
@@ -1,78 +0,0 @@
/**
* 工单补资料页未成年提示配置真实 PostgreSQL 集成测试。
*
* ORDER_SERVICE_AGE_GATE_TEST_DATABASE_URL=postgres://.../order_site_ctest \
* npx tsx --test src/services/worker-platform/order-service-age-gate-config.integration.test.ts
*/
import assert from 'node:assert/strict'
import test from 'node:test'
const TEST_DATABASE_URL = String(process.env.ORDER_SERVICE_AGE_GATE_TEST_DATABASE_URL || '').trim()
test(
'工单补资料页未成年提示配置可持久化并默认关闭',
{ skip: !TEST_DATABASE_URL ? '未设置 ORDER_SERVICE_AGE_GATE_TEST_DATABASE_URL' : false },
async () => {
process.env.DATABASE_URL = TEST_DATABASE_URL
const { closeDb, query } = await import('../../db/client.js')
const { loadAppConfigCacheFromDatabase } = await import('../config/app-config-store.js')
const { getOrderServiceAgeGateConfig, saveOrderServiceAgeGateConfig } =
await import('./order-service-age-gate-config-service.js')
let originalConfigJson: unknown = null
let hadOriginalConfig = false
try {
await loadAppConfigCacheFromDatabase()
const existing = await query<{ config_json: unknown }>(
`SELECT config_json FROM app_config_entries WHERE config_key = 'order_service_age_gate'`,
)
hadOriginalConfig = Boolean(existing.rows[0])
originalConfigJson = existing.rows[0]?.config_json ?? null
const defaults = getOrderServiceAgeGateConfig()
assert.equal(defaults.enabled, false)
assert.equal(defaults.title, '购买前必读')
await saveOrderServiceAgeGateConfig({
enabled: true,
title: '购买前确认',
warningText: '未成年人请勿购买',
content: '1. 请核对商品和角色信息',
importantNotice: '请警惕冒充售后诈骗',
adultButtonText: '已成年',
minorButtonText: '未成年',
minorBlockedTitle: '不能购买',
minorBlockedContent: '当前流程已停止',
})
const saved = getOrderServiceAgeGateConfig()
assert.equal(saved.enabled, true)
assert.equal(saved.title, '购买前确认')
assert.equal(saved.content, '1. 请核对商品和角色信息')
const persisted = await query<{
config_json: { enabled: boolean; title: string; content: string }
}>(`SELECT config_json FROM app_config_entries WHERE config_key = 'order_service_age_gate'`)
assert.equal(persisted.rows[0]?.config_json.enabled, true)
assert.equal(persisted.rows[0]?.config_json.title, '购买前确认')
assert.equal(persisted.rows[0]?.config_json.content, '1. 请核对商品和角色信息')
await saveOrderServiceAgeGateConfig({ enabled: false })
assert.equal(getOrderServiceAgeGateConfig().enabled, false)
} finally {
if (hadOriginalConfig) {
await query(
`UPDATE app_config_entries
SET config_json = $1::jsonb
WHERE config_key = 'order_service_age_gate'`,
[JSON.stringify(originalConfigJson ?? {})],
)
} else {
await query(`DELETE FROM app_config_entries WHERE config_key = 'order_service_age_gate'`)
}
await loadAppConfigCacheFromDatabase()
await closeDb()
}
},
)
@@ -0,0 +1,132 @@
/**
* 订单服务分类级未成年提示/底部引导图真实 PostgreSQL 集成测试。
*
* ORDER_SERVICE_CONTENT_TEST_DATABASE_URL=postgres://.../order_site_ctest \
* npx tsx --test src/services/worker-platform/order-service-content-config.integration.test.ts
*/
import assert from 'node:assert/strict'
import test from 'node:test'
const TEST_DATABASE_URL = String(process.env.ORDER_SERVICE_CONTENT_TEST_DATABASE_URL || '').trim()
test(
'分类订单服务草稿和发布版本都能保存未成年提示与底部引导图',
{ skip: !TEST_DATABASE_URL ? '未设置 ORDER_SERVICE_CONTENT_TEST_DATABASE_URL' : false },
async () => {
process.env.DATABASE_URL = TEST_DATABASE_URL
const { closeDb, query } = await import('../../db/client.js')
const { publishAdminOrderServiceProfile, saveAdminOrderServiceProfile } =
await import('./order-service-profile-service.js')
const suffix = `${Date.now()}-${process.pid}`
let categoryId = 0
let profileId = 0
try {
const category = await query<{ id: number }>(
`INSERT INTO work_categories
(category_key, name, sort_order, status, created_at, updated_at)
VALUES ($1, $2, 1, 'active', NOW(), NOW())
RETURNING id`,
[`order-service-content-test-${suffix}`, '订单服务内容测试分类'],
)
categoryId = Number(category.rows[0]?.id || 0)
const saved = await saveAdminOrderServiceProfile({
categoryId,
name: '订单服务内容测试',
title: '测试订单服务',
description: '',
guideImage: {},
guideImageDescription: '',
ageGate: {
enabled: true,
title: '测试未成年提示',
warningText: '测试警示',
content: '测试正文',
importantNotice: '测试重要提示',
adultButtonText: '我已成年',
minorButtonText: '我是未成年',
minorBlockedTitle: '不能购买',
minorBlockedContent: '流程停止',
},
bottomGuideImage: {
enabled: true,
image: {
objectKey: 'order-service-guide/integration/demo.png',
url: '/api/v1/files/object?key=order-service-guide%2Fintegration%2Fdemo.png',
contentType: 'image/png',
},
},
fields: [
{
key: 'gameId',
label: '游戏编号',
type: 'text',
validation: 'none',
required: false,
placeholder: '',
helpText: '',
options: [],
sortOrder: 10,
},
],
screenshots: { enabled: false, required: false, minCount: 0, maxCount: 5 },
autoPublish: { enabled: false, requireVoucherConsume: true, retryMax: 3 },
materialConfirmation: {
enabled: false,
title: '',
content: '',
confirmText: '',
cancelText: '',
},
statusSteps: {
submitted: { title: '提交资料', description: '' },
scheduled: { title: '客服安排', description: '' },
processing: { title: '订单处理', description: '' },
completed: { title: '交付完成', description: '' },
},
})
profileId = Number(saved.profile?.id || 0)
const draft = await query<{
age_gate_json: { enabled: boolean; title: string }
bottom_guide_image_json: { enabled: boolean; image: { objectKey?: string } }
}>(
`SELECT age_gate_json, bottom_guide_image_json
FROM order_service_profiles
WHERE id = $1`,
[profileId],
)
assert.equal(draft.rows[0]?.age_gate_json.enabled, true)
assert.equal(draft.rows[0]?.age_gate_json.title, '测试未成年提示')
assert.equal(draft.rows[0]?.bottom_guide_image_json.enabled, true)
assert.equal(
draft.rows[0]?.bottom_guide_image_json.image.objectKey,
'order-service-guide/integration/demo.png',
)
await publishAdminOrderServiceProfile(profileId)
const version = await query<{
config_json: { ageGate: { enabled: boolean }; bottomGuideImage: { enabled: boolean } }
}>(
`SELECT config_json
FROM order_service_profile_versions
WHERE profile_id = $1
ORDER BY version_no DESC
LIMIT 1`,
[profileId],
)
assert.equal(version.rows[0]?.config_json.ageGate.enabled, true)
assert.equal(version.rows[0]?.config_json.bottomGuideImage.enabled, true)
} finally {
if (profileId > 0) {
await query(`DELETE FROM order_service_profiles WHERE id = $1`, [profileId])
}
if (categoryId > 0) {
await query(`DELETE FROM work_categories WHERE id = $1`, [categoryId])
}
await closeDb()
}
},
)
@@ -221,3 +221,37 @@ test('订单服务配置:二级分类优先,未发布时沿分类链继承
assert.match(capturedSql, /ORDER BY chain\.depth ASC/) assert.match(capturedSql, /ORDER BY chain\.depth ASC/)
assert.match(capturedSql, /p\.status <> 'archived'/) assert.match(capturedSql, /p\.status <> 'archived'/)
}) })
test('分类订单服务配置包含未成年提示和独立底部引导图,旧配置默认关闭', () => {
const normalized = config()
assert.equal(normalized.ageGate.enabled, false)
assert.equal(normalized.bottomGuideImage.enabled, false)
assert.deepEqual(normalized.bottomGuideImage.image, {})
const custom = config({
ageGate: {
enabled: true,
title: '分类未成年提示',
warningText: '警示',
content: '正文',
importantNotice: '重要提示',
adultButtonText: '已成年',
minorButtonText: '未成年',
minorBlockedTitle: '不能购买',
minorBlockedContent: '已停止',
},
bottomGuideImage: {
enabled: true,
image: {
objectKey: 'order-service-guide/2026/11/27/demo.png',
url: '/api/v1/files/object?key=order-service-guide%2F2026%2F11%2F27%2Fdemo.png',
contentType: 'image/png',
},
},
})
assert.equal(custom.ageGate.enabled, true)
assert.equal(custom.ageGate.title, '分类未成年提示')
assert.equal(custom.bottomGuideImage.enabled, true)
assert.equal(custom.bottomGuideImage.image.objectKey, 'order-service-guide/2026/11/27/demo.png')
})
@@ -18,6 +18,14 @@ import {
} from '../../repositories/worker-platform/order-service-profile-repo.js' } from '../../repositories/worker-platform/order-service-profile-repo.js'
import { listAllWorkCategories } from '../../repositories/worker-platform/work-category-repo.js' import { listAllWorkCategories } from '../../repositories/worker-platform/work-category-repo.js'
import { normalizeUploadedFiles } from './worker-input-normalizers.js' import { normalizeUploadedFiles } from './worker-input-normalizers.js'
import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
normalizeOrderServiceAgeGateConfig,
normalizeOrderServiceBottomGuideImageConfig,
type OrderServiceAgeGateConfig,
type OrderServiceBottomGuideImageConfig,
} from './order-service-age-gate-config-service.js'
export type OrderServiceFieldType = 'text' | 'textarea' | 'select' | 'radio' | 'number' | 'date' export type OrderServiceFieldType = 'text' | 'textarea' | 'select' | 'radio' | 'number' | 'date'
export type OrderServiceFieldValidation = 'none' | 'digits' export type OrderServiceFieldValidation = 'none' | 'digits'
@@ -70,6 +78,8 @@ export type OrderServiceProfileConfig = {
description: string description: string
guideImage: Record<string, unknown> guideImage: Record<string, unknown>
guideImageDescription: string guideImageDescription: string
ageGate: OrderServiceAgeGateConfig
bottomGuideImage: OrderServiceBottomGuideImageConfig
fields: OrderServiceField[] fields: OrderServiceField[]
screenshots: OrderServiceScreenshots screenshots: OrderServiceScreenshots
autoPublish: OrderServiceAutoPublish autoPublish: OrderServiceAutoPublish
@@ -168,6 +178,10 @@ export async function saveAdminOrderServiceProfile(payload: JsonObject = {}) {
payload.guideImage ?? payload.guide_image_json, payload.guideImage ?? payload.guide_image_json,
guideImageDescription, guideImageDescription,
) )
const ageGate = normalizeOrderServiceAgeGateConfig(payload.ageGate ?? payload.age_gate_json)
const bottomGuideImage = normalizeOrderServiceBottomGuideImageConfig(
payload.bottomGuideImage ?? payload.bottom_guide_image_json,
)
const adminUserId = Number(payload.adminUserId ?? payload.admin_user_id ?? 0) || null const adminUserId = Number(payload.adminUserId ?? payload.admin_user_id ?? 0) || null
const saved = await upsertOrderServiceProfile({ const saved = await upsertOrderServiceProfile({
@@ -176,6 +190,8 @@ export async function saveAdminOrderServiceProfile(payload: JsonObject = {}) {
title: text(payload.title, 80), title: text(payload.title, 80),
description: text(payload.description, 300), description: text(payload.description, 300),
guideImage, guideImage,
ageGate,
bottomGuideImage,
fields, fields,
screenshots, screenshots,
autoPublish, autoPublish,
@@ -257,6 +273,8 @@ function mapAdminProfile(row: OrderServiceProfileRow) {
description: row.description, description: row.description,
guideImage: row.guide_image_json, guideImage: row.guide_image_json,
guideImageDescription: buildProfileConfig(row).guideImageDescription, guideImageDescription: buildProfileConfig(row).guideImageDescription,
ageGate: buildProfileConfig(row).ageGate,
bottomGuideImage: buildProfileConfig(row).bottomGuideImage,
fields: buildProfileConfig(row).fields, fields: buildProfileConfig(row).fields,
screenshots: row.screenshots_json, screenshots: row.screenshots_json,
autoPublish: row.auto_publish_json, autoPublish: row.auto_publish_json,
@@ -278,6 +296,8 @@ export function buildProfileConfig(row: {
title: string title: string
description: string description: string
guide_image_json: unknown guide_image_json: unknown
age_gate_json?: unknown
bottom_guide_image_json?: unknown
fields_json: unknown fields_json: unknown
screenshots_json: unknown screenshots_json: unknown
auto_publish_json: unknown auto_publish_json: unknown
@@ -294,6 +314,8 @@ export function buildProfileConfig(row: {
description: row.description, description: row.description,
guideImage, guideImage,
guideImageDescription: readGuideImageDescription(guideImage), guideImageDescription: readGuideImageDescription(guideImage),
ageGate: normalizeOrderServiceAgeGateConfig(row.age_gate_json),
bottomGuideImage: normalizeOrderServiceBottomGuideImageConfig(row.bottom_guide_image_json),
fields: normalizeFields(row.fields_json), fields: normalizeFields(row.fields_json),
screenshots: normalizeScreenshots(row.screenshots_json), screenshots: normalizeScreenshots(row.screenshots_json),
autoPublish: normalizeAutoPublish(row.auto_publish_json), autoPublish: normalizeAutoPublish(row.auto_publish_json),
@@ -358,6 +380,8 @@ export function normalizeProfileConfig(value: JsonObject): OrderServiceProfileCo
description: text(value.description, 300), description: text(value.description, 300),
guideImage, guideImage,
guideImageDescription: readGuideImageDescription(guideImage), guideImageDescription: readGuideImageDescription(guideImage),
ageGate: normalizeOrderServiceAgeGateConfig(value.ageGate),
bottomGuideImage: normalizeOrderServiceBottomGuideImageConfig(value.bottomGuideImage),
fields: normalizeFields(value.fields), fields: normalizeFields(value.fields),
screenshots: normalizeScreenshots(value.screenshots), screenshots: normalizeScreenshots(value.screenshots),
autoPublish: normalizeAutoPublish(value.autoPublish), autoPublish: normalizeAutoPublish(value.autoPublish),
@@ -48,7 +48,12 @@ import {
processDueOrderServiceAutoPublishJobs, processDueOrderServiceAutoPublishJobs,
} from './order-service-auto-publish-service.js' } from './order-service-auto-publish-service.js'
import { mapAcceptanceForResponse } from './work-order-material-mappers.js' import { mapAcceptanceForResponse } from './work-order-material-mappers.js'
import { getOrderServiceAgeGateConfig } from './order-service-age-gate-config-service.js' import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
type OrderServiceAgeGateConfig,
type OrderServiceBottomGuideImageConfig,
} from './order-service-age-gate-config-service.js'
const PUBLIC_STATUS_MESSAGES: Record<string, string> = { const PUBLIC_STATUS_MESSAGES: Record<string, string> = {
[WORK_ORDER_STATUS.PENDING_MATERIAL]: '请补充订单资料。', [WORK_ORDER_STATUS.PENDING_MATERIAL]: '请补充订单资料。',
@@ -100,6 +105,8 @@ export type OrderServicePublicItem = {
submittedAt?: string submittedAt?: string
acceptanceSubmittedAt?: string acceptanceSubmittedAt?: string
acceptedAt?: string acceptedAt?: string
ageGate?: OrderServiceAgeGateConfig
bottomGuideImage?: OrderServiceBottomGuideImageConfig
} }
const PUBLIC_ACCEPTANCE_IMAGE_STATUSES = new Set<string>([ const PUBLIC_ACCEPTANCE_IMAGE_STATUSES = new Set<string>([
@@ -227,7 +234,6 @@ export async function getOrderServiceByPlatformOrderId(platformOrderIdInput: unk
platformOrderId, platformOrderId,
items, items,
pendingCount: items.filter((item) => item.canSubmit).length, pendingCount: items.filter((item) => item.canSubmit).length,
ageGate: getOrderServiceAgeGateConfig(),
} }
} }
@@ -498,6 +504,15 @@ async function mapPublicOrderItem(order: WorkOrderRow): Promise<OrderServicePubl
.map(refreshUploadedFileUrls) .map(refreshUploadedFileUrls)
.filter(Boolean) .filter(Boolean)
const ageGate = profile?.ageGate?.enabled ? profile.ageGate : undefined
const bottomGuideImage =
profile?.bottomGuideImage?.enabled && profile.bottomGuideImage.image
? {
enabled: true,
image: refreshUploadedFileUrls(profile.bottomGuideImage.image),
}
: undefined
const base: OrderServicePublicItem = { const base: OrderServicePublicItem = {
workOrderId: Number(order.id), workOrderId: Number(order.id),
productName: String(order.product_name || ''), productName: String(order.product_name || ''),
@@ -527,6 +542,8 @@ async function mapPublicOrderItem(order: WorkOrderRow): Promise<OrderServicePubl
...(profile?.materialConfirmation ...(profile?.materialConfirmation
? { materialConfirmation: profile.materialConfirmation } ? { materialConfirmation: profile.materialConfirmation }
: {}), : {}),
...(state.canSubmit && ageGate ? { ageGate } : {}),
...(state.canSubmit && bottomGuideImage ? { bottomGuideImage } : {}),
fields: profile?.fields || [], fields: profile?.fields || [],
values, values,
screenshots, screenshots,
@@ -586,6 +603,8 @@ async function resolveProfileConfig(
description: '', description: '',
guideImage: {}, guideImage: {},
guideImageDescription: '', guideImageDescription: '',
ageGate: DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
bottomGuideImage: DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
fields: normalizeProfileConfig({ fields: normalizeProfileConfig({
name: '通用资料', name: '通用资料',
fields: legacy.fields, fields: legacy.fields,
@@ -45,7 +45,6 @@ import { formatAdminDateTime } from '@/utils/admin-time'
import { normalizeProductNameSuffixText } from '@/utils/product-name-source-suffix' import { normalizeProductNameSuffixText } from '@/utils/product-name-source-suffix'
import HallConfigPanel from './HallConfigPanel' import HallConfigPanel from './HallConfigPanel'
import OrderServiceAgeGateConfigCard from './OrderServiceAgeGateConfigCard'
function isDepositUnfreezeJob(job: AdminScheduledJobItem) { function isDepositUnfreezeJob(job: AdminScheduledJobItem) {
return job.type === 'deposit_unfreeze' || job.id === 'deposit-unfreeze' return job.type === 'deposit_unfreeze' || job.id === 'deposit-unfreeze'
@@ -55,7 +54,6 @@ export default function AnnouncementPanel() {
return ( return (
<Space direction="vertical" size={16} style={{ width: '100%' }}> <Space direction="vertical" size={16} style={{ width: '100%' }}>
<AnnouncementCard /> <AnnouncementCard />
<OrderServiceAgeGateConfigCard />
<SupportContactCard /> <SupportContactCard />
<ProductNameSourceSuffixCard /> <ProductNameSourceSuffixCard />
<DepositUnfreezeCard /> <DepositUnfreezeCard />
@@ -1,198 +0,0 @@
import { SaveOutlined } from '@ant-design/icons'
import { App, Button, Card, Col, Form, Input, Row, Space, Switch, Typography } from 'antd'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useEffect, useState } from 'react'
import {
fetchAdminOrderServiceAgeGateConfig,
saveAdminOrderServiceAgeGateConfig,
} from '@/services/admin'
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
mergeOrderServiceAgeGateConfig,
} from '@/utils/order-service-age-gate'
const { Text } = Typography
export default function OrderServiceAgeGateConfigCard() {
const { message } = App.useApp()
const queryClient = useQueryClient()
const [form] = Form.useForm<OrderServiceAgeGateConfig>()
const [saving, setSaving] = useState(false)
const configQuery = useQuery({
queryKey: ['admin-order-service-age-gate'],
queryFn: fetchAdminOrderServiceAgeGateConfig,
})
const enabled = Form.useWatch('enabled', form) === true
useEffect(() => {
if (!configQuery.data?.data) return
form.setFieldsValue(mergeOrderServiceAgeGateConfig(configQuery.data.data))
}, [configQuery.data, form])
async function save(values: OrderServiceAgeGateConfig) {
setSaving(true)
try {
await saveAdminOrderServiceAgeGateConfig(values)
await queryClient.invalidateQueries({ queryKey: ['admin-order-service-age-gate'] })
message.success('工单补资料页未成年提示已保存')
} catch (error) {
message.error(error instanceof Error ? error.message : '保存未成年提示配置失败')
} finally {
setSaving(false)
}
}
return (
<Card
title="工单补资料页未成年提示"
bordered={false}
extra={
<Button
type="primary"
icon={<SaveOutlined />}
loading={saving}
disabled={configQuery.isLoading}
onClick={() => void form.submit()}
>
保存配置
</Button>
}
>
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
仅作用于客户工单补资料页(<Text code>/o/&lt;订单号&gt;</Text>)的待补资料工单。
默认关闭;启用后,客户进入页面先看到购买前提示,点击“已成年”才显示资料表单。
提示内容、按钮文字和未成年拦截提示都可在下方配置。
</Typography.Paragraph>
{enabled ? (
<Typography.Paragraph type="warning" style={{ marginBottom: 16 }}>
当前已启用:所有待补资料工单进入页面时都会显示该提示。
</Typography.Paragraph>
) : (
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
当前未启用:不会影响现有补资料流程。
</Typography.Paragraph>
)}
{configQuery.isError ? (
<Typography.Paragraph type="danger" style={{ marginBottom: 16 }}>
读取配置失败,当前显示的是默认文案;请确认后端已更新并重启后再保存。
</Typography.Paragraph>
) : null}
<Form
form={form}
layout="vertical"
initialValues={DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG}
onFinish={(values) => void save(values)}
style={{ maxWidth: 900 }}
>
<Form.Item
name="enabled"
label="启用未成年提示"
valuePropName="checked"
extra="默认关闭。将该开关打开并保存后,客户端才会弹出提示。"
>
<Switch checkedChildren="启用" unCheckedChildren="关闭" />
</Form.Item>
<Row gutter={[12, 0]}>
<Col xs={24} md={12}>
<Form.Item
name="title"
label="弹窗标题"
rules={[{ required: true, whitespace: true, message: '请填写弹窗标题' }]}
>
<Input maxLength={40} placeholder="购买前必读" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item
name="warningText"
label="红色警示语"
rules={[{ required: true, whitespace: true, message: '请填写红色警示语' }]}
>
<Input maxLength={200} placeholder="无法向未成年人操作发货,请认真阅读作答!!!" />
</Form.Item>
</Col>
</Row>
<Form.Item
name="content"
label="正文内容"
rules={[{ required: true, whitespace: true, message: '请填写正文内容' }]}
extra="支持换行;客户页面会按原样展示。"
>
<Input.TextArea
autoSize={{ minRows: 8, maxRows: 18 }}
maxLength={2000}
showCount
placeholder="请输入购买前须知"
/>
</Form.Item>
<Form.Item
name="importantNotice"
label="重要提示"
extra="显示在正文下方的红色提示框;留空后后端会使用默认内容。"
>
<Input.TextArea
autoSize={{ minRows: 2, maxRows: 5 }}
maxLength={500}
showCount
placeholder="【重要提示】请警惕冒充售后、道具回收等诈骗行为。"
/>
</Form.Item>
<Row gutter={[12, 0]}>
<Col xs={24} md={12}>
<Form.Item
name="adultButtonText"
label="已成年按钮文字"
rules={[{ required: true, whitespace: true, message: '请填写已成年按钮文字' }]}
>
<Input maxLength={12} placeholder="我已成年" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item
name="minorButtonText"
label="未成年按钮文字"
rules={[{ required: true, whitespace: true, message: '请填写未成年按钮文字' }]}
>
<Input maxLength={12} placeholder="我是未成年" />
</Form.Item>
</Col>
</Row>
<Form.Item
name="minorBlockedTitle"
label="未成年拦截标题"
rules={[{ required: true, whitespace: true, message: '请填写未成年拦截标题' }]}
>
<Input maxLength={40} placeholder="未成年不能购买" />
</Form.Item>
<Form.Item
name="minorBlockedContent"
label="未成年拦截正文"
rules={[{ required: true, whitespace: true, message: '请填写未成年拦截正文' }]}
>
<Input.TextArea
autoSize={{ minRows: 3, maxRows: 6 }}
maxLength={500}
showCount
placeholder="根据平台规则,本店无法向未成年人销售或操作发货。当前流程已停止。"
/>
</Form.Item>
<Space>
<Button type="primary" htmlType="submit" loading={saving}>
保存配置
</Button>
<Text type="secondary">保存后新打开的客户工单补资料页立即使用最新配置。</Text>
</Space>
</Form>
</Card>
)
}
@@ -50,8 +50,9 @@ import {
type OrderServiceStatusSteps, type OrderServiceStatusSteps,
} from '@/services/admin/worker-platform' } from '@/services/admin/worker-platform'
import { uploadFile } from '@/services/files' import { uploadFile } from '@/services/files'
import type { UploadedFile } from '@/types/worker-platform' import type { OrderServiceAgeGateConfig, UploadedFile } from '@/types/worker-platform'
import { formatAdminDateTime } from '@/utils/admin-time' import { formatAdminDateTime } from '@/utils/admin-time'
import { DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG } from '@/utils/order-service-age-gate'
const { Text, Title } = Typography const { Text, Title } = Typography
@@ -82,6 +83,8 @@ type OrderServiceFormValues = {
autoPublish: AutoPublishForm autoPublish: AutoPublishForm
materialConfirmation: OrderServiceMaterialConfirmation materialConfirmation: OrderServiceMaterialConfirmation
statusSteps: OrderServiceStatusSteps statusSteps: OrderServiceStatusSteps
ageGate: OrderServiceAgeGateConfig
bottomGuideImage: { enabled: boolean }
} }
type OrderServiceCategoryNode = { type OrderServiceCategoryNode = {
@@ -256,6 +259,9 @@ export default function OrderServicePanel() {
const [expandedCategoryIds, setExpandedCategoryIds] = useState<Set<number>>(() => new Set()) const [expandedCategoryIds, setExpandedCategoryIds] = useState<Set<number>>(() => new Set())
const [fields, setFields] = useState<OrderServiceField[]>([]) const [fields, setFields] = useState<OrderServiceField[]>([])
const [guideImage, setGuideImage] = useState<UploadedFile | Record<string, unknown> | null>(null) const [guideImage, setGuideImage] = useState<UploadedFile | Record<string, unknown> | null>(null)
const [bottomGuideImage, setBottomGuideImage] = useState<
UploadedFile | Record<string, unknown> | null
>(null)
const [saving, setSaving] = useState(false) const [saving, setSaving] = useState(false)
const [publishing, setPublishing] = useState(false) const [publishing, setPublishing] = useState(false)
const [retryingJobId, setRetryingJobId] = useState(0) const [retryingJobId, setRetryingJobId] = useState(0)
@@ -342,6 +348,12 @@ export default function OrderServicePanel() {
Form.useWatch('materialConfirmation', form) || DEFAULT_MATERIAL_CONFIRMATION Form.useWatch('materialConfirmation', form) || DEFAULT_MATERIAL_CONFIRMATION
const confirmationEnabledValue = Form.useWatch(['materialConfirmation', 'enabled'], form) const confirmationEnabledValue = Form.useWatch(['materialConfirmation', 'enabled'], form)
const confirmationEnabled = confirmationEnabledValue !== false const confirmationEnabled = confirmationEnabledValue !== false
const ageGateEnabled = Form.useWatch(['ageGate', 'enabled'], form) === true
const bottomGuideEnabled = Form.useWatch(['bottomGuideImage', 'enabled'], form) === true
const bottomGuideFiles = useMemo(() => {
const image = resolveGuideImage(bottomGuideImage)
return image ? [image] : []
}, [bottomGuideImage])
useEffect(() => { useEffect(() => {
if (selectedCategoryId !== null || categories.length === 0) return if (selectedCategoryId !== null || categories.length === 0) return
@@ -361,6 +373,8 @@ export default function OrderServicePanel() {
title: nextProfile?.title || '', title: nextProfile?.title || '',
description: nextProfile?.description || '', description: nextProfile?.description || '',
guideImageDescription: nextProfile?.guideImageDescription || '', guideImageDescription: nextProfile?.guideImageDescription || '',
ageGate: nextProfile?.ageGate || DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
bottomGuideImage: { enabled: nextProfile?.bottomGuideImage?.enabled === true },
submitText: nextProfile?.submitText || '提交资料', submitText: nextProfile?.submitText || '提交资料',
successText: nextProfile?.successText || '资料已提交,请等待处理', successText: nextProfile?.successText || '资料已提交,请等待处理',
postSubmitText: nextProfile?.postSubmitText || DEFAULT_POST_SUBMIT_TEXT, postSubmitText: nextProfile?.postSubmitText || DEFAULT_POST_SUBMIT_TEXT,
@@ -375,6 +389,7 @@ export default function OrderServicePanel() {
), ),
) )
setGuideImage(resolveGuideImage(nextProfile?.guideImage)) setGuideImage(resolveGuideImage(nextProfile?.guideImage))
setBottomGuideImage(resolveGuideImage(nextProfile?.bottomGuideImage?.image || null))
} }
async function refresh() { async function refresh() {
@@ -473,6 +488,11 @@ export default function OrderServicePanel() {
description: values.description || '', description: values.description || '',
guideImage: guideImage || {}, guideImage: guideImage || {},
guideImageDescription: values.guideImageDescription || '', guideImageDescription: values.guideImageDescription || '',
ageGate: values.ageGate,
bottomGuideImage: {
enabled: values.bottomGuideImage?.enabled === true,
image: bottomGuideImage || null,
},
fields: normalizedFields, fields: normalizedFields,
screenshots: values.screenshots, screenshots: values.screenshots,
autoPublish: values.autoPublish, autoPublish: values.autoPublish,
@@ -1243,6 +1263,147 @@ export default function OrderServicePanel() {
</Col> </Col>
</Row> </Row>
<section className="order-service-section">
<div className="order-service-section-head">
<OrderServiceSectionTitle
index="07"
title="未成年提示"
description="客户进入待补资料页时先展示,确认成年后才显示资料表单"
/>
<div className="order-service-confirmation-switch">
<span>
<Text strong>{ageGateEnabled ? '已启用' : '已停用'}</Text>
<Text type="secondary">
{ageGateEnabled ? '命中该分类时弹窗' : '命中该分类时不弹窗'}
</Text>
</span>
<Form.Item name={['ageGate', 'enabled']} valuePropName="checked" noStyle>
<Switch />
</Form.Item>
</div>
</div>
<Row gutter={[12, 0]}>
<Col xs={24} md={12}>
<Form.Item
name={['ageGate', 'title']}
label="弹窗标题"
rules={[{ required: true, whitespace: true, message: '请填写弹窗标题' }]}
>
<Input maxLength={40} placeholder="购买前必读" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item
name={['ageGate', 'warningText']}
label="红色警示语"
rules={[
{ required: true, whitespace: true, message: '请填写红色警示语' },
]}
>
<Input
maxLength={200}
placeholder="无法向未成年人操作发货,请认真阅读作答!!!"
/>
</Form.Item>
</Col>
</Row>
<Form.Item
name={['ageGate', 'content']}
label="正文内容"
rules={[{ required: true, whitespace: true, message: '请填写正文内容' }]}
extra="支持换行;客户页面按原样展示。"
>
<Input.TextArea
autoSize={{ minRows: 8, maxRows: 18 }}
maxLength={2000}
showCount
/>
</Form.Item>
<Form.Item name={['ageGate', 'importantNotice']} label="重要提示">
<Input.TextArea
autoSize={{ minRows: 2, maxRows: 5 }}
maxLength={500}
showCount
placeholder="显示在正文下方的重要提示"
/>
</Form.Item>
<Row gutter={[12, 0]}>
<Col xs={24} md={12}>
<Form.Item
name={['ageGate', 'adultButtonText']}
label="已成年按钮文字"
rules={[{ required: true, whitespace: true, message: '请填写按钮文字' }]}
>
<Input maxLength={12} placeholder="我已成年" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item
name={['ageGate', 'minorButtonText']}
label="未成年按钮文字"
rules={[{ required: true, whitespace: true, message: '请填写按钮文字' }]}
>
<Input maxLength={12} placeholder="我是未成年" />
</Form.Item>
</Col>
</Row>
<Form.Item
name={['ageGate', 'minorBlockedTitle']}
label="未成年拦截标题"
rules={[{ required: true, whitespace: true, message: '请填写拦截标题' }]}
>
<Input maxLength={40} placeholder="未成年不能购买" />
</Form.Item>
<Form.Item
name={['ageGate', 'minorBlockedContent']}
label="未成年拦截正文"
rules={[{ required: true, whitespace: true, message: '请填写拦截正文' }]}
>
<Input.TextArea
autoSize={{ minRows: 3, maxRows: 6 }}
maxLength={500}
showCount
/>
</Form.Item>
</section>
<section className="order-service-section">
<div className="order-service-section-head">
<OrderServiceSectionTitle
index="08"
title="底部引导图"
description="独立于截图填写参考图,显示在客户填写资料页最底部"
/>
<div className="order-service-confirmation-switch">
<span>
<Text strong>{bottomGuideEnabled ? '已启用' : '已停用'}</Text>
<Text type="secondary">
{bottomGuideEnabled ? '命中分类时展示图片' : '命中分类时不展示'}
</Text>
</span>
<Form.Item
name={['bottomGuideImage', 'enabled']}
valuePropName="checked"
noStyle
>
<Switch />
</Form.Item>
</div>
</div>
<Form.Item
label="引导图"
extra="只配置图片,不配置说明文字;没有图片或未启用时不显示。"
>
<ImageUpload
scene="order-service-guide"
scope="admin"
maxCount={1}
value={bottomGuideFiles}
onChange={(files) => setBottomGuideImage(files[0] || null)}
uploader={uploadGuideImage}
/>
</Form.Item>
</section>
<div className="order-service-save-bar"> <div className="order-service-save-bar">
<Text type="secondary">保存只更新草稿,发布后才会影响新工单。</Text> <Text type="secondary">保存只更新草稿,发布后才会影响新工单。</Text>
<Space> <Space>
@@ -38,8 +38,10 @@ import {
import type { UploadedFile } from '@/types/worker-platform' import type { UploadedFile } from '@/types/worker-platform'
import { normalizeOrderServiceInput } from '@/utils/order-service-link' import { normalizeOrderServiceInput } from '@/utils/order-service-link'
import { import {
dedupeOrderServiceBottomGuideImages,
isOrderServiceAgeGateOpen, isOrderServiceAgeGateOpen,
resolveOrderServiceAgeGateDecision, resolveOrderServiceAgeGateDecision,
selectFirstOrderServiceAgeGate,
shouldRequireOrderServiceAgeGate, shouldRequireOrderServiceAgeGate,
type OrderServiceAgeGateState, type OrderServiceAgeGateState,
} from '@/utils/order-service-age-gate' } from '@/utils/order-service-age-gate'
@@ -109,11 +111,14 @@ export default function OrderServicePage() {
const confirmationOpenRef = useRef(false) const confirmationOpenRef = useRef(false)
const requestSeqRef = useRef(0) const requestSeqRef = useRef(0)
const loadedOrderRef = useRef('') const loadedOrderRef = useRef('')
const infoRef = useRef<OrderServiceInfo | null>(null)
const pendingItems = (info?.items || []).filter((item) => item.canSubmit) const pendingItems = (info?.items || []).filter((item) => item.canSubmit)
const selectedAgeGate = selectFirstOrderServiceAgeGate(pendingItems)
const bottomGuideImages = dedupeOrderServiceBottomGuideImages(pendingItems)
const ageGateDecision = resolveOrderServiceAgeGateDecision(ageGateState, orderNo) const ageGateDecision = resolveOrderServiceAgeGateDecision(ageGateState, orderNo)
const ageGateRequired = shouldRequireOrderServiceAgeGate({ const ageGateRequired = shouldRequireOrderServiceAgeGate({
enabled: info?.ageGate?.enabled, enabled: Boolean(selectedAgeGate),
pendingCount: pendingItems.length, pendingCount: pendingItems.length,
}) })
const ageGateOpen = isOrderServiceAgeGateOpen({ const ageGateOpen = isOrderServiceAgeGateOpen({
@@ -123,6 +128,11 @@ export default function OrderServicePage() {
useOrderServicePageMeta(ageGateOpen ? '购买前确认' : info?.items[0]?.title || '订单服务') useOrderServicePageMeta(ageGateOpen ? '购买前确认' : info?.items[0]?.title || '订单服务')
useEffect(() => {
infoRef.current = info
}, [info])
/* eslint-disable react-hooks/preserve-manual-memoization */
const load = useCallback( const load = useCallback(
async (options: { silent?: boolean } = {}) => { async (options: { silent?: boolean } = {}) => {
const seq = requestSeqRef.current + 1 const seq = requestSeqRef.current + 1
@@ -145,7 +155,7 @@ export default function OrderServicePage() {
setLoadError(null) setLoadError(null)
} catch (error) { } catch (error) {
if (seq !== requestSeqRef.current) return if (seq !== requestSeqRef.current) return
if (options.silent && info) return if (options.silent && infoRef.current) return
setInfo(null) setInfo(null)
setLoadError({ setLoadError({
code: resolveErrorCode(error), code: resolveErrorCode(error),
@@ -155,7 +165,7 @@ export default function OrderServicePage() {
if (seq === requestSeqRef.current && !options.silent) setLoading(false) if (seq === requestSeqRef.current && !options.silent) setLoading(false)
} }
}, },
[info, orderNo, setInfo, setLoading, setLoadError, setSubmittedNames, setLastSuccessText], [orderNo],
) )
useEffect(() => { useEffect(() => {
@@ -320,11 +330,11 @@ export default function OrderServicePage() {
return ( return (
<main className="collect-link-page"> <main className="collect-link-page">
{info?.ageGate ? ( {selectedAgeGate ? (
<OrderServiceAgeGateModal <OrderServiceAgeGateModal
open={ageGateOpen} open={ageGateOpen}
minorSelected={ageGateDecision === 'minor'} minorSelected={ageGateDecision === 'minor'}
config={info.ageGate} config={selectedAgeGate}
onAdult={() => setAgeGateState({ orderNo, decision: 'adult' })} onAdult={() => setAgeGateState({ orderNo, decision: 'adult' })}
onMinor={() => setAgeGateState({ orderNo, decision: 'minor' })} onMinor={() => setAgeGateState({ orderNo, decision: 'minor' })}
/> />
@@ -419,6 +429,21 @@ export default function OrderServicePage() {
<Text type="secondary" className="collect-link-footnote"> <Text type="secondary" className="collect-link-footnote">
{pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'} {pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'}
</Text> </Text>
{bottomGuideImages.length > 0 ? (
<Image.PreviewGroup>
<div className="collect-link-bottom-guides">
{bottomGuideImages.map((guide) => (
<Image
key={guide.image.objectKey || guide.image.url}
alt="资料填写引导图"
className="collect-link-bottom-guide-image"
preview={{ mask: '查看大图' }}
src={guide.image.url}
/>
))}
</div>
</Image.PreviewGroup>
) : null}
</Space> </Space>
) : null} ) : null}
</Card> </Card>
@@ -34,6 +34,7 @@ import type {
WorkerProductMatchConfig, WorkerProductMatchConfig,
WorkerAnnouncementConfig, WorkerAnnouncementConfig,
OrderServiceAgeGateConfig, OrderServiceAgeGateConfig,
OrderServiceBottomGuideImageConfig,
WorkerSupportContactConfig, WorkerSupportContactConfig,
WorkerProductNameSuffixConfig, WorkerProductNameSuffixConfig,
WorkerLevel, WorkerLevel,
@@ -138,17 +139,6 @@ export function saveAdminWorkerAnnouncement(payload: WorkerAnnouncementConfig) {
return apiPost<WorkerAnnouncementConfig>('/api/v1/admin/worker-platform/announcement', payload) return apiPost<WorkerAnnouncementConfig>('/api/v1/admin/worker-platform/announcement', payload)
} }
export function fetchAdminOrderServiceAgeGateConfig() {
return apiGet<OrderServiceAgeGateConfig>('/api/v1/admin/worker-platform/order-service-age-gate')
}
export function saveAdminOrderServiceAgeGateConfig(payload: OrderServiceAgeGateConfig) {
return apiPost<OrderServiceAgeGateConfig>(
'/api/v1/admin/worker-platform/order-service-age-gate',
payload,
)
}
export function fetchAdminWorkerSupportContact() { export function fetchAdminWorkerSupportContact() {
return apiGet<WorkerSupportContactConfig>('/api/v1/admin/worker-platform/support-contact') return apiGet<WorkerSupportContactConfig>('/api/v1/admin/worker-platform/support-contact')
} }
@@ -1281,6 +1271,11 @@ export type AdminOrderServiceProfile = {
description: string description: string
guideImage: UploadedFile | Record<string, unknown> guideImage: UploadedFile | Record<string, unknown>
guideImageDescription: string guideImageDescription: string
ageGate: OrderServiceAgeGateConfig
bottomGuideImage: {
enabled: boolean
image: UploadedFile | Record<string, unknown> | null
}
fields: OrderServiceField[] fields: OrderServiceField[]
screenshots: { screenshots: {
enabled: boolean enabled: boolean
@@ -1331,6 +1326,11 @@ export function saveAdminOrderServiceProfile(payload: {
description?: string description?: string
guideImage?: UploadedFile | Record<string, unknown> guideImage?: UploadedFile | Record<string, unknown>
guideImageDescription?: string guideImageDescription?: string
ageGate: OrderServiceAgeGateConfig
bottomGuideImage: {
enabled: boolean
image: UploadedFile | Record<string, unknown> | null
}
fields: OrderServiceField[] fields: OrderServiceField[]
screenshots: { screenshots: {
enabled: boolean enabled: boolean
+3 -1
View File
@@ -10,6 +10,7 @@ import type {
WorkerCancelRequestRisk, WorkerCancelRequestRisk,
WorkerAnnouncementConfig, WorkerAnnouncementConfig,
OrderServiceAgeGateConfig, OrderServiceAgeGateConfig,
OrderServiceBottomGuideImageConfig,
WorkerSupportContactConfig, WorkerSupportContactConfig,
WorkerProductNameSuffixConfig, WorkerProductNameSuffixConfig,
WorkerProductNameSuffixDisplayConfig, WorkerProductNameSuffixDisplayConfig,
@@ -707,13 +708,14 @@ export type OrderServiceItem = {
submittedAt?: string submittedAt?: string
acceptanceSubmittedAt?: string acceptanceSubmittedAt?: string
acceptedAt?: string acceptedAt?: string
ageGate?: OrderServiceAgeGateConfig
bottomGuideImage?: OrderServiceBottomGuideImageConfig
} }
export type OrderServiceInfo = { export type OrderServiceInfo = {
platformOrderId: string platformOrderId: string
items: OrderServiceItem[] items: OrderServiceItem[]
pendingCount: number pendingCount: number
ageGate?: OrderServiceAgeGateConfig
} }
export type OrderServiceSubmitResult = { export type OrderServiceSubmitResult = {
@@ -1002,3 +1002,26 @@
font-size: 15px; font-size: 15px;
} }
} }
/* ===== 工单补资料页底部引导图 ===== */
.collect-link-bottom-guides {
display: grid;
gap: 12px;
width: 100%;
margin-top: 4px;
}
.collect-link-bottom-guides .ant-image {
display: block;
width: 100%;
}
.collect-link-bottom-guides .ant-image-img {
display: block;
width: 100%;
height: auto;
border: 1px solid #e7edf5;
border-radius: 10px;
background: #ffffff;
}
+6 -1
View File
@@ -349,7 +349,7 @@ export type WorkerAnnouncementConfig = {
content: string content: string
} }
/** 工单补资料页未成年提示:全局配置,默认关闭。 */ /** 订单服务分类级未成年提示配置。 */
export type OrderServiceAgeGateConfig = { export type OrderServiceAgeGateConfig = {
enabled: boolean enabled: boolean
title: string title: string
@@ -362,6 +362,11 @@ export type OrderServiceAgeGateConfig = {
minorBlockedContent: string minorBlockedContent: string
} }
export type OrderServiceBottomGuideImageConfig = {
enabled: boolean
image: UploadedFile | null
}
export type WorkerSupportContactConfig = { export type WorkerSupportContactConfig = {
enabled: boolean enabled: boolean
wechatId: string wechatId: string
@@ -68,11 +68,7 @@ export const WORKER_PLATFORM_TAB_QUERY_KEYS: Record<string, string[][]> = {
finance: [['admin-finance-settlements'], ['admin-finance-withdrawals']], finance: [['admin-finance-settlements'], ['admin-finance-withdrawals']],
levels: [['admin-worker-levels']], levels: [['admin-worker-levels']],
notifications: [['admin-notifications']], notifications: [['admin-notifications']],
announcement: [ announcement: [['admin-announcements'], ['admin-worker-support-contact']],
['admin-announcements'],
['admin-worker-support-contact'],
['admin-order-service-age-gate'],
],
'hall-config': [['admin-hall-config']], 'hall-config': [['admin-hall-config']],
'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']], 'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']],
} }
@@ -1,4 +1,8 @@
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform' import type {
OrderServiceAgeGateConfig,
OrderServiceBottomGuideImageConfig,
UploadedFile,
} from '@/types/worker-platform'
export type OrderServiceAgeGateDecision = 'pending' | 'adult' | 'minor' export type OrderServiceAgeGateDecision = 'pending' | 'adult' | 'minor'
@@ -127,3 +131,25 @@ export function mergeOrderServiceAgeGateConfig(
), ),
} }
} }
export function selectFirstOrderServiceAgeGate(
items: Array<{ ageGate?: OrderServiceAgeGateConfig }>,
): OrderServiceAgeGateConfig | null {
return items.find((item) => item.ageGate)?.ageGate || null
}
export function dedupeOrderServiceBottomGuideImages(
items: Array<{ bottomGuideImage?: OrderServiceBottomGuideImageConfig }>,
): Array<OrderServiceBottomGuideImageConfig & { image: UploadedFile }> {
const result: Array<OrderServiceBottomGuideImageConfig & { image: UploadedFile }> = []
const seen = new Set<string>()
for (const item of items) {
const config = item.bottomGuideImage
if (!config?.enabled || !config.image) continue
const identity = String(config.image.objectKey || config.image.url || '').trim()
if (!identity || seen.has(identity)) continue
seen.add(identity)
result.push({ ...config, image: config.image })
}
return result
}
@@ -3,10 +3,12 @@ import test from 'node:test'
import { import {
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
dedupeOrderServiceBottomGuideImages,
canAccessOrderServiceMaterial, canAccessOrderServiceMaterial,
isOrderServiceAgeGateOpen, isOrderServiceAgeGateOpen,
mergeOrderServiceAgeGateConfig, mergeOrderServiceAgeGateConfig,
parseOrderServiceAgeGateContent, parseOrderServiceAgeGateContent,
selectFirstOrderServiceAgeGate,
resolveOrderServiceAgeGateDecision, resolveOrderServiceAgeGateDecision,
shouldRequireOrderServiceAgeGate, shouldRequireOrderServiceAgeGate,
} from '../src/utils/order-service-age-gate.ts' } from '../src/utils/order-service-age-gate.ts'
@@ -79,3 +81,37 @@ test('弹窗打开时整页内容必须隐藏,已成年后才恢复', () => {
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'adult' }), false) assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'adult' }), false)
assert.equal(isOrderServiceAgeGateOpen({ required: false, decision: 'pending' }), false) assert.equal(isOrderServiceAgeGateOpen({ required: false, decision: 'pending' }), false)
}) })
test('多商品只选第一个未成年提示配置,底部引导图按图片去重', () => {
const gateA = {
enabled: true,
title: 'A',
warningText: 'A',
content: 'A',
importantNotice: 'A',
adultButtonText: '我已成年',
minorButtonText: '我是未成年',
minorBlockedTitle: '不能购买',
minorBlockedContent: '停止',
}
const gateB = { ...gateA, title: 'B' }
const image = {
objectKey: 'order-service-guide/a.png',
url: '/a.png',
thumbnailUrl: '/a.png',
mediumUrl: '/a.png',
filename: 'a.png',
contentType: 'image/png',
size: 1,
}
assert.equal(selectFirstOrderServiceAgeGate([{ ageGate: gateA }, { ageGate: gateB }])?.title, 'A')
assert.equal(
dedupeOrderServiceBottomGuideImages([
{ bottomGuideImage: { enabled: true, image } },
{ bottomGuideImage: { enabled: true, image } },
{ bottomGuideImage: { enabled: false, image } },
]).length,
1,
)
})
@@ -3,7 +3,7 @@ type: 权威架构与实施计划
description: 订单、内部 SKU、履约路由、履约执行、商品、成本与财务的唯一权威口径及重构计划。 description: 订单、内部 SKU、履约路由、履约执行、商品、成本与财务的唯一权威口径及重构计划。
tags: [订单, 内部SKU, 履约, 商品, 成本, 财务, 迁移] tags: [订单, 内部SKU, 履约, 商品, 成本, 财务, 迁移]
status: authoritative status: authoritative
version: 2.39 version: 2.40
updated_at: 2026-11-27 updated_at: 2026-11-27
--- ---
@@ -821,16 +821,44 @@ has_active_cost
发布流程恢复。 发布流程恢复。
- 关闭动作只记录 `closed_by_admin` 工单事件和后台审计,不修改平台支付、退款或售后事实。 - 关闭动作只记录 `closed_by_admin` 工单事件和后台审计,不修改平台支付、退款或售后事实。
### 7.3 工单补资料页未成年提示 ### 7.3 工单补资料页分类内容配置
工单补资料页 `/o/<平台订单号>` 在存在待补资料商品时,可以展示购买前未成年提示: 工单补资料页 `/o/<平台订单号>` 的未成年提示和底部引导图,直接属于分类级订单服务配置:
- 配置真源为 `app_config_entries.order_service_age_gate`,后台入口为“接单平台 → 杂项配置”。 - 配置真源为 `order_service_profiles.age_gate_json` 和
- 配置默认关闭;运营在杂项配置中保存并启用后才生效,适用范围为所有 `/o/<平台订单号>` 待补资料页面。 `order_service_profiles.bottom_guide_image_json`;草稿、发布版本和工单快照继续复用
- 已成年只对当前页面打开周期有效,刷新或重新进入需要重新确认;不得用 `localStorage` 长期放行。 `order_service_profiles` / `order_service_profile_versions`。
- 客户点击“我已成年”后关闭提示并继续原有资料填写流程;点击“我是未成年”后提示不可关闭、不可点遮罩或按 ESC 关闭,页面不得渲染可填写表单,也不能继续提交。 - 后台入口为“接单平台 → 订单服务”;选中分类后在现有资料收集配置编辑区维护,
- 标题、红色警示语、正文、重要提示、按钮文字和未成年拦截文案均来自上述配置;正文和提示按纯文本换行展示,不使用富文本 HTML。 不另设独立配置列表。
- 该提示是客户自述确认,不构成真实年龄核验;服务端提交接口仍保持原有权限和状态校验,不把前端弹窗当作身份认证。 - 一个分类最多一份未成年提示配置和一份底部引导图配置,可以单独启停。
- 子分类有独立订单服务配置时使用自己的配置;没有独立配置时整体继承父分类配置。
不按字段逐项回退,不新增第二套命中逻辑。
- 配置随订单服务草稿保存、发布版本和工单创建快照生效;发布后按现有逻辑回填该分类下
尚未提交资料的工单快照。
- 旧 `app_config_entries.order_service_age_gate` 不再作为运行期真源或全局兜底;
内容仅作为默认文案参考保留。
未成年提示规则:
- 只有存在待补资料商品且该商品所属分类的有效订单服务配置启用未成年提示时才展示。
- 多个待补资料商品命中不同配置时,按商品顺序只使用第一个命中的启用配置。
- 弹窗打开时整张资料卡片不渲染;客户点击“我已成年”后才显示完整填写页面。
- 点击“我是未成年”后提示不可关闭、不可点遮罩或按 ESC 关闭,页面不得渲染可填写表单,
也不能继续提交。
- 已成年只对当前页面打开周期有效,刷新或重新进入需要重新确认;不得用 `localStorage`
长期放行。
- 标题、红色警示语、正文、重要提示、按钮文字和未成年拦截文案均来自分类配置;
正文和提示按纯文本换行展示,不使用富文本 HTML。
- 该提示是客户自述确认,不构成真实年龄核验;服务端提交接口仍保持原有权限和状态校验,
不把前端弹窗当作身份认证。
底部引导图规则:
- 与订单服务配置中的截图填写参考图相互独立,不替换、不复用原 `guideImage`。
- 只配置图片,不配置说明文字;图片使用公开文件场景 `order-service-guide`。
- 只对待补资料商品按分类配置解析;没有配置、配置停用或图片为空时不渲染。
- 多商品订单按商品顺序展示不同引导图,同一图片只展示一次。
- 引导图位于填写资料页面最底部,在所有商品表单和底部说明之后,可点击查看大图。
## 八、存量数据处理方案 ## 八、存量数据处理方案