feat: v3.4.12 ticket iteration
Refund rollback, winery T+3, multi withdraw, mini-user store detail, dev plan batch edit and WeCom dispatch, support ticket edit/attachments/batch status, package imageUrl. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
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 type { StorePackageItemDto } from '@dukang/shared-types';
|
||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
|
||||
import OssUpload from './OssUpload';
|
||||
type PackageRow = StorePackageItemDto;
|
||||
|
||||
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 }) {
|
||||
@@ -41,18 +41,33 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
||||
}
|
||||
|
||||
function removeAt(index: number) {
|
||||
setItems((prev) => prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })));
|
||||
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;
|
||||
const run = () => {
|
||||
setItems((prev) => {
|
||||
const next = prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i }));
|
||||
return next.length ? next : [];
|
||||
});
|
||||
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) {
|
||||
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||
}
|
||||
@@ -65,6 +80,7 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
||||
dishes: item.dishes.trim(),
|
||||
usableTime: item.usableTime?.trim() || null,
|
||||
otherNotes: item.otherNotes?.trim() || null,
|
||||
imageUrl: item.imageUrl?.trim() || null,
|
||||
sortOrder: index,
|
||||
}))
|
||||
.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 (
|
||||
<Form layout="vertical" requiredMark={false}>
|
||||
if (!items.length) {
|
||||
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
|
||||
type="info"
|
||||
showIcon
|
||||
@@ -140,12 +169,11 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
||||
{displayName}
|
||||
</Typography.Title>
|
||||
</Button>
|
||||
{items.length > 1 ? (
|
||||
{items.length > 0 ? (
|
||||
<Button type="link" danger onClick={() => removeAt(index)}>
|
||||
删除
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
) : null} </Space>
|
||||
|
||||
{!isCollapsed ? (
|
||||
<>
|
||||
@@ -186,8 +214,16 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他说明" style={{ marginBottom: 0 }}>
|
||||
<Input
|
||||
<Form.Item label="套餐图片" style={{ marginBottom: 12 }}>
|
||||
<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="不可叠加"
|
||||
value={item.otherNotes || ''}
|
||||
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
type DevPlanTaskDto,
|
||||
type DevPlanTaskStatusDto,
|
||||
type DevPlanTaskTypeDto,
|
||||
type DevPlanVersionDto,
|
||||
} from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
@@ -46,11 +47,22 @@ export default function DevPlanTasksPage() {
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<string[]>([]);
|
||||
const [modalOpen, setModalOpen] = 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 [saving, setSaving] = useState(false);
|
||||
const [dispatching, setDispatching] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
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>(
|
||||
'/admin/dev-plan/tasks',
|
||||
@@ -119,6 +131,38 @@ export default function DevPlanTasksPage() {
|
||||
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() {
|
||||
const values = await dispatchForm.validateFields();
|
||||
setDispatching(true);
|
||||
@@ -186,6 +230,9 @@ export default function DevPlanTasksPage() {
|
||||
开发计划 · 任务列表
|
||||
</Typography.Title>
|
||||
<Space>
|
||||
<Button disabled={!selectedRowKeys.length} onClick={openBatchEdit}>
|
||||
批量编辑
|
||||
</Button>
|
||||
<Button disabled={!selectedRowKeys.length} onClick={openDispatch}>
|
||||
评审
|
||||
</Button>
|
||||
@@ -280,6 +327,29 @@ export default function DevPlanTasksPage() {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ function ProductDetailFields({ form, aromaType }: { form: FormInstance; aromaTyp
|
||||
<>
|
||||
<ProductDetailTemplatePicker form={form} aromaType={aromaType} />
|
||||
<Divider />
|
||||
<Typography.Text type="secondary">详情页轮播(CAROUSEL)</Typography.Text>
|
||||
<Typography.Text type="secondary">详情页轮播(CAROUSEL,单张最大 10MB)</Typography.Text>
|
||||
<ImageUrlList name="carouselUrls" label="轮播图" bizType="CAROUSEL" />
|
||||
<Divider />
|
||||
<Typography.Text type="secondary">详情长图(DETAIL,可逐张修改)</Typography.Text>
|
||||
<Typography.Text type="secondary">详情长图(DETAIL,可逐张修改,单张最大 10MB)</Typography.Text>
|
||||
<DetailImageUrlList label="详情图" bizType="DETAIL" />
|
||||
<Divider />
|
||||
<Form.Item name="storyTitle" label="故事标题">
|
||||
|
||||
@@ -2,8 +2,10 @@ import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Checkbox,
|
||||
Drawer,
|
||||
Form,
|
||||
Image,
|
||||
Input,
|
||||
Modal,
|
||||
Radio,
|
||||
@@ -40,6 +42,10 @@ import {
|
||||
import { request, type HqProfile } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
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> = {
|
||||
PENDING_REVIEW: 'orange',
|
||||
@@ -88,12 +94,26 @@ export default function SupportTicketsPage() {
|
||||
const [batchPreviewOpen, setBatchPreviewOpen] = useState(false);
|
||||
const [batchPreview, setBatchPreview] = useState<BatchReviewPreviewItem[]>([]);
|
||||
const [batchConfirming, setBatchConfirming] = useState(false);
|
||||
const [batchStatusOpen, setBatchStatusOpen] = useState(false);
|
||||
const [batchStatusSaving, setBatchStatusSaving] = useState(false);
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [editSaving, setEditSaving] = useState(false);
|
||||
const [reviewDecision, setReviewDecision] = useState<'APPROVE' | 'REJECT'>('APPROVE');
|
||||
|
||||
const [createForm] = Form.useForm();
|
||||
const [editForm] = Form.useForm();
|
||||
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 [batchStatusForm] = Form.useForm<{
|
||||
status: SupportTicketStatusDto;
|
||||
rejectReason?: string;
|
||||
note?: string;
|
||||
}>();
|
||||
|
||||
const isSuperAdmin = profile?.adminRole === 'SUPER_ADMIN';
|
||||
|
||||
@@ -117,6 +137,7 @@ export default function SupportTicketsPage() {
|
||||
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('技术支持工单已创建,等待最高管理员评审');
|
||||
@@ -166,13 +187,80 @@ export default function SupportTicketsPage() {
|
||||
const summary = [detail!.title, detail!.content].filter(Boolean).join('\n').slice(0, 500);
|
||||
tasksForm.setFieldsValue({
|
||||
tasks: [{ content: summary || detail!.title, type: mapSupportTicketTypeToDevPlanTask(detail!.ticketType) }],
|
||||
dispatchToWecom: localStorage.getItem(DISPATCH_WECOM_STORAGE_KEY) !== 'false',
|
||||
dispatchSupplement: DEFAULT_DISPATCH_SUPPLEMENT,
|
||||
});
|
||||
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 submitCreateTasks() {
|
||||
const values = await tasksForm.validateFields();
|
||||
const note = reviewForm.getFieldValue('note') as string | undefined;
|
||||
localStorage.setItem(DISPATCH_WECOM_STORAGE_KEY, values.dispatchToWecom ? 'true' : 'false');
|
||||
setActing(true);
|
||||
try {
|
||||
await request(`/admin/support-tickets/${detail!.id}/review`, {
|
||||
@@ -181,9 +269,11 @@ export default function SupportTicketsPage() {
|
||||
decision: 'APPROVE',
|
||||
note: note?.trim() || undefined,
|
||||
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);
|
||||
setDrawerOpen(false);
|
||||
reload();
|
||||
@@ -309,9 +399,12 @@ export default function SupportTicketsPage() {
|
||||
if (!detail) return null;
|
||||
if (detail.status === 'PENDING_REVIEW' && isSuperAdmin) {
|
||||
return (
|
||||
<Button type="primary" loading={acting} onClick={openReview}>
|
||||
审批
|
||||
</Button>
|
||||
<Space>
|
||||
<Button onClick={openEdit}>编辑</Button>
|
||||
<Button type="primary" loading={acting} onClick={openReview}>
|
||||
审批
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
if (detail.status === 'DEVELOPING') {
|
||||
@@ -346,9 +439,20 @@ export default function SupportTicketsPage() {
|
||||
</Typography.Title>
|
||||
<Space>
|
||||
{isSuperAdmin ? (
|
||||
<Button disabled={!selectedRowKeys.length} loading={acting} onClick={() => void startBatchPreview()}>
|
||||
批量审核
|
||||
</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}
|
||||
<Button type="primary" onClick={() => setCreateOpen(true)}>
|
||||
创建工单
|
||||
@@ -612,6 +716,18 @@ export default function SupportTicketsPage() {
|
||||
</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>
|
||||
|
||||
{/* 关联开发任务 */}
|
||||
@@ -661,7 +777,7 @@ export default function SupportTicketsPage() {
|
||||
</Drawer>
|
||||
|
||||
<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 }]}>
|
||||
<Select options={TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
@@ -674,6 +790,27 @@ export default function SupportTicketsPage() {
|
||||
<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>
|
||||
|
||||
@@ -725,6 +862,86 @@ export default function SupportTicketsPage() {
|
||||
</>
|
||||
)}
|
||||
</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>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
||||
import type { PackageFormItem } from '../lib/storePackages';
|
||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||
import { emptyPackage } from '../lib/storePackages';
|
||||
import OssUploadField from './OssUploadField';
|
||||
|
||||
type Props = {
|
||||
items: PackageFormItem[];
|
||||
@@ -129,6 +130,16 @@ export default function StorePackagesForm({ items, onChange, disabled, embedded
|
||||
</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">
|
||||
<label>其他说明</label>
|
||||
<div className="partner-field-input">
|
||||
|
||||
@@ -10,6 +10,7 @@ export function emptyPackage(index = 0): PackageFormItem {
|
||||
dishes: '',
|
||||
usableTime: '',
|
||||
otherNotes: '',
|
||||
imageUrl: '',
|
||||
sortOrder: index,
|
||||
};
|
||||
}
|
||||
@@ -22,9 +23,13 @@ export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormIt
|
||||
dishes: item.dishes.trim(),
|
||||
usableTime: item.usableTime?.trim() || '',
|
||||
otherNotes: item.otherNotes?.trim() || '',
|
||||
imageUrl: item.imageUrl?.trim() || '',
|
||||
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 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||
import { emptyPackage, type PackageFormItem } from '../lib/storePackages';
|
||||
import { uploadFileToOss } from '../lib/upload';
|
||||
|
||||
type Props = {
|
||||
items: PackageFormItem[];
|
||||
@@ -10,6 +11,19 @@ type Props = {
|
||||
|
||||
export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
||||
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>) {
|
||||
onChange(items.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
||||
@@ -116,6 +130,36 @@ export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
||||
/>
|
||||
</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">
|
||||
<span className="shop-packages-label">其他说明</span>
|
||||
<input
|
||||
|
||||
@@ -10,6 +10,7 @@ export function emptyPackage(index = 0): PackageFormItem {
|
||||
dishes: '',
|
||||
usableTime: '',
|
||||
otherNotes: '',
|
||||
imageUrl: '',
|
||||
sortOrder: index,
|
||||
};
|
||||
}
|
||||
@@ -22,9 +23,13 @@ export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormIt
|
||||
dishes: item.dishes.trim(),
|
||||
usableTime: item.usableTime?.trim() || '',
|
||||
otherNotes: item.otherNotes?.trim() || '',
|
||||
imageUrl: item.imageUrl?.trim() || '',
|
||||
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 {
|
||||
|
||||
@@ -80,7 +80,6 @@ export default function WithdrawPage() {
|
||||
const canApply =
|
||||
!!summary?.isPrimary &&
|
||||
summary.availableAmount > 0 &&
|
||||
!summary.hasPendingRequest &&
|
||||
summary.hasBankAccount &&
|
||||
!submitting;
|
||||
|
||||
@@ -126,7 +125,6 @@ export default function WithdrawPage() {
|
||||
info
|
||||
</span>
|
||||
单日上限 ¥{formatMoney(summary?.dailyLimit ?? 5000)}
|
||||
{summary?.hasPendingRequest ? ' · 已有待审核申请' : ''}
|
||||
{!summary?.hasBankAccount ? ' · 请先完善收款账户' : ''}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
import { useState } from 'react';
|
||||
import { View, Image, Swiper, SwiperItem } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
type ProductCarouselProps = {
|
||||
images: string[];
|
||||
alt: string;
|
||||
variant?: 'home' | 'detail' | 'store';
|
||||
previewable?: boolean;
|
||||
};
|
||||
|
||||
/** 商品/门店轮播(对齐 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 [activeIndex, setActiveIndex] = useState(0);
|
||||
const prefix =
|
||||
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 (
|
||||
<View className={`${prefix}-wrap`}>
|
||||
<Swiper
|
||||
@@ -24,7 +38,13 @@ export default function ProductCarousel({ images, alt, variant = 'detail' }: Pro
|
||||
{slides.map((src, index) => (
|
||||
<SwiperItem key={`${src}-${index}`} className={`${prefix}-item`}>
|
||||
{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`} />
|
||||
)}
|
||||
|
||||
@@ -34,6 +34,7 @@ type StorePackage = {
|
||||
dishes: string;
|
||||
usableTime?: string | null;
|
||||
otherNotes?: string | null;
|
||||
imageUrl?: string | null;
|
||||
sortOrder?: number;
|
||||
};
|
||||
|
||||
@@ -315,11 +316,7 @@ export default function StoreDetailPage() {
|
||||
}
|
||||
|
||||
const envPhotos = envPhotoUrls(store);
|
||||
const images = uniqueUrls([
|
||||
store.coverUrl,
|
||||
...(store.carouselUrls || []),
|
||||
...envPhotos,
|
||||
]);
|
||||
const heroImages = uniqueUrls([store.coverUrl, ...(store.carouselUrls || [])]);
|
||||
|
||||
const intro = store.intro?.trim() || '';
|
||||
const benefitRuleRaw = store.benefitUsageRule?.trim() || '';
|
||||
@@ -346,7 +343,7 @@ export default function StoreDetailPage() {
|
||||
/>
|
||||
|
||||
<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 className="store-detail-info-card">
|
||||
@@ -404,6 +401,9 @@ export default function StoreDetailPage() {
|
||||
<Text className="store-detail-section-title">门店套餐</Text>
|
||||
{store.packages.map((pkg, index) => (
|
||||
<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-body">
|
||||
{formatRedeemAmountYuan(pkg.price)} 元 · {pkg.dishes}
|
||||
@@ -443,7 +443,7 @@ export default function StoreDetailPage() {
|
||||
className="store-detail-env-item"
|
||||
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>
|
||||
|
||||
@@ -176,17 +176,18 @@
|
||||
|
||||
.store-detail-env-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.store-detail-env-item {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
aspect-ratio: 4 / 3;
|
||||
border-radius: var(--radius-md, 8px);
|
||||
overflow: hidden;
|
||||
background: var(--color-surface-container);
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.store-detail-env-img {
|
||||
@@ -240,6 +241,14 @@
|
||||
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 {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,6 @@ describe('validateStoreWithdraw', () => {
|
||||
requestAmount: 200,
|
||||
todayApplied: 0,
|
||||
dailyLimit: 5000,
|
||||
hasPendingRequest: false,
|
||||
hasBankAccount: true,
|
||||
};
|
||||
|
||||
@@ -261,8 +260,7 @@ describe('validateStoreWithdraw', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects pending request / missing bank / over available', () => {
|
||||
expect(validateStoreWithdraw({ ...base, hasPendingRequest: true }).ok).toBe(false);
|
||||
it('rejects missing bank / over available', () => {
|
||||
expect(validateStoreWithdraw({ ...base, hasBankAccount: false }).ok).toBe(false);
|
||||
expect(validateStoreWithdraw({ ...base, requestAmount: 1001 }).ok).toBe(false);
|
||||
});
|
||||
|
||||
@@ -105,20 +105,16 @@ export type ValidateStoreWithdrawInput = {
|
||||
requestAmount: number;
|
||||
todayApplied: number;
|
||||
dailyLimit: number;
|
||||
hasPendingRequest: boolean;
|
||||
hasBankAccount: boolean;
|
||||
};
|
||||
|
||||
/** 门店未出账提现护栏(FIN-002 单日上限 + 幂等/账户) */
|
||||
/** 门店未出账提现护栏(FIN-002 单日上限 + 账户) */
|
||||
export function validateStoreWithdraw(
|
||||
input: ValidateStoreWithdrawInput,
|
||||
): { ok: boolean; message?: string } {
|
||||
if (!input.hasBankAccount) {
|
||||
return { ok: false, message: '请先完善入驻收款账户后再提现' };
|
||||
}
|
||||
if (input.hasPendingRequest) {
|
||||
return { ok: false, message: '已有待审核提现申请,请等待处理完成' };
|
||||
}
|
||||
if (!(input.requestAmount > 0)) {
|
||||
return { ok: false, message: '提现金额必须大于 0' };
|
||||
}
|
||||
@@ -354,3 +350,4 @@ export function orderTabToStatuses(tab: string): string[] | undefined {
|
||||
|
||||
export * from './city-partner';
|
||||
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 {
|
||||
|
||||
id: string;
|
||||
|
||||
@@ -63,7 +63,6 @@ export interface StoreWithdrawSummaryDto {
|
||||
remainingDailyLimit: number;
|
||||
isPrimary: boolean;
|
||||
hasBankAccount: boolean;
|
||||
hasPendingRequest: boolean;
|
||||
bankAccount?: StoreWithdrawBankAccountDto | null;
|
||||
}
|
||||
|
||||
@@ -184,6 +183,9 @@ export const STORE_SETTLEMENT_DEFAULT_RATE = 0.6;
|
||||
/** 酒厂账单结算比例(酒单实付 × 比例),暂定 30% */
|
||||
export const WINERY_SETTLEMENT_RATE = 0.3;
|
||||
|
||||
/** 酒厂账单出账滞后自然日(T+3:支付日 + 3 天后纳入账单) */
|
||||
export const WINERY_SETTLEMENT_LAG_DAYS = 3;
|
||||
|
||||
export type { LogisticsSettlementMethod } from './enums';
|
||||
export { LOGISTICS_SETTLEMENT_METHOD_LABELS } from './enums';
|
||||
import type { LogisticsSettlementMethod } from './enums';
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface StorePackageItemDto {
|
||||
dishes: string;
|
||||
usableTime?: string | null;
|
||||
otherNotes?: string | null;
|
||||
imageUrl?: string | null;
|
||||
sortOrder: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ export interface SupportTicketDto {
|
||||
reviewerName?: string | null;
|
||||
reviewedAt?: string | null;
|
||||
remark?: string | null;
|
||||
attachmentUrls?: string[] | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
completedAt?: string | null;
|
||||
@@ -57,6 +58,15 @@ export interface CreateSupportTicketRequest {
|
||||
title: string;
|
||||
content?: string;
|
||||
remark?: string;
|
||||
attachmentUrls?: string[];
|
||||
}
|
||||
|
||||
export interface UpdateSupportTicketRequest {
|
||||
ticketType?: SupportTicketTypeDto;
|
||||
title?: string;
|
||||
content?: string;
|
||||
remark?: string;
|
||||
attachmentUrls?: string[];
|
||||
}
|
||||
|
||||
export interface RejectSupportTicketRequest {
|
||||
@@ -73,6 +83,8 @@ export interface ReviewSupportTicketRequest {
|
||||
rejectReason?: string;
|
||||
note?: string;
|
||||
tasks?: CreateDevPlanTaskFromTicketInput[];
|
||||
dispatchToWecom?: boolean;
|
||||
dispatchSupplement?: string;
|
||||
}
|
||||
|
||||
export interface SupportTicketLinkedTaskDto {
|
||||
@@ -108,3 +120,10 @@ export interface BatchReviewConfirmItem {
|
||||
export interface BatchReviewConfirmRequest {
|
||||
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)
|
||||
reviewedAt DateTime? @map("reviewed_at") @db.DateTime(3)
|
||||
remark String? @db.VarChar(512)
|
||||
attachmentUrls Json? @map("attachment_urls")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
completedAt DateTime? @map("completed_at") @db.DateTime(3)
|
||||
@@ -1278,6 +1279,7 @@ model StorePackage {
|
||||
dishes String @db.Text
|
||||
usableTime String? @map("usable_time") @db.VarChar(256)
|
||||
otherNotes String? @map("other_notes") @db.VarChar(512)
|
||||
imageUrl String? @map("image_url") @db.VarChar(512)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
|
||||
@@ -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 { IsInt, Min } from 'class-validator';
|
||||
|
||||
@@ -41,6 +41,58 @@ export class CreateSupportTicketDto {
|
||||
@IsString()
|
||||
@MaxLength(512)
|
||||
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 RejectSupportTicketDto {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import type { SupportTicketStatus, SupportTicketType } from '@prisma/client';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import type { CreateDevPlanTaskFromTicketInput } from '@dukang/shared-types';
|
||||
import { validateSupportTicketStatusTransition } from '@dukang/domain';
|
||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||
import { AlertService } from '../../common/alert/alert.service';
|
||||
@@ -16,8 +17,22 @@ import type {
|
||||
RejectSupportTicketDto,
|
||||
SupportTicketListQueryDto,
|
||||
SupportTicketRemarkDto,
|
||||
UpdateSupportTicketDto,
|
||||
} 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() {
|
||||
return `ST${Date.now()}${Math.floor(Math.random() * 900 + 100)}`;
|
||||
}
|
||||
@@ -43,6 +58,9 @@ export class SupportTicketService {
|
||||
title: dto.title.trim(),
|
||||
content: dto.content?.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,
|
||||
creatorName: creator.name,
|
||||
},
|
||||
@@ -73,7 +91,80 @@ export class SupportTicketService {
|
||||
].join('\n'),
|
||||
)
|
||||
.catch(() => {});
|
||||
return serializeBigInt(ticket);
|
||||
return serializeBigInt(mapSupportTicketRow(ticket));
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -98,7 +189,7 @@ export class SupportTicketService {
|
||||
]);
|
||||
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds(items.map((i) => i.id));
|
||||
const enriched = items.map((ticket) => ({
|
||||
...ticket,
|
||||
...mapSupportTicketRow(ticket),
|
||||
linkedTasks: (linkedMap.get(String(ticket.id)) ?? []).map((t) => ({
|
||||
id: t.id,
|
||||
taskNo: t.taskNo,
|
||||
@@ -114,7 +205,7 @@ export class SupportTicketService {
|
||||
if (!ticket) throw new NotFoundException('技术支持工单不存在');
|
||||
const linkedMap = await this.devPlan.listLinkedTasksByTicketIds([id]);
|
||||
return serializeBigInt({
|
||||
...ticket,
|
||||
...mapSupportTicketRow(ticket),
|
||||
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
||||
id: t.id,
|
||||
taskNo: t.taskNo,
|
||||
@@ -189,6 +280,8 @@ export class SupportTicketService {
|
||||
rejectReason?: string;
|
||||
note?: string;
|
||||
tasks?: CreateDevPlanTaskFromTicketInput[];
|
||||
dispatchToWecom?: boolean;
|
||||
dispatchSupplement?: string;
|
||||
},
|
||||
) {
|
||||
if (input.decision === 'REJECT') {
|
||||
@@ -202,7 +295,7 @@ export class SupportTicketService {
|
||||
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({
|
||||
where: { id },
|
||||
@@ -214,9 +307,31 @@ export class SupportTicketService {
|
||||
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]);
|
||||
return serializeBigInt({
|
||||
...updated,
|
||||
...mapSupportTicketRow(updated),
|
||||
linkedTasks: (linkedMap.get(String(id)) ?? []).map((t) => ({
|
||||
id: t.id,
|
||||
taskNo: t.taskNo,
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
UpdateDevPlanSettingsDto,
|
||||
UpdateDevPlanTaskDto,
|
||||
UpdateDevPlanVersionDto,
|
||||
DevPlanTaskBatchUpdateDto,
|
||||
} from './dto/dev-plan.dto';
|
||||
|
||||
@Controller('admin/dev-plan')
|
||||
@@ -91,6 +92,12 @@ export class AdminDevPlanController {
|
||||
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')
|
||||
listVersions(
|
||||
@Query('status') status?: string,
|
||||
|
||||
@@ -48,6 +48,8 @@ import type {
|
||||
|
||||
DevPlanTaskDispatchDto,
|
||||
|
||||
DevPlanTaskBatchUpdateDto,
|
||||
|
||||
DevPlanTaskListQueryDto,
|
||||
|
||||
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 {
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsIn,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { ArrayMinSize, IsArray, IsBoolean, IsIn, IsNotEmpty, IsOptional, IsString, ValidateIf, ValidateNested } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
DEV_PLAN_TASK_STATUSES,
|
||||
@@ -161,6 +152,29 @@ export class ReviewSupportTicketDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => 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 {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Get,
|
||||
NotFoundException,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
@@ -22,6 +23,8 @@ import {
|
||||
RejectSupportTicketDto,
|
||||
SupportTicketListQueryDto,
|
||||
SupportTicketRemarkDto,
|
||||
UpdateSupportTicketDto,
|
||||
BatchUpdateSupportTicketStatusDto,
|
||||
} from '../common/dto/support-ticket.dto';
|
||||
import {
|
||||
BatchReviewConfirmDto,
|
||||
@@ -83,11 +86,39 @@ export class AdminSupportTicketsController {
|
||||
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,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
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')
|
||||
@UseGuards(SuperAdminGuard)
|
||||
@HqOperation({
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Prisma } from '@prisma/client';
|
||||
import {
|
||||
DEFAULT_STORE_WITHDRAW_DAILY_LIMIT,
|
||||
DEFAULT_XFX_LOGISTICS_PRICING,
|
||||
WINERY_SETTLEMENT_LAG_DAYS,
|
||||
WINERY_SETTLEMENT_RATE,
|
||||
} from '@dukang/shared-types';
|
||||
import {
|
||||
@@ -40,6 +41,15 @@ function dayWindow(anchor = new Date()) {
|
||||
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) {
|
||||
return Math.round(n * 100) / 100;
|
||||
}
|
||||
@@ -205,7 +215,6 @@ export class SettlementService {
|
||||
remainingDailyLimit: Math.max(0, round2(dailyLimit - todayApplied)),
|
||||
isPrimary: account.isPrimary === 1,
|
||||
hasBankAccount,
|
||||
hasPendingRequest: !!pending,
|
||||
bankAccount: {
|
||||
bankAccountName: account.bankAccountName,
|
||||
bankAccountNo: account.bankAccountNo,
|
||||
@@ -264,7 +273,6 @@ export class SettlementService {
|
||||
requestAmount,
|
||||
todayApplied,
|
||||
dailyLimit,
|
||||
hasPendingRequest: !!pending,
|
||||
hasBankAccount,
|
||||
});
|
||||
if (!guard.ok) throw new BadRequestException(guard.message);
|
||||
@@ -276,14 +284,6 @@ export class SettlementService {
|
||||
if (!picked.ok) throw new BadRequestException(picked.message);
|
||||
|
||||
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 locked = await tx.storePayout.findMany({
|
||||
where: {
|
||||
@@ -1573,7 +1573,7 @@ export class SettlementService {
|
||||
// ─── Winery bills ────────────────────────────────────
|
||||
|
||||
async generateWineryBillForDay(anchor = new Date()) {
|
||||
const { start, end, billDate } = dayWindow(anchor);
|
||||
const { start, end, billDate } = wineryDayWindow(anchor);
|
||||
const rate = WINERY_SETTLEMENT_RATE;
|
||||
|
||||
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()
|
||||
? String(item.otherNotes).trim()
|
||||
: null;
|
||||
const imageUrl = item.imageUrl != null && String(item.imageUrl).trim()
|
||||
? String(item.imageUrl).trim()
|
||||
: null;
|
||||
const sortOrder = item.sortOrder != null ? Number(item.sortOrder) : index;
|
||||
return {
|
||||
name,
|
||||
@@ -51,6 +54,7 @@ export class StorePackageService {
|
||||
dishes,
|
||||
usableTime,
|
||||
otherNotes,
|
||||
imageUrl,
|
||||
sortOrder: Number.isFinite(sortOrder) ? sortOrder : index,
|
||||
};
|
||||
}
|
||||
@@ -62,6 +66,7 @@ export class StorePackageService {
|
||||
dishes: string;
|
||||
usableTime: string | null;
|
||||
otherNotes: string | null;
|
||||
imageUrl: string | null;
|
||||
sortOrder: number;
|
||||
}) {
|
||||
return {
|
||||
@@ -71,6 +76,7 @@ export class StorePackageService {
|
||||
dishes: row.dishes,
|
||||
usableTime: row.usableTime,
|
||||
otherNotes: row.otherNotes,
|
||||
imageUrl: row.imageUrl,
|
||||
sortOrder: row.sortOrder,
|
||||
};
|
||||
}
|
||||
@@ -214,6 +220,7 @@ export class StorePackageService {
|
||||
dishes: pkg.dishes,
|
||||
usableTime: pkg.usableTime ?? null,
|
||||
otherNotes: pkg.otherNotes ?? null,
|
||||
imageUrl: pkg.imageUrl ?? null,
|
||||
sortOrder: pkg.sortOrder ?? index,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -225,6 +225,7 @@ export class StoreService {
|
||||
dishes: p.dishes,
|
||||
usableTime: p.usableTime,
|
||||
otherNotes: p.otherNotes,
|
||||
imageUrl: p.imageUrl,
|
||||
sortOrder: p.sortOrder,
|
||||
})),
|
||||
}),
|
||||
|
||||
@@ -593,6 +593,22 @@ export class TradeService {
|
||||
try {
|
||||
refundResult = await this.payProvider.refundOrder(orderId, outRefundNo, remark);
|
||||
} 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({
|
||||
level: 'P0',
|
||||
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) |
|
||||
|
||||
### 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. 背景与目标
|
||||
|
||||
+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-07-12 | **P0 已执行**:C2~C7、C14 代码与文档对齐;§1 改为计划+状态表 |
|
||||
| 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