fix: 补全拦截链路操作日志 — Qimen/OpenAPI/inbox AI 写入 ORDER_INTERCEPT_REQUEST
修复: 3处拦截入口缺失操作日志 - Qimen cancel: 拦截路径补 ORDER_INTERCEPT_REQUEST - OpenAPI cancel: 拦截路径补 ORDER_INTERCEPT_REQUEST - inbox AI interceptWaybill + 取消拦截: 补 ORDER_INTERCEPT_REQUEST
This commit is contained in:
parent
a024a20356
commit
2795ae0758
@ -1032,6 +1032,23 @@ class InboxFunctionsService extends Service {
|
||||
{ is_intercept: 'Y' },
|
||||
{ where: { order_id: { [ctx.app.Sequelize.Op.in]: interceptOrderIds }, warehouse_id: warehouseId } }
|
||||
);
|
||||
// 写入操作日志(失败不影响主流程)
|
||||
try {
|
||||
const logService = ctx.service?.systems?.operationLog;
|
||||
if (logService && typeof logService.createOperationLogs === 'function') {
|
||||
await logService.createOperationLogs(
|
||||
interceptOrderIds.map(oid => ({
|
||||
businessType: 'order',
|
||||
businessId: String(warehouseId),
|
||||
operationCode: 'ORDER_INTERCEPT_REQUEST',
|
||||
operator: { id: '0', name: groupName || 'AI系统' },
|
||||
extras: { warehouseId, orderId: oid, newInterceptStatus: 'requested' },
|
||||
}))
|
||||
);
|
||||
}
|
||||
} catch (logErr) {
|
||||
ctx.logger.warn(`[inbox functions] 写入拦截操作日志失败: ${logErr.message}`);
|
||||
}
|
||||
ctx.logger.info(
|
||||
`[inbox functions] 设置拦截状态: ${interceptOrderIds.length} 个订单`
|
||||
);
|
||||
@ -1367,6 +1384,23 @@ class InboxFunctionsService extends Service {
|
||||
{ is_intercept: 'Y' },
|
||||
{ where: { order_id: { [ctx.app.Sequelize.Op.in]: interceptOrderIds }, warehouse_id: warehouseId } }
|
||||
);
|
||||
// 写入操作日志(失败不影响主流程)
|
||||
try {
|
||||
const logSvc = ctx.service?.systems?.operationLog;
|
||||
if (logSvc && typeof logSvc.createOperationLogs === 'function') {
|
||||
await logSvc.createOperationLogs(
|
||||
interceptOrderIds.map(oid => ({
|
||||
businessType: 'order',
|
||||
businessId: String(warehouseId),
|
||||
operationCode: 'ORDER_INTERCEPT_REQUEST',
|
||||
operator: { id: '0', name: groupName || 'AI系统' },
|
||||
extras: { warehouseId, orderId: oid, newInterceptStatus: 'requested' },
|
||||
}))
|
||||
);
|
||||
}
|
||||
} catch (logErr) {
|
||||
ctx.logger.warn(`[inbox functions] 取消拦截-写入操作日志失败: ${logErr.message}`);
|
||||
}
|
||||
ctx.logger.info(`[inbox functions] 取消拦截-设置拦截状态: ${interceptOrderIds.length} 个订单`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,27 @@ class OpenapiOrderService extends MainService {
|
||||
|
||||
await transaction.commit();
|
||||
|
||||
// 写入拦截操作日志(失败不影响主流程)
|
||||
try {
|
||||
const { ctx: ctx2 } = this;
|
||||
if (ctx2.model && ctx2.model.OperationLog) {
|
||||
const whId2 = ctx2.user && ctx2.user.store_id ? Number(ctx2.user.store_id) : 0;
|
||||
await ctx2.model.OperationLog.create({
|
||||
business_type: 'order',
|
||||
business_id: String(existingOrder.id),
|
||||
operation_code: 'ORDER_INTERCEPT_REQUEST',
|
||||
operator_id: ctx2.user?.employees_id || ctx2.user?.id || null,
|
||||
operator_name: ctx2.user?.employees_name || 'OpenAPI',
|
||||
external_log_type: 'NONE',
|
||||
warehouse_id: whId2 || null,
|
||||
platform_code: 'OPENAPI',
|
||||
message: 'OpenAPI取消订单-触发拦截',
|
||||
});
|
||||
}
|
||||
} catch (logErr) {
|
||||
this.ctx.logger.warn('[OpenAPIOrderCancel] 写入拦截操作日志失败,不影响主流程', logErr);
|
||||
}
|
||||
|
||||
// 创建售后工单 + 通知快递群(失败不影响主流程)
|
||||
try {
|
||||
const { ctx } = this;
|
||||
|
||||
@ -208,6 +208,26 @@ class orderServer extends MainService {
|
||||
|
||||
await transaction.commit();
|
||||
|
||||
// 写入拦截操作日志(失败不影响主流程)
|
||||
try {
|
||||
if (ctx.model && ctx.model.OperationLog) {
|
||||
const customerId2 = String(info.customerId || '').trim();
|
||||
await ctx.model.OperationLog.create({
|
||||
business_type: 'order',
|
||||
business_id: String(existingOrder.id),
|
||||
operation_code: 'ORDER_INTERCEPT_REQUEST',
|
||||
operator_id: null,
|
||||
operator_name: customerId2 ? `qimen:${customerId2}` : 'qimen',
|
||||
external_log_type: 'NONE',
|
||||
warehouse_id: info.warehouseId || null,
|
||||
platform_code: customerId2 || 'SYSTEM',
|
||||
message: '奇门取消订单-触发拦截',
|
||||
});
|
||||
}
|
||||
} catch (logErr) {
|
||||
ctx.logger.warn('[QimenOrderCancel] 写入拦截操作日志失败,不影响主流程', logErr);
|
||||
}
|
||||
|
||||
// 创建售后工单 + 通知快递群(失败不影响主流程)
|
||||
try {
|
||||
await ctx.service.systems.afterSale.createInterceptWorkOrdersAndNotify({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user