wenminjie
2026-08-04 93414e8ee25852aca467213402585d0e65c08a4a
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.talentcard.server.business.admin;
 
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
 
import com.talentcard.server.business.PageResult;
import com.talentcard.server.business.admin.auth.AdminAuthInterceptor;
import com.talentcard.server.common.ApiResponse;
import com.talentcard.server.request.ParkingPlateStatusUpdateRequest;
import com.talentcard.server.service.ParkingPlateSubmissionAdminService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
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.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
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/admin/parking-plate-submissions")
public class ParkingPlateSubmissionAdminController {
    private final ParkingPlateSubmissionAdminService service;
 
    public ParkingPlateSubmissionAdminController(ParkingPlateSubmissionAdminService service) {
        this.service = service;
    }
 
    @Operation(summary = "车牌提交汇总列表", description = "分页汇总车牌、持卡人、提交时间和处理状态,支持停车场、卡等级、状态和提交时间筛选")
    @GetMapping
    public ApiResponse<PageResult<Map<String, Object>>> page(
            @Parameter(description = "停车商家ID") @RequestParam(required = false) Long merchantId,
            @Parameter(description = "停车场ID") @RequestParam(required = false) Long parkingLotId,
            @Parameter(description = "持卡人姓名、手机号、卡号、车牌号、提交单号关键词") @RequestParam(required = false) String keyword,
            @Parameter(description = "停车商家或停车场关键词") @RequestParam(required = false) String serviceKeyword,
            @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(merchantId, parkingLotId, keyword, serviceKeyword, cardLevel, status, submissionType, submittedStart, submittedEnd, page, size));
    }
 
    @Operation(summary = "车牌提交详情", description = "查看持卡人信息、提交信息和状态信息")
    @GetMapping("/{id}")
    public ApiResponse<Map<String, Object>> detail(@PathVariable Long id) {
        return ApiResponse.success(service.detail(id));
    }
 
    @Operation(summary = "处理车牌提交", description = "维护处理状态和处理备注,支持已处理、已拒绝、已取消和待处理")
    @PatchMapping("/{id}/status")
    public ApiResponse<Map<String, Object>> updateStatus(
            @PathVariable Long id,
            @Valid @RequestBody ParkingPlateStatusUpdateRequest request,
            @RequestAttribute(value = AdminAuthInterceptor.OPERATOR_ID_ATTRIBUTE, required = false) Long operatorId
    ) {
        return ApiResponse.success(service.updateStatus(id, request, operatorId));
    }
 
    @Operation(summary = "导出车牌提交", description = "按当前筛选条件导出车牌提交Excel")
    @GetMapping(value = "/export", produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
    public void export(
            @Parameter(description = "停车商家ID") @RequestParam(required = false) Long merchantId,
            @Parameter(description = "停车场ID") @RequestParam(required = false) Long parkingLotId,
            @Parameter(description = "持卡人姓名、手机号、卡号、车牌号、提交单号关键词") @RequestParam(required = false) String keyword,
            @Parameter(description = "停车商家或停车场关键词") @RequestParam(required = false) String serviceKeyword,
            @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,
            HttpServletResponse response
    ) throws IOException {
        byte[] data = service.exportExcel(merchantId, parkingLotId, keyword, serviceKeyword, cardLevel, status, submissionType, submittedStart, submittedEnd);
        String filename = URLEncoder.encode("车牌提交列表.xlsx", StandardCharsets.UTF_8).replace("+", "%20");
        response.setCharacterEncoding(StandardCharsets.UTF_8.name());
        response.setContentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").toString());
        response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + filename);
        response.setContentLength(data.length);
        response.getOutputStream().write(data);
        response.flushBuffer();
    }
}