fix(attachment): 官网电子发票下载报「发票ID不能为空」
取票中转 route 的转发 query 是手写白名单,只带 kind/orderNo/projectNo/index,漏了 invoiceId。官网点发票下载时后端因此只收到 kind=invoice、没有发票 id,命中 HjcAttachmentController 的入参校验,原样回 code=1「发票ID不能为空」。补上解构与转发,并在注释里写清三种资源标识都要转发(tender 按订单号、bulletin 按项目编号、invoice 按发票 id)。
This commit is contained in:
@@ -7,10 +7,15 @@ import { getTenantFromContext } from '../../utils/tenant'
|
|||||||
* 取附件下载票据(一次性、短时)。
|
* 取附件下载票据(一次性、短时)。
|
||||||
* GET /api/tender/attachment-ticket?kind=tender&orderNo=xxx&index=0
|
* GET /api/tender/attachment-ticket?kind=tender&orderNo=xxx&index=0
|
||||||
* GET /api/tender/attachment-ticket?kind=bulletin&projectNo=xxx&index=0
|
* GET /api/tender/attachment-ticket?kind=bulletin&projectNo=xxx&index=0
|
||||||
|
* GET /api/tender/attachment-ticket?kind=invoice&invoiceId=xxx&index=0
|
||||||
|
*
|
||||||
|
* **三种资源标识都要转发**:`kind=invoice`(电子发票)的标识是 `invoiceId`,
|
||||||
|
* 漏了它后端只会看到「kind=invoice 但没有发票 id」,直接回
|
||||||
|
* `{"code":1,"message":"发票ID不能为空"}`——本路由曾漏过这一个字段。
|
||||||
*
|
*
|
||||||
* 为什么要它:一站式的静态文件服务加了鉴权,附件不再直连,改由后端反代
|
* 为什么要它:一站式的静态文件服务加了鉴权,附件不再直连,改由后端反代
|
||||||
* (工作区根目录 `docs/adr/0007-attachment-download-via-platform-proxy.md`)。
|
* (工作区根目录 `docs/adr/0007-attachment-download-via-platform-proxy.md`)。
|
||||||
* 下发给前端的附件地址是**本平台的资源地址**(只有 kind/订单号或项目编号/序号,
|
* 下发给前端的附件地址是**本平台的资源地址**(只有 kind/订单号或项目编号或发票 id/序号,
|
||||||
* 没有路径、也没有票据);**点击下载时**才来这里换一张票据,再用票据去
|
* 没有路径、也没有票据);**点击下载时**才来这里换一张票据,再用票据去
|
||||||
* `{modulesApiBase}/api/hjc/attachment?ticket=…` 取文件。
|
* `{modulesApiBase}/api/hjc/attachment?ticket=…` 取文件。
|
||||||
*
|
*
|
||||||
@@ -24,7 +29,7 @@ import { getTenantFromContext } from '../../utils/tenant'
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
const ctx = getTenantFromContext(event, config)
|
const ctx = getTenantFromContext(event, config)
|
||||||
const { kind, orderNo, projectNo, index } = getQuery(event)
|
const { kind, orderNo, projectNo, invoiceId, index } = getQuery(event)
|
||||||
const cookieToken = getCookie(event, 'hjc_token')
|
const cookieToken = getCookie(event, 'hjc_token')
|
||||||
const auth = getHeader(event, 'authorization') || (cookieToken ? `Bearer ${cookieToken}` : null)
|
const auth = getHeader(event, 'authorization') || (cookieToken ? `Bearer ${cookieToken}` : null)
|
||||||
|
|
||||||
@@ -41,7 +46,9 @@ export default defineEventHandler(async (event) => {
|
|||||||
kind,
|
kind,
|
||||||
index,
|
index,
|
||||||
...(orderNo ? { orderNo } : {}),
|
...(orderNo ? { orderNo } : {}),
|
||||||
...(projectNo ? { projectNo } : {})
|
...(projectNo ? { projectNo } : {}),
|
||||||
|
// 电子发票按发票 id 取件;漏掉这一行,发票下载必报「发票ID不能为空」
|
||||||
|
...(invoiceId ? { invoiceId } : {})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user