From a7206eef2e8bee2309ad6f7c0efb5af2f1f135ed Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 25 Dec 2025 03:59:27 -0800 Subject: [PATCH] =?UTF-8?q?fix(planting-service):=20=E4=BF=AE=E5=A4=8D=20B?= =?UTF-8?q?igInt=20userId=20=E6=AF=94=E8=BE=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 toString() 比较 BigInt 避免类型不匹配 - 添加调试日志帮助排查问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../services/contract-signing.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/services/planting-service/src/application/services/contract-signing.service.ts b/backend/services/planting-service/src/application/services/contract-signing.service.ts index d7476165..20c7ee1e 100644 --- a/backend/services/planting-service/src/application/services/contract-signing.service.ts +++ b/backend/services/planting-service/src/application/services/contract-signing.service.ts @@ -157,7 +157,13 @@ export class ContractSigningService { */ async getTask(orderNo: string, userId: bigint): Promise { const task = await this.taskRepo.findByOrderNo(orderNo); - if (!task || task.userId !== userId) { + if (!task) { + this.logger.warn(`Task not found for orderNo: ${orderNo}`); + return null; + } + // 使用 toString() 比较以避免 BigInt 类型不匹配问题 + if (task.userId.toString() !== userId.toString()) { + this.logger.warn(`User mismatch for orderNo: ${orderNo}, task.userId=${task.userId}, requestUserId=${userId}`); return null; } return this.toDto(task); @@ -168,7 +174,7 @@ export class ContractSigningService { */ async markScrollComplete(orderNo: string, userId: bigint): Promise { const task = await this.taskRepo.findByOrderNo(orderNo); - if (!task || task.userId !== userId) { + if (!task || task.userId.toString() !== userId.toString()) { throw new Error('签署任务不存在'); } @@ -182,7 +188,7 @@ export class ContractSigningService { */ async acknowledgeContract(orderNo: string, userId: bigint): Promise { const task = await this.taskRepo.findByOrderNo(orderNo); - if (!task || task.userId !== userId) { + if (!task || task.userId.toString() !== userId.toString()) { throw new Error('签署任务不存在'); } @@ -201,7 +207,7 @@ export class ContractSigningService { params: SignContractParams, ): Promise { const task = await this.taskRepo.findByOrderNo(orderNo); - if (!task || task.userId !== userId) { + if (!task || task.userId.toString() !== userId.toString()) { throw new Error('签署任务不存在'); } @@ -231,7 +237,7 @@ export class ContractSigningService { params: SignContractParams, ): Promise { const task = await this.taskRepo.findByOrderNo(orderNo); - if (!task || task.userId !== userId) { + if (!task || task.userId.toString() !== userId.toString()) { throw new Error('签署任务不存在'); }