fix(planting-service): 修复 BigInt userId 比较问题

- 使用 toString() 比较 BigInt 避免类型不匹配
- 添加调试日志帮助排查问题

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-25 03:59:27 -08:00
parent 82ca233d54
commit a7206eef2e
1 changed files with 11 additions and 5 deletions

View File

@ -157,7 +157,13 @@ export class ContractSigningService {
*/
async getTask(orderNo: string, userId: bigint): Promise<ContractSigningTaskDto | null> {
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<void> {
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<void> {
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<void> {
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<void> {
const task = await this.taskRepo.findByOrderNo(orderNo);
if (!task || task.userId !== userId) {
if (!task || task.userId.toString() !== userId.toString()) {
throw new Error('签署任务不存在');
}