From c4b3a547cfafd21fb98c8652ce3b94b48dea793f Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 20 Oct 2026 16:57:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=80=E5=9B=9E=E5=AF=B9=E6=8E=A5):=20in?= =?UTF-8?q?gest=20=E6=8E=A5=E5=8F=A3=E5=A4=8D=E7=94=A8=E6=97=A2=E6=9C=89?= =?UTF-8?q?=20supplier=5Fintegration=20=E5=AF=B9=E6=8E=A5=E4=BB=A4?= =?UTF-8?q?=E7=89=8C=E9=89=B4=E6=9D=83=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E7=94=A8=E6=88=B7=E8=B4=A6=E5=8F=B7/=E6=9D=83?= =?UTF-8?q?=E9=99=90=E2=80=94=E2=80=94=E9=83=A8=E7=BD=B2=E5=90=8E=E4=B8=BB?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=94=A8=E7=8E=B0=E6=9C=89=E5=87=AD=E6=8D=AE?= =?UTF-8?q?=E5=8D=B3=E5=8F=AF=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/workflow/routes/orderRoutes.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/server/src/modules/workflow/routes/orderRoutes.ts b/server/src/modules/workflow/routes/orderRoutes.ts index de583f4..f0a490e 100644 --- a/server/src/modules/workflow/routes/orderRoutes.ts +++ b/server/src/modules/workflow/routes/orderRoutes.ts @@ -1907,9 +1907,21 @@ router.get('/after-sales/order-context/:orderCode', authMiddleware, async (req: */ router.post('/after-sales/returns/ingest', authMiddleware, async (req: AuthRequest, res: Response) => { try { - const ctx = await getWorkflowCtx(req); - requireWorkflowPermission(ctx, ['aftersales_manage']); - const branchCode = String(req.body?.branch_code || ctx?.branchCode || '').trim(); + /** + * 鉴权(2026-10-20 开发者裁定:**不新建账号**,复用既有对接凭据): + * · `supplier_integration` 对接 token(client_id/client_secret 换来的集成令牌)⇒ 直接放行, + * 分公司从 token 里取(主系统调用走这条,部署后即可用,无需额外开账号); + * · 普通用户 token ⇒ 仍要求 `aftersales_manage` 权限(界面/人工补调用)。 + */ + const isIntegration = (req as any).tokenScope === 'supplier_integration'; + let ctx: any = null; + if (!isIntegration) { + ctx = await getWorkflowCtx(req); + requireWorkflowPermission(ctx, ['aftersales_manage']); + } + const branchCode = String( + req.body?.branch_code || (isIntegration ? (req as any).branchCode : ctx?.branchCode) || '' + ).trim(); const body = req.body || {}; let ourOrderCode = String(body.our_order_code || '').trim(); const prepId = String(body.prep_id || '').trim(); @@ -1920,7 +1932,7 @@ router.post('/after-sales/returns/ingest', authMiddleware, async (req: AuthReque if (!ourOrderCode) { return res.status(400).json({ error: 'invalid_request', error_description: '缺少 our_order_code(或 prep_id 无法定位到订单)' }); } - await assertOrderCodeAccess(ourOrderCode, ctx!); + if (!isIntegration) await assertOrderCodeAccess(ourOrderCode, ctx!); const { ingestMainSystemReturn } = await import('../../../services/mainSystemReturnService'); const data = await ingestMainSystemReturn({ branchCode,