新增(接单平台): 增加冻结账号售后微信提示
This commit is contained in:
@@ -25,14 +25,22 @@ import {
|
||||
fetchAdminWorkerAnnouncement,
|
||||
fetchAdminWorkerProductNameSuffix,
|
||||
fetchAdminWorkerProductNameSuffixSources,
|
||||
fetchAdminWorkerSupportContact,
|
||||
renameAdminMockCustomShop,
|
||||
runAdminScheduledJob,
|
||||
saveAdminWorkerAnnouncement,
|
||||
saveAdminWorkerProductNameSuffix,
|
||||
saveAdminWorkerSupportContact,
|
||||
saveAdminScheduledJobsConfig,
|
||||
} from '@/services/admin'
|
||||
import type { AdminScheduledJobItem, AdminScheduledJobRuntimeState } from '@/types/admin'
|
||||
import type { WorkerAnnouncementConfig, WorkerProductNameSuffixItem } from '@/types/worker-platform'
|
||||
import type {
|
||||
UploadedFile,
|
||||
WorkerAnnouncementConfig,
|
||||
WorkerProductNameSuffixItem,
|
||||
WorkerSupportContactConfig,
|
||||
} from '@/types/worker-platform'
|
||||
import ImageUpload from '@/components/files/ImageUpload'
|
||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { normalizeProductNameSuffixText } from '@/utils/product-name-source-suffix'
|
||||
|
||||
@@ -46,6 +54,7 @@ export default function AnnouncementPanel() {
|
||||
return (
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<AnnouncementCard />
|
||||
<SupportContactCard />
|
||||
<ProductNameSourceSuffixCard />
|
||||
<DepositUnfreezeCard />
|
||||
<MockCustomShopsCard />
|
||||
@@ -192,6 +201,107 @@ function DepositUnfreezeCard() {
|
||||
)
|
||||
}
|
||||
|
||||
type SupportContactFormValues = {
|
||||
enabled?: boolean
|
||||
wechatId?: string
|
||||
wechatQrCodeImageList?: UploadedFile[]
|
||||
notice?: string
|
||||
}
|
||||
|
||||
function SupportContactCard() {
|
||||
const { message } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
const [form] = Form.useForm<SupportContactFormValues>()
|
||||
const [saving, setSaving] = useState(false)
|
||||
const contactQuery = useQuery({
|
||||
queryKey: ['admin-worker-support-contact'],
|
||||
queryFn: fetchAdminWorkerSupportContact,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const config = contactQuery.data?.data
|
||||
if (!config) return
|
||||
form.setFieldsValue({
|
||||
enabled: config.enabled,
|
||||
wechatId: config.wechatId,
|
||||
wechatQrCodeImageList: config.wechatQrCodeImage ? [config.wechatQrCodeImage] : [],
|
||||
notice: config.notice,
|
||||
})
|
||||
}, [contactQuery.data, form])
|
||||
|
||||
async function saveSupportContact(values: SupportContactFormValues) {
|
||||
const enabled = values.enabled === true
|
||||
const wechatId = String(values.wechatId || '').trim()
|
||||
const qrCodeImage = values.wechatQrCodeImageList?.[0] || null
|
||||
if (enabled && !wechatId && !qrCodeImage) {
|
||||
message.warning('启用售后微信后,请至少配置微信号或二维码')
|
||||
return
|
||||
}
|
||||
setSaving(true)
|
||||
try {
|
||||
await saveAdminWorkerSupportContact({
|
||||
enabled,
|
||||
wechatId,
|
||||
wechatQrCodeImage: qrCodeImage,
|
||||
notice: String(values.notice || '').trim(),
|
||||
})
|
||||
await queryClient.invalidateQueries({ queryKey: ['admin-worker-support-contact'] })
|
||||
message.success('售后微信配置已保存')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '保存售后微信配置失败')
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card title="售后微信(冻结账号联系)" bordered={false}>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 16 }}>
|
||||
账号被冻结后,登录页会展示这里的售后微信。建议同时配置微信号和二维码,方便手机端直接复制微信号。
|
||||
</Typography.Paragraph>
|
||||
<Form form={form} layout="vertical" onFinish={saveSupportContact} style={{ maxWidth: 760 }}>
|
||||
<Form.Item
|
||||
name="enabled"
|
||||
label="启用售后微信提示"
|
||||
valuePropName="checked"
|
||||
extra="关闭后,冻结账号登录时只提示账号已冻结,不展示售后微信。"
|
||||
>
|
||||
<Switch checkedChildren="启用" unCheckedChildren="关闭" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="wechatId"
|
||||
label="售后微信号"
|
||||
extra="支持填写微信号或手机号;手机端可一键复制后到微信中搜索。"
|
||||
>
|
||||
<Input maxLength={64} placeholder="例如:after_sales_wechat 或 13800138000" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="wechatQrCodeImageList"
|
||||
label="售后微信二维码"
|
||||
extra="可选。建议上传清晰二维码,方便另一台设备扫码添加。"
|
||||
>
|
||||
<ImageUpload scene="worker-support-contact" scope="admin" maxCount={1} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="notice"
|
||||
label="冻结提示文案"
|
||||
extra="显示在冻结账号的登录提示中;留空会使用默认文案。"
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
maxLength={240}
|
||||
showCount
|
||||
placeholder="账号已被冻结,如有疑问请添加售后微信处理。"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit" loading={saving}>
|
||||
保存售后微信配置
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
function AnnouncementCard() {
|
||||
const { message } = App.useApp()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
App,
|
||||
Button,
|
||||
Form,
|
||||
Image,
|
||||
Input,
|
||||
Modal,
|
||||
Segmented,
|
||||
@@ -26,6 +27,7 @@ import { Navigate, useNavigate } from 'react-router'
|
||||
|
||||
import {
|
||||
deleteWorkerSessionWithCredentials,
|
||||
fetchWorkerSupportContact,
|
||||
loginWorker,
|
||||
loginWorkerBySmsCode,
|
||||
manageWorkerSessions,
|
||||
@@ -35,7 +37,7 @@ import {
|
||||
sendWorkerPasswordResetSmsCode,
|
||||
sendWorkerLoginSmsCode,
|
||||
} from '@/services/worker'
|
||||
import type { WorkerSessionDevice } from '@/types/worker-platform'
|
||||
import type { WorkerSessionDevice, WorkerSupportContactConfig } from '@/types/worker-platform'
|
||||
import { hasWorkerSession, setWorkerSession } from '@/utils/worker-auth'
|
||||
import { isWorkerPasswordStrong, WORKER_PASSWORD_RULE_MESSAGE } from '@/utils/worker-password'
|
||||
|
||||
@@ -79,6 +81,10 @@ export default function WorkerLoginPage() {
|
||||
const [deviceManagerOpen, setDeviceManagerOpen] = useState(false)
|
||||
const [deviceManagerLoading, setDeviceManagerLoading] = useState(false)
|
||||
const [managedDevices, setManagedDevices] = useState<WorkerSessionDevice[]>([])
|
||||
const [frozenAccountBlocked, setFrozenAccountBlocked] = useState(false)
|
||||
const [supportContact, setSupportContact] = useState<WorkerSupportContactConfig | null>(null)
|
||||
const [supportContactLoading, setSupportContactLoading] = useState(false)
|
||||
const [supportContactError, setSupportContactError] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (countdown <= 0) return
|
||||
@@ -127,6 +133,9 @@ export default function WorkerLoginPage() {
|
||||
await loadManagedDevices(values)
|
||||
return
|
||||
}
|
||||
if (getWorkerErrorCode(error) === 'worker_rejected') {
|
||||
void loadFrozenSupportContact()
|
||||
}
|
||||
message.error(error instanceof Error ? error.message : '登录失败')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
@@ -164,6 +173,9 @@ export default function WorkerLoginPage() {
|
||||
message.success('登录成功')
|
||||
void navigate('/hall', { replace: true })
|
||||
} catch (error) {
|
||||
if (getWorkerErrorCode(error) === 'worker_rejected') {
|
||||
void loadFrozenSupportContact()
|
||||
}
|
||||
message.error(error instanceof Error ? error.message : '验证码登录失败')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
@@ -174,6 +186,21 @@ export default function WorkerLoginPage() {
|
||||
return String(loginSmsPhoneInputRef.current?.input?.value || loginSmsPhone).trim()
|
||||
}
|
||||
|
||||
async function loadFrozenSupportContact() {
|
||||
setFrozenAccountBlocked(true)
|
||||
setSupportContact(null)
|
||||
setSupportContactError('')
|
||||
setSupportContactLoading(true)
|
||||
try {
|
||||
const response = await fetchWorkerSupportContact()
|
||||
setSupportContact(response.data)
|
||||
} catch (error) {
|
||||
setSupportContactError(error instanceof Error ? error.message : '售后微信加载失败')
|
||||
} finally {
|
||||
setSupportContactLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadManagedDevices(values?: { username: string; password: string }) {
|
||||
const credentials = values || deviceForm.getFieldsValue()
|
||||
if (!credentials.username || !credentials.password) {
|
||||
@@ -462,6 +489,61 @@ export default function WorkerLoginPage() {
|
||||
</Button>
|
||||
</Form>
|
||||
)}
|
||||
{frozenAccountBlocked ? (
|
||||
<Alert
|
||||
showIcon
|
||||
type="warning"
|
||||
closable
|
||||
onClose={() => setFrozenAccountBlocked(false)}
|
||||
message="接单账号已被冻结,无法登录"
|
||||
style={{ marginTop: 20 }}
|
||||
description={
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
{supportContactLoading ? (
|
||||
<Typography.Text type="secondary">
|
||||
正在加载售后微信…
|
||||
</Typography.Text>
|
||||
) : supportContact?.enabled ? (
|
||||
<>
|
||||
<Typography.Text>
|
||||
{supportContact.notice ||
|
||||
'账号已被冻结,如有疑问请添加售后微信处理。'}
|
||||
</Typography.Text>
|
||||
{supportContact.wechatId ? (
|
||||
<div>
|
||||
<Typography.Text strong>售后微信:</Typography.Text>
|
||||
<Typography.Text copyable={{ text: supportContact.wechatId }}>
|
||||
{supportContact.wechatId}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
) : null}
|
||||
{supportContact.wechatQrCodeImage ? (
|
||||
<div style={{ width: '100%', textAlign: 'center' }}>
|
||||
<Image
|
||||
width={180}
|
||||
src={
|
||||
supportContact.wechatQrCodeImage.mediumUrl ||
|
||||
supportContact.wechatQrCodeImage.url
|
||||
}
|
||||
alt="售后微信二维码"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
) : (
|
||||
<Typography.Text type="secondary">
|
||||
售后微信暂未启用,请稍后重试或通过平台其他渠道联系。
|
||||
</Typography.Text>
|
||||
)}
|
||||
{supportContactError ? (
|
||||
<Typography.Text type="danger">
|
||||
{supportContactError}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
),
|
||||
},
|
||||
@@ -704,3 +786,7 @@ export default function WorkerLoginPage() {
|
||||
function isMobileViewport() {
|
||||
return typeof window !== 'undefined' && window.innerWidth < 768
|
||||
}
|
||||
|
||||
function getWorkerErrorCode(error: unknown) {
|
||||
return String((error as { errorCode?: string } | null)?.errorCode || '').trim()
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import type {
|
||||
WorkerPlatformNotificationConfig,
|
||||
WorkerProductMatchConfig,
|
||||
WorkerAnnouncementConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerLevel,
|
||||
WorkerListResponse,
|
||||
@@ -133,6 +134,17 @@ export function saveAdminWorkerAnnouncement(payload: WorkerAnnouncementConfig) {
|
||||
return apiPost<WorkerAnnouncementConfig>('/api/v1/admin/worker-platform/announcement', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminWorkerSupportContact() {
|
||||
return apiGet<WorkerSupportContactConfig>('/api/v1/admin/worker-platform/support-contact')
|
||||
}
|
||||
|
||||
export function saveAdminWorkerSupportContact(payload: WorkerSupportContactConfig) {
|
||||
return apiPost<WorkerSupportContactConfig>(
|
||||
'/api/v1/admin/worker-platform/support-contact',
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAdminWorkerProductNameSuffix() {
|
||||
return apiGet<WorkerProductNameSuffixConfig>('/api/v1/admin/worker-platform/product-name-suffix')
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
WorkerCancelRequest,
|
||||
WorkerCancelRequestRisk,
|
||||
WorkerAnnouncementConfig,
|
||||
WorkerSupportContactConfig,
|
||||
WorkerProductNameSuffixConfig,
|
||||
WorkerProductNameSuffixDisplayConfig,
|
||||
WorkerAcceptanceConfig,
|
||||
@@ -154,6 +155,10 @@ export function fetchWorkerAnnouncement() {
|
||||
return apiGet<WorkerAnnouncementConfig>('/api/v1/worker/announcement')
|
||||
}
|
||||
|
||||
export function fetchWorkerSupportContact() {
|
||||
return apiGet<WorkerSupportContactConfig>('/api/v1/worker/support-contact')
|
||||
}
|
||||
|
||||
/** 商品名来源后缀映射(后台「杂项配置」维护,只返回已启用项),打手端列表/详情/大厅展示用。 */
|
||||
export function fetchWorkerProductNameSuffix() {
|
||||
return apiGet<WorkerProductNameSuffixDisplayConfig>('/api/v1/worker/product-name-suffix')
|
||||
|
||||
@@ -342,6 +342,13 @@ export type WorkerAnnouncementConfig = {
|
||||
content: string
|
||||
}
|
||||
|
||||
export type WorkerSupportContactConfig = {
|
||||
enabled: boolean
|
||||
wechatId: string
|
||||
wechatQrCodeImage: UploadedFile | null
|
||||
notice: string
|
||||
}
|
||||
|
||||
export type WorkerProductNameSuffixItem = {
|
||||
/** 来源标识(精确匹配、不区分大小写),如 91kaquan */
|
||||
source: string
|
||||
|
||||
@@ -64,7 +64,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']],
|
||||
announcement: [['admin-announcements'], ['admin-worker-support-contact']],
|
||||
'hall-config': [['admin-hall-config']],
|
||||
'risk-control': [['admin-worker-risk-overview'], ['admin-worker-risk-events']],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user