新增打手端滚动公告
This commit is contained in:
@@ -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