后端迁移快手Cloud核心履约
This commit is contained in:
+28
-10
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
import { createTaskEvent } from "../../repositories/task-event-repo.js";
|
import { createTaskEvent } from "../../repositories/task-event-repo.js";
|
||||||
import { getOrderById } from "../../repositories/order-repo.js";
|
import { getOrderById } from "../../repositories/order-repo.js";
|
||||||
import { updateTask } from "../../repositories/task-repo.js";
|
import { updateTask } from "../../repositories/task-repo.js";
|
||||||
@@ -46,6 +44,8 @@ import { nowIso } from "../../utils/time.js";
|
|||||||
|
|
||||||
const KUAISHOU_CLOUD_FIXED_VN_KEY = "1";
|
const KUAISHOU_CLOUD_FIXED_VN_KEY = "1";
|
||||||
|
|
||||||
|
type JsonObject = Record<string, any>;
|
||||||
|
|
||||||
export function isKuaishouCloudTask(task) {
|
export function isKuaishouCloudTask(task) {
|
||||||
return String(task?.executor_key || "").trim() === "kuaishou_ct_assisted";
|
return String(task?.executor_key || "").trim() === "kuaishou_ct_assisted";
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,10 @@ export async function ensureTaskClaimLink(task) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function prepareKuaishouCloudFulfillmentTask(task, options = {}) {
|
export async function prepareKuaishouCloudFulfillmentTask(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -534,7 +537,10 @@ export async function prepareKuaishouCloudFulfillmentTask(task, options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function refreshKuaishouCloudTaskBindUrl(task, options = {}) {
|
export async function refreshKuaishouCloudTaskBindUrl(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -704,7 +710,10 @@ export async function refreshKuaishouCloudTaskBindUrl(task, options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function probeKuaishouCloudTaskBindUrl(task, options = {}) {
|
export async function probeKuaishouCloudTaskBindUrl(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -800,7 +809,7 @@ export async function probeKuaishouCloudTaskBindUrl(task, options = {}) {
|
|||||||
*/
|
*/
|
||||||
async function markKuaishouCloudBindUrlRefreshFailed(
|
async function markKuaishouCloudBindUrlRefreshFailed(
|
||||||
task,
|
task,
|
||||||
{ taskContext, flow, now, actor, error } = {}
|
{ taskContext, flow, now, actor, error }: JsonObject = {}
|
||||||
) {
|
) {
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
error instanceof Error
|
error instanceof Error
|
||||||
@@ -864,7 +873,10 @@ async function markKuaishouCloudBindUrlRefreshFailed(
|
|||||||
return updatedTask;
|
return updatedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function refreshKuaishouCloudTaskRoleInfo(task, options = {}) {
|
export async function refreshKuaishouCloudTaskRoleInfo(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -985,7 +997,10 @@ export async function refreshKuaishouCloudTaskRoleInfo(task, options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function dispatchKuaishouCloudFulfillmentTask(task, options = {}) {
|
export async function dispatchKuaishouCloudFulfillmentTask(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -1117,7 +1132,10 @@ export async function dispatchKuaishouCloudFulfillmentTask(task, options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnKuaishouCloudFulfillmentTask(task, options = {}) {
|
export async function returnKuaishouCloudFulfillmentTask(
|
||||||
|
task,
|
||||||
|
options: JsonObject = {}
|
||||||
|
) {
|
||||||
if (!isKuaishouCloudTask(task)) {
|
if (!isKuaishouCloudTask(task)) {
|
||||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||||
statusCode: 409,
|
statusCode: 409,
|
||||||
@@ -1424,7 +1442,7 @@ function resolveKuaishouCloudVnKeyCandidates(_input = {}) {
|
|||||||
return [KUAISHOU_CLOUD_FIXED_VN_KEY];
|
return [KUAISHOU_CLOUD_FIXED_VN_KEY];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function prepareKuaishouCloudBindResourceWithFallback(input = {}) {
|
async function prepareKuaishouCloudBindResourceWithFallback(input: JsonObject = {}) {
|
||||||
const { cloudContext = {}, vnKeyCandidates = [] } = input;
|
const { cloudContext = {}, vnKeyCandidates = [] } = input;
|
||||||
const candidates = Array.isArray(vnKeyCandidates) ? vnKeyCandidates : [];
|
const candidates = Array.isArray(vnKeyCandidates) ? vnKeyCandidates : [];
|
||||||
let lastError = null;
|
let lastError = null;
|
||||||
@@ -695,6 +695,14 @@
|
|||||||
- `npm run typecheck`
|
- `npm run typecheck`
|
||||||
- `npm run build`
|
- `npm run build`
|
||||||
- `npm test` 共 139 个用例通过
|
- `npm test` 共 139 个用例通过
|
||||||
|
171. 快手 Cloud 核心履约任务服务迁移到 `.ts`:
|
||||||
|
- `src/services/fulfillment/kuaishou-cloud-task-service.ts`
|
||||||
|
172. 快手 Cloud 绑定准备、过期链接刷新、绑定链接探测、角色信息刷新、cloudtentacles 发货、退还虚拟号、快手电子券核销、履约 flow 归一化与敏感信息脱敏已进入 TS 编译链路;入口 options、失败标记 input 与虚拟号准备 input 补齐动态对象类型
|
||||||
|
173. Docker 内验证通过:
|
||||||
|
- `src/services/order/kuaishou-cloud-fulfillment-config-service.test.js` 相关用例通过
|
||||||
|
- `npm run typecheck`
|
||||||
|
- `npm run build`
|
||||||
|
- `npm test` 共 139 个用例通过
|
||||||
|
|
||||||
## 下一步建议
|
## 下一步建议
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user