You've already forked FrameTour-BE
feat(pricing): 调整价格计算请求参数并完善优惠券使用逻辑
- 将 previewOnly 默认值从 false 改为 true - 新增 orderId 字段用于实际使用优惠时的订单标识 - 实现优惠券使用标记逻辑,调用 couponService.useCoupon - 添加优惠券使用日志记录,包括 couponId、userId 和 orderId - 补充 scenicId 参数转换处理逻辑
This commit is contained in:
@@ -44,9 +44,14 @@ public class PriceCalculationRequest {
|
||||
* 是否自动使用券码优惠
|
||||
*/
|
||||
private Boolean autoUseVoucher = true;
|
||||
|
||||
|
||||
/**
|
||||
* 是否仅预览优惠(不实际使用)
|
||||
*/
|
||||
private Boolean previewOnly = false;
|
||||
private Boolean previewOnly = true;
|
||||
|
||||
/**
|
||||
* 订单ID(在实际使用优惠时必填)
|
||||
*/
|
||||
private String orderId;
|
||||
}
|
||||
@@ -402,8 +402,19 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
||||
log.info("已标记券码为使用: {}", result.getUsedVoucher().getVoucherCode());
|
||||
}
|
||||
|
||||
// 优惠券的使用标记由原有的CouponService处理
|
||||
// 这里不需要额外处理
|
||||
// 标记优惠券为已使用
|
||||
if (result.getUsedCoupon() != null && result.getUsedCoupon().getCouponId() != null) {
|
||||
CouponUseRequest couponUseRequest = new CouponUseRequest();
|
||||
couponUseRequest.setCouponId(result.getUsedCoupon().getCouponId());
|
||||
couponUseRequest.setUserId(request.getUserId());
|
||||
couponUseRequest.setOrderId(request.getOrderId());
|
||||
couponUseRequest.setDiscountAmount(result.getUsedCoupon().getActualDiscountAmount());
|
||||
couponUseRequest.setScenicId(request.getScenicId() != null ? String.valueOf(request.getScenicId()) : null);
|
||||
|
||||
couponService.useCoupon(couponUseRequest);
|
||||
log.info("已标记优惠券为使用: couponId={}, userId={}, orderId={}",
|
||||
result.getUsedCoupon().getCouponId(), request.getUserId(), request.getOrderId());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("标记优惠使用状态时发生异常", e);
|
||||
|
||||
Reference in New Issue
Block a user