diff --git a/backend/services/planting-service/src/pre-planting/api/controllers/pre-planting.controller.ts b/backend/services/planting-service/src/pre-planting/api/controllers/pre-planting.controller.ts index 144faecd..f085f4a1 100644 --- a/backend/services/planting-service/src/pre-planting/api/controllers/pre-planting.controller.ts +++ b/backend/services/planting-service/src/pre-planting/api/controllers/pre-planting.controller.ts @@ -3,6 +3,7 @@ import { Post, Get, Body, + Param, UseGuards, Req, HttpCode, @@ -98,4 +99,16 @@ export class PrePlantingController { const userId = BigInt(req.user.id); return this.prePlantingService.getMerges(userId); } + + @Get('merges/:mergeNo') + @ApiOperation({ summary: '获取单条合并记录详情' }) + @ApiResponse({ status: HttpStatus.OK, description: '合并记录详情' }) + @ApiResponse({ status: HttpStatus.NOT_FOUND, description: '合并记录不存在' }) + async getMergeDetail( + @Req() req: AuthenticatedRequest, + @Param('mergeNo') mergeNo: string, + ) { + const userId = BigInt(req.user.id); + return this.prePlantingService.getMergeDetail(userId, mergeNo); + } } diff --git a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-application.service.ts b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-application.service.ts index e433c3de..0131aaef 100644 --- a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-application.service.ts +++ b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-application.service.ts @@ -358,6 +358,38 @@ export class PrePlantingApplicationService { }); } + /** + * 获取单条合并记录详情 + */ + async getMergeDetail( + userId: bigint, + mergeNo: string, + ): Promise<{ + mergeNo: string; + sourceOrderNos: string[]; + treeCount: number; + contractStatus: string; + contractSignedAt: Date | null; + miningEnabledAt: Date | null; + mergedAt: Date; + }> { + return this.prisma.$transaction(async (tx) => { + const merge = await this.mergeRepo.findByMergeNo(tx, mergeNo); + if (!merge || merge.userId !== userId) { + throw new NotFoundException(`合并记录不存在: ${mergeNo}`); + } + return { + mergeNo: merge.mergeNo, + sourceOrderNos: merge.sourceOrderNos, + treeCount: merge.treeCount, + contractStatus: merge.contractStatus, + contractSignedAt: merge.contractSignedAt, + miningEnabledAt: merge.miningEnabledAt, + mergedAt: merge.mergedAt, + }; + }); + } + /** * 获取预种资格信息(供内部 API + 移动端购买页使用) *