Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b40eb83f27 | |||
| f80a0f2c27 | |||
| 528669f662 | |||
| f5e523a425 | |||
| 16fa07ceaf | |||
| b21403a47c | |||
| 02d89e6385 | |||
| f9a5b6e81a | |||
| 16c386f165 | |||
| 1c787ed576 | |||
| 4372018c09 |
@@ -1,14 +1,14 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Alert, Button, Form, Input, InputNumber, Space, Typography, message } from 'antd';
|
import { Alert, Button, Form, Input, InputNumber, Modal, Space, Typography, message } from 'antd';
|
||||||
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
||||||
import type { StorePackageItemDto } from '@dukang/shared-types';
|
import type { StorePackageItemDto } from '@dukang/shared-types';
|
||||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import OssUpload from './OssUpload';
|
||||||
type PackageRow = StorePackageItemDto;
|
type PackageRow = StorePackageItemDto;
|
||||||
|
|
||||||
function emptyRow(index = 0): PackageRow {
|
function emptyRow(index = 0): PackageRow {
|
||||||
return { name: '', price: '0', dishes: '', usableTime: '', otherNotes: '', sortOrder: index };
|
return { name: '', price: '0', dishes: '', usableTime: '', otherNotes: '', imageUrl: '', sortOrder: index };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AdminStorePackagesSection({ storeId }: { storeId: string }) {
|
export default function AdminStorePackagesSection({ storeId }: { storeId: string }) {
|
||||||
@@ -41,18 +41,33 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeAt(index: number) {
|
function removeAt(index: number) {
|
||||||
setItems((prev) => prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })));
|
const run = () => {
|
||||||
setCollapsed((prev) => {
|
setItems((prev) => {
|
||||||
const next: Record<number, boolean> = {};
|
const next = prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i }));
|
||||||
Object.entries(prev).forEach(([k, v]) => {
|
return next.length ? next : [];
|
||||||
const i = Number(k);
|
|
||||||
if (i < index) next[i] = v;
|
|
||||||
else if (i > index) next[i - 1] = v;
|
|
||||||
});
|
});
|
||||||
return next;
|
setCollapsed((prev) => {
|
||||||
});
|
const next: Record<number, boolean> = {};
|
||||||
|
Object.entries(prev).forEach(([k, v]) => {
|
||||||
|
const i = Number(k);
|
||||||
|
if (i < index) next[i] = v;
|
||||||
|
else if (i > index) next[i - 1] = v;
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (items.length === 1) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '清空门店套餐',
|
||||||
|
content: '删除最后一条套餐后,该门店将无展示套餐,确认继续?',
|
||||||
|
okText: '确认删除',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: run,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleCollapse(index: number) {
|
function toggleCollapse(index: number) {
|
||||||
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||||
}
|
}
|
||||||
@@ -65,6 +80,7 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
|||||||
dishes: item.dishes.trim(),
|
dishes: item.dishes.trim(),
|
||||||
usableTime: item.usableTime?.trim() || null,
|
usableTime: item.usableTime?.trim() || null,
|
||||||
otherNotes: item.otherNotes?.trim() || null,
|
otherNotes: item.otherNotes?.trim() || null,
|
||||||
|
imageUrl: item.imageUrl?.trim() || null,
|
||||||
sortOrder: index,
|
sortOrder: index,
|
||||||
}))
|
}))
|
||||||
.filter((item) => item.name || item.dishes || item.price);
|
.filter((item) => item.name || item.dishes || item.price);
|
||||||
@@ -106,8 +122,21 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
|||||||
return <Typography.Text type="secondary">加载套餐中…</Typography.Text>;
|
return <Typography.Text type="secondary">加载套餐中…</Typography.Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
if (!items.length) {
|
||||||
<Form layout="vertical" requiredMark={false}>
|
return (
|
||||||
|
<Form layout="vertical" requiredMark={false}>
|
||||||
|
<Alert type="info" showIcon style={{ marginBottom: 16 }} message="该门店暂无套餐,可添加或保存为空。" />
|
||||||
|
<Button onClick={addRow} style={{ marginBottom: 16 }}>
|
||||||
|
添加套餐
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" loading={saving} onClick={() => void save()}>
|
||||||
|
保存套餐
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( <Form layout="vertical" requiredMark={false}>
|
||||||
<Alert
|
<Alert
|
||||||
type="info"
|
type="info"
|
||||||
showIcon
|
showIcon
|
||||||
@@ -140,12 +169,11 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
|||||||
{displayName}
|
{displayName}
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
</Button>
|
</Button>
|
||||||
{items.length > 1 ? (
|
{items.length > 0 ? (
|
||||||
<Button type="link" danger onClick={() => removeAt(index)}>
|
<Button type="link" danger onClick={() => removeAt(index)}>
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null} </Space>
|
||||||
</Space>
|
|
||||||
|
|
||||||
{!isCollapsed ? (
|
{!isCollapsed ? (
|
||||||
<>
|
<>
|
||||||
@@ -186,8 +214,16 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="其他说明" style={{ marginBottom: 0 }}>
|
<Form.Item label="套餐图片" style={{ marginBottom: 12 }}>
|
||||||
<Input
|
<OssUpload
|
||||||
|
bizType="STORE_PACKAGE"
|
||||||
|
mediaType="IMAGE"
|
||||||
|
value={item.imageUrl || undefined}
|
||||||
|
onChange={(url) => updateAt(index, { imageUrl: url })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="其他说明" style={{ marginBottom: 0 }}> <Input
|
||||||
placeholder="不可叠加"
|
placeholder="不可叠加"
|
||||||
value={item.otherNotes || ''}
|
value={item.otherNotes || ''}
|
||||||
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Form,
|
Form,
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
type DevPlanTaskDto,
|
type DevPlanTaskDto,
|
||||||
type DevPlanTaskStatusDto,
|
type DevPlanTaskStatusDto,
|
||||||
type DevPlanTaskTypeDto,
|
type DevPlanTaskTypeDto,
|
||||||
|
type DevPlanVersionDto,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
@@ -46,11 +47,22 @@ export default function DevPlanTasksPage() {
|
|||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<string[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<string[]>([]);
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [dispatchOpen, setDispatchOpen] = useState(false);
|
const [dispatchOpen, setDispatchOpen] = useState(false);
|
||||||
|
const [batchEditOpen, setBatchEditOpen] = useState(false);
|
||||||
|
const [batchSaving, setBatchSaving] = useState(false);
|
||||||
|
const [versions, setVersions] = useState<DevPlanVersionDto[]>([]);
|
||||||
const [editing, setEditing] = useState<DevPlanTaskDto | null>(null);
|
const [editing, setEditing] = useState<DevPlanTaskDto | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [dispatching, setDispatching] = useState(false);
|
const [dispatching, setDispatching] = useState(false);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [dispatchForm] = Form.useForm<{ supplement?: string }>();
|
const [dispatchForm] = Form.useForm<{ supplement?: string }>();
|
||||||
|
const [batchForm] = Form.useForm<{ status?: DevPlanTaskStatusDto; versionId?: string }>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!batchEditOpen) return;
|
||||||
|
request<{ items: DevPlanVersionDto[] }>('/admin/dev-plan/versions?pageSize=100')
|
||||||
|
.then((res) => setVersions(res.items ?? []))
|
||||||
|
.catch(() => setVersions([]));
|
||||||
|
}, [batchEditOpen]);
|
||||||
|
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<DevPlanTaskDto>(
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<DevPlanTaskDto>(
|
||||||
'/admin/dev-plan/tasks',
|
'/admin/dev-plan/tasks',
|
||||||
@@ -119,6 +131,38 @@ export default function DevPlanTasksPage() {
|
|||||||
setDispatchOpen(true);
|
setDispatchOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openBatchEdit() {
|
||||||
|
batchForm.setFieldsValue({ status: undefined, versionId: undefined });
|
||||||
|
setBatchEditOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitBatchEdit() {
|
||||||
|
const values = await batchForm.validateFields();
|
||||||
|
if (!values.status && !values.versionId) {
|
||||||
|
message.warning('请至少选择状态或关联版本');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setBatchSaving(true);
|
||||||
|
try {
|
||||||
|
await request('/admin/dev-plan/tasks/batch-update', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
taskIds: selectedRowKeys,
|
||||||
|
status: values.status || undefined,
|
||||||
|
versionId: values.versionId || undefined,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
message.success('批量更新成功');
|
||||||
|
setBatchEditOpen(false);
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '批量更新失败');
|
||||||
|
} finally {
|
||||||
|
setBatchSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function submitDispatch() {
|
async function submitDispatch() {
|
||||||
const values = await dispatchForm.validateFields();
|
const values = await dispatchForm.validateFields();
|
||||||
setDispatching(true);
|
setDispatching(true);
|
||||||
@@ -186,6 +230,9 @@ export default function DevPlanTasksPage() {
|
|||||||
开发计划 · 任务列表
|
开发计划 · 任务列表
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Space>
|
<Space>
|
||||||
|
<Button disabled={!selectedRowKeys.length} onClick={openBatchEdit}>
|
||||||
|
批量编辑
|
||||||
|
</Button>
|
||||||
<Button disabled={!selectedRowKeys.length} onClick={openDispatch}>
|
<Button disabled={!selectedRowKeys.length} onClick={openDispatch}>
|
||||||
评审
|
评审
|
||||||
</Button>
|
</Button>
|
||||||
@@ -280,6 +327,29 @@ export default function DevPlanTasksPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="批量编辑任务"
|
||||||
|
open={batchEditOpen}
|
||||||
|
onCancel={() => setBatchEditOpen(false)}
|
||||||
|
onOk={() => void submitBatchEdit()}
|
||||||
|
confirmLoading={batchSaving}
|
||||||
|
destroyOnClose
|
||||||
|
>
|
||||||
|
<Typography.Paragraph type="secondary">已选 {selectedRowKeys.length} 条任务</Typography.Paragraph>
|
||||||
|
<Form form={batchForm} layout="vertical">
|
||||||
|
<Form.Item name="status" label="状态(不修改请留空)">
|
||||||
|
<Select allowClear placeholder="不修改" options={STATUS_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="versionId" label="关联版本(追加关联,不修改请留空)">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
placeholder="不修改"
|
||||||
|
options={versions.map((v) => ({ value: v.id, label: v.versionNo }))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import type { ColumnsType } from 'antd/es/table';
|
|||||||
import { UploadOutlined } from '@ant-design/icons';
|
import { UploadOutlined } from '@ant-design/icons';
|
||||||
import type {
|
import type {
|
||||||
KnowledgeBaseDto,
|
KnowledgeBaseDto,
|
||||||
|
KnowledgeDocumentDetailDto,
|
||||||
KnowledgeDocumentDto,
|
KnowledgeDocumentDto,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
@@ -49,6 +50,10 @@ export default function KnowledgeBasesPage() {
|
|||||||
const [docsLoading, setDocsLoading] = useState(false);
|
const [docsLoading, setDocsLoading] = useState(false);
|
||||||
const [docModalOpen, setDocModalOpen] = useState(false);
|
const [docModalOpen, setDocModalOpen] = useState(false);
|
||||||
const [docSaving, setDocSaving] = useState(false);
|
const [docSaving, setDocSaving] = useState(false);
|
||||||
|
const [editingDoc, setEditingDoc] = useState<KnowledgeDocumentDto | null>(null);
|
||||||
|
const [editDocModalOpen, setEditDocModalOpen] = useState(false);
|
||||||
|
const [editDocSaving, setEditDocSaving] = useState(false);
|
||||||
|
const [editDocForm] = Form.useForm<DocForm>();
|
||||||
|
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } =
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } =
|
||||||
useAdminList<KnowledgeBaseDto>(
|
useAdminList<KnowledgeBaseDto>(
|
||||||
@@ -195,28 +200,52 @@ export default function KnowledgeBasesPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 80,
|
width: 140,
|
||||||
render: (_, row) =>
|
render: (_, row) =>
|
||||||
drawerKb?.canEditFull ? (
|
drawerKb?.canEditFull ? (
|
||||||
<Popconfirm
|
<Space>
|
||||||
title="删除文档?"
|
<Button
|
||||||
onConfirm={async () => {
|
type="link"
|
||||||
try {
|
size="small"
|
||||||
await request(`/admin/knowledge-bases/${drawerKb.id}/documents/${row.id}`, {
|
onClick={async () => {
|
||||||
method: 'DELETE',
|
if (!drawerKb) return;
|
||||||
});
|
try {
|
||||||
message.success('已删除');
|
const detail = await request<KnowledgeDocumentDetailDto>(
|
||||||
void loadDocs(drawerKb);
|
`/admin/knowledge-bases/${drawerKb.id}/documents/${row.id}`,
|
||||||
reload();
|
);
|
||||||
} catch (e) {
|
setEditingDoc(row);
|
||||||
message.error(e instanceof Error ? e.message : String(e));
|
editDocForm.setFieldsValue({
|
||||||
}
|
title: detail.title,
|
||||||
}}
|
contentText: detail.contentText || '',
|
||||||
>
|
});
|
||||||
<Button type="link" size="small" danger>
|
setEditDocModalOpen(true);
|
||||||
删除
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : String(e));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
<Popconfirm
|
||||||
|
title="删除文档?"
|
||||||
|
onConfirm={async () => {
|
||||||
|
try {
|
||||||
|
await request(`/admin/knowledge-bases/${drawerKb.id}/documents/${row.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
message.success('已删除');
|
||||||
|
void loadDocs(drawerKb);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : String(e));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button type="link" size="small" danger>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
) : null,
|
) : null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -398,6 +427,50 @@ export default function KnowledgeBasesPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="编辑知识文档"
|
||||||
|
open={editDocModalOpen}
|
||||||
|
onCancel={() => {
|
||||||
|
setEditDocModalOpen(false);
|
||||||
|
setEditingDoc(null);
|
||||||
|
}}
|
||||||
|
confirmLoading={editDocSaving}
|
||||||
|
onOk={async () => {
|
||||||
|
if (!drawerKb || !editingDoc) return;
|
||||||
|
const values = await editDocForm.validateFields();
|
||||||
|
setEditDocSaving(true);
|
||||||
|
try {
|
||||||
|
await request(`/admin/knowledge-bases/${drawerKb.id}/documents/${editingDoc.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
title: values.title,
|
||||||
|
contentText: values.contentText || null,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
message.success('已保存');
|
||||||
|
setEditDocModalOpen(false);
|
||||||
|
setEditingDoc(null);
|
||||||
|
void loadDocs(drawerKb);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : String(e));
|
||||||
|
} finally {
|
||||||
|
setEditDocSaving(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
destroyOnClose
|
||||||
|
width={640}
|
||||||
|
>
|
||||||
|
<Form form={editDocForm} layout="vertical">
|
||||||
|
<Form.Item name="title" label="标题" rules={[{ required: true }]}>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="contentText" label="正文(可粘贴)">
|
||||||
|
<Input.TextArea rows={8} placeholder="支持 Markdown / 纯文本" />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,10 +168,10 @@ function ProductDetailFields({ form, aromaType }: { form: FormInstance; aromaTyp
|
|||||||
<>
|
<>
|
||||||
<ProductDetailTemplatePicker form={form} aromaType={aromaType} />
|
<ProductDetailTemplatePicker form={form} aromaType={aromaType} />
|
||||||
<Divider />
|
<Divider />
|
||||||
<Typography.Text type="secondary">详情页轮播(CAROUSEL)</Typography.Text>
|
<Typography.Text type="secondary">详情页轮播(CAROUSEL,单张最大 10MB)</Typography.Text>
|
||||||
<ImageUrlList name="carouselUrls" label="轮播图" bizType="CAROUSEL" />
|
<ImageUrlList name="carouselUrls" label="轮播图" bizType="CAROUSEL" />
|
||||||
<Divider />
|
<Divider />
|
||||||
<Typography.Text type="secondary">详情长图(DETAIL,可逐张修改)</Typography.Text>
|
<Typography.Text type="secondary">详情长图(DETAIL,可逐张修改,单张最大 10MB)</Typography.Text>
|
||||||
<DetailImageUrlList label="详情图" bizType="DETAIL" />
|
<DetailImageUrlList label="详情图" bizType="DETAIL" />
|
||||||
<Divider />
|
<Divider />
|
||||||
<Form.Item name="storyTitle" label="故事标题">
|
<Form.Item name="storyTitle" label="故事标题">
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import { useEffect, useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
Checkbox,
|
||||||
Drawer,
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
|
Image,
|
||||||
Input,
|
Input,
|
||||||
Modal,
|
Modal,
|
||||||
Radio,
|
Radio,
|
||||||
@@ -32,6 +34,7 @@ import {
|
|||||||
type BatchReviewPreviewItem,
|
type BatchReviewPreviewItem,
|
||||||
type BatchReviewPreviewResponse,
|
type BatchReviewPreviewResponse,
|
||||||
type DevPlanTaskTypeDto,
|
type DevPlanTaskTypeDto,
|
||||||
|
type DevPlanVersionDto,
|
||||||
type SupportTicketDto,
|
type SupportTicketDto,
|
||||||
type SupportTicketLinkedTaskDto,
|
type SupportTicketLinkedTaskDto,
|
||||||
type SupportTicketStatusDto,
|
type SupportTicketStatusDto,
|
||||||
@@ -40,6 +43,10 @@ import {
|
|||||||
import { request, type HqProfile } from '../lib/api';
|
import { request, type HqProfile } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
import OssUpload from '../components/OssUpload';
|
||||||
|
|
||||||
|
const DISPATCH_WECOM_STORAGE_KEY = 'support_ticket_dispatch_wecom';
|
||||||
|
const DEFAULT_DISPATCH_SUPPLEMENT = '请按以下任务进入开发流程';
|
||||||
|
|
||||||
const STATUS_COLOR: Record<SupportTicketStatusDto, string> = {
|
const STATUS_COLOR: Record<SupportTicketStatusDto, string> = {
|
||||||
PENDING_REVIEW: 'orange',
|
PENDING_REVIEW: 'orange',
|
||||||
@@ -88,15 +95,45 @@ export default function SupportTicketsPage() {
|
|||||||
const [batchPreviewOpen, setBatchPreviewOpen] = useState(false);
|
const [batchPreviewOpen, setBatchPreviewOpen] = useState(false);
|
||||||
const [batchPreview, setBatchPreview] = useState<BatchReviewPreviewItem[]>([]);
|
const [batchPreview, setBatchPreview] = useState<BatchReviewPreviewItem[]>([]);
|
||||||
const [batchConfirming, setBatchConfirming] = useState(false);
|
const [batchConfirming, setBatchConfirming] = useState(false);
|
||||||
|
const [batchStatusOpen, setBatchStatusOpen] = useState(false);
|
||||||
|
const [batchStatusSaving, setBatchStatusSaving] = useState(false);
|
||||||
|
const [batchCreateSaving, setBatchCreateSaving] = useState(false);
|
||||||
|
const [batchPublishOpen, setBatchPublishOpen] = useState(false);
|
||||||
|
const [batchPublishSaving, setBatchPublishSaving] = useState(false);
|
||||||
|
const [versions, setVersions] = useState<DevPlanVersionDto[]>([]);
|
||||||
|
const [editOpen, setEditOpen] = useState(false);
|
||||||
|
const [editSaving, setEditSaving] = useState(false);
|
||||||
const [reviewDecision, setReviewDecision] = useState<'APPROVE' | 'REJECT'>('APPROVE');
|
const [reviewDecision, setReviewDecision] = useState<'APPROVE' | 'REJECT'>('APPROVE');
|
||||||
|
|
||||||
const [createForm] = Form.useForm();
|
const [createForm] = Form.useForm();
|
||||||
|
const [editForm] = Form.useForm();
|
||||||
const [reviewForm] = Form.useForm<{ decision: 'APPROVE' | 'REJECT'; rejectReason?: string; note?: string }>();
|
const [reviewForm] = Form.useForm<{ decision: 'APPROVE' | 'REJECT'; rejectReason?: string; note?: string }>();
|
||||||
const [tasksForm] = Form.useForm<{ tasks: Array<{ content: string; type: DevPlanTaskTypeDto }> }>();
|
const [tasksForm] = Form.useForm<{
|
||||||
|
tasks: Array<{ content: string; type: DevPlanTaskTypeDto }>;
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
dispatchSupplement?: string;
|
||||||
|
}>();
|
||||||
const [batchForm] = Form.useForm<{ items: BatchReviewPreviewItem[] }>();
|
const [batchForm] = Form.useForm<{ items: BatchReviewPreviewItem[] }>();
|
||||||
|
const [batchStatusForm] = Form.useForm<{
|
||||||
|
status: SupportTicketStatusDto;
|
||||||
|
rejectReason?: string;
|
||||||
|
note?: string;
|
||||||
|
}>();
|
||||||
|
const [batchPublishForm] = Form.useForm<{
|
||||||
|
versionId: string;
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
dispatchSupplement?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!batchPublishOpen) return;
|
||||||
|
request<{ items: DevPlanVersionDto[] }>('/admin/dev-plan/versions?pageSize=100')
|
||||||
|
.then((res) => setVersions(res.items ?? []))
|
||||||
|
.catch(() => setVersions([]));
|
||||||
|
}, [batchPublishOpen]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
@@ -117,6 +154,7 @@ export default function SupportTicketsPage() {
|
|||||||
title: values.title.trim(),
|
title: values.title.trim(),
|
||||||
content: values.content?.trim() || undefined,
|
content: values.content?.trim() || undefined,
|
||||||
remark: values.remark?.trim() || undefined,
|
remark: values.remark?.trim() || undefined,
|
||||||
|
attachmentUrls: (values.attachmentUrls ?? []).map((u: string) => u?.trim()).filter(Boolean),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
message.success('技术支持工单已创建,等待最高管理员评审');
|
message.success('技术支持工单已创建,等待最高管理员评审');
|
||||||
@@ -166,13 +204,141 @@ export default function SupportTicketsPage() {
|
|||||||
const summary = [detail!.title, detail!.content].filter(Boolean).join('\n').slice(0, 500);
|
const summary = [detail!.title, detail!.content].filter(Boolean).join('\n').slice(0, 500);
|
||||||
tasksForm.setFieldsValue({
|
tasksForm.setFieldsValue({
|
||||||
tasks: [{ content: summary || detail!.title, type: mapSupportTicketTypeToDevPlanTask(detail!.ticketType) }],
|
tasks: [{ content: summary || detail!.title, type: mapSupportTicketTypeToDevPlanTask(detail!.ticketType) }],
|
||||||
|
dispatchToWecom: localStorage.getItem(DISPATCH_WECOM_STORAGE_KEY) !== 'false',
|
||||||
|
dispatchSupplement: DEFAULT_DISPATCH_SUPPLEMENT,
|
||||||
});
|
});
|
||||||
setCreateTasksOpen(true);
|
setCreateTasksOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openEdit() {
|
||||||
|
if (!detail) return;
|
||||||
|
editForm.setFieldsValue({
|
||||||
|
ticketType: detail.ticketType,
|
||||||
|
title: detail.title,
|
||||||
|
content: detail.content || '',
|
||||||
|
remark: detail.remark || '',
|
||||||
|
attachmentUrls: detail.attachmentUrls?.length ? detail.attachmentUrls : [''],
|
||||||
|
});
|
||||||
|
setEditOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitEdit() {
|
||||||
|
const values = await editForm.validateFields();
|
||||||
|
setEditSaving(true);
|
||||||
|
try {
|
||||||
|
await request(`/admin/support-tickets/${detail!.id}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify({
|
||||||
|
ticketType: values.ticketType,
|
||||||
|
title: values.title.trim(),
|
||||||
|
content: values.content?.trim() || undefined,
|
||||||
|
remark: values.remark?.trim() || undefined,
|
||||||
|
attachmentUrls: (values.attachmentUrls ?? []).map((u: string) => u?.trim()).filter(Boolean),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
message.success('已保存');
|
||||||
|
setEditOpen(false);
|
||||||
|
await openDetail(String(detail!.id));
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
} finally {
|
||||||
|
setEditSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitBatchStatus() {
|
||||||
|
const values = await batchStatusForm.validateFields();
|
||||||
|
setBatchStatusSaving(true);
|
||||||
|
try {
|
||||||
|
const res = await request<{ successCount: number; failCount: number }>(
|
||||||
|
'/admin/support-tickets/batch-update-status',
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
ticketIds: selectedRowKeys,
|
||||||
|
status: values.status,
|
||||||
|
rejectReason: values.rejectReason?.trim() || undefined,
|
||||||
|
note: values.note?.trim() || undefined,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
message.success(`成功 ${res.successCount} 条,失败 ${res.failCount} 条`);
|
||||||
|
setBatchStatusOpen(false);
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '批量更新失败');
|
||||||
|
} finally {
|
||||||
|
setBatchStatusSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitBatchCreateTasks() {
|
||||||
|
if (!selectedRowKeys.length) return;
|
||||||
|
setBatchCreateSaving(true);
|
||||||
|
try {
|
||||||
|
const res = await request<{ successCount: number; failCount: number }>(
|
||||||
|
'/admin/support-tickets/batch-create-tasks',
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ ticketIds: selectedRowKeys }),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
message.success(`已创建 ${res.successCount} 条任务,跳过/失败 ${res.failCount} 条`);
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '批量创建任务失败');
|
||||||
|
} finally {
|
||||||
|
setBatchCreateSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openBatchPublish() {
|
||||||
|
batchPublishForm.setFieldsValue({
|
||||||
|
versionId: undefined,
|
||||||
|
dispatchToWecom: localStorage.getItem(DISPATCH_WECOM_STORAGE_KEY) !== 'false',
|
||||||
|
dispatchSupplement: DEFAULT_DISPATCH_SUPPLEMENT,
|
||||||
|
});
|
||||||
|
setBatchPublishOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitBatchPublish() {
|
||||||
|
const values = await batchPublishForm.validateFields();
|
||||||
|
localStorage.setItem(DISPATCH_WECOM_STORAGE_KEY, values.dispatchToWecom ? 'true' : 'false');
|
||||||
|
setBatchPublishSaving(true);
|
||||||
|
try {
|
||||||
|
const res = await request<{
|
||||||
|
successCount: number;
|
||||||
|
failCount: number;
|
||||||
|
linkedTaskCount: number;
|
||||||
|
}>('/admin/support-tickets/batch-publish', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
ticketIds: selectedRowKeys,
|
||||||
|
versionId: values.versionId,
|
||||||
|
dispatchToWecom: !!values.dispatchToWecom,
|
||||||
|
dispatchSupplement: values.dispatchSupplement?.trim() || undefined,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
message.success(
|
||||||
|
`已关联 ${res.linkedTaskCount} 条任务到版本,工单成功 ${res.successCount} 条,失败 ${res.failCount} 条`,
|
||||||
|
);
|
||||||
|
setBatchPublishOpen(false);
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '批量发布失败');
|
||||||
|
} finally {
|
||||||
|
setBatchPublishSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function submitCreateTasks() {
|
async function submitCreateTasks() {
|
||||||
const values = await tasksForm.validateFields();
|
const values = await tasksForm.validateFields();
|
||||||
const note = reviewForm.getFieldValue('note') as string | undefined;
|
const note = reviewForm.getFieldValue('note') as string | undefined;
|
||||||
|
localStorage.setItem(DISPATCH_WECOM_STORAGE_KEY, values.dispatchToWecom ? 'true' : 'false');
|
||||||
setActing(true);
|
setActing(true);
|
||||||
try {
|
try {
|
||||||
await request(`/admin/support-tickets/${detail!.id}/review`, {
|
await request(`/admin/support-tickets/${detail!.id}/review`, {
|
||||||
@@ -181,9 +347,11 @@ export default function SupportTicketsPage() {
|
|||||||
decision: 'APPROVE',
|
decision: 'APPROVE',
|
||||||
note: note?.trim() || undefined,
|
note: note?.trim() || undefined,
|
||||||
tasks: values.tasks.map((t) => ({ content: t.content.trim(), type: t.type })),
|
tasks: values.tasks.map((t) => ({ content: t.content.trim(), type: t.type })),
|
||||||
|
dispatchToWecom: !!values.dispatchToWecom,
|
||||||
|
dispatchSupplement: values.dispatchSupplement?.trim() || undefined,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
message.success('审批通过,已创建开发任务');
|
message.success(values.dispatchToWecom ? '审批通过,已创建任务并派发企微' : '审批通过,已创建开发任务');
|
||||||
setCreateTasksOpen(false);
|
setCreateTasksOpen(false);
|
||||||
setDrawerOpen(false);
|
setDrawerOpen(false);
|
||||||
reload();
|
reload();
|
||||||
@@ -309,9 +477,12 @@ export default function SupportTicketsPage() {
|
|||||||
if (!detail) return null;
|
if (!detail) return null;
|
||||||
if (detail.status === 'PENDING_REVIEW' && isSuperAdmin) {
|
if (detail.status === 'PENDING_REVIEW' && isSuperAdmin) {
|
||||||
return (
|
return (
|
||||||
<Button type="primary" loading={acting} onClick={openReview}>
|
<Space>
|
||||||
审批
|
<Button onClick={openEdit}>编辑</Button>
|
||||||
</Button>
|
<Button type="primary" loading={acting} onClick={openReview}>
|
||||||
|
审批
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (detail.status === 'DEVELOPING') {
|
if (detail.status === 'DEVELOPING') {
|
||||||
@@ -346,9 +517,30 @@ export default function SupportTicketsPage() {
|
|||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Space>
|
<Space>
|
||||||
{isSuperAdmin ? (
|
{isSuperAdmin ? (
|
||||||
<Button disabled={!selectedRowKeys.length} loading={acting} onClick={() => void startBatchPreview()}>
|
<>
|
||||||
批量审核
|
<Button
|
||||||
</Button>
|
disabled={!selectedRowKeys.length}
|
||||||
|
loading={batchCreateSaving}
|
||||||
|
onClick={() => void submitBatchCreateTasks()}
|
||||||
|
>
|
||||||
|
一键创建任务
|
||||||
|
</Button>
|
||||||
|
<Button disabled={!selectedRowKeys.length} onClick={openBatchPublish}>
|
||||||
|
一键发布
|
||||||
|
</Button>
|
||||||
|
<Button disabled={!selectedRowKeys.length} loading={acting} onClick={() => void startBatchPreview()}>
|
||||||
|
批量审核
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={!selectedRowKeys.length}
|
||||||
|
onClick={() => {
|
||||||
|
batchStatusForm.setFieldsValue({ status: 'TESTING', rejectReason: '', note: '' });
|
||||||
|
setBatchStatusOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
批量改状态
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||||
创建工单
|
创建工单
|
||||||
@@ -612,6 +804,18 @@ export default function SupportTicketsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{detail.attachmentUrls?.length ? (
|
||||||
|
<div style={{ marginTop: 16 }}>
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||||
|
附件
|
||||||
|
</Typography.Text>
|
||||||
|
<Space wrap style={{ marginTop: 8 }}>
|
||||||
|
{detail.attachmentUrls.map((url) => (
|
||||||
|
<Image key={url} src={url} width={80} height={80} style={{ objectFit: 'cover', borderRadius: 4 }} />
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* 关联开发任务 */}
|
{/* 关联开发任务 */}
|
||||||
@@ -661,7 +865,7 @@ export default function SupportTicketsPage() {
|
|||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
<Modal title="创建技术支持工单" open={createOpen} onCancel={() => setCreateOpen(false)} onOk={() => void submitCreate()} confirmLoading={creating} destroyOnClose okText="提交">
|
<Modal title="创建技术支持工单" open={createOpen} onCancel={() => setCreateOpen(false)} onOk={() => void submitCreate()} confirmLoading={creating} destroyOnClose okText="提交">
|
||||||
<Form form={createForm} layout="vertical" initialValues={{ ticketType: 'BUG' }}>
|
<Form form={createForm} layout="vertical" initialValues={{ ticketType: 'BUG', attachmentUrls: [''] }}>
|
||||||
<Form.Item name="ticketType" label="类型" rules={[{ required: true }]}>
|
<Form.Item name="ticketType" label="类型" rules={[{ required: true }]}>
|
||||||
<Select options={TYPE_OPTIONS} />
|
<Select options={TYPE_OPTIONS} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@@ -674,6 +878,27 @@ export default function SupportTicketsPage() {
|
|||||||
<Form.Item name="remark" label="备注">
|
<Form.Item name="remark" label="备注">
|
||||||
<Input.TextArea rows={2} maxLength={512} showCount />
|
<Input.TextArea rows={2} maxLength={512} showCount />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="附件图片">
|
||||||
|
<Form.List name="attachmentUrls">
|
||||||
|
{(fields, { add, remove }) => (
|
||||||
|
<>
|
||||||
|
{fields.map((field) => (
|
||||||
|
<Space key={field.key} align="start" style={{ display: 'flex', marginBottom: 8 }}>
|
||||||
|
<Form.Item {...field} style={{ flex: 1, marginBottom: 0 }}>
|
||||||
|
<OssUpload bizType="SUPPORT_TICKET_ATTACHMENT" mediaType="IMAGE" />
|
||||||
|
</Form.Item>
|
||||||
|
{fields.length > 1 ? (
|
||||||
|
<MinusCircleOutlined onClick={() => remove(field.name)} style={{ marginTop: 8 }} />
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
<Button type="dashed" onClick={() => add('')} block icon={<PlusOutlined />}>
|
||||||
|
添加附件
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Form.List>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
@@ -725,6 +950,113 @@ export default function SupportTicketsPage() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
|
<Form.Item name="dispatchToWecom" valuePropName="checked" style={{ marginTop: 16 }}>
|
||||||
|
<Checkbox>审批通过后发送到企微开发助手</Checkbox>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="dispatchSupplement" label="派发补充说明">
|
||||||
|
<Input.TextArea rows={2} placeholder={DEFAULT_DISPATCH_SUPPLEMENT} />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="编辑工单"
|
||||||
|
open={editOpen}
|
||||||
|
onCancel={() => setEditOpen(false)}
|
||||||
|
onOk={() => void submitEdit()}
|
||||||
|
confirmLoading={editSaving}
|
||||||
|
destroyOnClose
|
||||||
|
width={640}
|
||||||
|
>
|
||||||
|
<Form form={editForm} layout="vertical">
|
||||||
|
<Form.Item name="ticketType" label="类型" rules={[{ required: true }]}>
|
||||||
|
<Select options={TYPE_OPTIONS} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="title" label="标题" rules={[{ required: true }]}>
|
||||||
|
<Input maxLength={128} showCount />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="content" label="详细说明">
|
||||||
|
<Input.TextArea rows={5} maxLength={4000} showCount />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="remark" label="备注">
|
||||||
|
<Input.TextArea rows={2} maxLength={512} showCount />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="附件图片">
|
||||||
|
<Form.List name="attachmentUrls">
|
||||||
|
{(fields, { add, remove }) => (
|
||||||
|
<>
|
||||||
|
{fields.map((field) => (
|
||||||
|
<Space key={field.key} align="start" style={{ display: 'flex', marginBottom: 8 }}>
|
||||||
|
<Form.Item {...field} style={{ flex: 1, marginBottom: 0 }}>
|
||||||
|
<OssUpload bizType="SUPPORT_TICKET_ATTACHMENT" mediaType="IMAGE" />
|
||||||
|
</Form.Item>
|
||||||
|
{fields.length > 1 ? (
|
||||||
|
<MinusCircleOutlined onClick={() => remove(field.name)} style={{ marginTop: 8 }} />
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
))}
|
||||||
|
<Button type="dashed" onClick={() => add('')} block icon={<PlusOutlined />}>
|
||||||
|
添加附件
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Form.List>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="批量改状态"
|
||||||
|
open={batchStatusOpen}
|
||||||
|
onCancel={() => setBatchStatusOpen(false)}
|
||||||
|
onOk={() => void submitBatchStatus()}
|
||||||
|
confirmLoading={batchStatusSaving}
|
||||||
|
destroyOnClose
|
||||||
|
>
|
||||||
|
<Typography.Paragraph type="secondary">已选 {selectedRowKeys.length} 条工单</Typography.Paragraph>
|
||||||
|
<Form form={batchStatusForm} layout="vertical">
|
||||||
|
<Form.Item name="status" label="目标状态" rules={[{ required: true }]}>
|
||||||
|
<Select options={STATUS_OPTIONS.filter((o) => o.value !== 'PENDING_REVIEW')} />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item noStyle shouldUpdate={(prev, cur) => prev.status !== cur.status}>
|
||||||
|
{({ getFieldValue }) =>
|
||||||
|
getFieldValue('status') === 'REJECTED' ? (
|
||||||
|
<Form.Item name="rejectReason" label="驳回理由" rules={[{ required: true }]}>
|
||||||
|
<Input.TextArea rows={2} maxLength={512} showCount />
|
||||||
|
</Form.Item>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="note" label="备注">
|
||||||
|
<Input.TextArea rows={2} maxLength={512} showCount />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="一键发布"
|
||||||
|
open={batchPublishOpen}
|
||||||
|
onCancel={() => setBatchPublishOpen(false)}
|
||||||
|
onOk={() => void submitBatchPublish()}
|
||||||
|
confirmLoading={batchPublishSaving}
|
||||||
|
destroyOnClose
|
||||||
|
>
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
已选 {selectedRowKeys.length} 条工单。将把各工单关联的开发任务追加到所选版本;无任务的工单将跳过。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
<Form form={batchPublishForm} layout="vertical">
|
||||||
|
<Form.Item name="versionId" label="开发版本" rules={[{ required: true, message: '请选择开发版本' }]}>
|
||||||
|
<Select
|
||||||
|
placeholder="选择版本"
|
||||||
|
options={versions.map((v) => ({ value: v.id, label: v.versionNo }))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="dispatchToWecom" valuePropName="checked">
|
||||||
|
<Checkbox>同时发送到企微开发助手</Checkbox>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="dispatchSupplement" label="派发补充说明">
|
||||||
|
<Input.TextArea rows={2} placeholder={DEFAULT_DISPATCH_SUPPLEMENT} />
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
|||||||
import type { PackageFormItem } from '../lib/storePackages';
|
import type { PackageFormItem } from '../lib/storePackages';
|
||||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
import { emptyPackage } from '../lib/storePackages';
|
import { emptyPackage } from '../lib/storePackages';
|
||||||
|
import OssUploadField from './OssUploadField';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
items: PackageFormItem[];
|
items: PackageFormItem[];
|
||||||
@@ -129,6 +130,16 @@ export default function StorePackagesForm({ items, onChange, disabled, embedded
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>套餐图片</label>
|
||||||
|
<OssUploadField
|
||||||
|
bizType="STORE_PACKAGE"
|
||||||
|
value={item.imageUrl || ''}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(url) => updateAt(index, { imageUrl: url })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="partner-field">
|
<div className="partner-field">
|
||||||
<label>其他说明</label>
|
<label>其他说明</label>
|
||||||
<div className="partner-field-input">
|
<div className="partner-field-input">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { PartnerMe, PartnerStaffRole } from '@dukang/shared-types';
|
import type { PartnerMe, PartnerStaffRole } from '@dukang/shared-types';
|
||||||
|
import { reportApiError } from '@dukang/client-logging';
|
||||||
import { isOnAppPath, toAppPath } from '@dukang/weixin-sdk';
|
import { isOnAppPath, toAppPath } from '@dukang/weixin-sdk';
|
||||||
import { showPartnerToast } from './toast';
|
import { showPartnerToast } from './toast';
|
||||||
|
|
||||||
@@ -159,6 +160,12 @@ async function rawRequest<T>(
|
|||||||
if (json.code !== 0) {
|
if (json.code !== 0) {
|
||||||
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
||||||
err.status = json.code === 401 ? 401 : json.code;
|
err.status = json.code === 401 ? 401 : json.code;
|
||||||
|
if (json.code === 400) {
|
||||||
|
reportApiError(
|
||||||
|
{ apiBase, clientApp: CLIENT_APP, getToken: () => localStorage.getItem(ACCESS_TOKEN) },
|
||||||
|
{ message: json.message || '请求失败', status: 400, url: path, category: 'validation_error' },
|
||||||
|
);
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return json.data as T;
|
return json.data as T;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export function emptyPackage(index = 0): PackageFormItem {
|
|||||||
dishes: '',
|
dishes: '',
|
||||||
usableTime: '',
|
usableTime: '',
|
||||||
otherNotes: '',
|
otherNotes: '',
|
||||||
|
imageUrl: '',
|
||||||
sortOrder: index,
|
sortOrder: index,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -22,9 +23,13 @@ export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormIt
|
|||||||
dishes: item.dishes.trim(),
|
dishes: item.dishes.trim(),
|
||||||
usableTime: item.usableTime?.trim() || '',
|
usableTime: item.usableTime?.trim() || '',
|
||||||
otherNotes: item.otherNotes?.trim() || '',
|
otherNotes: item.otherNotes?.trim() || '',
|
||||||
|
imageUrl: item.imageUrl?.trim() || '',
|
||||||
sortOrder: index,
|
sortOrder: index,
|
||||||
}))
|
}))
|
||||||
.filter((item) => item.name || item.price || item.dishes || item.usableTime || item.otherNotes);
|
.filter(
|
||||||
|
(item) =>
|
||||||
|
item.name || item.price || item.dishes || item.usableTime || item.otherNotes || item.imageUrl,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
import { emptyPackage, type PackageFormItem } from '../lib/storePackages';
|
import { emptyPackage, type PackageFormItem } from '../lib/storePackages';
|
||||||
|
import { uploadFileToOss } from '../lib/upload';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
items: PackageFormItem[];
|
items: PackageFormItem[];
|
||||||
@@ -10,6 +11,19 @@ type Props = {
|
|||||||
|
|
||||||
export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
||||||
const [collapsed, setCollapsed] = useState<Record<number, boolean>>({});
|
const [collapsed, setCollapsed] = useState<Record<number, boolean>>({});
|
||||||
|
const [uploadingIndex, setUploadingIndex] = useState<number | null>(null);
|
||||||
|
const fileRefs = useRef<Record<number, HTMLInputElement | null>>({});
|
||||||
|
|
||||||
|
async function pickPackageImage(index: number, file?: File | null) {
|
||||||
|
if (!file || disabled) return;
|
||||||
|
setUploadingIndex(index);
|
||||||
|
try {
|
||||||
|
const result = await uploadFileToOss(file, 'STORE_PACKAGE');
|
||||||
|
updateAt(index, { imageUrl: result.url });
|
||||||
|
} finally {
|
||||||
|
setUploadingIndex(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateAt(index: number, patch: Partial<PackageFormItem>) {
|
function updateAt(index: number, patch: Partial<PackageFormItem>) {
|
||||||
onChange(items.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
onChange(items.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
||||||
@@ -116,6 +130,36 @@ export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">套餐图片</span>
|
||||||
|
{item.imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={item.imageUrl}
|
||||||
|
alt=""
|
||||||
|
style={{ width: '100%', maxHeight: 160, objectFit: 'cover', borderRadius: 8, marginBottom: 8 }}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
<input
|
||||||
|
ref={(el) => {
|
||||||
|
fileRefs.current[index] = el;
|
||||||
|
}}
|
||||||
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
hidden
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => void pickPackageImage(index, e.target.files?.[0])}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-packages-add"
|
||||||
|
style={{ marginTop: 0 }}
|
||||||
|
disabled={disabled || uploadingIndex === index}
|
||||||
|
onClick={() => fileRefs.current[index]?.click()}
|
||||||
|
>
|
||||||
|
{uploadingIndex === index ? '上传中…' : item.imageUrl ? '更换图片' : '上传图片'}
|
||||||
|
</button>
|
||||||
|
</label>
|
||||||
|
|
||||||
<label className="shop-packages-field">
|
<label className="shop-packages-field">
|
||||||
<span className="shop-packages-label">其他说明</span>
|
<span className="shop-packages-label">其他说明</span>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { reportApiError } from '@dukang/client-logging';
|
||||||
|
|
||||||
export const apiBase = '/api/v1';
|
export const apiBase = '/api/v1';
|
||||||
const CLIENT_APP = 'SHOP_H5';
|
const CLIENT_APP = 'SHOP_H5';
|
||||||
|
|
||||||
@@ -213,6 +215,12 @@ async function rawRequest<T>(
|
|||||||
if (json.code !== 0) {
|
if (json.code !== 0) {
|
||||||
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
||||||
err.status = res.status >= 500 ? res.status : json.code;
|
err.status = res.status >= 500 ? res.status : json.code;
|
||||||
|
if (json.code === 400) {
|
||||||
|
reportApiError(
|
||||||
|
{ apiBase, clientApp: CLIENT_APP, getToken: () => localStorage.getItem(ACCESS_TOKEN) },
|
||||||
|
{ message: json.message || '请求失败', status: 400, url: path, category: 'validation_error' },
|
||||||
|
);
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return json.data as T;
|
return json.data as T;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export function emptyPackage(index = 0): PackageFormItem {
|
|||||||
dishes: '',
|
dishes: '',
|
||||||
usableTime: '',
|
usableTime: '',
|
||||||
otherNotes: '',
|
otherNotes: '',
|
||||||
|
imageUrl: '',
|
||||||
sortOrder: index,
|
sortOrder: index,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -22,9 +23,13 @@ export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormIt
|
|||||||
dishes: item.dishes.trim(),
|
dishes: item.dishes.trim(),
|
||||||
usableTime: item.usableTime?.trim() || '',
|
usableTime: item.usableTime?.trim() || '',
|
||||||
otherNotes: item.otherNotes?.trim() || '',
|
otherNotes: item.otherNotes?.trim() || '',
|
||||||
|
imageUrl: item.imageUrl?.trim() || '',
|
||||||
sortOrder: index,
|
sortOrder: index,
|
||||||
}))
|
}))
|
||||||
.filter((item) => item.name || item.price || item.dishes || item.usableTime || item.otherNotes);
|
.filter(
|
||||||
|
(item) =>
|
||||||
|
item.name || item.price || item.dishes || item.usableTime || item.otherNotes || item.imageUrl,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export type RegisteredResource = {
|
|||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function uploadFileToOss(file: File, bizType: string): Promise<UploadFileResult> {
|
export async function uploadFileToOss(file: File, bizType: string): Promise<UploadFileResult> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
formData.append('bizType', bizType);
|
formData.append('bizType', bizType);
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ export default function WithdrawPage() {
|
|||||||
const canApply =
|
const canApply =
|
||||||
!!summary?.isPrimary &&
|
!!summary?.isPrimary &&
|
||||||
summary.availableAmount > 0 &&
|
summary.availableAmount > 0 &&
|
||||||
!summary.hasPendingRequest &&
|
|
||||||
summary.hasBankAccount &&
|
summary.hasBankAccount &&
|
||||||
!submitting;
|
!submitting;
|
||||||
|
|
||||||
@@ -126,7 +125,6 @@ export default function WithdrawPage() {
|
|||||||
info
|
info
|
||||||
</span>
|
</span>
|
||||||
单日上限 ¥{formatMoney(summary?.dailyLimit ?? 5000)}
|
单日上限 ¥{formatMoney(summary?.dailyLimit ?? 5000)}
|
||||||
{summary?.hasPendingRequest ? ' · 已有待审核申请' : ''}
|
|
||||||
{!summary?.hasBankAccount ? ' · 请先完善收款账户' : ''}
|
{!summary?.hasBankAccount ? ' · 请先完善收款账户' : ''}
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { reportApiError } from '@dukang/client-logging';
|
||||||
|
|
||||||
export const BRAND = {
|
export const BRAND = {
|
||||||
red: '#A02D30',
|
red: '#A02D30',
|
||||||
yellow: '#FFC107',
|
yellow: '#FFC107',
|
||||||
@@ -83,6 +85,12 @@ async function rawRequest<T>(
|
|||||||
if (json.code !== 0) {
|
if (json.code !== 0) {
|
||||||
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
const err = new Error(json.message || '请求失败') as Error & { status?: number };
|
||||||
err.status = json.code;
|
err.status = json.code;
|
||||||
|
if (json.code === 400) {
|
||||||
|
reportApiError(
|
||||||
|
{ apiBase, clientApp: CLIENT_APP, getToken: () => localStorage.getItem(ACCESS_TOKEN) },
|
||||||
|
{ message: json.message || '请求失败', status: 400, url: path, category: 'validation_error' },
|
||||||
|
);
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return json.data as T;
|
return json.data as T;
|
||||||
|
|||||||
@@ -1,19 +1,33 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { View, Image, Swiper, SwiperItem } from '@tarojs/components';
|
import { View, Image, Swiper, SwiperItem } from '@tarojs/components';
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
|
|
||||||
type ProductCarouselProps = {
|
type ProductCarouselProps = {
|
||||||
images: string[];
|
images: string[];
|
||||||
alt: string;
|
alt: string;
|
||||||
variant?: 'home' | 'detail' | 'store';
|
variant?: 'home' | 'detail' | 'store';
|
||||||
|
previewable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 商品/门店轮播(对齐 h5 ProductCarousel 三变体) */
|
/** 商品/门店轮播(对齐 h5 ProductCarousel 三变体) */
|
||||||
export default function ProductCarousel({ images, alt, variant = 'detail' }: ProductCarouselProps) {
|
export default function ProductCarousel({
|
||||||
|
images,
|
||||||
|
alt,
|
||||||
|
variant = 'detail',
|
||||||
|
previewable = false,
|
||||||
|
}: ProductCarouselProps) {
|
||||||
const slides = images.length > 0 ? images : [''];
|
const slides = images.length > 0 ? images : [''];
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
const prefix =
|
const prefix =
|
||||||
variant === 'store' ? 'store-detail-carousel' : variant === 'home' ? 'home-carousel' : 'detail-carousel';
|
variant === 'store' ? 'store-detail-carousel' : variant === 'home' ? 'home-carousel' : 'detail-carousel';
|
||||||
|
|
||||||
|
function previewAt(index: number) {
|
||||||
|
const urls = slides.filter(Boolean);
|
||||||
|
if (!urls.length) return;
|
||||||
|
const current = slides[index] || urls[0];
|
||||||
|
Taro.previewImage({ current, urls }).catch(() => undefined);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={`${prefix}-wrap`}>
|
<View className={`${prefix}-wrap`}>
|
||||||
<Swiper
|
<Swiper
|
||||||
@@ -24,7 +38,13 @@ export default function ProductCarousel({ images, alt, variant = 'detail' }: Pro
|
|||||||
{slides.map((src, index) => (
|
{slides.map((src, index) => (
|
||||||
<SwiperItem key={`${src}-${index}`} className={`${prefix}-item`}>
|
<SwiperItem key={`${src}-${index}`} className={`${prefix}-item`}>
|
||||||
{src ? (
|
{src ? (
|
||||||
<Image className={`${prefix}-image`} src={src} mode="aspectFill" alt={alt} />
|
<Image
|
||||||
|
className={`${prefix}-image`}
|
||||||
|
src={src}
|
||||||
|
mode="aspectFill"
|
||||||
|
alt={alt}
|
||||||
|
onClick={previewable ? () => previewAt(index) : undefined}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<View className={`${prefix}-placeholder`} />
|
<View className={`${prefix}-placeholder`} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ClientApp } from '@dukang/shared-types';
|
|||||||
import { forceReloadAfterAccountMerge } from './auth-nav';
|
import { forceReloadAfterAccountMerge } from './auth-nav';
|
||||||
import { resetStoresSessionBootstrap } from './stores-session';
|
import { resetStoresSessionBootstrap } from './stores-session';
|
||||||
import { resetHomeCatalogBootstrap } from './home-catalog-session';
|
import { resetHomeCatalogBootstrap } from './home-catalog-session';
|
||||||
|
import { reportClientValidationError } from './client-error';
|
||||||
|
|
||||||
function resolveApiBase(): string {
|
function resolveApiBase(): string {
|
||||||
const origin =
|
const origin =
|
||||||
@@ -113,6 +114,12 @@ export async function request<T = unknown>(path: string, options: ReqOptions = {
|
|||||||
throw new Error('接口不可达,请确认 API 服务已启动');
|
throw new Error('接口不可达,请确认 API 服务已启动');
|
||||||
}
|
}
|
||||||
if (status >= 400 || body.code !== 0) {
|
if (status >= 400 || body.code !== 0) {
|
||||||
|
if (status === 400 || body?.code === 400) {
|
||||||
|
reportClientValidationError({
|
||||||
|
message: body?.message || `请求失败(${status})`,
|
||||||
|
apiPath: path,
|
||||||
|
});
|
||||||
|
}
|
||||||
throw new Error(body?.message || `请求失败(${status})`);
|
throw new Error(body?.message || `请求失败(${status})`);
|
||||||
}
|
}
|
||||||
return (res.data as { data: T }).data;
|
return (res.data as { data: T }).data;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export type ClientErrorCategory =
|
|||||||
| 'js_error'
|
| 'js_error'
|
||||||
| 'unhandled_rejection'
|
| 'unhandled_rejection'
|
||||||
| 'api_error'
|
| 'api_error'
|
||||||
|
| 'validation_error'
|
||||||
| 'network'
|
| 'network'
|
||||||
| 'render'
|
| 'render'
|
||||||
| 'bridge'
|
| 'bridge'
|
||||||
@@ -57,6 +58,17 @@ export function reportClientError(payload: ClientErrorPayload): void {
|
|||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 上报 API 400 验证错误(失败静默) */
|
||||||
|
export function reportClientValidationError(input: { message: string; apiPath?: string }): void {
|
||||||
|
if (input.apiPath?.includes('/common/client-errors')) return;
|
||||||
|
reportClientError({
|
||||||
|
level: 'warn',
|
||||||
|
category: 'validation_error',
|
||||||
|
message: input.message,
|
||||||
|
extra: { status: 400, url: input.apiPath },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let installed = false;
|
let installed = false;
|
||||||
|
|
||||||
/** 安装小程序/H5 全局未捕获错误钩子(幂等) */
|
/** 安装小程序/H5 全局未捕获错误钩子(幂等) */
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type StorePackage = {
|
|||||||
dishes: string;
|
dishes: string;
|
||||||
usableTime?: string | null;
|
usableTime?: string | null;
|
||||||
otherNotes?: string | null;
|
otherNotes?: string | null;
|
||||||
|
imageUrl?: string | null;
|
||||||
sortOrder?: number;
|
sortOrder?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -315,11 +316,7 @@ export default function StoreDetailPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const envPhotos = envPhotoUrls(store);
|
const envPhotos = envPhotoUrls(store);
|
||||||
const images = uniqueUrls([
|
const heroImages = uniqueUrls([store.coverUrl, ...(store.carouselUrls || [])]);
|
||||||
store.coverUrl,
|
|
||||||
...(store.carouselUrls || []),
|
|
||||||
...envPhotos,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const intro = store.intro?.trim() || '';
|
const intro = store.intro?.trim() || '';
|
||||||
const benefitRuleRaw = store.benefitUsageRule?.trim() || '';
|
const benefitRuleRaw = store.benefitUsageRule?.trim() || '';
|
||||||
@@ -346,7 +343,7 @@ export default function StoreDetailPage() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<View className="store-detail-hero full-bleed">
|
<View className="store-detail-hero full-bleed">
|
||||||
<ProductCarousel images={images} alt={store.name} variant="store" />
|
<ProductCarousel images={heroImages} alt={store.name} variant="store" previewable />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="store-detail-info-card">
|
<View className="store-detail-info-card">
|
||||||
@@ -404,6 +401,9 @@ export default function StoreDetailPage() {
|
|||||||
<Text className="store-detail-section-title">门店套餐</Text>
|
<Text className="store-detail-section-title">门店套餐</Text>
|
||||||
{store.packages.map((pkg, index) => (
|
{store.packages.map((pkg, index) => (
|
||||||
<View key={`${pkg.name}-${index}`} className="store-detail-package-card">
|
<View key={`${pkg.name}-${index}`} className="store-detail-package-card">
|
||||||
|
{pkg.imageUrl ? (
|
||||||
|
<Image className="store-detail-package-img" src={pkg.imageUrl} mode="aspectFill" />
|
||||||
|
) : null}
|
||||||
<Text className="store-detail-package-name">{pkg.name}</Text>
|
<Text className="store-detail-package-name">{pkg.name}</Text>
|
||||||
<Text className="store-detail-package-body">
|
<Text className="store-detail-package-body">
|
||||||
{formatRedeemAmountYuan(pkg.price)} 元 · {pkg.dishes}
|
{formatRedeemAmountYuan(pkg.price)} 元 · {pkg.dishes}
|
||||||
@@ -443,7 +443,7 @@ export default function StoreDetailPage() {
|
|||||||
className="store-detail-env-item"
|
className="store-detail-env-item"
|
||||||
onClick={() => previewEnv(index)}
|
onClick={() => previewEnv(index)}
|
||||||
>
|
>
|
||||||
<Image className="store-detail-env-img" src={url} mode="aspectFill" />
|
<Image className="store-detail-env-img" src={url} mode="widthFix" />
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { View, Text, Image, Input } from '@tarojs/components';
|
import { View, Text, Image, Input } from '@tarojs/components';
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
||||||
|
import { StoreStatus, STORE_STATUS_LABELS } from '@dukang/shared-types';
|
||||||
import PageShell from '../../components/PageShell';
|
import PageShell from '../../components/PageShell';
|
||||||
import TabMainHeader from '../../components/TabMainHeader';
|
import TabMainHeader from '../../components/TabMainHeader';
|
||||||
import WechatShareReady from '../../components/WechatShareReady';
|
import WechatShareReady from '../../components/WechatShareReady';
|
||||||
@@ -342,10 +343,17 @@ export default function StoresPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatHours(store: Store) {
|
function formatHours(store: Store) {
|
||||||
const parts: string[] = [];
|
// 列表只展示第一段营业时间,避免挤占一行
|
||||||
if (store.openTime && store.closeTime) parts.push(`${store.openTime}-${store.closeTime}`);
|
if (store.openTime && store.closeTime) {
|
||||||
if (store.openTime2 && store.closeTime2) parts.push(`${store.openTime2}-${store.closeTime2}`);
|
return `营业时间: ${store.openTime}-${store.closeTime}`;
|
||||||
return parts.length ? `营业时间: ${parts.join(',')}` : '营业时间: 10:00-22:00';
|
}
|
||||||
|
return '营业时间: 10:00-22:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatStatus(store: Store) {
|
||||||
|
const status = store.status as StoreStatus | undefined;
|
||||||
|
if (status && STORE_STATUS_LABELS[status]) return STORE_STATUS_LABELS[status];
|
||||||
|
return STORE_STATUS_LABELS[StoreStatus.OPEN];
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharePayload = useMemo(
|
const sharePayload = useMemo(
|
||||||
@@ -427,31 +435,39 @@ export default function StoresPage() {
|
|||||||
{s.coverUrl ? (
|
{s.coverUrl ? (
|
||||||
<Image className="store-card-cover" src={s.coverUrl} mode="aspectFill" />
|
<Image className="store-card-cover" src={s.coverUrl} mode="aspectFill" />
|
||||||
) : (
|
) : (
|
||||||
<View className="store-card-cover--empty" />
|
<View className="store-card-cover store-card-cover--empty" />
|
||||||
)}
|
)}
|
||||||
<View className="store-card-body">
|
<View className="store-card-body">
|
||||||
<Text className="store-card-name">{s.name}</Text>
|
{/* 第1行:标题 + 距离 */}
|
||||||
<Text className="store-card-meta">
|
<View className="store-card-row store-card-row--head">
|
||||||
{s.district ? `${s.district} · ` : ''}
|
<Text className="store-card-name" numberOfLines={1}>
|
||||||
{s.address || '地址待完善'}
|
{s.name}
|
||||||
</Text>
|
</Text>
|
||||||
<Text className="store-card-meta">{formatHours(s)}</Text>
|
|
||||||
{s.avgPrice != null && Number(s.avgPrice) > 0 ? (
|
|
||||||
<Text className="store-card-meta">人均¥{Number(s.avgPrice).toFixed(0)}</Text>
|
|
||||||
) : null}
|
|
||||||
<View className="store-card-footer">
|
|
||||||
<Text className="store-card-distance">
|
<Text className="store-card-distance">
|
||||||
{formatDistanceMeters(s.distanceMeters)}
|
{formatDistanceMeters(s.distanceMeters)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
</View>
|
||||||
|
{/* 第2行:状态 + 营业时间(仅第一段) */}
|
||||||
|
<View className="store-card-row store-card-row--meta">
|
||||||
|
<Text className="store-card-status">{formatStatus(s)}</Text>
|
||||||
|
<Text className="store-card-hours" numberOfLines={1}>
|
||||||
|
{formatHours(s)}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
{/* 第3行:地址 + 去核销 */}
|
||||||
|
<View className="store-card-row store-card-row--foot">
|
||||||
|
<Text className="store-card-address" numberOfLines={1}>
|
||||||
|
{s.address || (s.district ? `${s.district}` : '地址待完善')}
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
className="store-card-cta"
|
className="store-card-cta"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
Taro.navigateTo({ url: '/pages/redeem/index' });
|
Taro.navigateTo({ url: '/pages/redeem/index' });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
去核销
|
<Text className="store-card-cta-text">去核销</Text>
|
||||||
</Text>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -175,24 +175,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-env-grid {
|
.store-detail-env-grid {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-env-item {
|
.store-detail-env-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
aspect-ratio: 1;
|
|
||||||
border-radius: var(--radius-md, 8px);
|
border-radius: var(--radius-md, 8px);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--color-surface-container);
|
background: var(--color-surface-container);
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-env-img {
|
.store-detail-env-img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: auto;
|
||||||
display: block;
|
display: block;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-bar {
|
.store-detail-bar {
|
||||||
@@ -240,6 +241,14 @@
|
|||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.store-detail-package-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 160px;
|
||||||
|
border-radius: var(--radius-md, 8px);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.store-detail-package-card:last-of-type {
|
.store-detail-package-card:last-of-type {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,63 +144,144 @@
|
|||||||
padding: 4px var(--space-page) 16px;
|
padding: 4px var(--space-page) 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 左图右文,卡片等高 */
|
||||||
.store-card {
|
.store-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
box-sizing: border-box;
|
||||||
background: var(--color-card);
|
background: var(--color-card);
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
overflow: hidden;
|
|
||||||
box-shadow: var(--shadow-card);
|
box-shadow: var(--shadow-card);
|
||||||
margin-bottom: 16px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-cover {
|
.store-card-cover {
|
||||||
width: 100%;
|
flex-shrink: 0;
|
||||||
height: 160px;
|
width: 96px;
|
||||||
|
height: 96px;
|
||||||
|
border-radius: 8px;
|
||||||
background: var(--color-surface-container);
|
background: var(--color-surface-container);
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-cover--empty {
|
.store-card-cover--empty {
|
||||||
height: 160px;
|
|
||||||
background: var(--color-surface-container);
|
background: var(--color-surface-container);
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-body {
|
.store-card-body {
|
||||||
padding: 14px 16px 16px;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 96px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 第1行:加粗标题(单行截断)+ 右对齐距离 */
|
||||||
|
.store-card-row--head {
|
||||||
|
gap: 8px;
|
||||||
|
height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-name {
|
.store-card-name {
|
||||||
display: block;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
font-family: var(--font-headline);
|
font-family: var(--font-headline);
|
||||||
font-size: 16px;
|
font-size: 15px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--color-on-surface);
|
line-height: 22px;
|
||||||
margin-bottom: 6px;
|
color: #1a1a1a;
|
||||||
}
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
.store-card-meta {
|
white-space: nowrap;
|
||||||
display: block;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--color-subtle-gray);
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-card-footer {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-distance {
|
.store-card-distance {
|
||||||
|
flex-shrink: 0;
|
||||||
|
max-width: 40%;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--color-on-surface-variant);
|
font-weight: 400;
|
||||||
|
line-height: 22px;
|
||||||
|
color: #999;
|
||||||
|
text-align: right;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 第2行:营业状态 + 营业时间(单行) */
|
||||||
|
.store-card-row--meta {
|
||||||
|
gap: 6px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-status {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: rgba(45, 106, 79, 0.12);
|
||||||
|
color: #2d6a4f;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 18px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-hours {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 20px;
|
||||||
|
color: #999;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 第3行:地址(单行截断)+ 右对齐去核销 */
|
||||||
|
.store-card-row--foot {
|
||||||
|
gap: 8px;
|
||||||
|
height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-address {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 28px;
|
||||||
|
color: #999;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-cta {
|
.store-card-cta {
|
||||||
padding: 6px 14px;
|
flex-shrink: 0;
|
||||||
border-radius: var(--radius-full);
|
display: flex;
|
||||||
background: rgba(166, 29, 36, 0.08);
|
align-items: center;
|
||||||
color: var(--color-heritage-red);
|
justify-content: center;
|
||||||
|
padding: 0 14px;
|
||||||
|
height: 26px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--color-heritage-red, #a61d24);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-cta-text {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
line-height: 26px;
|
||||||
|
color: #fff;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export type ClientErrorCategory =
|
|||||||
| 'js_error'
|
| 'js_error'
|
||||||
| 'unhandled_rejection'
|
| 'unhandled_rejection'
|
||||||
| 'api_error'
|
| 'api_error'
|
||||||
|
| 'validation_error'
|
||||||
| 'network'
|
| 'network'
|
||||||
| 'render'
|
| 'render'
|
||||||
| 'bridge'
|
| 'bridge'
|
||||||
@@ -73,6 +74,7 @@ export function reportApiError(
|
|||||||
input: { message: string; status?: number; url?: string; category?: ClientErrorCategory },
|
input: { message: string; status?: number; url?: string; category?: ClientErrorCategory },
|
||||||
) {
|
) {
|
||||||
if (typeof window === 'undefined') return;
|
if (typeof window === 'undefined') return;
|
||||||
|
if (input.url?.includes('/common/client-errors')) return;
|
||||||
const token = opts.getToken?.() ?? localStorage.getItem('accessToken');
|
const token = opts.getToken?.() ?? localStorage.getItem('accessToken');
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -85,7 +87,7 @@ export function reportApiError(
|
|||||||
headers,
|
headers,
|
||||||
body: {
|
body: {
|
||||||
level: 'warn',
|
level: 'warn',
|
||||||
category: input.category ?? 'api_error',
|
category: input.category ?? (input.status === 400 ? 'validation_error' : 'api_error'),
|
||||||
message: input.message.slice(0, 1000),
|
message: input.message.slice(0, 1000),
|
||||||
pagePath: window.location.pathname,
|
pagePath: window.location.pathname,
|
||||||
clientApp: opts.clientApp,
|
clientApp: opts.clientApp,
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ describe('validateStoreWithdraw', () => {
|
|||||||
requestAmount: 200,
|
requestAmount: 200,
|
||||||
todayApplied: 0,
|
todayApplied: 0,
|
||||||
dailyLimit: 5000,
|
dailyLimit: 5000,
|
||||||
hasPendingRequest: false,
|
|
||||||
hasBankAccount: true,
|
hasBankAccount: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,8 +260,7 @@ describe('validateStoreWithdraw', () => {
|
|||||||
).toBe(false);
|
).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects pending request / missing bank / over available', () => {
|
it('rejects missing bank / over available', () => {
|
||||||
expect(validateStoreWithdraw({ ...base, hasPendingRequest: true }).ok).toBe(false);
|
|
||||||
expect(validateStoreWithdraw({ ...base, hasBankAccount: false }).ok).toBe(false);
|
expect(validateStoreWithdraw({ ...base, hasBankAccount: false }).ok).toBe(false);
|
||||||
expect(validateStoreWithdraw({ ...base, requestAmount: 1001 }).ok).toBe(false);
|
expect(validateStoreWithdraw({ ...base, requestAmount: 1001 }).ok).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -105,20 +105,16 @@ export type ValidateStoreWithdrawInput = {
|
|||||||
requestAmount: number;
|
requestAmount: number;
|
||||||
todayApplied: number;
|
todayApplied: number;
|
||||||
dailyLimit: number;
|
dailyLimit: number;
|
||||||
hasPendingRequest: boolean;
|
|
||||||
hasBankAccount: boolean;
|
hasBankAccount: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 门店未出账提现护栏(FIN-002 单日上限 + 幂等/账户) */
|
/** 门店未出账提现护栏(FIN-002 单日上限 + 账户) */
|
||||||
export function validateStoreWithdraw(
|
export function validateStoreWithdraw(
|
||||||
input: ValidateStoreWithdrawInput,
|
input: ValidateStoreWithdrawInput,
|
||||||
): { ok: boolean; message?: string } {
|
): { ok: boolean; message?: string } {
|
||||||
if (!input.hasBankAccount) {
|
if (!input.hasBankAccount) {
|
||||||
return { ok: false, message: '请先完善入驻收款账户后再提现' };
|
return { ok: false, message: '请先完善入驻收款账户后再提现' };
|
||||||
}
|
}
|
||||||
if (input.hasPendingRequest) {
|
|
||||||
return { ok: false, message: '已有待审核提现申请,请等待处理完成' };
|
|
||||||
}
|
|
||||||
if (!(input.requestAmount > 0)) {
|
if (!(input.requestAmount > 0)) {
|
||||||
return { ok: false, message: '提现金额必须大于 0' };
|
return { ok: false, message: '提现金额必须大于 0' };
|
||||||
}
|
}
|
||||||
@@ -354,3 +350,4 @@ export function orderTabToStatuses(tab: string): string[] | undefined {
|
|||||||
|
|
||||||
export * from './city-partner';
|
export * from './city-partner';
|
||||||
export * from './dev-plan';
|
export * from './dev-plan';
|
||||||
|
export * from './support-ticket';
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { validateSupportTicketStatusTransition } from './support-ticket';
|
||||||
|
|
||||||
|
describe('validateSupportTicketStatusTransition', () => {
|
||||||
|
it('allows DEVELOPING -> TESTING', () => {
|
||||||
|
expect(
|
||||||
|
validateSupportTicketStatusTransition('DEVELOPING', 'TESTING', {
|
||||||
|
linkedTaskCount: 1,
|
||||||
|
isSuperAdmin: true,
|
||||||
|
}).ok,
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('blocks PENDING_REVIEW -> DEVELOPING without tasks', () => {
|
||||||
|
expect(
|
||||||
|
validateSupportTicketStatusTransition('PENDING_REVIEW', 'DEVELOPING', {
|
||||||
|
linkedTaskCount: 0,
|
||||||
|
isSuperAdmin: true,
|
||||||
|
}).ok,
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('blocks rollback PASSED -> DEVELOPING', () => {
|
||||||
|
expect(
|
||||||
|
validateSupportTicketStatusTransition('PASSED', 'DEVELOPING', {
|
||||||
|
linkedTaskCount: 1,
|
||||||
|
isSuperAdmin: true,
|
||||||
|
}).ok,
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('requires super admin and reason for REJECTED', () => {
|
||||||
|
expect(
|
||||||
|
validateSupportTicketStatusTransition('DEVELOPING', 'REJECTED', {
|
||||||
|
linkedTaskCount: 1,
|
||||||
|
isSuperAdmin: false,
|
||||||
|
rejectReason: 'x',
|
||||||
|
}).ok,
|
||||||
|
).toBe(false);
|
||||||
|
expect(
|
||||||
|
validateSupportTicketStatusTransition('DEVELOPING', 'REJECTED', {
|
||||||
|
linkedTaskCount: 1,
|
||||||
|
isSuperAdmin: true,
|
||||||
|
rejectReason: '',
|
||||||
|
}).ok,
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
export type SupportTicketStatus =
|
||||||
|
| 'PENDING_REVIEW'
|
||||||
|
| 'REJECTED'
|
||||||
|
| 'DEVELOPING'
|
||||||
|
| 'TESTING'
|
||||||
|
| 'PASSED';
|
||||||
|
|
||||||
|
export type SupportTicketStatusTransitionContext = {
|
||||||
|
linkedTaskCount: number;
|
||||||
|
isSuperAdmin: boolean;
|
||||||
|
rejectReason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FORWARD_TRANSITIONS: Record<SupportTicketStatus, SupportTicketStatus[]> = {
|
||||||
|
PENDING_REVIEW: ['DEVELOPING', 'REJECTED'],
|
||||||
|
DEVELOPING: ['TESTING', 'REJECTED'],
|
||||||
|
TESTING: ['PASSED', 'REJECTED'],
|
||||||
|
REJECTED: [],
|
||||||
|
PASSED: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 技术支持工单批量/人工改状态校验(禁止回退) */
|
||||||
|
export function validateSupportTicketStatusTransition(
|
||||||
|
from: SupportTicketStatus,
|
||||||
|
to: SupportTicketStatus,
|
||||||
|
ctx: SupportTicketStatusTransitionContext,
|
||||||
|
): { ok: boolean; message?: string } {
|
||||||
|
if (from === to) return { ok: true };
|
||||||
|
|
||||||
|
const allowed = FORWARD_TRANSITIONS[from] ?? [];
|
||||||
|
if (!allowed.includes(to)) {
|
||||||
|
return { ok: false, message: `不允许从「${from}」变更为「${to}」` };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to === 'REJECTED') {
|
||||||
|
if (!ctx.isSuperAdmin) return { ok: false, message: '仅最高管理员可驳回工单' };
|
||||||
|
if (!ctx.rejectReason?.trim()) return { ok: false, message: '请填写驳回理由' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (from === 'PENDING_REVIEW' && to === 'DEVELOPING' && ctx.linkedTaskCount < 1) {
|
||||||
|
return { ok: false, message: '待评审工单转入开发须至少 1 条关联开发任务' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { ok: true };
|
||||||
|
}
|
||||||
@@ -202,6 +202,18 @@ export interface DevPlanTaskDispatchInput {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface DevPlanTaskBatchUpdateInput {
|
||||||
|
|
||||||
|
taskIds: string[];
|
||||||
|
|
||||||
|
status?: DevPlanTaskStatusDto;
|
||||||
|
|
||||||
|
versionId?: string | null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface DevPlanLinkedTaskSummary {
|
export interface DevPlanLinkedTaskSummary {
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -50,6 +50,20 @@ export type CreateKnowledgeDocumentRequest = {
|
|||||||
sizeBytes?: number | null;
|
sizeBytes?: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type UpdateKnowledgeDocumentRequest = {
|
||||||
|
title?: string;
|
||||||
|
contentText?: string | null;
|
||||||
|
fileName?: string | null;
|
||||||
|
fileUrl?: string | null;
|
||||||
|
mimeType?: string | null;
|
||||||
|
sizeBytes?: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 编辑文档时含正文 */
|
||||||
|
export type KnowledgeDocumentDetailDto = KnowledgeDocumentDto & {
|
||||||
|
contentText: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
export type KnowledgeBaseOptionDto = {
|
export type KnowledgeBaseOptionDto = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ export interface StoreWithdrawSummaryDto {
|
|||||||
remainingDailyLimit: number;
|
remainingDailyLimit: number;
|
||||||
isPrimary: boolean;
|
isPrimary: boolean;
|
||||||
hasBankAccount: boolean;
|
hasBankAccount: boolean;
|
||||||
hasPendingRequest: boolean;
|
|
||||||
bankAccount?: StoreWithdrawBankAccountDto | null;
|
bankAccount?: StoreWithdrawBankAccountDto | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +183,9 @@ export const STORE_SETTLEMENT_DEFAULT_RATE = 0.6;
|
|||||||
/** 酒厂账单结算比例(酒单实付 × 比例),暂定 30% */
|
/** 酒厂账单结算比例(酒单实付 × 比例),暂定 30% */
|
||||||
export const WINERY_SETTLEMENT_RATE = 0.3;
|
export const WINERY_SETTLEMENT_RATE = 0.3;
|
||||||
|
|
||||||
|
/** 酒厂账单出账滞后自然日(T+3:支付日 + 3 天后纳入账单) */
|
||||||
|
export const WINERY_SETTLEMENT_LAG_DAYS = 3;
|
||||||
|
|
||||||
export type { LogisticsSettlementMethod } from './enums';
|
export type { LogisticsSettlementMethod } from './enums';
|
||||||
export { LOGISTICS_SETTLEMENT_METHOD_LABELS } from './enums';
|
export { LOGISTICS_SETTLEMENT_METHOD_LABELS } from './enums';
|
||||||
import type { LogisticsSettlementMethod } from './enums';
|
import type { LogisticsSettlementMethod } from './enums';
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export interface StorePackageItemDto {
|
|||||||
dishes: string;
|
dishes: string;
|
||||||
usableTime?: string | null;
|
usableTime?: string | null;
|
||||||
otherNotes?: string | null;
|
otherNotes?: string | null;
|
||||||
|
imageUrl?: string | null;
|
||||||
sortOrder: number;
|
sortOrder: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export interface SupportTicketDto {
|
|||||||
reviewerName?: string | null;
|
reviewerName?: string | null;
|
||||||
reviewedAt?: string | null;
|
reviewedAt?: string | null;
|
||||||
remark?: string | null;
|
remark?: string | null;
|
||||||
|
attachmentUrls?: string[] | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
completedAt?: string | null;
|
completedAt?: string | null;
|
||||||
@@ -57,6 +58,15 @@ export interface CreateSupportTicketRequest {
|
|||||||
title: string;
|
title: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
|
attachmentUrls?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateSupportTicketRequest {
|
||||||
|
ticketType?: SupportTicketTypeDto;
|
||||||
|
title?: string;
|
||||||
|
content?: string;
|
||||||
|
remark?: string;
|
||||||
|
attachmentUrls?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RejectSupportTicketRequest {
|
export interface RejectSupportTicketRequest {
|
||||||
@@ -73,6 +83,8 @@ export interface ReviewSupportTicketRequest {
|
|||||||
rejectReason?: string;
|
rejectReason?: string;
|
||||||
note?: string;
|
note?: string;
|
||||||
tasks?: CreateDevPlanTaskFromTicketInput[];
|
tasks?: CreateDevPlanTaskFromTicketInput[];
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
dispatchSupplement?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SupportTicketLinkedTaskDto {
|
export interface SupportTicketLinkedTaskDto {
|
||||||
@@ -108,3 +120,10 @@ export interface BatchReviewConfirmItem {
|
|||||||
export interface BatchReviewConfirmRequest {
|
export interface BatchReviewConfirmRequest {
|
||||||
items: BatchReviewConfirmItem[];
|
items: BatchReviewConfirmItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BatchUpdateSupportTicketStatusRequest {
|
||||||
|
ticketIds: string[];
|
||||||
|
status: SupportTicketStatusDto;
|
||||||
|
rejectReason?: string;
|
||||||
|
note?: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -655,6 +655,7 @@ model CommonSupportTicket {
|
|||||||
reviewerName String? @map("reviewer_name") @db.VarChar(64)
|
reviewerName String? @map("reviewer_name") @db.VarChar(64)
|
||||||
reviewedAt DateTime? @map("reviewed_at") @db.DateTime(3)
|
reviewedAt DateTime? @map("reviewed_at") @db.DateTime(3)
|
||||||
remark String? @db.VarChar(512)
|
remark String? @db.VarChar(512)
|
||||||
|
attachmentUrls Json? @map("attachment_urls")
|
||||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||||
completedAt DateTime? @map("completed_at") @db.DateTime(3)
|
completedAt DateTime? @map("completed_at") @db.DateTime(3)
|
||||||
@@ -1278,6 +1279,7 @@ model StorePackage {
|
|||||||
dishes String @db.Text
|
dishes String @db.Text
|
||||||
usableTime String? @map("usable_time") @db.VarChar(256)
|
usableTime String? @map("usable_time") @db.VarChar(256)
|
||||||
otherNotes String? @map("other_notes") @db.VarChar(512)
|
otherNotes String? @map("other_notes") @db.VarChar(512)
|
||||||
|
imageUrl String? @map("image_url") @db.VarChar(512)
|
||||||
sortOrder Int @default(0) @map("sort_order")
|
sortOrder Int @default(0) @map("sort_order")
|
||||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export const HqOperationAction = {
|
|||||||
KNOWLEDGE_BASE_UPDATE: 'KNOWLEDGE_BASE_UPDATE',
|
KNOWLEDGE_BASE_UPDATE: 'KNOWLEDGE_BASE_UPDATE',
|
||||||
KNOWLEDGE_BASE_DELETE: 'KNOWLEDGE_BASE_DELETE',
|
KNOWLEDGE_BASE_DELETE: 'KNOWLEDGE_BASE_DELETE',
|
||||||
KNOWLEDGE_DOC_CREATE: 'KNOWLEDGE_DOC_CREATE',
|
KNOWLEDGE_DOC_CREATE: 'KNOWLEDGE_DOC_CREATE',
|
||||||
|
KNOWLEDGE_DOC_UPDATE: 'KNOWLEDGE_DOC_UPDATE',
|
||||||
KNOWLEDGE_DOC_DELETE: 'KNOWLEDGE_DOC_DELETE',
|
KNOWLEDGE_DOC_DELETE: 'KNOWLEDGE_DOC_DELETE',
|
||||||
REDEEM_PENDING_COMPLETE: 'REDEEM_PENDING_COMPLETE',
|
REDEEM_PENDING_COMPLETE: 'REDEEM_PENDING_COMPLETE',
|
||||||
REDEEM_PENDING_REJECT: 'REDEEM_PENDING_REJECT',
|
REDEEM_PENDING_REJECT: 'REDEEM_PENDING_REJECT',
|
||||||
@@ -218,6 +219,7 @@ export const HQ_OPERATION_ACTION_LABELS: Record<string, string> = {
|
|||||||
[HqOperationAction.KNOWLEDGE_BASE_UPDATE]: '更新知识库',
|
[HqOperationAction.KNOWLEDGE_BASE_UPDATE]: '更新知识库',
|
||||||
[HqOperationAction.KNOWLEDGE_BASE_DELETE]: '删除知识库',
|
[HqOperationAction.KNOWLEDGE_BASE_DELETE]: '删除知识库',
|
||||||
[HqOperationAction.KNOWLEDGE_DOC_CREATE]: '上传知识库文档',
|
[HqOperationAction.KNOWLEDGE_DOC_CREATE]: '上传知识库文档',
|
||||||
|
[HqOperationAction.KNOWLEDGE_DOC_UPDATE]: '编辑知识库文档',
|
||||||
[HqOperationAction.KNOWLEDGE_DOC_DELETE]: '删除知识库文档',
|
[HqOperationAction.KNOWLEDGE_DOC_DELETE]: '删除知识库文档',
|
||||||
[HqOperationAction.REDEEM_PENDING_COMPLETE]: '弱网待处理单-补核销',
|
[HqOperationAction.REDEEM_PENDING_COMPLETE]: '弱网待处理单-补核销',
|
||||||
[HqOperationAction.REDEEM_PENDING_REJECT]: '弱网待处理单-驳回',
|
[HqOperationAction.REDEEM_PENDING_REJECT]: '弱网待处理单-驳回',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { AlertService } from '../../common/alert/alert.service';
|
|||||||
import type { AlertLevel } from '../../common/alert/alert.constants';
|
import type { AlertLevel } from '../../common/alert/alert.constants';
|
||||||
import type { AuthUser } from '../../common/guards/jwt-auth.guard';
|
import type { AuthUser } from '../../common/guards/jwt-auth.guard';
|
||||||
import type { ReportClientErrorDto } from './dto/client-error.dto';
|
import type { ReportClientErrorDto } from './dto/client-error.dto';
|
||||||
|
import { SupportTicketService } from './support-ticket.service';
|
||||||
|
|
||||||
const WECOM_LEVELS = new Set(['fatal', 'error']);
|
const WECOM_LEVELS = new Set(['fatal', 'error']);
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ export class ClientErrorService {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly alert: AlertService,
|
private readonly alert: AlertService,
|
||||||
|
private readonly supportTicket: SupportTicketService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async report(dto: ReportClientErrorDto, user?: AuthUser, headerClientApp?: string) {
|
async report(dto: ReportClientErrorDto, user?: AuthUser, headerClientApp?: string) {
|
||||||
@@ -107,6 +109,25 @@ export class ClientErrorService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dto.category === 'validation_error') {
|
||||||
|
const apiPath =
|
||||||
|
dto.extra && typeof dto.extra.url === 'string' ? dto.extra.url.slice(0, 256) : undefined;
|
||||||
|
void this.supportTicket
|
||||||
|
.createFromClientValidation({
|
||||||
|
clientApp,
|
||||||
|
message,
|
||||||
|
pagePath,
|
||||||
|
apiPath,
|
||||||
|
actorLabel:
|
||||||
|
user?.actorId != null ? `${user.actorType}:${String(user.actorId)}` : undefined,
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
this.logger.warn(
|
||||||
|
`auto support ticket failed: ${e instanceof Error ? e.message : String(e)}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const CLIENT_ERROR_CATEGORIES = [
|
|||||||
'js_error',
|
'js_error',
|
||||||
'unhandled_rejection',
|
'unhandled_rejection',
|
||||||
'api_error',
|
'api_error',
|
||||||
|
'validation_error',
|
||||||
'network',
|
'network',
|
||||||
'render',
|
'render',
|
||||||
'bridge',
|
'bridge',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IsIn, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
import { ArrayMinSize, IsArray, IsBoolean, IsIn, IsNotEmpty, IsOptional, IsString, MaxLength, ValidateIf, ValidateNested } from 'class-validator';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
import { IsInt, Min } from 'class-validator';
|
import { IsInt, Min } from 'class-validator';
|
||||||
|
|
||||||
@@ -41,6 +41,84 @@ export class CreateSupportTicketDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@MaxLength(512)
|
@MaxLength(512)
|
||||||
remark?: string;
|
remark?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsArray()
|
||||||
|
@IsString({ each: true })
|
||||||
|
attachmentUrls?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UpdateSupportTicketDto {
|
||||||
|
@IsOptional()
|
||||||
|
@IsIn(['BUG', 'SUGGESTION', 'OTHER'])
|
||||||
|
ticketType?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
@MaxLength(128)
|
||||||
|
title?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
content?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(512)
|
||||||
|
remark?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsArray()
|
||||||
|
@IsString({ each: true })
|
||||||
|
attachmentUrls?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BatchUpdateSupportTicketStatusDto {
|
||||||
|
@IsArray()
|
||||||
|
@ArrayMinSize(1)
|
||||||
|
@IsString({ each: true })
|
||||||
|
ticketIds!: string[];
|
||||||
|
|
||||||
|
@IsIn(['PENDING_REVIEW', 'REJECTED', 'DEVELOPING', 'TESTING', 'PASSED'])
|
||||||
|
status!: string;
|
||||||
|
|
||||||
|
@ValidateIf((o: BatchUpdateSupportTicketStatusDto) => o.status === 'REJECTED')
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
@MaxLength(512)
|
||||||
|
rejectReason?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(512)
|
||||||
|
note?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BatchCreateSupportTicketTasksDto {
|
||||||
|
@IsArray()
|
||||||
|
@ArrayMinSize(1)
|
||||||
|
@IsString({ each: true })
|
||||||
|
ticketIds!: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BatchPublishSupportTicketsDto {
|
||||||
|
@IsArray()
|
||||||
|
@ArrayMinSize(1)
|
||||||
|
@IsString({ each: true })
|
||||||
|
ticketIds!: string[];
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
versionId!: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsBoolean()
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
dispatchSupplement?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RejectSupportTicketDto {
|
export class RejectSupportTicketDto {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
import type { SupportTicketStatus, SupportTicketType } from '@prisma/client';
|
import type { SupportTicketStatus, SupportTicketType } from '@prisma/client';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
import type { CreateDevPlanTaskFromTicketInput } from '@dukang/shared-types';
|
import type { CreateDevPlanTaskFromTicketInput } from '@dukang/shared-types';
|
||||||
|
import { mapSupportTicketTypeToDevPlanTask } from '@dukang/shared-types';
|
||||||
|
import { validateSupportTicketStatusTransition } from '@dukang/domain';
|
||||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||||
import { AlertService } from '../../common/alert/alert.service';
|
import { AlertService } from '../../common/alert/alert.service';
|
||||||
@@ -16,14 +18,37 @@ import type {
|
|||||||
RejectSupportTicketDto,
|
RejectSupportTicketDto,
|
||||||
SupportTicketListQueryDto,
|
SupportTicketListQueryDto,
|
||||||
SupportTicketRemarkDto,
|
SupportTicketRemarkDto,
|
||||||
|
UpdateSupportTicketDto,
|
||||||
} from './dto/support-ticket.dto';
|
} from './dto/support-ticket.dto';
|
||||||
|
|
||||||
|
function normalizeAttachmentUrls(raw: unknown): string[] | null {
|
||||||
|
if (!Array.isArray(raw)) return null;
|
||||||
|
const urls = raw.map((u) => String(u || '').trim()).filter(Boolean);
|
||||||
|
return urls.length ? urls : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapSupportTicketRow<T extends { attachmentUrls?: unknown }>(ticket: T) {
|
||||||
|
return {
|
||||||
|
...ticket,
|
||||||
|
attachmentUrls: normalizeAttachmentUrls(ticket.attachmentUrls),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function generateSupportTicketNo() {
|
function generateSupportTicketNo() {
|
||||||
return `ST${Date.now()}${Math.floor(Math.random() * 900 + 100)}`;
|
return `ST${Date.now()}${Math.floor(Math.random() * 900 + 100)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AUTO_VALIDATION_TICKET_APPS = new Set([
|
||||||
|
'USER_H5',
|
||||||
|
'USER_MINI',
|
||||||
|
'SHOP_H5',
|
||||||
|
'PARTNER_H5',
|
||||||
|
]);
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SupportTicketService {
|
export class SupportTicketService {
|
||||||
|
private systemCreatorCache: { id: bigint; name: string } | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly alert: AlertService,
|
private readonly alert: AlertService,
|
||||||
@@ -43,6 +68,9 @@ export class SupportTicketService {
|
|||||||
title: dto.title.trim(),
|
title: dto.title.trim(),
|
||||||
content: dto.content?.trim() || null,
|
content: dto.content?.trim() || null,
|
||||||
remark: dto.remark?.trim() || null,
|
remark: dto.remark?.trim() || null,
|
||||||
|
attachmentUrls: dto.attachmentUrls?.length
|
||||||
|
? (dto.attachmentUrls.map((u) => u.trim()).filter(Boolean) as unknown as Prisma.InputJsonValue)
|
||||||
|
: undefined,
|
||||||
creatorId: creator.id,
|
creatorId: creator.id,
|
||||||
creatorName: creator.name,
|
creatorName: creator.name,
|
||||||
},
|
},
|
||||||
@@ -73,7 +101,140 @@ export class SupportTicketService {
|
|||||||
].join('\n'),
|
].join('\n'),
|
||||||
)
|
)
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
return serializeBigInt(ticket);
|
return serializeBigInt(mapSupportTicketRow(ticket));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 客户端 400 验证错误自动建单(1 小时内同标题去重) */
|
||||||
|
async createFromClientValidation(input: {
|
||||||
|
clientApp: string;
|
||||||
|
message: string;
|
||||||
|
pagePath?: string;
|
||||||
|
apiPath?: string;
|
||||||
|
actorLabel?: string;
|
||||||
|
}) {
|
||||||
|
if (!AUTO_VALIDATION_TICKET_APPS.has(input.clientApp)) {
|
||||||
|
return { skipped: true as const, reason: 'unsupported_app' as const };
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = `[客户端验证] ${input.clientApp}${input.pagePath ? ` · ${input.pagePath}` : ''} · ${input.message.slice(0, 60)}`;
|
||||||
|
const oneHourAgo = new Date(Date.now() - 3600_000);
|
||||||
|
const existing = await this.prisma.commonSupportTicket.findFirst({
|
||||||
|
where: { title, createdAt: { gte: oneHourAgo } },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
if (existing) {
|
||||||
|
return { skipped: true as const, ticketId: existing.id.toString() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const creator = await this.resolveSystemCreator();
|
||||||
|
const content = [
|
||||||
|
`端:${input.clientApp}`,
|
||||||
|
input.pagePath ? `页面:${input.pagePath}` : null,
|
||||||
|
input.apiPath ? `接口:${input.apiPath}` : null,
|
||||||
|
input.actorLabel ? `用户:${input.actorLabel}` : null,
|
||||||
|
'',
|
||||||
|
input.message,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
const ticket = await this.create(
|
||||||
|
{
|
||||||
|
ticketType: 'BUG',
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
remark: '客户端验证错误自动上报',
|
||||||
|
},
|
||||||
|
creator,
|
||||||
|
);
|
||||||
|
return { skipped: false as const, ticketId: String(ticket.id) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private async resolveSystemCreator() {
|
||||||
|
if (this.systemCreatorCache) return this.systemCreatorCache;
|
||||||
|
const account = await this.prisma.hqAccount.findFirst({
|
||||||
|
where: { adminRole: 'SUPER_ADMIN', status: 'ACTIVE' },
|
||||||
|
orderBy: { id: 'asc' },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
if (!account) {
|
||||||
|
throw new BadRequestException('未找到系统管理员账号,无法自动创建工单');
|
||||||
|
}
|
||||||
|
this.systemCreatorCache = { id: account.id, name: '系统自动' };
|
||||||
|
return this.systemCreatorCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: bigint, dto: UpdateSupportTicketDto) {
|
||||||
|
const ticket = await this.getOrThrow(id);
|
||||||
|
if (ticket.status !== 'PENDING_REVIEW') {
|
||||||
|
throw new BadRequestException('仅待评审工单可编辑');
|
||||||
|
}
|
||||||
|
const data: Prisma.CommonSupportTicketUpdateInput = {};
|
||||||
|
if (dto.ticketType != null) data.ticketType = dto.ticketType as SupportTicketType;
|
||||||
|
if (dto.title != null) data.title = dto.title.trim();
|
||||||
|
if (dto.content !== undefined) data.content = dto.content?.trim() || null;
|
||||||
|
if (dto.remark !== undefined) data.remark = dto.remark?.trim() || null;
|
||||||
|
if (dto.attachmentUrls !== undefined) {
|
||||||
|
const urls = dto.attachmentUrls.map((u) => u.trim()).filter(Boolean);
|
||||||
|
data.attachmentUrls = urls.length ? (urls as unknown as Prisma.InputJsonValue) : Prisma.JsonNull;
|
||||||
|
}
|
||||||
|
const updated = await this.prisma.commonSupportTicket.update({ where: { id }, data });
|
||||||
|
return serializeBigInt(mapSupportTicketRow(updated));
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchUpdateStatus(
|
||||||
|
ticketIds: bigint[],
|
||||||
|
status: SupportTicketStatus,
|
||||||
|
ctx: {
|
||||||
|
isSuperAdmin: boolean;
|
||||||
|
rejectReason?: string;
|
||||||
|
note?: string;
|
||||||
|
reviewer?: { id: bigint; name: string };
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const results: Array<{ ticketId: string; ok: boolean; message?: string }> = [];
|
||||||
|
for (const id of ticketIds) {
|
||||||
|
try {
|
||||||
|
const ticket = await this.getOrThrow(id);
|
||||||
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||||
|
const linkedTaskCount = linkedMap.get(String(id))?.length ?? 0;
|
||||||
|
const guard = validateSupportTicketStatusTransition(
|
||||||
|
ticket.status as 'PENDING_REVIEW' | 'REJECTED' | 'DEVELOPING' | 'TESTING' | 'PASSED',
|
||||||
|
status as 'PENDING_REVIEW' | 'REJECTED' | 'DEVELOPING' | 'TESTING' | 'PASSED',
|
||||||
|
{
|
||||||
|
linkedTaskCount,
|
||||||
|
isSuperAdmin: ctx.isSuperAdmin,
|
||||||
|
rejectReason: ctx.rejectReason,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (!guard.ok) {
|
||||||
|
results.push({ ticketId: String(id), ok: false, message: guard.message });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const data: Prisma.CommonSupportTicketUpdateInput = { status };
|
||||||
|
if (ctx.note?.trim()) data.remark = ctx.note.trim();
|
||||||
|
if (status === 'REJECTED') {
|
||||||
|
data.rejectReason = ctx.rejectReason!.trim();
|
||||||
|
data.completedAt = new Date();
|
||||||
|
if (ctx.reviewer) {
|
||||||
|
data.reviewerId = ctx.reviewer.id;
|
||||||
|
data.reviewerName = ctx.reviewer.name;
|
||||||
|
data.reviewedAt = new Date();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status === 'PASSED') data.completedAt = new Date();
|
||||||
|
await this.prisma.commonSupportTicket.update({ where: { id }, data });
|
||||||
|
results.push({ ticketId: String(id), ok: true });
|
||||||
|
} catch (err) {
|
||||||
|
results.push({
|
||||||
|
ticketId: String(id),
|
||||||
|
ok: false,
|
||||||
|
message: err instanceof Error ? err.message : '更新失败',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const successCount = results.filter((r) => r.ok).length;
|
||||||
|
return { results, successCount, failCount: results.length - successCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
async list(query: SupportTicketListQueryDto) {
|
async list(query: SupportTicketListQueryDto) {
|
||||||
@@ -98,7 +259,7 @@ export class SupportTicketService {
|
|||||||
]);
|
]);
|
||||||
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds(items.map((i) => i.id));
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds(items.map((i) => i.id));
|
||||||
const enriched = items.map((ticket) => ({
|
const enriched = items.map((ticket) => ({
|
||||||
...ticket,
|
...mapSupportTicketRow(ticket),
|
||||||
linkedTasks: (linkedMap.get(String(ticket.id)) ?? []).map((t) => ({
|
linkedTasks: (linkedMap.get(String(ticket.id)) ?? []).map((t) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
taskNo: t.taskNo,
|
taskNo: t.taskNo,
|
||||||
@@ -114,7 +275,7 @@ export class SupportTicketService {
|
|||||||
if (!ticket) throw new NotFoundException('技术支持工单不存在');
|
if (!ticket) throw new NotFoundException('技术支持工单不存在');
|
||||||
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||||
return serializeBigInt({
|
return serializeBigInt({
|
||||||
...ticket,
|
...mapSupportTicketRow(ticket),
|
||||||
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
taskNo: t.taskNo,
|
taskNo: t.taskNo,
|
||||||
@@ -189,6 +350,8 @@ export class SupportTicketService {
|
|||||||
rejectReason?: string;
|
rejectReason?: string;
|
||||||
note?: string;
|
note?: string;
|
||||||
tasks?: CreateDevPlanTaskFromTicketInput[];
|
tasks?: CreateDevPlanTaskFromTicketInput[];
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
dispatchSupplement?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
if (input.decision === 'REJECT') {
|
if (input.decision === 'REJECT') {
|
||||||
@@ -202,7 +365,7 @@ export class SupportTicketService {
|
|||||||
throw new BadRequestException('仅待评审工单可审批');
|
throw new BadRequestException('仅待评审工单可审批');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.devPlan.createTasksFromTicket(id, input.tasks, reviewer.id);
|
const createdTasks = await this.devPlan.createTasksFromTicket(id, input.tasks, reviewer.id);
|
||||||
|
|
||||||
const updated = await this.prisma.commonSupportTicket.update({
|
const updated = await this.prisma.commonSupportTicket.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
@@ -214,9 +377,31 @@ export class SupportTicketService {
|
|||||||
remark: input.note?.trim() || ticket.remark,
|
remark: input.note?.trim() || ticket.remark,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (input.dispatchToWecom) {
|
||||||
|
try {
|
||||||
|
await this.devPlan.dispatchTasks(
|
||||||
|
{
|
||||||
|
taskIds: createdTasks.map((t) => t.id),
|
||||||
|
supplement: input.dispatchSupplement,
|
||||||
|
},
|
||||||
|
reviewer.id,
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
this.alert.notify({
|
||||||
|
level: 'P2',
|
||||||
|
category: 'ops',
|
||||||
|
title: '审批后企微派发失败',
|
||||||
|
detail: `工单 ${ticket.ticketNo}\n${err instanceof Error ? err.message : String(err)}`,
|
||||||
|
dedupeKey: `support_review_dispatch_fail|${ticket.ticketNo}`,
|
||||||
|
dedupeTtlSec: 120,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||||
return serializeBigInt({
|
return serializeBigInt({
|
||||||
...updated,
|
...mapSupportTicketRow(updated),
|
||||||
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
taskNo: t.taskNo,
|
taskNo: t.taskNo,
|
||||||
@@ -245,6 +430,134 @@ export class SupportTicketService {
|
|||||||
return { items: results };
|
return { items: results };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 批量一键创建开发任务(每工单 1 条,内容取自标题/说明) */
|
||||||
|
async batchCreateTasks(
|
||||||
|
ticketIds: bigint[],
|
||||||
|
operator: { id: bigint; name: string },
|
||||||
|
) {
|
||||||
|
const results: Array<{
|
||||||
|
ticketId: string;
|
||||||
|
ok: boolean;
|
||||||
|
message?: string;
|
||||||
|
taskIds?: string[];
|
||||||
|
}> = [];
|
||||||
|
|
||||||
|
for (const id of ticketIds) {
|
||||||
|
try {
|
||||||
|
const ticket = await this.getOrThrow(id);
|
||||||
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||||
|
const existing = linkedMap.get(String(id)) ?? [];
|
||||||
|
if (existing.length > 0) {
|
||||||
|
results.push({ ticketId: String(id), ok: false, message: '已有开发任务,已跳过' });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const summary = [ticket.title, ticket.content].filter(Boolean).join('\n').slice(0, 500);
|
||||||
|
const createdTasks = await this.devPlan.createTasksFromTicket(
|
||||||
|
id,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
content: summary || ticket.title,
|
||||||
|
type: mapSupportTicketTypeToDevPlanTask(ticket.ticketType as 'BUG' | 'SUGGESTION' | 'OTHER'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
operator.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ticket.status === 'PENDING_REVIEW') {
|
||||||
|
await this.prisma.commonSupportTicket.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
status: 'DEVELOPING',
|
||||||
|
reviewerId: operator.id,
|
||||||
|
reviewerName: operator.name,
|
||||||
|
reviewedAt: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
ticketId: String(id),
|
||||||
|
ok: true,
|
||||||
|
taskIds: createdTasks.map((t) => t.id),
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
results.push({
|
||||||
|
ticketId: String(id),
|
||||||
|
ok: false,
|
||||||
|
message: err instanceof Error ? err.message : '创建失败',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const successCount = results.filter((r) => r.ok).length;
|
||||||
|
return { results, successCount, failCount: results.length - successCount };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量一键发布:关联开发版本,可选企微派发 */
|
||||||
|
async batchPublish(
|
||||||
|
ticketIds: bigint[],
|
||||||
|
input: {
|
||||||
|
versionId: string;
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
dispatchSupplement?: string;
|
||||||
|
},
|
||||||
|
operator: { id: bigint; name: string },
|
||||||
|
) {
|
||||||
|
const perTicket: Array<{ ticketId: string; ok: boolean; message?: string }> = [];
|
||||||
|
const taskIdSet = new Set<string>();
|
||||||
|
|
||||||
|
for (const id of ticketIds) {
|
||||||
|
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||||
|
const linked = linkedMap.get(String(id)) ?? [];
|
||||||
|
if (!linked.length) {
|
||||||
|
perTicket.push({ ticketId: String(id), ok: false, message: '无关联开发任务' });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
linked.forEach((t) => taskIdSet.add(t.id));
|
||||||
|
perTicket.push({ ticketId: String(id), ok: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const taskIds = [...taskIdSet];
|
||||||
|
if (!taskIds.length) {
|
||||||
|
return {
|
||||||
|
results: perTicket,
|
||||||
|
successCount: 0,
|
||||||
|
failCount: perTicket.length,
|
||||||
|
linkedTaskCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.devPlan.batchUpdateTasks({ taskIds, versionId: input.versionId });
|
||||||
|
|
||||||
|
if (input.dispatchToWecom) {
|
||||||
|
try {
|
||||||
|
await this.devPlan.dispatchTasks(
|
||||||
|
{ taskIds, supplement: input.dispatchSupplement },
|
||||||
|
operator.id,
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
this.alert.notify({
|
||||||
|
level: 'P2',
|
||||||
|
category: 'ops',
|
||||||
|
title: '批量发布企微派发失败',
|
||||||
|
detail: err instanceof Error ? err.message : String(err),
|
||||||
|
dedupeKey: `support_batch_publish_dispatch_fail|${Date.now()}`,
|
||||||
|
dedupeTtlSec: 120,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const successCount = perTicket.filter((r) => r.ok).length;
|
||||||
|
return {
|
||||||
|
results: perTicket,
|
||||||
|
successCount,
|
||||||
|
failCount: perTicket.length - successCount,
|
||||||
|
linkedTaskCount: taskIds.length,
|
||||||
|
versionId: input.versionId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/** 开发完成 → 测试 */
|
/** 开发完成 → 测试 */
|
||||||
async startTesting(id: bigint, dto?: SupportTicketRemarkDto) {
|
async startTesting(id: bigint, dto?: SupportTicketRemarkDto) {
|
||||||
const ticket = await this.getOrThrow(id);
|
const ticket = await this.getOrThrow(id);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
UpdateDevPlanSettingsDto,
|
UpdateDevPlanSettingsDto,
|
||||||
UpdateDevPlanTaskDto,
|
UpdateDevPlanTaskDto,
|
||||||
UpdateDevPlanVersionDto,
|
UpdateDevPlanVersionDto,
|
||||||
|
DevPlanTaskBatchUpdateDto,
|
||||||
} from './dto/dev-plan.dto';
|
} from './dto/dev-plan.dto';
|
||||||
|
|
||||||
@Controller('admin/dev-plan')
|
@Controller('admin/dev-plan')
|
||||||
@@ -91,6 +92,12 @@ export class AdminDevPlanController {
|
|||||||
return this.service.dispatchTasks(body, account.id);
|
return this.service.dispatchTasks(body, account.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('tasks/batch-update')
|
||||||
|
@HqOperation({ action: HqOperationAction.DEV_PLAN_TASK_UPDATE, refType: 'DEV_PLAN_TASK', includeBody: true, batch: true })
|
||||||
|
batchUpdateTasks(@Body() body: DevPlanTaskBatchUpdateDto) {
|
||||||
|
return this.service.batchUpdateTasks(body);
|
||||||
|
}
|
||||||
|
|
||||||
@Get('versions')
|
@Get('versions')
|
||||||
listVersions(
|
listVersions(
|
||||||
@Query('status') status?: string,
|
@Query('status') status?: string,
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import type {
|
|||||||
|
|
||||||
DevPlanTaskDispatchDto,
|
DevPlanTaskDispatchDto,
|
||||||
|
|
||||||
|
DevPlanTaskBatchUpdateDto,
|
||||||
|
|
||||||
DevPlanTaskListQueryDto,
|
DevPlanTaskListQueryDto,
|
||||||
|
|
||||||
UpdateDevPlanSettingsDto,
|
UpdateDevPlanSettingsDto,
|
||||||
@@ -1009,6 +1011,100 @@ export class DevPlanService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async appendVersionTasks(versionId: bigint, taskIds: string[]) {
|
||||||
|
|
||||||
|
const version = await this.prisma.devPlanVersion.findUnique({ where: { id: versionId } });
|
||||||
|
|
||||||
|
if (!version) throw new NotFoundException('版本不存在');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const ids = taskIds.map(BigInt);
|
||||||
|
|
||||||
|
const existing = await this.prisma.devPlanVersionTask.findMany({
|
||||||
|
|
||||||
|
where: { versionId, taskId: { in: ids } },
|
||||||
|
|
||||||
|
select: { taskId: true },
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const linked = new Set(existing.map((row) => row.taskId.toString()));
|
||||||
|
|
||||||
|
const toAdd = ids.filter((id) => !linked.has(id.toString()));
|
||||||
|
|
||||||
|
if (!toAdd.length) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const maxSort = await this.prisma.devPlanVersionTask.aggregate({
|
||||||
|
|
||||||
|
where: { versionId },
|
||||||
|
|
||||||
|
_max: { sortOrder: true },
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
let sort = (maxSort._max.sortOrder ?? -1) + 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await this.prisma.devPlanVersionTask.createMany({
|
||||||
|
|
||||||
|
data: toAdd.map((taskId, index) => ({ versionId, taskId, sortOrder: sort + index })),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async batchUpdateTasks(dto: DevPlanTaskBatchUpdateDto) {
|
||||||
|
|
||||||
|
if (!dto.taskIds.length) throw new BadRequestException('请至少选择 1 条任务');
|
||||||
|
|
||||||
|
if (!dto.status && !dto.versionId) {
|
||||||
|
|
||||||
|
throw new BadRequestException('请至少指定状态或关联版本');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const taskIds = dto.taskIds.map(BigInt);
|
||||||
|
|
||||||
|
const tasks = await this.prisma.devPlanTask.findMany({ where: { id: { in: taskIds } } });
|
||||||
|
|
||||||
|
if (tasks.length !== taskIds.length) throw new BadRequestException('部分任务不存在');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dto.status) {
|
||||||
|
|
||||||
|
for (const task of tasks) {
|
||||||
|
|
||||||
|
await this.updateTask(task.id, { status: dto.status });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dto.versionId) {
|
||||||
|
|
||||||
|
await this.appendVersionTasks(BigInt(dto.versionId), dto.taskIds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return { updated: taskIds.length };
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,4 @@
|
|||||||
import {
|
import { ArrayMinSize, IsArray, IsBoolean, IsIn, IsNotEmpty, IsOptional, IsString, ValidateIf, ValidateNested } from 'class-validator';
|
||||||
ArrayMinSize,
|
|
||||||
IsArray,
|
|
||||||
IsIn,
|
|
||||||
IsNotEmpty,
|
|
||||||
IsOptional,
|
|
||||||
IsString,
|
|
||||||
ValidateIf,
|
|
||||||
ValidateNested,
|
|
||||||
} from 'class-validator';
|
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
DEV_PLAN_TASK_STATUSES,
|
DEV_PLAN_TASK_STATUSES,
|
||||||
@@ -161,6 +152,29 @@ export class ReviewSupportTicketDto {
|
|||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@Type(() => DevPlanTaskFromTicketDto)
|
@Type(() => DevPlanTaskFromTicketDto)
|
||||||
tasks?: DevPlanTaskFromTicketDto[];
|
tasks?: DevPlanTaskFromTicketDto[];
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsBoolean()
|
||||||
|
dispatchToWecom?: boolean;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
dispatchSupplement?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DevPlanTaskBatchUpdateDto {
|
||||||
|
@IsArray()
|
||||||
|
@ArrayMinSize(1)
|
||||||
|
@IsString({ each: true })
|
||||||
|
taskIds!: string[];
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsIn(DEV_PLAN_TASK_STATUSES)
|
||||||
|
status?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
versionId?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BatchReviewPreviewDto {
|
export class BatchReviewPreviewDto {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import type {
|
|||||||
CreateKnowledgeBaseRequest,
|
CreateKnowledgeBaseRequest,
|
||||||
CreateKnowledgeDocumentRequest,
|
CreateKnowledgeDocumentRequest,
|
||||||
UpdateKnowledgeBaseRequest,
|
UpdateKnowledgeBaseRequest,
|
||||||
|
UpdateKnowledgeDocumentRequest,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||||||
import {
|
import {
|
||||||
@@ -119,6 +120,33 @@ export class AdminKnowledgeBasesController {
|
|||||||
return this.service.addDocument(actor, BigInt(id), body);
|
return this.service.addDocument(actor, BigInt(id), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':id/documents/:docId')
|
||||||
|
async getDocument(
|
||||||
|
@CurrentUser() user: AuthUser,
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Param('docId') docId: string,
|
||||||
|
) {
|
||||||
|
const actor = await this.service.resolveActor(user.actorId);
|
||||||
|
return this.service.getDocument(actor, BigInt(id), BigInt(docId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id/documents/:docId')
|
||||||
|
@HqOperation({
|
||||||
|
action: HqOperationAction.KNOWLEDGE_DOC_UPDATE,
|
||||||
|
refType: 'KNOWLEDGE_DOCUMENT',
|
||||||
|
refIdField: 'docId',
|
||||||
|
includeBody: true,
|
||||||
|
})
|
||||||
|
async updateDocument(
|
||||||
|
@CurrentUser() user: AuthUser,
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Param('docId') docId: string,
|
||||||
|
@Body() body: UpdateKnowledgeDocumentRequest,
|
||||||
|
) {
|
||||||
|
const actor = await this.service.resolveActor(user.actorId);
|
||||||
|
return this.service.updateDocument(actor, BigInt(id), BigInt(docId), body);
|
||||||
|
}
|
||||||
|
|
||||||
@Delete(':id/documents/:docId')
|
@Delete(':id/documents/:docId')
|
||||||
@HqOperation({
|
@HqOperation({
|
||||||
action: HqOperationAction.KNOWLEDGE_DOC_DELETE,
|
action: HqOperationAction.KNOWLEDGE_DOC_DELETE,
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import type {
|
|||||||
CreateKnowledgeDocumentRequest,
|
CreateKnowledgeDocumentRequest,
|
||||||
KnowledgeBaseDto,
|
KnowledgeBaseDto,
|
||||||
KnowledgeBaseOptionDto,
|
KnowledgeBaseOptionDto,
|
||||||
|
KnowledgeDocumentDetailDto,
|
||||||
KnowledgeDocumentDto,
|
KnowledgeDocumentDto,
|
||||||
UpdateKnowledgeBaseRequest,
|
UpdateKnowledgeBaseRequest,
|
||||||
|
UpdateKnowledgeDocumentRequest,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||||
@@ -228,6 +230,113 @@ export class AdminKnowledgeBasesService {
|
|||||||
return this.toDocDto(row);
|
return this.toDocDto(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getDocument(actor: ActorCtx, kbId: bigint, docId: bigint): Promise<KnowledgeDocumentDetailDto> {
|
||||||
|
await this.requireKb(actor, kbId);
|
||||||
|
const doc = await this.prisma.knowledgeDocument.findFirst({
|
||||||
|
where: { id: docId, knowledgeBaseId: kbId },
|
||||||
|
});
|
||||||
|
if (!doc) throw new NotFoundException('文档不存在');
|
||||||
|
return {
|
||||||
|
...this.toDocDto(doc),
|
||||||
|
contentText: doc.contentText,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateDocument(
|
||||||
|
actor: ActorCtx,
|
||||||
|
kbId: bigint,
|
||||||
|
docId: bigint,
|
||||||
|
dto: UpdateKnowledgeDocumentRequest,
|
||||||
|
) {
|
||||||
|
const kb = await this.requireKb(actor, kbId);
|
||||||
|
this.requireWrite(actor, kb);
|
||||||
|
const doc = await this.prisma.knowledgeDocument.findFirst({
|
||||||
|
where: { id: docId, knowledgeBaseId: kbId },
|
||||||
|
});
|
||||||
|
if (!doc) throw new NotFoundException('文档不存在');
|
||||||
|
|
||||||
|
const data: {
|
||||||
|
title?: string;
|
||||||
|
fileName?: string | null;
|
||||||
|
fileUrl?: string | null;
|
||||||
|
mimeType?: string | null;
|
||||||
|
sizeBytes?: number | null;
|
||||||
|
contentText?: string | null;
|
||||||
|
status?: 'READY' | 'EMPTY' | 'FAILED';
|
||||||
|
errorMessage?: string | null;
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
if (dto.title !== undefined) {
|
||||||
|
const title = dto.title.trim();
|
||||||
|
if (!title) throw new BadRequestException('请填写标题');
|
||||||
|
data.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasContentInput =
|
||||||
|
dto.contentText !== undefined ||
|
||||||
|
dto.fileUrl !== undefined ||
|
||||||
|
dto.fileName !== undefined ||
|
||||||
|
dto.mimeType !== undefined;
|
||||||
|
|
||||||
|
if (hasContentInput) {
|
||||||
|
let contentText = dto.contentText !== undefined ? dto.contentText?.trim() || '' : doc.contentText?.trim() || '';
|
||||||
|
let status: 'READY' | 'EMPTY' | 'FAILED' = doc.status as 'READY' | 'EMPTY' | 'FAILED';
|
||||||
|
let errorMessage: string | null = doc.errorMessage;
|
||||||
|
|
||||||
|
if (dto.contentText !== undefined) {
|
||||||
|
if (contentText) {
|
||||||
|
status = 'READY';
|
||||||
|
errorMessage = null;
|
||||||
|
} else if (!dto.fileUrl?.trim() && !doc.fileUrl) {
|
||||||
|
status = 'EMPTY';
|
||||||
|
errorMessage = null;
|
||||||
|
}
|
||||||
|
data.contentText = contentText || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dto.fileUrl !== undefined) data.fileUrl = dto.fileUrl?.trim() || null;
|
||||||
|
if (dto.fileName !== undefined) data.fileName = dto.fileName?.trim() || null;
|
||||||
|
if (dto.mimeType !== undefined) data.mimeType = dto.mimeType?.trim() || null;
|
||||||
|
if (dto.sizeBytes !== undefined) data.sizeBytes = dto.sizeBytes ?? null;
|
||||||
|
|
||||||
|
const fileUrl = dto.fileUrl?.trim() || doc.fileUrl;
|
||||||
|
const fileName = dto.fileName?.trim() || doc.fileName || '';
|
||||||
|
const mimeType = dto.mimeType?.trim() || doc.mimeType;
|
||||||
|
|
||||||
|
if (dto.fileUrl?.trim() && dto.contentText === undefined) {
|
||||||
|
if (TEXT_EXT.test(fileName) || isLikelyTextMime(mimeType)) {
|
||||||
|
try {
|
||||||
|
contentText = await fetchText(dto.fileUrl.trim());
|
||||||
|
data.contentText = contentText || null;
|
||||||
|
status = contentText.trim() ? 'READY' : 'EMPTY';
|
||||||
|
errorMessage = contentText.trim() ? null : '文件内容为空';
|
||||||
|
} catch (e) {
|
||||||
|
status = 'FAILED';
|
||||||
|
errorMessage = e instanceof Error ? e.message : String(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = 'EMPTY';
|
||||||
|
errorMessage = '非文本文件未抽取正文,请粘贴文本或上传 .txt/.md';
|
||||||
|
}
|
||||||
|
} else if (dto.contentText !== undefined && contentText) {
|
||||||
|
status = 'READY';
|
||||||
|
errorMessage = null;
|
||||||
|
} else if (dto.contentText !== undefined && !contentText && !fileUrl) {
|
||||||
|
status = 'EMPTY';
|
||||||
|
errorMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.status = status;
|
||||||
|
data.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updated = await this.prisma.knowledgeDocument.update({
|
||||||
|
where: { id: docId },
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
return this.toDocDto(updated);
|
||||||
|
}
|
||||||
|
|
||||||
async removeDocument(actor: ActorCtx, kbId: bigint, docId: bigint) {
|
async removeDocument(actor: ActorCtx, kbId: bigint, docId: bigint) {
|
||||||
const kb = await this.requireKb(actor, kbId);
|
const kb = await this.requireKb(actor, kbId);
|
||||||
this.requireWrite(actor, kb);
|
this.requireWrite(actor, kb);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
Param,
|
Param,
|
||||||
|
Patch,
|
||||||
Post,
|
Post,
|
||||||
Query,
|
Query,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
@@ -22,6 +23,10 @@ import {
|
|||||||
RejectSupportTicketDto,
|
RejectSupportTicketDto,
|
||||||
SupportTicketListQueryDto,
|
SupportTicketListQueryDto,
|
||||||
SupportTicketRemarkDto,
|
SupportTicketRemarkDto,
|
||||||
|
UpdateSupportTicketDto,
|
||||||
|
BatchUpdateSupportTicketStatusDto,
|
||||||
|
BatchCreateSupportTicketTasksDto,
|
||||||
|
BatchPublishSupportTicketsDto,
|
||||||
} from '../common/dto/support-ticket.dto';
|
} from '../common/dto/support-ticket.dto';
|
||||||
import {
|
import {
|
||||||
BatchReviewConfirmDto,
|
BatchReviewConfirmDto,
|
||||||
@@ -83,11 +88,59 @@ export class AdminSupportTicketsController {
|
|||||||
return this.service.batchReviewConfirm(account, body.items);
|
return this.service.batchReviewConfirm(account, body.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('batch-update-status')
|
||||||
|
@UseGuards(SuperAdminGuard)
|
||||||
|
async batchUpdateStatus(
|
||||||
|
@CurrentUser() user: AuthUser,
|
||||||
|
@Body() body: BatchUpdateSupportTicketStatusDto,
|
||||||
|
) {
|
||||||
|
const account = await this.resolveHqAccount(user);
|
||||||
|
const profile = await this.prisma.hqAccount.findUnique({
|
||||||
|
where: { id: user.actorId },
|
||||||
|
select: { adminRole: true },
|
||||||
|
});
|
||||||
|
return this.service.batchUpdateStatus(
|
||||||
|
body.ticketIds.map(BigInt),
|
||||||
|
body.status as never,
|
||||||
|
{
|
||||||
|
isSuperAdmin: profile?.adminRole === 'SUPER_ADMIN',
|
||||||
|
rejectReason: body.rejectReason,
|
||||||
|
note: body.note,
|
||||||
|
reviewer: account,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('batch-create-tasks')
|
||||||
|
@UseGuards(SuperAdminGuard)
|
||||||
|
async batchCreateTasks(
|
||||||
|
@CurrentUser() user: AuthUser,
|
||||||
|
@Body() body: BatchCreateSupportTicketTasksDto,
|
||||||
|
) {
|
||||||
|
const account = await this.resolveHqAccount(user);
|
||||||
|
return this.service.batchCreateTasks(body.ticketIds.map(BigInt), account);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('batch-publish')
|
||||||
|
@UseGuards(SuperAdminGuard)
|
||||||
|
async batchPublish(
|
||||||
|
@CurrentUser() user: AuthUser,
|
||||||
|
@Body() body: BatchPublishSupportTicketsDto,
|
||||||
|
) {
|
||||||
|
const account = await this.resolveHqAccount(user);
|
||||||
|
return this.service.batchPublish(body.ticketIds.map(BigInt), body, account);
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
detail(@Param('id') id: string) {
|
detail(@Param('id') id: string) {
|
||||||
return this.service.detail(BigInt(id));
|
return this.service.detail(BigInt(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() body: UpdateSupportTicketDto) {
|
||||||
|
return this.service.update(BigInt(id), body);
|
||||||
|
}
|
||||||
|
|
||||||
@Post(':id/review')
|
@Post(':id/review')
|
||||||
@UseGuards(SuperAdminGuard)
|
@UseGuards(SuperAdminGuard)
|
||||||
@HqOperation({
|
@HqOperation({
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Prisma } from '@prisma/client';
|
|||||||
import {
|
import {
|
||||||
DEFAULT_STORE_WITHDRAW_DAILY_LIMIT,
|
DEFAULT_STORE_WITHDRAW_DAILY_LIMIT,
|
||||||
DEFAULT_XFX_LOGISTICS_PRICING,
|
DEFAULT_XFX_LOGISTICS_PRICING,
|
||||||
|
WINERY_SETTLEMENT_LAG_DAYS,
|
||||||
WINERY_SETTLEMENT_RATE,
|
WINERY_SETTLEMENT_RATE,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import {
|
import {
|
||||||
@@ -40,6 +41,15 @@ function dayWindow(anchor = new Date()) {
|
|||||||
return { start, end, billDate: start };
|
return { start, end, billDate: start };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wineryDayWindow(anchor = new Date(), lagDays = WINERY_SETTLEMENT_LAG_DAYS) {
|
||||||
|
const billDate = startOfDay(anchor);
|
||||||
|
billDate.setDate(billDate.getDate() - lagDays);
|
||||||
|
const start = billDate;
|
||||||
|
const end = new Date(start);
|
||||||
|
end.setDate(end.getDate() + 1);
|
||||||
|
return { start, end, billDate: start };
|
||||||
|
}
|
||||||
|
|
||||||
function round2(n: number) {
|
function round2(n: number) {
|
||||||
return Math.round(n * 100) / 100;
|
return Math.round(n * 100) / 100;
|
||||||
}
|
}
|
||||||
@@ -205,7 +215,6 @@ export class SettlementService {
|
|||||||
remainingDailyLimit: Math.max(0, round2(dailyLimit - todayApplied)),
|
remainingDailyLimit: Math.max(0, round2(dailyLimit - todayApplied)),
|
||||||
isPrimary: account.isPrimary === 1,
|
isPrimary: account.isPrimary === 1,
|
||||||
hasBankAccount,
|
hasBankAccount,
|
||||||
hasPendingRequest: !!pending,
|
|
||||||
bankAccount: {
|
bankAccount: {
|
||||||
bankAccountName: account.bankAccountName,
|
bankAccountName: account.bankAccountName,
|
||||||
bankAccountNo: account.bankAccountNo,
|
bankAccountNo: account.bankAccountNo,
|
||||||
@@ -264,7 +273,6 @@ export class SettlementService {
|
|||||||
requestAmount,
|
requestAmount,
|
||||||
todayApplied,
|
todayApplied,
|
||||||
dailyLimit,
|
dailyLimit,
|
||||||
hasPendingRequest: !!pending,
|
|
||||||
hasBankAccount,
|
hasBankAccount,
|
||||||
});
|
});
|
||||||
if (!guard.ok) throw new BadRequestException(guard.message);
|
if (!guard.ok) throw new BadRequestException(guard.message);
|
||||||
@@ -276,14 +284,6 @@ export class SettlementService {
|
|||||||
if (!picked.ok) throw new BadRequestException(picked.message);
|
if (!picked.ok) throw new BadRequestException(picked.message);
|
||||||
|
|
||||||
const created = await this.prisma.$transaction(async (tx) => {
|
const created = await this.prisma.$transaction(async (tx) => {
|
||||||
const stillPending = await tx.storeWithdrawRequest.findFirst({
|
|
||||||
where: { storeId, status: 'PENDING_REVIEW' },
|
|
||||||
select: { id: true },
|
|
||||||
});
|
|
||||||
if (stillPending) {
|
|
||||||
throw new BadRequestException('已有待审核提现申请,请等待处理完成');
|
|
||||||
}
|
|
||||||
|
|
||||||
const payoutIds = picked.selected.map((p) => p.id);
|
const payoutIds = picked.selected.map((p) => p.id);
|
||||||
const locked = await tx.storePayout.findMany({
|
const locked = await tx.storePayout.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -1573,7 +1573,7 @@ export class SettlementService {
|
|||||||
// ─── Winery bills ────────────────────────────────────
|
// ─── Winery bills ────────────────────────────────────
|
||||||
|
|
||||||
async generateWineryBillForDay(anchor = new Date()) {
|
async generateWineryBillForDay(anchor = new Date()) {
|
||||||
const { start, end, billDate } = dayWindow(anchor);
|
const { start, end, billDate } = wineryDayWindow(anchor);
|
||||||
const rate = WINERY_SETTLEMENT_RATE;
|
const rate = WINERY_SETTLEMENT_RATE;
|
||||||
|
|
||||||
const existing = await this.prisma.wineryBill.findUnique({ where: { billDate } });
|
const existing = await this.prisma.wineryBill.findUnique({ where: { billDate } });
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ export class StorePackageService {
|
|||||||
const otherNotes = item.otherNotes != null && String(item.otherNotes).trim()
|
const otherNotes = item.otherNotes != null && String(item.otherNotes).trim()
|
||||||
? String(item.otherNotes).trim()
|
? String(item.otherNotes).trim()
|
||||||
: null;
|
: null;
|
||||||
|
const imageUrl = item.imageUrl != null && String(item.imageUrl).trim()
|
||||||
|
? String(item.imageUrl).trim()
|
||||||
|
: null;
|
||||||
const sortOrder = item.sortOrder != null ? Number(item.sortOrder) : index;
|
const sortOrder = item.sortOrder != null ? Number(item.sortOrder) : index;
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@@ -51,6 +54,7 @@ export class StorePackageService {
|
|||||||
dishes,
|
dishes,
|
||||||
usableTime,
|
usableTime,
|
||||||
otherNotes,
|
otherNotes,
|
||||||
|
imageUrl,
|
||||||
sortOrder: Number.isFinite(sortOrder) ? sortOrder : index,
|
sortOrder: Number.isFinite(sortOrder) ? sortOrder : index,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -62,6 +66,7 @@ export class StorePackageService {
|
|||||||
dishes: string;
|
dishes: string;
|
||||||
usableTime: string | null;
|
usableTime: string | null;
|
||||||
otherNotes: string | null;
|
otherNotes: string | null;
|
||||||
|
imageUrl: string | null;
|
||||||
sortOrder: number;
|
sortOrder: number;
|
||||||
}) {
|
}) {
|
||||||
return {
|
return {
|
||||||
@@ -71,6 +76,7 @@ export class StorePackageService {
|
|||||||
dishes: row.dishes,
|
dishes: row.dishes,
|
||||||
usableTime: row.usableTime,
|
usableTime: row.usableTime,
|
||||||
otherNotes: row.otherNotes,
|
otherNotes: row.otherNotes,
|
||||||
|
imageUrl: row.imageUrl,
|
||||||
sortOrder: row.sortOrder,
|
sortOrder: row.sortOrder,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -214,6 +220,7 @@ export class StorePackageService {
|
|||||||
dishes: pkg.dishes,
|
dishes: pkg.dishes,
|
||||||
usableTime: pkg.usableTime ?? null,
|
usableTime: pkg.usableTime ?? null,
|
||||||
otherNotes: pkg.otherNotes ?? null,
|
otherNotes: pkg.otherNotes ?? null,
|
||||||
|
imageUrl: pkg.imageUrl ?? null,
|
||||||
sortOrder: pkg.sortOrder ?? index,
|
sortOrder: pkg.sortOrder ?? index,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ export class StoreService {
|
|||||||
dishes: p.dishes,
|
dishes: p.dishes,
|
||||||
usableTime: p.usableTime,
|
usableTime: p.usableTime,
|
||||||
otherNotes: p.otherNotes,
|
otherNotes: p.otherNotes,
|
||||||
|
imageUrl: p.imageUrl,
|
||||||
sortOrder: p.sortOrder,
|
sortOrder: p.sortOrder,
|
||||||
})),
|
})),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -593,6 +593,22 @@ export class TradeService {
|
|||||||
try {
|
try {
|
||||||
refundResult = await this.payProvider.refundOrder(orderId, outRefundNo, remark);
|
refundResult = await this.payProvider.refundOrder(orderId, outRefundNo, remark);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
await this.prisma.order.update({
|
||||||
|
where: { id: orderId },
|
||||||
|
data: { status: fromStatus, payStatus: 'PAID' },
|
||||||
|
});
|
||||||
|
await this.prisma.commonEvent.create({
|
||||||
|
data: buildOrderStatusEvent({
|
||||||
|
orderId,
|
||||||
|
fromStatus: 'REFUNDING',
|
||||||
|
toStatus: fromStatus,
|
||||||
|
operator: actorType,
|
||||||
|
remark: `退款发起失败,已恢复:${err instanceof Error ? err.message : String(err)}`.slice(
|
||||||
|
0,
|
||||||
|
500,
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
});
|
||||||
this.alert.notify({
|
this.alert.notify({
|
||||||
level: 'P0',
|
level: 'P0',
|
||||||
category: 'pay',
|
category: 'pay',
|
||||||
|
|||||||
@@ -38,6 +38,12 @@
|
|||||||
|------|------|------|
|
|------|------|------|
|
||||||
| **3.4.11** | 2026-08-04 | 新增 §3.10 开发计划、§3.11 企微机器人角色与权限重构;REQ-H-026 ~ REQ-H-028;开发设计见 [`杜康好客-开发计划功能开发文档-v3.4.11.md`](./杜康好客-开发计划功能开发文档-v3.4.11.md) |
|
| **3.4.11** | 2026-08-04 | 新增 §3.10 开发计划、§3.11 企微机器人角色与权限重构;REQ-H-026 ~ REQ-H-028;开发设计见 [`杜康好客-开发计划功能开发文档-v3.4.11.md`](./杜康好客-开发计划功能开发文档-v3.4.11.md) |
|
||||||
|
|
||||||
|
### 0.4 变更:3.4.12 工单迭代
|
||||||
|
|
||||||
|
| 版本 | 日期 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| **3.4.12** | 2026-08-04 | 售后退款回滚、mini-user 门店详情、酒厂 T+3、门店多笔提现、开发计划批量编辑/审批企微派发、技术支持编辑/附件/批量改状态、套餐 imageUrl;开发设计见 [`杜康好客-v3.4.12-工单迭代开发文档.md`](./杜康好客-v3.4.12-工单迭代开发文档.md) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. 背景与目标
|
## 1. 背景与目标
|
||||||
|
|||||||
+19
-1
@@ -313,10 +313,28 @@ C2~C7、C14 见 §1.3。
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 9. 变更记录
|
## 9. v3.4.12 工单迭代(2026-08-04)
|
||||||
|
|
||||||
|
| 项 | 状态 | 说明 |
|
||||||
|
|----|------|------|
|
||||||
|
| P0 售后退款回滚 | ✅ | `initiateRefund` 微信失败恢复 PAID |
|
||||||
|
| mini-user 门店详情 | ✅ | 门头轮播 preview + 环境图双列 |
|
||||||
|
| 酒厂 T+3 | ✅ | `WINERY_SETTLEMENT_LAG_DAYS=3` |
|
||||||
|
| 门店多笔提现 | ✅ | 移除单 pending 限制 |
|
||||||
|
| 审批企微派发 | ✅ | review `dispatchToWecom` |
|
||||||
|
| 开发任务批量编辑 | ✅ | `POST /admin/dev-plan/tasks/batch-update` |
|
||||||
|
| 技术支持编辑/附件 | ✅ | `PATCH /admin/support-tickets/:id` + `attachmentUrls` |
|
||||||
|
| 技术支持批量改状态 | ✅ | domain 状态机 + batch API |
|
||||||
|
| 套餐 imageUrl | ✅ | 四端 + Prisma |
|
||||||
|
| 文档 | ✅ | PRD §0.4 + v3.4.12 开发文档 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. 变更记录
|
||||||
|
|
||||||
| 日期 | 说明 |
|
| 日期 | 说明 |
|
||||||
|------|------|
|
|------|------|
|
||||||
|
| 2026-08-04 | v3.4.12 工单迭代(退款/财务/C端/开发计划/技术支持/套餐) |
|
||||||
| 2026-08-04 | v3.4.11 开发计划 + 企微智能机器人/消息推送 + 角色权限重构 |
|
| 2026-08-04 | v3.4.11 开发计划 + 企微智能机器人/消息推送 + 角色权限重构 |
|
||||||
| 2026-07-12 | **P0 已执行**:C2~C7、C14 代码与文档对齐;§1 改为计划+状态表 |
|
| 2026-07-12 | **P0 已执行**:C2~C7、C14 代码与文档对齐;§1 改为计划+状态表 |
|
||||||
| 2026-07-12 | 明确总部端保持 WebAdmin,不改为 H5 |
|
| 2026-07-12 | 明确总部端保持 WebAdmin,不改为 H5 |
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# 杜康好客 · v3.4.12 工单迭代开发文档
|
||||||
|
|
||||||
|
> 版本:**v3.4.12** · 日期:2026-08-04
|
||||||
|
> 需求源:ST 工单 + 开发计划/技术支持批量能力补充
|
||||||
|
|
||||||
|
## 1. 范围
|
||||||
|
|
||||||
|
| 模块 | 内容 |
|
||||||
|
|------|------|
|
||||||
|
| P0 售后 | `initiateRefund` 微信失败回滚订单状态 |
|
||||||
|
| mini-user | 门店详情门头 preview、环境图双列 |
|
||||||
|
| 财务 | 酒厂账单 T+3;门店可多笔 pending 提现 |
|
||||||
|
| 开发计划 | 审批创建任务可选企微派发;任务批量改状态/关联版本 |
|
||||||
|
| 技术支持 | 单条编辑/附件;批量改状态(状态机) |
|
||||||
|
| 套餐 | `StorePackage.imageUrl` 四端;HQ 删除至 0 条 UX |
|
||||||
|
|
||||||
|
**不在本版**:ST1785812832352437(门店列表,已完成)
|
||||||
|
|
||||||
|
## 2. 后端 API
|
||||||
|
|
||||||
|
| 方法 | 路径 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| — | `trade.initiateRefund` | 失败时 `REFUNDING→原状态` + 事件 |
|
||||||
|
| — | `settlement.generateWineryBillForDay` | `wineryDayWindow(lag=3)` |
|
||||||
|
| — | `validateStoreWithdraw` | 移除 `hasPendingRequest` |
|
||||||
|
| POST | `/admin/dev-plan/tasks/batch-update` | `{ taskIds, status?, versionId? }` |
|
||||||
|
| POST | `/admin/support-tickets/:id/review` | 扩展 `dispatchToWecom`, `dispatchSupplement` |
|
||||||
|
| PATCH | `/admin/support-tickets/:id` | 待评审可编辑 |
|
||||||
|
| POST | `/admin/support-tickets/batch-update-status` | 批量改状态 |
|
||||||
|
|
||||||
|
## 3. 数据表
|
||||||
|
|
||||||
|
- `common_support_ticket.attachment_urls` JSON
|
||||||
|
- `store_package.image_url` VARCHAR(512)
|
||||||
|
|
||||||
|
## 4. 验收
|
||||||
|
|
||||||
|
- [ ] 售后 REFUND 审批后 Mock 退款成功
|
||||||
|
- [ ] mini-user 门头点击大图、环境图双列
|
||||||
|
- [ ] 酒厂账单滞后 3 天;门店第二笔提现可提交
|
||||||
|
- [ ] 审批勾选企微后开发群收到任务
|
||||||
|
- [ ] 任务多选批量改状态/关联版本
|
||||||
|
- [ ] 技术支持待评审可编辑附件;批量 TESTING→PASSED
|
||||||
|
- [ ] 套餐 imageUrl 四端展示;HQ 可删至 0 条
|
||||||
Reference in New Issue
Block a user