补齐 admin 100108 联调入口;track 优先用缓存签收照,上传失败回退 dataURI,日志截断大图。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -47,13 +47,27 @@ export function sceneForXfxCmd(cmd: string) {
|
||||
return CMD_SCENE[cmd] ?? `XFX_CMD_${cmd}`;
|
||||
}
|
||||
|
||||
/** 签收照等大字段入库前截断,避免撑爆 JSON / 影响后续业务返回 */
|
||||
function sanitizeCourierResponseBody(scene: string, body: unknown): Record<string, unknown> | undefined {
|
||||
if (body === undefined) return undefined;
|
||||
if (typeof body !== 'object' || body === null) {
|
||||
return { value: body };
|
||||
}
|
||||
const root = { ...(body as Record<string, unknown>) };
|
||||
if (scene === 'GET_SIGN_PHOTOS' && Array.isArray(root.data)) {
|
||||
const photos = root.data as unknown[];
|
||||
root.data = photos.map((item) => {
|
||||
if (typeof item !== 'string') return item;
|
||||
if (item.length <= 120) return item;
|
||||
return `${item.slice(0, 80)}…(len=${item.length})`;
|
||||
});
|
||||
root.dataCount = photos.length;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
export async function logCourierCall(prisma: PrismaService, input: LogCourierCallInput) {
|
||||
const responseBody =
|
||||
input.responseBody === undefined
|
||||
? undefined
|
||||
: typeof input.responseBody === 'object' && input.responseBody !== null
|
||||
? (input.responseBody as Record<string, unknown>)
|
||||
: { value: input.responseBody };
|
||||
const responseBody = sanitizeCourierResponseBody(input.scene, input.responseBody);
|
||||
|
||||
const row = await prisma.logThirdParty.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user