PromotionCalcResponse.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package com.ruoyi.system.dto;
  2. import java.math.BigDecimal;
  3. import java.util.List;
  4. import com.fasterxml.jackson.annotation.JsonInclude;
  5. import lombok.Data;
  6. /**
  7. * 优惠算价响应DTO
  8. *
  9. * 返回字段:
  10. * - originalAmount 商品原价总额
  11. * - pathA 路径A(折扣/第二份半价)
  12. * - pathB 路径B(满减)
  13. * - optimalPath 最优路径 "A" 或 "B"
  14. * - finalAmount 最终实付金额(最低¥0.01)
  15. * - newCustomerReduce 新客立减金额(新客时返回)
  16. * - couponId 使用的优惠券ID(选券时返回)
  17. * - couponName 使用的券名称
  18. * - couponReduce 优惠券减免金额
  19. * - couponConflict 优惠券是否与促销冲突
  20. * - conflictNote 冲突说明
  21. * - details 优惠明细列表
  22. * - availableCoupons 可用优惠券列表
  23. */
  24. @Data
  25. @JsonInclude(JsonInclude.Include.NON_NULL)
  26. public class PromotionCalcResponse {
  27. /** 商品原价总额 */
  28. private BigDecimal originalAmount;
  29. /** 路径A(折扣/第二份半价) */
  30. private PathResult pathA;
  31. /** 路径B(满减) */
  32. private PathResult pathB;
  33. /** 最优路径 "A" 或 "B" */
  34. private String optimalPath;
  35. /** 最终实付金额(最低¥0.01) */
  36. private BigDecimal finalAmount;
  37. /** 新客立减金额(新客时返回) */
  38. private BigDecimal newCustomerReduce;
  39. /** 使用的优惠券ID(选券时返回) */
  40. private Long couponId;
  41. /** 使用的券名称 */
  42. private String couponName;
  43. /** 优惠券减免金额 */
  44. private BigDecimal couponReduce;
  45. /** 优惠券是否与促销冲突 */
  46. private Boolean couponConflict;
  47. /** 冲突说明 */
  48. private String conflictNote;
  49. /** 优惠明细列表 */
  50. private List<PromotionDetail> details;
  51. /** 可用优惠券列表 */
  52. private List<AvailableCoupon> availableCoupons;
  53. /** 优惠券批次ID(使用券时返回, 对应 promotion_coupon_batch.id) */
  54. private Long couponBatchId;
  55. /**
  56. * 路径结果
  57. */
  58. @Data
  59. @JsonInclude(JsonInclude.Include.NON_NULL)
  60. public static class PathResult {
  61. /** 路径标签(折扣/第二份半价/满减) */
  62. private String label;
  63. /** 促销子类型(仅路径A): 2=折扣 3=第二份半价 */
  64. private Integer appliedType;
  65. /** 路径小计金额 */
  66. private BigDecimal subtotal;
  67. /** 促销减免金额 */
  68. private BigDecimal promotionReduce;
  69. /** 商品行明细 */
  70. private List<LineItem> items;
  71. /** 匹配到的满减规则(仅路径B) */
  72. private MatchedRule matchedRule;
  73. }
  74. /**
  75. * 商品行明细
  76. */
  77. @Data
  78. @JsonInclude(JsonInclude.Include.NON_NULL)
  79. public static class LineItem {
  80. private Long productId;
  81. private Integer quantity;
  82. private BigDecimal unitPrice;
  83. private String name;
  84. private BigDecimal originalLineTotal;
  85. private BigDecimal finalLineTotal;
  86. /** 折扣率(仅折扣路径, 如 0.70=7折) */
  87. private BigDecimal discountRate;
  88. /** 是否命中第二份半价 */
  89. private Boolean halfPriceApplied;
  90. }
  91. /**
  92. * 匹配到的满减规则(仅路径B)
  93. */
  94. @Data
  95. @JsonInclude(JsonInclude.Include.NON_NULL)
  96. public static class MatchedRule {
  97. private Long id;
  98. private Long activityId;
  99. private String activityName;
  100. private BigDecimal threshold;
  101. private BigDecimal reduceAmount;
  102. }
  103. /**
  104. * 优惠明细
  105. */
  106. @Data
  107. @JsonInclude(JsonInclude.Include.NON_NULL)
  108. public static class PromotionDetail {
  109. /** 优惠类型: promotion=促销, coupon=优惠券 */
  110. private String type;
  111. /** 促销子类型: 1=满减 2=折扣 3=第二份半价 4=新客立减 (coupon时为0) */
  112. private Integer subType;
  113. /** 优惠名称 */
  114. private String name;
  115. /** 减免金额 */
  116. private BigDecimal reduce;
  117. /** 关联ID: 促销活动ID(promo_type=1) 或 券批次ID(promo_type=2) */
  118. private Long refId;
  119. }
  120. /**
  121. * 可用优惠券
  122. */
  123. @Data
  124. @JsonInclude(JsonInclude.Include.NON_NULL)
  125. public static class AvailableCoupon {
  126. private Long id;
  127. private String name;
  128. /** 券类型: 1=满减券 2=商品券 3=免配送费券 */
  129. private Integer couponType;
  130. /** 是否互斥: 0=同享 1=互斥 */
  131. private Integer isMutex;
  132. private BigDecimal threshold;
  133. private BigDecimal amount;
  134. private BigDecimal discountRate;
  135. /** 是否可用 */
  136. private Boolean usable;
  137. /** 是否与当前促销冲突 */
  138. private Boolean conflictWithPromotion;
  139. }
  140. }