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('签署任务不存在'); }