From b17bf824430c1dc645cf0c088acfa9755d35be19 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 10:07:53 -0800 Subject: [PATCH] =?UTF-8?q?feat(pre-planting):=20=E6=96=B0=E5=A2=9E=20GET?= =?UTF-8?q?=20/merges/:mergeNo=20=E5=90=88=E5=B9=B6=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../controllers/pre-planting.controller.ts | 13 ++++++++ .../pre-planting-application.service.ts | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+) 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 + 移动端购买页使用) *