功能(订单服务): 将未成年提示和底部引导图并入分类配置
This commit is contained in:
@@ -6,8 +6,6 @@ export const APP_CONFIG_KEYS = {
|
||||
workerPlatformNotifications: 'worker_platform_notifications',
|
||||
workerProductMatch: 'worker_product_match',
|
||||
workerAnnouncement: 'worker_announcement',
|
||||
/** 工单补资料页未成年提示:全局配置,默认关闭 */
|
||||
orderServiceAgeGate: 'order_service_age_gate',
|
||||
workerSupportContact: 'worker_support_contact',
|
||||
workerHall: 'worker_hall',
|
||||
/** 商品名来源后缀:按 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
|
||||
description: string
|
||||
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>>
|
||||
screenshots_json: Record<string, unknown>
|
||||
auto_publish_json: Record<string, unknown>
|
||||
@@ -99,6 +101,8 @@ export async function upsertOrderServiceProfile(input: {
|
||||
title: string
|
||||
description: string
|
||||
guideImage: Record<string, unknown>
|
||||
ageGate: Record<string, unknown>
|
||||
bottomGuideImage: Record<string, unknown>
|
||||
fields: Array<Record<string, unknown>>
|
||||
screenshots: Record<string, unknown>
|
||||
autoPublish: Record<string, unknown>
|
||||
@@ -113,19 +117,24 @@ export async function upsertOrderServiceProfile(input: {
|
||||
`
|
||||
INSERT INTO order_service_profiles (
|
||||
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,
|
||||
submit_text, success_text, post_submit_text, status, created_by_admin_user_id
|
||||
) VALUES (
|
||||
$1, $2, $3, $4,
|
||||
$5::jsonb, $6::jsonb, $7::jsonb, $8::jsonb, $9::jsonb, $10::jsonb,
|
||||
$11, $12, $13, 'draft', $14
|
||||
$5::jsonb, $6::jsonb, $7::jsonb,
|
||||
$8::jsonb, $9::jsonb, $10::jsonb,
|
||||
$11::jsonb, $12::jsonb,
|
||||
$13, $14, $15, 'draft', $16
|
||||
)
|
||||
ON CONFLICT (category_id) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
title = EXCLUDED.title,
|
||||
description = EXCLUDED.description,
|
||||
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,
|
||||
screenshots_json = EXCLUDED.screenshots_json,
|
||||
auto_publish_json = EXCLUDED.auto_publish_json,
|
||||
@@ -148,6 +157,8 @@ export async function upsertOrderServiceProfile(input: {
|
||||
input.title,
|
||||
input.description,
|
||||
JSON.stringify(input.guideImage),
|
||||
JSON.stringify(input.ageGate),
|
||||
JSON.stringify(input.bottomGuideImage),
|
||||
JSON.stringify(input.fields),
|
||||
JSON.stringify(input.screenshots),
|
||||
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')
|
||||
return mapProfile(row)
|
||||
}
|
||||
|
||||
export async function archiveOrderServiceProfile(
|
||||
profileId: number | string,
|
||||
): Promise<OrderServiceProfileRow | null> {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
deleteAdminWorkProductRule,
|
||||
deleteAdminWorkProductRuleMapping,
|
||||
deleteAdminWorkerLevel,
|
||||
getAdminOrderServiceAgeGateConfig,
|
||||
getAdminWorkerAnnouncementConfig,
|
||||
getAdminWorkerFinanceConfig,
|
||||
getAdminWorkerHallConfig,
|
||||
@@ -26,7 +25,6 @@ import {
|
||||
saveAdminWorkCategory,
|
||||
saveAdminWorkProductRule,
|
||||
saveAdminWorkProductRuleMapping,
|
||||
saveAdminOrderServiceAgeGateConfig,
|
||||
saveAdminWorkerAnnouncementConfig,
|
||||
archiveAdminOrderServiceProfile,
|
||||
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(
|
||||
'/worker-platform/support-contact',
|
||||
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) {
|
||||
const normalized = normalizeObjectKey(objectKey)
|
||||
|
||||
@@ -4,10 +4,6 @@ import {
|
||||
getWorkerAnnouncementConfig,
|
||||
saveWorkerAnnouncementConfig,
|
||||
} from './worker-announcement-config-service.js'
|
||||
import {
|
||||
getOrderServiceAgeGateConfig,
|
||||
saveOrderServiceAgeGateConfig,
|
||||
} from './order-service-age-gate-config-service.js'
|
||||
import {
|
||||
getWorkerPlatformNotificationConfig,
|
||||
saveWorkerPlatformNotificationConfig,
|
||||
@@ -45,14 +41,6 @@ export async function saveAdminWorkerAnnouncementConfig(payload: JsonObject = {}
|
||||
return saveWorkerAnnouncementConfig(payload)
|
||||
}
|
||||
|
||||
export async function getAdminOrderServiceAgeGateConfig() {
|
||||
return getOrderServiceAgeGateConfig()
|
||||
}
|
||||
|
||||
export async function saveAdminOrderServiceAgeGateConfig(payload: JsonObject = {}) {
|
||||
return saveOrderServiceAgeGateConfig(payload)
|
||||
}
|
||||
|
||||
export async function saveAdminWorkerProductMatchConfig(payload: JsonObject = {}) {
|
||||
return saveWorkerProductMatchConfig(payload)
|
||||
}
|
||||
|
||||
+19
@@ -3,6 +3,8 @@ import test from 'node:test'
|
||||
|
||||
import {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT,
|
||||
DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
|
||||
normalizeOrderServiceBottomGuideImageConfig,
|
||||
normalizeOrderServiceAgeGateConfig,
|
||||
} from './order-service-age-gate-config-service.js'
|
||||
|
||||
@@ -74,3 +76,20 @@ test('非布尔启用值和超长文本不会穿透配置边界', () => {
|
||||
assert.equal(config.minorBlockedTitle.length, 40)
|
||||
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')
|
||||
})
|
||||
|
||||
+20
-22
@@ -1,6 +1,5 @@
|
||||
import { APP_CONFIG_KEYS } from '../../config/app-config-keys.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 = {
|
||||
enabled: boolean
|
||||
@@ -14,6 +13,11 @@ export type OrderServiceAgeGateConfig = {
|
||||
minorBlockedContent: string
|
||||
}
|
||||
|
||||
export type OrderServiceBottomGuideImageConfig = {
|
||||
enabled: boolean
|
||||
image: Record<string, unknown>
|
||||
}
|
||||
|
||||
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 {
|
||||
return { ...DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG }
|
||||
}
|
||||
|
||||
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 const DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG: OrderServiceBottomGuideImageConfig = {
|
||||
enabled: false,
|
||||
image: {},
|
||||
}
|
||||
|
||||
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) {
|
||||
const normalized = String(value ?? '')
|
||||
.trim()
|
||||
|
||||
-78
@@ -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()
|
||||
}
|
||||
},
|
||||
)
|
||||
+132
@@ -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, /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'
|
||||
import { listAllWorkCategories } from '../../repositories/worker-platform/work-category-repo.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 OrderServiceFieldValidation = 'none' | 'digits'
|
||||
@@ -70,6 +78,8 @@ export type OrderServiceProfileConfig = {
|
||||
description: string
|
||||
guideImage: Record<string, unknown>
|
||||
guideImageDescription: string
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: OrderServiceBottomGuideImageConfig
|
||||
fields: OrderServiceField[]
|
||||
screenshots: OrderServiceScreenshots
|
||||
autoPublish: OrderServiceAutoPublish
|
||||
@@ -168,6 +178,10 @@ export async function saveAdminOrderServiceProfile(payload: JsonObject = {}) {
|
||||
payload.guideImage ?? payload.guide_image_json,
|
||||
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 saved = await upsertOrderServiceProfile({
|
||||
@@ -176,6 +190,8 @@ export async function saveAdminOrderServiceProfile(payload: JsonObject = {}) {
|
||||
title: text(payload.title, 80),
|
||||
description: text(payload.description, 300),
|
||||
guideImage,
|
||||
ageGate,
|
||||
bottomGuideImage,
|
||||
fields,
|
||||
screenshots,
|
||||
autoPublish,
|
||||
@@ -257,6 +273,8 @@ function mapAdminProfile(row: OrderServiceProfileRow) {
|
||||
description: row.description,
|
||||
guideImage: row.guide_image_json,
|
||||
guideImageDescription: buildProfileConfig(row).guideImageDescription,
|
||||
ageGate: buildProfileConfig(row).ageGate,
|
||||
bottomGuideImage: buildProfileConfig(row).bottomGuideImage,
|
||||
fields: buildProfileConfig(row).fields,
|
||||
screenshots: row.screenshots_json,
|
||||
autoPublish: row.auto_publish_json,
|
||||
@@ -278,6 +296,8 @@ export function buildProfileConfig(row: {
|
||||
title: string
|
||||
description: string
|
||||
guide_image_json: unknown
|
||||
age_gate_json?: unknown
|
||||
bottom_guide_image_json?: unknown
|
||||
fields_json: unknown
|
||||
screenshots_json: unknown
|
||||
auto_publish_json: unknown
|
||||
@@ -294,6 +314,8 @@ export function buildProfileConfig(row: {
|
||||
description: row.description,
|
||||
guideImage,
|
||||
guideImageDescription: readGuideImageDescription(guideImage),
|
||||
ageGate: normalizeOrderServiceAgeGateConfig(row.age_gate_json),
|
||||
bottomGuideImage: normalizeOrderServiceBottomGuideImageConfig(row.bottom_guide_image_json),
|
||||
fields: normalizeFields(row.fields_json),
|
||||
screenshots: normalizeScreenshots(row.screenshots_json),
|
||||
autoPublish: normalizeAutoPublish(row.auto_publish_json),
|
||||
@@ -358,6 +380,8 @@ export function normalizeProfileConfig(value: JsonObject): OrderServiceProfileCo
|
||||
description: text(value.description, 300),
|
||||
guideImage,
|
||||
guideImageDescription: readGuideImageDescription(guideImage),
|
||||
ageGate: normalizeOrderServiceAgeGateConfig(value.ageGate),
|
||||
bottomGuideImage: normalizeOrderServiceBottomGuideImageConfig(value.bottomGuideImage),
|
||||
fields: normalizeFields(value.fields),
|
||||
screenshots: normalizeScreenshots(value.screenshots),
|
||||
autoPublish: normalizeAutoPublish(value.autoPublish),
|
||||
|
||||
@@ -48,7 +48,12 @@ import {
|
||||
processDueOrderServiceAutoPublishJobs,
|
||||
} from './order-service-auto-publish-service.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> = {
|
||||
[WORK_ORDER_STATUS.PENDING_MATERIAL]: '请补充订单资料。',
|
||||
@@ -100,6 +105,8 @@ export type OrderServicePublicItem = {
|
||||
submittedAt?: string
|
||||
acceptanceSubmittedAt?: string
|
||||
acceptedAt?: string
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
bottomGuideImage?: OrderServiceBottomGuideImageConfig
|
||||
}
|
||||
|
||||
const PUBLIC_ACCEPTANCE_IMAGE_STATUSES = new Set<string>([
|
||||
@@ -227,7 +234,6 @@ export async function getOrderServiceByPlatformOrderId(platformOrderIdInput: unk
|
||||
platformOrderId,
|
||||
items,
|
||||
pendingCount: items.filter((item) => item.canSubmit).length,
|
||||
ageGate: getOrderServiceAgeGateConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,6 +504,15 @@ async function mapPublicOrderItem(order: WorkOrderRow): Promise<OrderServicePubl
|
||||
.map(refreshUploadedFileUrls)
|
||||
.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 = {
|
||||
workOrderId: Number(order.id),
|
||||
productName: String(order.product_name || ''),
|
||||
@@ -527,6 +542,8 @@ async function mapPublicOrderItem(order: WorkOrderRow): Promise<OrderServicePubl
|
||||
...(profile?.materialConfirmation
|
||||
? { materialConfirmation: profile.materialConfirmation }
|
||||
: {}),
|
||||
...(state.canSubmit && ageGate ? { ageGate } : {}),
|
||||
...(state.canSubmit && bottomGuideImage ? { bottomGuideImage } : {}),
|
||||
fields: profile?.fields || [],
|
||||
values,
|
||||
screenshots,
|
||||
@@ -586,6 +603,8 @@ async function resolveProfileConfig(
|
||||
description: '',
|
||||
guideImage: {},
|
||||
guideImageDescription: '',
|
||||
ageGate: DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
bottomGuideImage: DEFAULT_ORDER_SERVICE_BOTTOM_GUIDE_IMAGE_CONFIG,
|
||||
fields: normalizeProfileConfig({
|
||||
name: '通用资料',
|
||||
fields: legacy.fields,
|
||||
|
||||
@@ -45,7 +45,6 @@ import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { normalizeProductNameSuffixText } from '@/utils/product-name-source-suffix'
|
||||
|
||||
import HallConfigPanel from './HallConfigPanel'
|
||||
import OrderServiceAgeGateConfigCard from './OrderServiceAgeGateConfigCard'
|
||||
|
||||
function isDepositUnfreezeJob(job: AdminScheduledJobItem) {
|
||||
return job.type === 'deposit_unfreeze' || job.id === 'deposit-unfreeze'
|
||||
@@ -55,7 +54,6 @@ export default function AnnouncementPanel() {
|
||||
return (
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<AnnouncementCard />
|
||||
<OrderServiceAgeGateConfigCard />
|
||||
<SupportContactCard />
|
||||
<ProductNameSourceSuffixCard />
|
||||
<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/<订单号></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,
|
||||
} from '@/services/admin/worker-platform'
|
||||
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 { DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG } from '@/utils/order-service-age-gate'
|
||||
|
||||
const { Text, Title } = Typography
|
||||
|
||||
@@ -82,6 +83,8 @@ type OrderServiceFormValues = {
|
||||
autoPublish: AutoPublishForm
|
||||
materialConfirmation: OrderServiceMaterialConfirmation
|
||||
statusSteps: OrderServiceStatusSteps
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: { enabled: boolean }
|
||||
}
|
||||
|
||||
type OrderServiceCategoryNode = {
|
||||
@@ -256,6 +259,9 @@ export default function OrderServicePanel() {
|
||||
const [expandedCategoryIds, setExpandedCategoryIds] = useState<Set<number>>(() => new Set())
|
||||
const [fields, setFields] = useState<OrderServiceField[]>([])
|
||||
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 [publishing, setPublishing] = useState(false)
|
||||
const [retryingJobId, setRetryingJobId] = useState(0)
|
||||
@@ -342,6 +348,12 @@ export default function OrderServicePanel() {
|
||||
Form.useWatch('materialConfirmation', form) || DEFAULT_MATERIAL_CONFIRMATION
|
||||
const confirmationEnabledValue = Form.useWatch(['materialConfirmation', 'enabled'], form)
|
||||
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(() => {
|
||||
if (selectedCategoryId !== null || categories.length === 0) return
|
||||
@@ -361,6 +373,8 @@ export default function OrderServicePanel() {
|
||||
title: nextProfile?.title || '',
|
||||
description: nextProfile?.description || '',
|
||||
guideImageDescription: nextProfile?.guideImageDescription || '',
|
||||
ageGate: nextProfile?.ageGate || DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
bottomGuideImage: { enabled: nextProfile?.bottomGuideImage?.enabled === true },
|
||||
submitText: nextProfile?.submitText || '提交资料',
|
||||
successText: nextProfile?.successText || '资料已提交,请等待处理',
|
||||
postSubmitText: nextProfile?.postSubmitText || DEFAULT_POST_SUBMIT_TEXT,
|
||||
@@ -375,6 +389,7 @@ export default function OrderServicePanel() {
|
||||
),
|
||||
)
|
||||
setGuideImage(resolveGuideImage(nextProfile?.guideImage))
|
||||
setBottomGuideImage(resolveGuideImage(nextProfile?.bottomGuideImage?.image || null))
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
@@ -473,6 +488,11 @@ export default function OrderServicePanel() {
|
||||
description: values.description || '',
|
||||
guideImage: guideImage || {},
|
||||
guideImageDescription: values.guideImageDescription || '',
|
||||
ageGate: values.ageGate,
|
||||
bottomGuideImage: {
|
||||
enabled: values.bottomGuideImage?.enabled === true,
|
||||
image: bottomGuideImage || null,
|
||||
},
|
||||
fields: normalizedFields,
|
||||
screenshots: values.screenshots,
|
||||
autoPublish: values.autoPublish,
|
||||
@@ -1243,6 +1263,147 @@ export default function OrderServicePanel() {
|
||||
</Col>
|
||||
</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">
|
||||
<Text type="secondary">保存只更新草稿,发布后才会影响新工单。</Text>
|
||||
<Space>
|
||||
|
||||
@@ -38,8 +38,10 @@ import {
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
import { normalizeOrderServiceInput } from '@/utils/order-service-link'
|
||||
import {
|
||||
dedupeOrderServiceBottomGuideImages,
|
||||
isOrderServiceAgeGateOpen,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
selectFirstOrderServiceAgeGate,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
type OrderServiceAgeGateState,
|
||||
} from '@/utils/order-service-age-gate'
|
||||
@@ -109,11 +111,14 @@ export default function OrderServicePage() {
|
||||
const confirmationOpenRef = useRef(false)
|
||||
const requestSeqRef = useRef(0)
|
||||
const loadedOrderRef = useRef('')
|
||||
const infoRef = useRef<OrderServiceInfo | null>(null)
|
||||
|
||||
const pendingItems = (info?.items || []).filter((item) => item.canSubmit)
|
||||
const selectedAgeGate = selectFirstOrderServiceAgeGate(pendingItems)
|
||||
const bottomGuideImages = dedupeOrderServiceBottomGuideImages(pendingItems)
|
||||
const ageGateDecision = resolveOrderServiceAgeGateDecision(ageGateState, orderNo)
|
||||
const ageGateRequired = shouldRequireOrderServiceAgeGate({
|
||||
enabled: info?.ageGate?.enabled,
|
||||
enabled: Boolean(selectedAgeGate),
|
||||
pendingCount: pendingItems.length,
|
||||
})
|
||||
const ageGateOpen = isOrderServiceAgeGateOpen({
|
||||
@@ -123,6 +128,11 @@ export default function OrderServicePage() {
|
||||
|
||||
useOrderServicePageMeta(ageGateOpen ? '购买前确认' : info?.items[0]?.title || '订单服务')
|
||||
|
||||
useEffect(() => {
|
||||
infoRef.current = info
|
||||
}, [info])
|
||||
|
||||
/* eslint-disable react-hooks/preserve-manual-memoization */
|
||||
const load = useCallback(
|
||||
async (options: { silent?: boolean } = {}) => {
|
||||
const seq = requestSeqRef.current + 1
|
||||
@@ -145,7 +155,7 @@ export default function OrderServicePage() {
|
||||
setLoadError(null)
|
||||
} catch (error) {
|
||||
if (seq !== requestSeqRef.current) return
|
||||
if (options.silent && info) return
|
||||
if (options.silent && infoRef.current) return
|
||||
setInfo(null)
|
||||
setLoadError({
|
||||
code: resolveErrorCode(error),
|
||||
@@ -155,7 +165,7 @@ export default function OrderServicePage() {
|
||||
if (seq === requestSeqRef.current && !options.silent) setLoading(false)
|
||||
}
|
||||
},
|
||||
[info, orderNo, setInfo, setLoading, setLoadError, setSubmittedNames, setLastSuccessText],
|
||||
[orderNo],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -320,11 +330,11 @@ export default function OrderServicePage() {
|
||||
|
||||
return (
|
||||
<main className="collect-link-page">
|
||||
{info?.ageGate ? (
|
||||
{selectedAgeGate ? (
|
||||
<OrderServiceAgeGateModal
|
||||
open={ageGateOpen}
|
||||
minorSelected={ageGateDecision === 'minor'}
|
||||
config={info.ageGate}
|
||||
config={selectedAgeGate}
|
||||
onAdult={() => setAgeGateState({ orderNo, decision: 'adult' })}
|
||||
onMinor={() => setAgeGateState({ orderNo, decision: 'minor' })}
|
||||
/>
|
||||
@@ -419,6 +429,21 @@ export default function OrderServicePage() {
|
||||
<Text type="secondary" className="collect-link-footnote">
|
||||
{pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'}
|
||||
</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>
|
||||
) : null}
|
||||
</Card>
|
||||
|
||||
@@ -34,6 +34,7 @@ import type {
|
||||
WorkerProductMatchConfig,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
OrderServiceBottomGuideImageConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerLevel,
|
||||
@@ -138,17 +139,6 @@ export function saveAdminWorkerAnnouncement(payload: WorkerAnnouncementConfig) {
|
||||
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() {
|
||||
return apiGet<WorkerSupportContactConfig>('/api/v1/admin/worker-platform/support-contact')
|
||||
}
|
||||
@@ -1281,6 +1271,11 @@ export type AdminOrderServiceProfile = {
|
||||
description: string
|
||||
guideImage: UploadedFile | Record<string, unknown>
|
||||
guideImageDescription: string
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: {
|
||||
enabled: boolean
|
||||
image: UploadedFile | Record<string, unknown> | null
|
||||
}
|
||||
fields: OrderServiceField[]
|
||||
screenshots: {
|
||||
enabled: boolean
|
||||
@@ -1331,6 +1326,11 @@ export function saveAdminOrderServiceProfile(payload: {
|
||||
description?: string
|
||||
guideImage?: UploadedFile | Record<string, unknown>
|
||||
guideImageDescription?: string
|
||||
ageGate: OrderServiceAgeGateConfig
|
||||
bottomGuideImage: {
|
||||
enabled: boolean
|
||||
image: UploadedFile | Record<string, unknown> | null
|
||||
}
|
||||
fields: OrderServiceField[]
|
||||
screenshots: {
|
||||
enabled: boolean
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
WorkerCancelRequestRisk,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
OrderServiceBottomGuideImageConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerProductNameSuffixDisplayConfig,
|
||||
@@ -707,13 +708,14 @@ export type OrderServiceItem = {
|
||||
submittedAt?: string
|
||||
acceptanceSubmittedAt?: string
|
||||
acceptedAt?: string
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
bottomGuideImage?: OrderServiceBottomGuideImageConfig
|
||||
}
|
||||
|
||||
export type OrderServiceInfo = {
|
||||
platformOrderId: string
|
||||
items: OrderServiceItem[]
|
||||
pendingCount: number
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
}
|
||||
|
||||
export type OrderServiceSubmitResult = {
|
||||
|
||||
@@ -1002,3 +1002,26 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ export type WorkerAnnouncementConfig = {
|
||||
content: string
|
||||
}
|
||||
|
||||
/** 工单补资料页未成年提示:全局配置,默认关闭。 */
|
||||
/** 订单服务分类级未成年提示配置。 */
|
||||
export type OrderServiceAgeGateConfig = {
|
||||
enabled: boolean
|
||||
title: string
|
||||
@@ -362,6 +362,11 @@ export type OrderServiceAgeGateConfig = {
|
||||
minorBlockedContent: string
|
||||
}
|
||||
|
||||
export type OrderServiceBottomGuideImageConfig = {
|
||||
enabled: boolean
|
||||
image: UploadedFile | null
|
||||
}
|
||||
|
||||
export type WorkerSupportContactConfig = {
|
||||
enabled: boolean
|
||||
wechatId: string
|
||||
|
||||
@@ -68,11 +68,7 @@ export const WORKER_PLATFORM_TAB_QUERY_KEYS: Record<string, string[][]> = {
|
||||
finance: [['admin-finance-settlements'], ['admin-finance-withdrawals']],
|
||||
levels: [['admin-worker-levels']],
|
||||
notifications: [['admin-notifications']],
|
||||
announcement: [
|
||||
['admin-announcements'],
|
||||
['admin-worker-support-contact'],
|
||||
['admin-order-service-age-gate'],
|
||||
],
|
||||
announcement: [['admin-announcements'], ['admin-worker-support-contact']],
|
||||
'hall-config': [['admin-hall-config']],
|
||||
'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'
|
||||
|
||||
@@ -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 {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
dedupeOrderServiceBottomGuideImages,
|
||||
canAccessOrderServiceMaterial,
|
||||
isOrderServiceAgeGateOpen,
|
||||
mergeOrderServiceAgeGateConfig,
|
||||
parseOrderServiceAgeGateContent,
|
||||
selectFirstOrderServiceAgeGate,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
} 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: 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,
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user