From 2795ae07580d49e7fc2350f0f8e397908e31f253 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Wed, 12 Aug 2026 22:13:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=A8=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E9=93=BE=E8=B7=AF=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=20?= =?UTF-8?q?=E2=80=94=20Qimen/OpenAPI/inbox=20AI=20=E5=86=99=E5=85=A5=20ORD?= =?UTF-8?q?ER=5FINTERCEPT=5FREQUEST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: 3处拦截入口缺失操作日志 - Qimen cancel: 拦截路径补 ORDER_INTERCEPT_REQUEST - OpenAPI cancel: 拦截路径补 ORDER_INTERCEPT_REQUEST - inbox AI interceptWaybill + 取消拦截: 补 ORDER_INTERCEPT_REQUEST --- app/service/inbox/functions.js | 34 +++++++++++++++++++++++++++++ app/service/openapiMethods/order.js | 21 ++++++++++++++++++ app/service/qimenMethods/order.js | 20 +++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/app/service/inbox/functions.js b/app/service/inbox/functions.js index 64ee1cc..5fac707 100644 --- a/app/service/inbox/functions.js +++ b/app/service/inbox/functions.js @@ -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} 个订单`); } } diff --git a/app/service/openapiMethods/order.js b/app/service/openapiMethods/order.js index 50c55e4..9fd9b6a 100644 --- a/app/service/openapiMethods/order.js +++ b/app/service/openapiMethods/order.js @@ -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; diff --git a/app/service/qimenMethods/order.js b/app/service/qimenMethods/order.js index a390248..dc40180 100644 --- a/app/service/qimenMethods/order.js +++ b/app/service/qimenMethods/order.js @@ -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({