feat(voucher): 优化优惠券打印逻辑

- 添加景区配置管理器验证逻辑,确保只有指定的代理可以打印优惠券
-优化代码结构,提高可读性和可维护性
This commit is contained in:
2025-09-03 14:34:42 +08:00
parent 03fd80a313
commit 829ab50b03

View File

@@ -81,6 +81,14 @@ public class VoucherPrintServiceImpl implements VoucherPrintService {
// 验证faceId是否属于当前用户
validateFaceOwnership(request.getFaceId(), currentUserId);
ScenicConfigManager config = scenicRepository.getScenicConfigManager(face.getScenicId());
Long brokerId = config.getLong("voucher_broker_id");
if (brokerId != null) {
if (!request.getBrokerId().equals(brokerId)) {
return null;
}
}
// 使用Redis分布式锁防止重复打印
String lockKey = String.format(PRINT_LOCK_KEY, request.getFaceId(), request.getBrokerId(), request.getScenicId());
@@ -107,7 +115,7 @@ public class VoucherPrintServiceImpl implements VoucherPrintService {
if (availableVoucher == null) {
throw new BaseException("暂无可用优惠券");
}
// 生成流水号
String code = generateCode();