新增打手端滚动公告
This commit is contained in:
@@ -5,6 +5,7 @@ export const APP_CONFIG_KEYS = {
|
||||
workerFinance: 'worker_finance',
|
||||
workerPlatformNotifications: 'worker_platform_notifications',
|
||||
workerProductMatch: 'worker_product_match',
|
||||
workerAnnouncement: 'worker_announcement',
|
||||
cloudtentaclesSources: 'cloudtentacles_sources',
|
||||
cloudtentaclesSession: 'cloudtentacles_session',
|
||||
cloudtentaclesOverrideRules: 'cloudtentacles_override_rules',
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
deleteAdminWorkerLevel,
|
||||
getAdminWorkerFinanceConfig,
|
||||
getAdminWorkerProductMatchConfig,
|
||||
getAdminWorkerAnnouncementConfig,
|
||||
getAdminWorkerPlatformNotificationConfig,
|
||||
getAdminWorkerPlatformSummary,
|
||||
getAdminWorkOrderEvents,
|
||||
@@ -46,6 +47,7 @@ import {
|
||||
resetAdminWorkerPassword,
|
||||
saveAdminWorkerFinanceConfig,
|
||||
saveAdminWorkerProductMatchConfig,
|
||||
saveAdminWorkerAnnouncementConfig,
|
||||
saveAdminWorkerPlatformNotificationConfig,
|
||||
saveAdminWorkerWithdrawalAccount,
|
||||
saveAdminWorkCategory,
|
||||
@@ -249,6 +251,32 @@ router.get(
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/worker-platform/announcement',
|
||||
requireAdminRoles(['admin', 'operator']),
|
||||
createJsonHandler(() => getAdminWorkerAnnouncementConfig(), {
|
||||
successMessage: 'ok',
|
||||
errorMessage: '读取公告失败',
|
||||
scope: '[admin/worker-platform/announcement]',
|
||||
}),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/worker-platform/announcement',
|
||||
requireAdminRoles(['admin']),
|
||||
createJsonHandler((req) => saveAdminWorkerAnnouncementConfig(req.body || {}), {
|
||||
successMessage: '公告已保存',
|
||||
errorMessage: '保存公告失败',
|
||||
scope: '[admin/worker-platform/announcement]',
|
||||
audit: (_req, data) => ({
|
||||
action: 'worker_announcement_saved',
|
||||
targetType: 'worker_announcement',
|
||||
targetId: 'worker_announcement',
|
||||
data: data && typeof data === 'object' ? (data as Record<string, unknown>) : {},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/worker-platform/product-match-config',
|
||||
requireAdminRoles(['admin', 'operator']),
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
supplementWorkerAcceptedOrderEvidence,
|
||||
submitWorkerOrderAcceptance,
|
||||
getWorkerCancelRequestSummary,
|
||||
getWorkerAnnouncement,
|
||||
getWorkerOrderFeedbackSummary,
|
||||
submitWorkerCancelRequest,
|
||||
submitWorkerOrderFeedback,
|
||||
@@ -454,6 +455,16 @@ router.get(
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/announcement',
|
||||
requireActiveWorker,
|
||||
createRouteHandler((req) => getWorkerAnnouncement(getRequiredWorkerSession(req)), {
|
||||
successMessage: 'ok',
|
||||
errorMessage: '读取公告失败',
|
||||
scope: '[worker/announcement]',
|
||||
}),
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/orders/feedbacks',
|
||||
requireActiveWorker,
|
||||
|
||||
@@ -84,6 +84,10 @@ import {
|
||||
getWorkerProductMatchConfig,
|
||||
saveWorkerProductMatchConfig,
|
||||
} from './worker-product-match-config-service.js'
|
||||
import {
|
||||
getWorkerAnnouncementConfig,
|
||||
saveWorkerAnnouncementConfig,
|
||||
} from './worker-announcement-config-service.js'
|
||||
import { refreshUploadedFileUrls } from '../file-storage/file-storage-service.js'
|
||||
import {
|
||||
createWorkOrderMaterialAdminNotification,
|
||||
@@ -1208,6 +1212,14 @@ export async function getAdminWorkerProductMatchConfig() {
|
||||
return getWorkerProductMatchConfig()
|
||||
}
|
||||
|
||||
export async function getAdminWorkerAnnouncementConfig() {
|
||||
return getWorkerAnnouncementConfig()
|
||||
}
|
||||
|
||||
export async function saveAdminWorkerAnnouncementConfig(payload: JsonObject = {}) {
|
||||
return saveWorkerAnnouncementConfig(payload)
|
||||
}
|
||||
|
||||
export async function saveAdminWorkerProductMatchConfig(payload: JsonObject = {}) {
|
||||
return saveWorkerProductMatchConfig(payload)
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from './mappers.js'
|
||||
export * from './worker-service.js'
|
||||
export * from './admin-service.js'
|
||||
export * from './worker-product-match-config-service.js'
|
||||
export * from './worker-announcement-config-service.js'
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
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 WorkerAnnouncementConfig = {
|
||||
enabled: boolean
|
||||
content: string
|
||||
}
|
||||
|
||||
export function getWorkerAnnouncementConfig(): WorkerAnnouncementConfig {
|
||||
return readAppConfigEntry({
|
||||
configKey: APP_CONFIG_KEYS.workerAnnouncement,
|
||||
fallback: createDefaultWorkerAnnouncementConfig,
|
||||
normalize: normalizeWorkerAnnouncementConfig,
|
||||
})
|
||||
}
|
||||
|
||||
export async function saveWorkerAnnouncementConfig(
|
||||
rawValue: unknown,
|
||||
): Promise<WorkerAnnouncementConfig> {
|
||||
return saveAppConfigEntry({
|
||||
configKey: APP_CONFIG_KEYS.workerAnnouncement,
|
||||
value: rawValue,
|
||||
normalize: normalizeWorkerAnnouncementConfig,
|
||||
})
|
||||
}
|
||||
|
||||
export function createDefaultWorkerAnnouncementConfig(): WorkerAnnouncementConfig {
|
||||
return {
|
||||
enabled: true,
|
||||
content: '平台担保交易,拒绝私下转账/共享验证码,交接全程留痕。',
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeWorkerAnnouncementConfig(rawValue: unknown): WorkerAnnouncementConfig {
|
||||
const source = isPlainObject(rawValue) ? rawValue : {}
|
||||
return {
|
||||
enabled: source.enabled !== false,
|
||||
content: String(source.content || '')
|
||||
.trim()
|
||||
.slice(0, 300),
|
||||
}
|
||||
}
|
||||
|
||||
function isPlainObject(value: unknown): value is JsonObject {
|
||||
return Object.prototype.toString.call(value) === '[object Object]'
|
||||
}
|
||||
@@ -84,6 +84,7 @@ import { addHours, nowIso } from '../../utils/time.js'
|
||||
import { normalizePage, normalizePageSize, safeParseJson } from '../admin/admin-query-utils.js'
|
||||
import { getSmsProvider } from '../sms/index.js'
|
||||
import { getWorkerFinanceConfig } from './worker-finance-config-service.js'
|
||||
import { getWorkerAnnouncementConfig } from './worker-announcement-config-service.js'
|
||||
import { refreshUploadedFileUrls } from '../file-storage/file-storage-service.js'
|
||||
import {
|
||||
createWorkerAcceptanceAdminNotification,
|
||||
@@ -1756,6 +1757,11 @@ export async function getWorkerCancelRequestSummary(session: WorkerSession) {
|
||||
return { risk, items: requests.map(mapWorkerCancelRequest) }
|
||||
}
|
||||
|
||||
export async function getWorkerAnnouncement(session: WorkerSession) {
|
||||
requireActiveWorkerSession(session)
|
||||
return getWorkerAnnouncementConfig()
|
||||
}
|
||||
|
||||
export async function getWorkerOrderFeedbackSummary(session: WorkerSession) {
|
||||
requireActiveWorkerSession(session)
|
||||
return { items: (await listWorkerOrderFeedbacks(session.workerId)).map(mapWorkerOrderFeedback) }
|
||||
|
||||
Reference in New Issue
Block a user