refactor(voucher): 移除券码领取接口中的景区ID参数验证

- 删除 VoucherClaimReq 中的 scenicId 字段
- 移除券码领取接口中对景区ID的空值检查
- 更新查询条件,不再按景区ID过滤券码
- 修改错误提示信息为"券码不存在"
- 调整领券权限校验逻辑,使用券码关联的景区ID进行验证
This commit is contained in:
2026-02-14 02:13:35 +08:00
parent 4ac59b1f31
commit 1110b5409b
2 changed files with 2 additions and 7 deletions

View File

@@ -4,6 +4,5 @@ import lombok.Data;
@Data
public class VoucherClaimReq {
private Long scenicId;
private String code;
}

View File

@@ -74,9 +74,6 @@ public void generateVoucherCodes(Long batchId, Long scenicId, Integer count) {
@Override
@Transactional
public VoucherCodeResp claimVoucher(VoucherClaimReq req) {
if (req.getScenicId() == null) {
throw new BizException(400, "景区ID不能为空");
}
if (!StringUtils.hasText(req.getCode())) {
throw new BizException(400, "券码不能为空");
}
@@ -86,19 +83,18 @@ public VoucherCodeResp claimVoucher(VoucherClaimReq req) {
// 验证券码是否存在且未被领取
LambdaQueryWrapper<PriceVoucherCode> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PriceVoucherCode::getCode, req.getCode())
.eq(PriceVoucherCode::getScenicId, req.getScenicId())
.eq(PriceVoucherCode::getDeleted, 0);
PriceVoucherCode voucherCode = voucherCodeMapper.selectOne(wrapper);
if (voucherCode == null) {
throw new BizException(400, "券码不存在或不属于该景区");
throw new BizException(400, "券码不存在");
}
if (!Objects.equals(voucherCode.getStatus(), VoucherCodeStatus.UNCLAIMED.getCode())) {
throw new BizException(400, "券码已被领取或已使用");
}
if (!canClaimVoucher(userId, req.getScenicId())) {
if (!canClaimVoucher(userId, voucherCode.getScenicId())) {
throw new BizException(400, "该用户在此景区已领取过券码");
}