| | |
| | | import com.talentcard.server.request.BenefitVerificationCodeRequest; |
| | | import com.talentcard.server.service.BenefitVerificationCodeService; |
| | | 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.http.CacheControl; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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 = "小程序生成电影票、酒店权益5分钟核销码") |
| | | @Tag(name = "小程序-权益核销码", description = "小程序查询电影票、酒店权益额度并生成动态核销码") |
| | | @RestController |
| | | @RequestMapping("/api/app/benefit-verification-codes") |
| | | public class BenefitVerificationCodeController { |
| | |
| | | this.service = service; |
| | | } |
| | | |
| | | @Operation(summary = "生成权益核销码", description = "根据主卡/亲属附属卡共享额度、商户剩余券或酒店库存生成5分钟有效核销码") |
| | | @Operation(summary = "获取电影票兑换码二维码", description = "返回电影票固定兑换码二维码,核销或电影券有效期结束后失效") |
| | | @GetMapping(value = "/{claimId}/image", produces = MediaType.IMAGE_PNG_VALUE) |
| | | public ResponseEntity<byte[]> movieImage( |
| | | @Parameter(description = "电影票领取记录ID", required = true) @PathVariable Long claimId) { |
| | | return ResponseEntity.ok() |
| | | .cacheControl(CacheControl.noStore()) |
| | | .body(service.movieCodeImage(claimId)); |
| | | } |
| | | |
| | | @Operation(summary = "查询权益可用次数", description = "按主卡或亲属附属卡、人才卡等级和商户配置查询当前可用权益次数,不生成核销码") |
| | | @GetMapping("/quota") |
| | | public ApiResponse<Map<String, Object>> quota( |
| | | @Parameter(description = "权益类型:MOVIE_TICKET电影票、HOTEL酒店", required = true) |
| | | @RequestParam String benefitType, |
| | | @Parameter(description = "人才用户ID;未传cardId时必填") |
| | | @RequestParam(required = false) Long talentId, |
| | | @Parameter(description = "人才卡ID;支持主卡或亲属附属卡") |
| | | @RequestParam(required = false) Long cardId, |
| | | @Parameter(description = "商户ID", required = true) |
| | | @RequestParam Long merchantId |
| | | ) { |
| | | return ApiResponse.success(service.quota(new BenefitVerificationCodeRequest( |
| | | benefitType, talentId, cardId, merchantId))); |
| | | } |
| | | |
| | | @Operation(summary = "生成权益核销码", description = "电影票生成固定兑换码,酒店生成60秒动态核销码") |
| | | @PostMapping |
| | | public ApiResponse<Map<String, Object>> create( |
| | | @Valid @RequestBody BenefitVerificationCodeRequest request, |
| | |
| | | ) { |
| | | return ApiResponse.success(service.generate(request, idempotencyKey)); |
| | | } |
| | | } |
| | | } |