yeg
2026-09-18 a058f6109834e29435f5ce4aa19a43d67d07c060
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.talentcard.server.business.merchant;
 
import java.util.Map;
 
import com.talentcard.server.business.PageResult;
import com.talentcard.server.business.merchant.auth.MerchantAuthService;
import com.talentcard.server.business.merchant.auth.MerchantPrincipal;
import com.talentcard.server.common.ApiResponse;
import com.talentcard.server.request.MerchantParkingPlateRegistrationRequest;
import com.talentcard.server.request.ParkingPlateStatusUpdateRequest;
import com.talentcard.server.service.ParkingPlateMerchantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@Tag(name = "商户端-停车车牌登记", description = "商户端查询、录入和处理停车车牌登记记录")
@RestController
@RequestMapping("/api/merchant/parking-plate-registrations")
public class MerchantParkingPlateRegistrationController {
    private final ParkingPlateMerchantService service;
 
    public MerchantParkingPlateRegistrationController(ParkingPlateMerchantService service) {
        this.service = service;
    }
 
    @Operation(summary = "查询车牌登记列表", description = "商户端分页查询当前停车商家的车牌登记记录")
    @GetMapping
    public ApiResponse<PageResult<Map<String, Object>>> page(
            @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal,
            @Parameter(description = "停车场ID") @RequestParam(required = false) Long parkingLotId,
            @Parameter(description = "持卡人姓名、手机号、卡号、车牌号、登记单号或停车场关键词") @RequestParam(required = false) String keyword,
            @Parameter(description = "人才卡等级") @RequestParam(required = false) String cardLevel,
            @Parameter(description = "处理状态") @RequestParam(required = false) String status,
            @Parameter(description = "提交类型:新增/修改") @RequestParam(required = false) String submissionType,
            @Parameter(description = "提交开始日期,格式yyyy-MM-dd") @RequestParam(required = false) String submittedStart,
            @Parameter(description = "提交结束日期,格式yyyy-MM-dd") @RequestParam(required = false) String submittedEnd,
            @Parameter(description = "页码") @RequestParam(defaultValue = "1") int page,
            @Parameter(description = "每页条数") @RequestParam(defaultValue = "10") int size
    ) {
        return ApiResponse.success(service.page(principal, parkingLotId, keyword, cardLevel, status, submissionType, submittedStart, submittedEnd, page, size));
    }
 
    @Operation(summary = "查询车牌登记详情", description = "查看持卡人信息、停车场信息和处理状态")
    @GetMapping("/{id}")
    public ApiResponse<Map<String, Object>> detail(
            @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal,
            @Parameter(description = "车牌登记ID") @PathVariable Long id
    ) {
        return ApiResponse.success(service.detail(principal, id));
    }
 
    @Operation(summary = "商户录入车牌", description = "商户端直接录入车牌到当前停车商家,校验人才卡停车权益后写入车牌登记表并置为已处理")
    @PostMapping
    public ApiResponse<Map<String, Object>> create(
            @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal,
            @Valid @RequestBody MerchantParkingPlateRegistrationRequest request,
            @RequestHeader(value = "X-Idempotency-Key", required = false) String idempotencyKey
    ) {
        return ApiResponse.success(service.create(principal, request, idempotencyKey));
    }
 
    @Operation(summary = "处理车牌登记", description = "商户端维护车牌登记处理状态和处理备注")
    @PatchMapping("/{id}/status")
    public ApiResponse<Map<String, Object>> updateStatus(
            @RequestAttribute(MerchantAuthService.PRINCIPAL_ATTRIBUTE) MerchantPrincipal principal,
            @Parameter(description = "车牌登记ID") @PathVariable Long id,
            @Valid @RequestBody ParkingPlateStatusUpdateRequest request
    ) {
        return ApiResponse.success(service.updateStatus(principal, id, request));
    }
}