功能(订单服务): 增加可配置未成年提示门禁
This commit is contained in:
@@ -6,6 +6,8 @@ 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 在商品名后追加(文字),仅展示用 */
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
deleteAdminWorkProductRule,
|
||||
deleteAdminWorkProductRuleMapping,
|
||||
deleteAdminWorkerLevel,
|
||||
getAdminOrderServiceAgeGateConfig,
|
||||
getAdminWorkerAnnouncementConfig,
|
||||
getAdminWorkerFinanceConfig,
|
||||
getAdminWorkerHallConfig,
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
saveAdminWorkCategory,
|
||||
saveAdminWorkProductRule,
|
||||
saveAdminWorkProductRuleMapping,
|
||||
saveAdminOrderServiceAgeGateConfig,
|
||||
saveAdminWorkerAnnouncementConfig,
|
||||
archiveAdminOrderServiceProfile,
|
||||
listAdminOrderServiceAutoPublishJobs,
|
||||
@@ -376,6 +378,33 @@ router.post(
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/worker-platform/order-service-age-gate',
|
||||
requireAdminRoles(['admin']),
|
||||
setHttpCache(0),
|
||||
createJsonHandler(() => getAdminOrderServiceAgeGateConfig(), {
|
||||
successMessage: 'ok',
|
||||
errorMessage: '读取工单补资料页未成年提示失败',
|
||||
scope: '[admin/worker-platform/order-service-age-gate]',
|
||||
}),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/worker-platform/order-service-age-gate',
|
||||
requireAdminRoles(['admin']),
|
||||
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',
|
||||
requireAdminRoles(['admin']),
|
||||
|
||||
@@ -4,6 +4,10 @@ import {
|
||||
getWorkerAnnouncementConfig,
|
||||
saveWorkerAnnouncementConfig,
|
||||
} from './worker-announcement-config-service.js'
|
||||
import {
|
||||
getOrderServiceAgeGateConfig,
|
||||
saveOrderServiceAgeGateConfig,
|
||||
} from './order-service-age-gate-config-service.js'
|
||||
import {
|
||||
getWorkerPlatformNotificationConfig,
|
||||
saveWorkerPlatformNotificationConfig,
|
||||
@@ -41,6 +45,14 @@ 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)
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export {
|
||||
} from './admin-work-order-acceptance-service.js'
|
||||
export * from './worker-product-match-config-service.js'
|
||||
export * from './worker-announcement-config-service.js'
|
||||
export * from './order-service-age-gate-config-service.js'
|
||||
export * from './worker-support-contact-config-service.js'
|
||||
export * from './worker-hall-config-service.js'
|
||||
export * from './worker-product-name-suffix-service.js'
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT,
|
||||
normalizeOrderServiceAgeGateConfig,
|
||||
} from './order-service-age-gate-config-service.js'
|
||||
|
||||
test('工单补资料页未成年提示默认关闭,并带完整通用文案', () => {
|
||||
const config = normalizeOrderServiceAgeGateConfig({})
|
||||
|
||||
assert.equal(config.enabled, false)
|
||||
assert.equal(config.title, '购买前必读')
|
||||
assert.equal(config.warningText, '无法向未成年人操作发货,请认真阅读作答!!!')
|
||||
assert.equal(config.adultButtonText, '我已成年')
|
||||
assert.equal(config.minorButtonText, '我是未成年')
|
||||
assert.equal(config.minorBlockedTitle, '未成年不能购买')
|
||||
assert.equal(config.content, DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT)
|
||||
assert.match(config.content, /购买商品和角色信息有没有错误/)
|
||||
assert.doesNotMatch(config.content, /苏尔南|鉴定物珍宝/)
|
||||
assert.match(config.importantNotice, /冒充本店售后专员/)
|
||||
})
|
||||
|
||||
test('只有显式启用才生效,空文本回退默认值并裁剪首尾空白', () => {
|
||||
const config = normalizeOrderServiceAgeGateConfig({
|
||||
enabled: true,
|
||||
title: ' 购买说明 ',
|
||||
warningText: ' ',
|
||||
content: ' 1. 请核对角色信息 ',
|
||||
importantNotice: ' ',
|
||||
adultButtonText: ' 已成年 ',
|
||||
minorButtonText: '',
|
||||
minorBlockedTitle: ' 未成年拦截 ',
|
||||
minorBlockedContent: ' ',
|
||||
})
|
||||
|
||||
assert.equal(config.enabled, true)
|
||||
assert.equal(config.title, '购买说明')
|
||||
assert.equal(config.warningText, '无法向未成年人操作发货,请认真阅读作答!!!')
|
||||
assert.equal(config.content, '1. 请核对角色信息')
|
||||
assert.equal(
|
||||
config.importantNotice,
|
||||
'【重要提示】近期有人冒充本店售后专员,以“道具回收”为由实施诈骗。请广大玩家务必以本店官方售后渠道为准,谨防上当受骗。',
|
||||
)
|
||||
assert.equal(config.adultButtonText, '已成年')
|
||||
assert.equal(config.minorButtonText, '我是未成年')
|
||||
assert.equal(config.minorBlockedTitle, '未成年拦截')
|
||||
assert.equal(
|
||||
config.minorBlockedContent,
|
||||
'根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。',
|
||||
)
|
||||
})
|
||||
|
||||
test('非布尔启用值和超长文本不会穿透配置边界', () => {
|
||||
const config = normalizeOrderServiceAgeGateConfig({
|
||||
enabled: 'true',
|
||||
title: '标'.repeat(80),
|
||||
warningText: '警'.repeat(260),
|
||||
content: '文'.repeat(2200),
|
||||
importantNotice: '重'.repeat(600),
|
||||
adultButtonText: '已'.repeat(20),
|
||||
minorButtonText: '未'.repeat(20),
|
||||
minorBlockedTitle: '拦'.repeat(80),
|
||||
minorBlockedContent: '止'.repeat(600),
|
||||
})
|
||||
|
||||
assert.equal(config.enabled, false)
|
||||
assert.equal(config.title.length, 40)
|
||||
assert.equal(config.warningText.length, 200)
|
||||
assert.equal(config.content.length, 2000)
|
||||
assert.equal(config.importantNotice.length, 500)
|
||||
assert.equal(config.adultButtonText.length, 12)
|
||||
assert.equal(config.minorButtonText.length, 12)
|
||||
assert.equal(config.minorBlockedTitle.length, 40)
|
||||
assert.equal(config.minorBlockedContent.length, 500)
|
||||
})
|
||||
@@ -0,0 +1,96 @@
|
||||
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'
|
||||
|
||||
export type OrderServiceAgeGateConfig = {
|
||||
enabled: boolean
|
||||
title: string
|
||||
warningText: string
|
||||
content: string
|
||||
importantNotice: string
|
||||
adultButtonText: string
|
||||
minorButtonText: string
|
||||
minorBlockedTitle: string
|
||||
minorBlockedContent: string
|
||||
}
|
||||
|
||||
export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT = `1. 购买商品和角色信息有没有错误
|
||||
角色名/系统/区服有无遗漏
|
||||
如未核对导致送错,本店概不负责哦~
|
||||
|
||||
2. 购买本人实际为成年用户!!
|
||||
|
||||
3. 虚拟商品到您的游戏里,一旦发货完成,概不退款。
|
||||
|
||||
4. 发货时间具体以排单顺序为准,活动期间可能会延迟送达,未发货前协商可退。
|
||||
|
||||
5. 由于市场成本原因,价格会有所浮动,不支持以此原因退差价。
|
||||
|
||||
6. 禁止私自交易,私自交易被骗本店概不负责!!!!`
|
||||
|
||||
export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG: OrderServiceAgeGateConfig = {
|
||||
enabled: false,
|
||||
title: '购买前必读',
|
||||
warningText: '无法向未成年人操作发货,请认真阅读作答!!!',
|
||||
content: DEFAULT_ORDER_SERVICE_AGE_GATE_CONTENT,
|
||||
importantNotice:
|
||||
'【重要提示】近期有人冒充本店售后专员,以“道具回收”为由实施诈骗。请广大玩家务必以本店官方售后渠道为准,谨防上当受骗。',
|
||||
adultButtonText: '我已成年',
|
||||
minorButtonText: '我是未成年',
|
||||
minorBlockedTitle: '未成年不能购买',
|
||||
minorBlockedContent:
|
||||
'根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。',
|
||||
}
|
||||
|
||||
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 function normalizeOrderServiceAgeGateConfig(rawValue: unknown): OrderServiceAgeGateConfig {
|
||||
const source = isPlainObject(rawValue) ? rawValue : {}
|
||||
const defaults = DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG
|
||||
return {
|
||||
enabled: source.enabled === true,
|
||||
title: textOrDefault(source.title, defaults.title, 40),
|
||||
warningText: textOrDefault(source.warningText, defaults.warningText, 200),
|
||||
content: textOrDefault(source.content, defaults.content, 2000),
|
||||
importantNotice: textOrDefault(source.importantNotice, defaults.importantNotice, 500),
|
||||
adultButtonText: textOrDefault(source.adultButtonText, defaults.adultButtonText, 12),
|
||||
minorButtonText: textOrDefault(source.minorButtonText, defaults.minorButtonText, 12),
|
||||
minorBlockedTitle: textOrDefault(source.minorBlockedTitle, defaults.minorBlockedTitle, 40),
|
||||
minorBlockedContent: textOrDefault(
|
||||
source.minorBlockedContent,
|
||||
defaults.minorBlockedContent,
|
||||
500,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
function textOrDefault(value: unknown, fallback: string, maxLength: number) {
|
||||
const normalized = String(value ?? '')
|
||||
.trim()
|
||||
.slice(0, maxLength)
|
||||
return normalized || fallback
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is JsonObject {
|
||||
return Object.prototype.toString.call(value) === '[object Object]'
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 工单补资料页未成年提示配置真实 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()
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -48,6 +48,7 @@ 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'
|
||||
|
||||
const PUBLIC_STATUS_MESSAGES: Record<string, string> = {
|
||||
[WORK_ORDER_STATUS.PENDING_MATERIAL]: '请补充订单资料。',
|
||||
@@ -226,6 +227,7 @@ export async function getOrderServiceByPlatformOrderId(platformOrderIdInput: unk
|
||||
platformOrderId,
|
||||
items,
|
||||
pendingCount: items.filter((item) => item.canSubmit).length,
|
||||
ageGate: getOrderServiceAgeGateConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { CloseCircleFilled } from '@ant-design/icons'
|
||||
import { Button, Modal, Typography } from 'antd'
|
||||
|
||||
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
|
||||
import { parseOrderServiceAgeGateContent } from '@/utils/order-service-age-gate'
|
||||
|
||||
const { Text } = Typography
|
||||
|
||||
type OrderServiceAgeGateModalProps = {
|
||||
open: boolean
|
||||
minorSelected: boolean
|
||||
config: OrderServiceAgeGateConfig
|
||||
onAdult: () => void
|
||||
onMinor: () => void
|
||||
}
|
||||
|
||||
export default function OrderServiceAgeGateModal({
|
||||
open,
|
||||
minorSelected,
|
||||
config,
|
||||
onAdult,
|
||||
onMinor,
|
||||
}: OrderServiceAgeGateModalProps) {
|
||||
const blocks = parseOrderServiceAgeGateContent(config.content)
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
title={minorSelected ? config.minorBlockedTitle : config.title}
|
||||
closable={false}
|
||||
maskClosable={false}
|
||||
keyboard={false}
|
||||
centered
|
||||
width="min(560px, calc(100vw - 32px))"
|
||||
className="order-service-age-gate"
|
||||
footer={
|
||||
minorSelected ? null : (
|
||||
<div className="order-service-age-gate-actions">
|
||||
<Button
|
||||
className="order-service-age-gate-button order-service-age-gate-minor-button"
|
||||
size="large"
|
||||
onClick={onMinor}
|
||||
>
|
||||
{config.minorButtonText}
|
||||
</Button>
|
||||
<Button
|
||||
className="order-service-age-gate-button order-service-age-gate-adult-button"
|
||||
size="large"
|
||||
type="primary"
|
||||
onClick={onAdult}
|
||||
>
|
||||
{config.adultButtonText}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
>
|
||||
{minorSelected ? (
|
||||
<div className="order-service-age-gate-blocked" role="alert">
|
||||
<CloseCircleFilled />
|
||||
<Text>{config.minorBlockedContent}</Text>
|
||||
</div>
|
||||
) : (
|
||||
<div className="order-service-age-gate-content">
|
||||
<div className="order-service-age-gate-warning">{config.warningText}</div>
|
||||
<div className="order-service-age-gate-copy">
|
||||
{blocks.map((block) => (
|
||||
<div className="order-service-age-gate-item" key={block.key}>
|
||||
{block.title ? (
|
||||
<div className="order-service-age-gate-item-title">
|
||||
{block.number ? (
|
||||
<span className="order-service-age-gate-item-number">{block.number}:</span>
|
||||
) : null}
|
||||
<span>{block.title}</span>
|
||||
</div>
|
||||
) : null}
|
||||
{block.lines.length > 0 ? (
|
||||
<div className="order-service-age-gate-item-lines">
|
||||
{block.lines.map((line, index) => (
|
||||
<p key={`${block.key}-line-${index}`}>{line}</p>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{config.importantNotice ? (
|
||||
<div className="order-service-age-gate-notice">{config.importantNotice}</div>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -45,6 +45,7 @@ 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'
|
||||
@@ -54,6 +55,7 @@ export default function AnnouncementPanel() {
|
||||
return (
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<AnnouncementCard />
|
||||
<OrderServiceAgeGateConfigCard />
|
||||
<SupportContactCard />
|
||||
<ProductNameSourceSuffixCard />
|
||||
<DepositUnfreezeCard />
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router'
|
||||
|
||||
import ImageUpload from '@/components/files/ImageUpload'
|
||||
import OrderServiceAgeGateModal from '@/components/public/OrderServiceAgeGateModal'
|
||||
import {
|
||||
fetchOrderService,
|
||||
submitOrderServiceMaterial,
|
||||
@@ -36,6 +37,12 @@ import {
|
||||
} from '@/services/worker'
|
||||
import type { UploadedFile } from '@/types/worker-platform'
|
||||
import { normalizeOrderServiceInput } from '@/utils/order-service-link'
|
||||
import {
|
||||
isOrderServiceAgeGateOpen,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
type OrderServiceAgeGateState,
|
||||
} from '@/utils/order-service-age-gate'
|
||||
import { useOrderServicePageMeta } from './use-order-service-page-meta'
|
||||
|
||||
const { Text, Title } = Typography
|
||||
@@ -94,12 +101,27 @@ export default function OrderServicePage() {
|
||||
const [lastSuccessText, setLastSuccessText] = useState('')
|
||||
const [submittingId, setSubmittingId] = useState(0)
|
||||
const [screenshotsByOrder, setScreenshotsByOrder] = useState<Record<number, UploadedFile[]>>({})
|
||||
const [ageGateState, setAgeGateState] = useState<OrderServiceAgeGateState>({
|
||||
orderNo: '',
|
||||
decision: 'pending',
|
||||
})
|
||||
const submittingRef = useRef(false)
|
||||
const confirmationOpenRef = useRef(false)
|
||||
const requestSeqRef = useRef(0)
|
||||
const loadedOrderRef = useRef('')
|
||||
|
||||
useOrderServicePageMeta(info?.items[0]?.title || '订单服务')
|
||||
const pendingItems = (info?.items || []).filter((item) => item.canSubmit)
|
||||
const ageGateDecision = resolveOrderServiceAgeGateDecision(ageGateState, orderNo)
|
||||
const ageGateRequired = shouldRequireOrderServiceAgeGate({
|
||||
enabled: info?.ageGate?.enabled,
|
||||
pendingCount: pendingItems.length,
|
||||
})
|
||||
const ageGateOpen = isOrderServiceAgeGateOpen({
|
||||
required: ageGateRequired,
|
||||
decision: ageGateDecision,
|
||||
})
|
||||
|
||||
useOrderServicePageMeta(ageGateOpen ? '购买前确认' : info?.items[0]?.title || '订单服务')
|
||||
|
||||
const load = useCallback(
|
||||
async (options: { silent?: boolean } = {}) => {
|
||||
@@ -133,7 +155,7 @@ export default function OrderServicePage() {
|
||||
if (seq === requestSeqRef.current && !options.silent) setLoading(false)
|
||||
}
|
||||
},
|
||||
[info, orderNo],
|
||||
[info, orderNo, setInfo, setLoading, setLoadError, setSubmittedNames, setLastSuccessText],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -291,7 +313,6 @@ export default function OrderServicePage() {
|
||||
}
|
||||
|
||||
const pageConfig = info?.items[0]
|
||||
const pendingItems = (info?.items || []).filter((item) => item.canSubmit)
|
||||
const purchaseSummary =
|
||||
[
|
||||
...new Set(info?.items.map((item) => item.productName || item.categoryName).filter(Boolean)),
|
||||
@@ -299,98 +320,109 @@ export default function OrderServicePage() {
|
||||
|
||||
return (
|
||||
<main className="collect-link-page">
|
||||
<Card className="collect-link-card" bordered={false}>
|
||||
{loading ? (
|
||||
<div className="collect-link-state">
|
||||
<Spin indicator={<LoadingOutlined spin />} size="large" />
|
||||
<Text type="secondary">正在读取订单信息...</Text>
|
||||
</div>
|
||||
) : loadError ? (
|
||||
<Result
|
||||
status={loadError.code === 'rate_limited' ? 'warning' : 'info'}
|
||||
title={resolveErrorTitle(loadError.code)}
|
||||
subTitle={loadError.message}
|
||||
extra={<Button onClick={() => void load()}>刷新重试</Button>}
|
||||
/>
|
||||
) : info ? (
|
||||
<Space direction="vertical" size={14} className="full-width">
|
||||
<div className="collect-link-heading">
|
||||
<div>
|
||||
<Title level={4}>{pageConfig?.title || '订单服务'}</Title>
|
||||
<div className="collect-link-order-meta">
|
||||
<span>订单号:{info.platformOrderId}</span>
|
||||
<span>
|
||||
购买物品:<strong>{purchaseSummary}</strong>
|
||||
</span>
|
||||
</div>
|
||||
{pageConfig?.description ? (
|
||||
<div className="collect-link-description">
|
||||
<Text type="secondary">{pageConfig.description}</Text>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
size="small"
|
||||
onClick={() => void load({ silent: true })}
|
||||
>
|
||||
刷新状态
|
||||
</Button>
|
||||
{info?.ageGate ? (
|
||||
<OrderServiceAgeGateModal
|
||||
open={ageGateOpen}
|
||||
minorSelected={ageGateDecision === 'minor'}
|
||||
config={info.ageGate}
|
||||
onAdult={() => setAgeGateState({ orderNo, decision: 'adult' })}
|
||||
onMinor={() => setAgeGateState({ orderNo, decision: 'minor' })}
|
||||
/>
|
||||
) : null}
|
||||
{ageGateOpen ? null : (
|
||||
<Card className="collect-link-card" bordered={false}>
|
||||
{loading ? (
|
||||
<div className="collect-link-state">
|
||||
<Spin indicator={<LoadingOutlined spin />} size="large" />
|
||||
<Text type="secondary">正在读取订单信息...</Text>
|
||||
</div>
|
||||
) : loadError ? (
|
||||
<Result
|
||||
status={loadError.code === 'rate_limited' ? 'warning' : 'info'}
|
||||
title={resolveErrorTitle(loadError.code)}
|
||||
subTitle={loadError.message}
|
||||
extra={<Button onClick={() => void load()}>刷新重试</Button>}
|
||||
/>
|
||||
) : info ? (
|
||||
<Space direction="vertical" size={14} className="full-width">
|
||||
<div className="collect-link-heading">
|
||||
<div>
|
||||
<Title level={4}>{pageConfig?.title || '订单服务'}</Title>
|
||||
<div className="collect-link-order-meta">
|
||||
<span>订单号:{info.platformOrderId}</span>
|
||||
<span>
|
||||
购买物品:<strong>{purchaseSummary}</strong>
|
||||
</span>
|
||||
</div>
|
||||
{pageConfig?.description ? (
|
||||
<div className="collect-link-description">
|
||||
<Text type="secondary">{pageConfig.description}</Text>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
size="small"
|
||||
onClick={() => void load({ silent: true })}
|
||||
>
|
||||
刷新状态
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{submittedNames.length > 0 ? (
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={lastSuccessText || '资料已提交'}
|
||||
description={`${submittedNames.join('、')};页面会每 15 秒自动更新订单状态。`}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{pendingItems.length > 1 ? (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前订单有 ${pendingItems.length} 个商品需要补充资料`}
|
||||
description="请逐个商品提交;每个商品资料仅可提交一次。"
|
||||
/>
|
||||
) : pendingItems.length === 1 ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="该商品资料仅可提交一次"
|
||||
description="提交成功后不能再修改;如需修改请联系客服。"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{info.items.map((item) =>
|
||||
item.canSubmit ? (
|
||||
<OrderServiceForm
|
||||
key={item.workOrderId}
|
||||
item={item}
|
||||
code={orderNo}
|
||||
submitting={submittingId === item.workOrderId}
|
||||
disabled={submittingId !== 0}
|
||||
screenshots={screenshotsByOrder[item.workOrderId] ?? item.screenshots ?? []}
|
||||
onScreenshotsChange={(files) => {
|
||||
setScreenshotsByOrder((current) => ({
|
||||
...current,
|
||||
[item.workOrderId]: files,
|
||||
}))
|
||||
}}
|
||||
onSubmit={(values) => void handleSubmit(item, values)}
|
||||
{submittedNames.length > 0 ? (
|
||||
<Alert
|
||||
type="success"
|
||||
showIcon
|
||||
message={lastSuccessText || '资料已提交'}
|
||||
description={`${submittedNames.join('、')};页面会每 15 秒自动更新订单状态。`}
|
||||
/>
|
||||
) : (
|
||||
<OrderServiceStatusCard key={item.workOrderId} item={item} />
|
||||
),
|
||||
)}
|
||||
) : null}
|
||||
|
||||
<Text type="secondary" className="collect-link-footnote">
|
||||
{pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'}
|
||||
</Text>
|
||||
</Space>
|
||||
) : null}
|
||||
</Card>
|
||||
{pendingItems.length > 1 ? (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前订单有 ${pendingItems.length} 个商品需要补充资料`}
|
||||
description="请逐个商品提交;每个商品资料仅可提交一次。"
|
||||
/>
|
||||
) : pendingItems.length === 1 ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="该商品资料仅可提交一次"
|
||||
description="提交成功后不能再修改;如需修改请联系客服。"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{info.items.map((item) =>
|
||||
item.canSubmit ? (
|
||||
<OrderServiceForm
|
||||
key={item.workOrderId}
|
||||
item={item}
|
||||
code={orderNo}
|
||||
submitting={submittingId === item.workOrderId}
|
||||
disabled={submittingId !== 0}
|
||||
screenshots={screenshotsByOrder[item.workOrderId] ?? item.screenshots ?? []}
|
||||
onScreenshotsChange={(files) => {
|
||||
setScreenshotsByOrder((current) => ({
|
||||
...current,
|
||||
[item.workOrderId]: files,
|
||||
}))
|
||||
}}
|
||||
onSubmit={(values) => void handleSubmit(item, values)}
|
||||
/>
|
||||
) : (
|
||||
<OrderServiceStatusCard key={item.workOrderId} item={item} />
|
||||
),
|
||||
)}
|
||||
|
||||
<Text type="secondary" className="collect-link-footnote">
|
||||
{pageConfig?.postSubmitText || '资料提交后如需修改,请联系客服。'}
|
||||
</Text>
|
||||
</Space>
|
||||
) : null}
|
||||
</Card>
|
||||
)}
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import type {
|
||||
WorkerPlatformNotificationConfig,
|
||||
WorkerProductMatchConfig,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerLevel,
|
||||
@@ -137,6 +138,17 @@ 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')
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
WorkerCancelRequest,
|
||||
WorkerCancelRequestRisk,
|
||||
WorkerAnnouncementConfig,
|
||||
OrderServiceAgeGateConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerProductNameSuffixDisplayConfig,
|
||||
@@ -712,6 +713,7 @@ export type OrderServiceInfo = {
|
||||
platformOrderId: string
|
||||
items: OrderServiceItem[]
|
||||
pendingCount: number
|
||||
ageGate?: OrderServiceAgeGateConfig
|
||||
}
|
||||
|
||||
export type OrderServiceSubmitResult = {
|
||||
|
||||
@@ -768,3 +768,237 @@
|
||||
display: grid;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== 工单补资料页未成年提示 ===== */
|
||||
|
||||
.order-service-age-gate .ant-modal-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 32px);
|
||||
max-height: calc(100dvh - 32px);
|
||||
overflow: hidden;
|
||||
border-radius: 14px;
|
||||
font-family:
|
||||
'PingFang SC', 'HarmonyOS Sans SC', 'MiSans', 'Hiragino Sans GB', 'Noto Sans SC',
|
||||
'Source Han Sans SC', 'Microsoft YaHei', sans-serif;
|
||||
}
|
||||
|
||||
.order-service-age-gate .ant-modal-header {
|
||||
flex: none;
|
||||
margin-bottom: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-service-age-gate .ant-modal-title {
|
||||
color: #171a21;
|
||||
font-size: 21px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.order-service-age-gate .ant-modal-body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
padding-right: 6px;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.order-service-age-gate .ant-modal-footer {
|
||||
flex: none;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-content {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-warning {
|
||||
color: #f04438;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.65;
|
||||
letter-spacing: 0.01em;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.order-service-age-gate-copy {
|
||||
display: grid;
|
||||
padding: 2px 14px;
|
||||
color: #4b5563;
|
||||
font-size: 13.5px;
|
||||
font-weight: 400;
|
||||
line-height: 1.72;
|
||||
background: transparent;
|
||||
border: 1px solid #edf0f4;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
padding: 9px 0;
|
||||
border-bottom: 1px dashed #e5e9ef;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-title {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
color: #252a33;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
line-height: 1.55;
|
||||
letter-spacing: 0.01em;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-number {
|
||||
flex: none;
|
||||
min-width: 18px;
|
||||
color: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-lines {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
padding-left: 24px;
|
||||
color: #657080;
|
||||
font-size: 13.5px;
|
||||
font-weight: 400;
|
||||
line-height: 1.72;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-lines p {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.order-service-age-gate-notice {
|
||||
padding: 10px 12px;
|
||||
color: #d92d20;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.72;
|
||||
background: #fff5f5;
|
||||
border: 1px solid #ffd8d6;
|
||||
border-radius: 8px;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.order-service-age-gate-actions {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-actions .ant-btn {
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-minor-button {
|
||||
color: #ffffff !important;
|
||||
background: #ff6b6b !important;
|
||||
border-color: #ff6b6b !important;
|
||||
}
|
||||
|
||||
.order-service-age-gate-minor-button:hover {
|
||||
color: #ffffff !important;
|
||||
background: #ff5252 !important;
|
||||
border-color: #ff5252 !important;
|
||||
}
|
||||
|
||||
.order-service-age-gate-adult-button {
|
||||
color: #ffffff !important;
|
||||
background: #1677ff !important;
|
||||
border-color: #1677ff !important;
|
||||
}
|
||||
|
||||
.order-service-age-gate-adult-button:hover {
|
||||
color: #ffffff !important;
|
||||
background: #0958d9 !important;
|
||||
border-color: #0958d9 !important;
|
||||
}
|
||||
|
||||
.order-service-age-gate-blocked {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
min-height: 160px;
|
||||
padding: 16px 6px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-service-age-gate-blocked .anticon {
|
||||
color: #ff4d4f;
|
||||
font-size: 52px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-blocked .ant-typography {
|
||||
color: #4b5563;
|
||||
font-weight: 400;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.order-service-age-gate .ant-modal-content {
|
||||
max-height: calc(100vh - 20px);
|
||||
max-height: calc(100dvh - 20px);
|
||||
}
|
||||
|
||||
.order-service-age-gate .ant-modal-body {
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-warning {
|
||||
font-size: 15.5px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.order-service-age-gate-copy {
|
||||
padding: 1px 11px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-title {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.order-service-age-gate-item-lines {
|
||||
padding-left: 22px;
|
||||
font-size: 13px;
|
||||
line-height: 1.68;
|
||||
}
|
||||
|
||||
.order-service-age-gate-notice {
|
||||
font-size: 13px;
|
||||
line-height: 1.68;
|
||||
}
|
||||
|
||||
.order-service-age-gate-actions .ant-btn {
|
||||
height: 46px;
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,6 +349,19 @@ export type WorkerAnnouncementConfig = {
|
||||
content: string
|
||||
}
|
||||
|
||||
/** 工单补资料页未成年提示:全局配置,默认关闭。 */
|
||||
export type OrderServiceAgeGateConfig = {
|
||||
enabled: boolean
|
||||
title: string
|
||||
warningText: string
|
||||
content: string
|
||||
importantNotice: string
|
||||
adultButtonText: string
|
||||
minorButtonText: string
|
||||
minorBlockedTitle: string
|
||||
minorBlockedContent: string
|
||||
}
|
||||
|
||||
export type WorkerSupportContactConfig = {
|
||||
enabled: boolean
|
||||
wechatId: string
|
||||
|
||||
@@ -66,7 +66,11 @@ 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']],
|
||||
announcement: [
|
||||
['admin-announcements'],
|
||||
['admin-worker-support-contact'],
|
||||
['admin-order-service-age-gate'],
|
||||
],
|
||||
'hall-config': [['admin-hall-config']],
|
||||
'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']],
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import type { OrderServiceAgeGateConfig } from '@/types/worker-platform'
|
||||
|
||||
export type OrderServiceAgeGateDecision = 'pending' | 'adult' | 'minor'
|
||||
|
||||
export type OrderServiceAgeGateState = {
|
||||
orderNo: string
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}
|
||||
|
||||
export const DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG: OrderServiceAgeGateConfig = {
|
||||
enabled: false,
|
||||
title: '购买前必读',
|
||||
warningText: '无法向未成年人操作发货,请认真阅读作答!!!',
|
||||
content: `1. 购买商品和角色信息有没有错误
|
||||
角色名/系统/区服有无遗漏
|
||||
如未核对导致送错,本店概不负责哦~
|
||||
|
||||
2. 购买本人实际为成年用户!!
|
||||
|
||||
3. 虚拟商品到您的游戏里,一旦发货完成,概不退款。
|
||||
|
||||
4. 发货时间具体以排单顺序为准,活动期间可能会延迟送达,未发货前协商可退。
|
||||
|
||||
5. 由于市场成本原因,价格会有所浮动,不支持以此原因退差价。
|
||||
|
||||
6. 禁止私自交易,私自交易被骗本店概不负责!!!!`,
|
||||
importantNotice:
|
||||
'【重要提示】近期有人冒充本店售后专员,以“道具回收”为由实施诈骗。请广大玩家务必以本店官方售后渠道为准,谨防上当受骗。',
|
||||
adultButtonText: '我已成年',
|
||||
minorButtonText: '我是未成年',
|
||||
minorBlockedTitle: '未成年不能购买',
|
||||
minorBlockedContent:
|
||||
'根据平台规则,本店无法向未成年人销售或操作发货。当前资料提交流程已停止,请勿继续操作。',
|
||||
}
|
||||
|
||||
export type OrderServiceAgeGateContentBlock = {
|
||||
key: string
|
||||
number: string
|
||||
title: string
|
||||
lines: string[]
|
||||
}
|
||||
|
||||
export function parseOrderServiceAgeGateContent(
|
||||
content: string,
|
||||
): OrderServiceAgeGateContentBlock[] {
|
||||
const blocks: OrderServiceAgeGateContentBlock[] = []
|
||||
for (const rawLine of String(content || '').split(/\r?\n/)) {
|
||||
const line = rawLine.trim()
|
||||
if (!line) continue
|
||||
const numbered = line.match(/^(\d+)[.、::]\s*(.*)$/)
|
||||
if (numbered) {
|
||||
blocks.push({
|
||||
key: `item-${blocks.length}`,
|
||||
number: numbered[1] || '',
|
||||
title: String(numbered[2] || '').trim(),
|
||||
lines: [],
|
||||
})
|
||||
continue
|
||||
}
|
||||
const current = blocks[blocks.length - 1]
|
||||
if (current) {
|
||||
current.lines.push(line)
|
||||
continue
|
||||
}
|
||||
blocks.push({ key: 'item-0', number: '', title: line, lines: [] })
|
||||
}
|
||||
return blocks
|
||||
}
|
||||
|
||||
export function shouldRequireOrderServiceAgeGate(input: {
|
||||
enabled?: boolean
|
||||
pendingCount: number
|
||||
}) {
|
||||
return input.enabled === true && Number(input.pendingCount || 0) > 0
|
||||
}
|
||||
|
||||
export function resolveOrderServiceAgeGateDecision(
|
||||
state: OrderServiceAgeGateState,
|
||||
orderNo: string,
|
||||
): OrderServiceAgeGateDecision {
|
||||
return state.orderNo === orderNo ? state.decision : 'pending'
|
||||
}
|
||||
|
||||
export function canAccessOrderServiceMaterial(input: {
|
||||
required: boolean
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}) {
|
||||
return !input.required || input.decision === 'adult'
|
||||
}
|
||||
|
||||
export function isOrderServiceAgeGateOpen(input: {
|
||||
required: boolean
|
||||
decision: OrderServiceAgeGateDecision
|
||||
}) {
|
||||
return !canAccessOrderServiceMaterial(input)
|
||||
}
|
||||
|
||||
export function mergeOrderServiceAgeGateConfig(
|
||||
value?: Partial<OrderServiceAgeGateConfig> | null,
|
||||
): OrderServiceAgeGateConfig {
|
||||
const source = value || {}
|
||||
const text = (input: unknown, fallback: string) => String(input || '').trim() || fallback
|
||||
return {
|
||||
enabled: source.enabled === true,
|
||||
title: text(source.title, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.title),
|
||||
warningText: text(source.warningText, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.warningText),
|
||||
content: text(source.content, DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.content),
|
||||
importantNotice: text(
|
||||
source.importantNotice,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.importantNotice,
|
||||
),
|
||||
adultButtonText: text(
|
||||
source.adultButtonText,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.adultButtonText,
|
||||
),
|
||||
minorButtonText: text(
|
||||
source.minorButtonText,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorButtonText,
|
||||
),
|
||||
minorBlockedTitle: text(
|
||||
source.minorBlockedTitle,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorBlockedTitle,
|
||||
),
|
||||
minorBlockedContent: text(
|
||||
source.minorBlockedContent,
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.minorBlockedContent,
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG,
|
||||
canAccessOrderServiceMaterial,
|
||||
isOrderServiceAgeGateOpen,
|
||||
mergeOrderServiceAgeGateConfig,
|
||||
parseOrderServiceAgeGateContent,
|
||||
resolveOrderServiceAgeGateDecision,
|
||||
shouldRequireOrderServiceAgeGate,
|
||||
} from '../src/utils/order-service-age-gate.ts'
|
||||
|
||||
test('只有启用且存在待补资料商品时才要求未成年确认', () => {
|
||||
assert.equal(shouldRequireOrderServiceAgeGate({ enabled: true, pendingCount: 1 }), true)
|
||||
assert.equal(shouldRequireOrderServiceAgeGate({ enabled: false, pendingCount: 1 }), false)
|
||||
assert.equal(shouldRequireOrderServiceAgeGate({ enabled: true, pendingCount: 0 }), false)
|
||||
assert.equal(shouldRequireOrderServiceAgeGate({ pendingCount: 1 }), false)
|
||||
})
|
||||
|
||||
test('已成年可以通过,未成年和未选择不能进入资料表单', () => {
|
||||
assert.equal(canAccessOrderServiceMaterial({ required: true, decision: 'adult' }), true)
|
||||
assert.equal(canAccessOrderServiceMaterial({ required: true, decision: 'minor' }), false)
|
||||
assert.equal(canAccessOrderServiceMaterial({ required: true, decision: 'pending' }), false)
|
||||
assert.equal(canAccessOrderServiceMaterial({ required: false, decision: 'minor' }), true)
|
||||
})
|
||||
|
||||
test('切换订单号后恢复为未确认状态', () => {
|
||||
const state = { orderNo: 'order-a', decision: 'adult' as const }
|
||||
assert.equal(resolveOrderServiceAgeGateDecision(state, 'order-a'), 'adult')
|
||||
assert.equal(resolveOrderServiceAgeGateDecision(state, 'order-b'), 'pending')
|
||||
})
|
||||
|
||||
test('配置页默认值直接可填,不依赖灰色 placeholder', () => {
|
||||
assert.equal(DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.enabled, false)
|
||||
assert.equal(DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.title, '购买前必读')
|
||||
assert.match(DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.content, /购买商品和角色信息有没有错误/)
|
||||
assert.match(DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.importantNotice, /冒充本店售后专员/)
|
||||
})
|
||||
|
||||
test('读取到旧配置空字段时仍用默认文案填充', () => {
|
||||
const config = mergeOrderServiceAgeGateConfig({
|
||||
enabled: true,
|
||||
title: '',
|
||||
warningText: ' ',
|
||||
content: '',
|
||||
importantNotice: '',
|
||||
adultButtonText: '',
|
||||
minorButtonText: '',
|
||||
minorBlockedTitle: '',
|
||||
minorBlockedContent: '',
|
||||
})
|
||||
|
||||
assert.equal(config.enabled, true)
|
||||
assert.equal(config.title, '购买前必读')
|
||||
assert.equal(config.warningText, '无法向未成年人操作发货,请认真阅读作答!!!')
|
||||
assert.match(config.content, /购买商品和角色信息有没有错误/)
|
||||
assert.equal(config.adultButtonText, '我已成年')
|
||||
assert.equal(config.minorButtonText, '我是未成年')
|
||||
assert.equal(config.minorBlockedTitle, '未成年不能购买')
|
||||
})
|
||||
|
||||
test('弹窗正文按编号拆分为标题和说明,保证编号加粗布局', () => {
|
||||
const blocks = parseOrderServiceAgeGateContent(DEFAULT_ORDER_SERVICE_AGE_GATE_CONFIG.content)
|
||||
assert.equal(blocks.length, 6)
|
||||
assert.equal(blocks[0]?.number, '1')
|
||||
assert.equal(blocks[0]?.title, '购买商品和角色信息有没有错误')
|
||||
assert.deepEqual(blocks[0]?.lines, [
|
||||
'角色名/系统/区服有无遗漏',
|
||||
'如未核对导致送错,本店概不负责哦~',
|
||||
])
|
||||
assert.equal(blocks[5]?.number, '6')
|
||||
assert.match(blocks[5]?.title || '', /禁止私自交易/)
|
||||
})
|
||||
|
||||
test('弹窗打开时整页内容必须隐藏,已成年后才恢复', () => {
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'pending' }), true)
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'minor' }), true)
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: true, decision: 'adult' }), false)
|
||||
assert.equal(isOrderServiceAgeGateOpen({ required: false, decision: 'pending' }), false)
|
||||
})
|
||||
Reference in New Issue
Block a user