feat: 新增项目中心——按项目组织任务/任务群/总群并一键推送

- 新表 projects / project_group_chats,partners 加 partner_type/wecom_userid,tasks 加 project_id(迁移 0010)
- 项目 CRUD、总群成员配置、任务群人工映射(群主→合作方)、任务挂项目
- 推送:总群成员逐人应用消息 + 任务群按群主企业群发,结果分项回显
This commit is contained in:
ABAPPLO
2026-08-31 16:35:17 +08:00
parent ed13262166
commit a6f5a5fd4a
11 changed files with 2557 additions and 15 deletions

View File

@@ -12,6 +12,7 @@ export type CreateDistributionTaskInput = {
dueAt: string;
platform?: "小红书" | "抖音";
contentFormat?: "image_text" | "video";
projectId?: string;
};
export type CreateScreenshotTaskInput = {
@@ -22,6 +23,7 @@ export type CreateScreenshotTaskInput = {
instructions: string;
quantity: number;
exampleImageKey?: string;
projectId?: string;
};
export type DistributionTaskCreation = {
@@ -140,10 +142,10 @@ async function insertTaskFromSource(
.prepare(
`INSERT INTO tasks
(id, name, brand, quantity, claimed_quantity, due_at, status,
platform, content_format,
platform, content_format, project_id,
source_url, source_sheet_id, source_sheet_name, source_synced_at,
share_token)
VALUES (?, ?, ?, ?, 0, ?, 'importing', ?, ?, ?, ?, ?, ?, ?)`,
VALUES (?, ?, ?, ?, 0, ?, 'importing', ?, ?, ?, ?, ?, ?, ?, ?)`,
)
.bind(
taskId,
@@ -153,6 +155,7 @@ async function insertTaskFromSource(
input.dueAt,
input.platform ?? "小红书",
input.contentFormat ?? "image_text",
input.projectId,
source.url,
source.sheetId,
source.sheetName,
@@ -220,6 +223,7 @@ export async function createDistributionTask(
dueAt: normalizedDueDate(rawInput.dueAt),
platform: rawInput.platform === "抖音" ? "抖音" : "小红书",
contentFormat: rawInput.contentFormat === "video" ? "video" : "image_text",
projectId: normalizedValue(rawInput.projectId ?? ""),
};
if (!input.feishuUrl || !input.name || !input.brand) {
throw new Error("请补全飞书链接、任务名称和品牌/项目");
@@ -281,6 +285,7 @@ export async function createScreenshotTask(
instructions: normalizedValue(rawInput.instructions),
quantity: Math.floor(Number(rawInput.quantity)),
exampleImageKey: normalizedValue(rawInput.exampleImageKey ?? ""),
projectId: normalizedValue(rawInput.projectId ?? ""),
};
if (!input.name || !input.brand || !input.keyword || !input.instructions) {
throw new Error("请补全任务名称、品牌/项目、搜索关键词和任务说明");
@@ -304,9 +309,9 @@ export async function createScreenshotTask(
.prepare(
`INSERT INTO tasks
(id, name, brand, quantity, claimed_quantity, due_at, status,
task_type, source_url, source_sheet_id, source_sheet_name,
task_type, project_id, source_url, source_sheet_id, source_sheet_name,
share_token, collection_days)
VALUES (?, ?, ?, ?, 0, ?, 'active', 'screenshot_collect', '', '', '', ?, '[]')`,
VALUES (?, ?, ?, ?, 0, ?, 'active', 'screenshot_collect', ?, '', '', '', ?, '[]')`,
)
.bind(
taskId,
@@ -314,6 +319,7 @@ export async function createScreenshotTask(
input.brand,
input.quantity,
input.dueAt,
input.projectId,
shareToken,
)
.run();