PromotionCalcResponse.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. package com.ruoyi.system.dto;
  2. import java.math.BigDecimal;
  3. import java.util.Date;
  4. import java.util.List;
  5. import com.fasterxml.jackson.annotation.JsonFormat;
  6. import com.fasterxml.jackson.annotation.JsonInclude;
  7. import lombok.Data;
  8. /**
  9. * 优惠算价响应DTO
  10. *
  11. * 返回字段:
  12. * - originalAmount 商品原价总额
  13. * - pathA 路径A(折扣/第二份半价)
  14. * - pathB 路径B(满减)
  15. * - optimalPath 最优路径 "A" 或 "B"
  16. * - finalAmount 最终实付金额(最低¥0.01)
  17. * - newCustomerReduce 新客立减金额(新客时返回)
  18. * - couponId 使用的优惠券ID(选券时返回)
  19. * - couponName 使用的券名称
  20. * - couponReduce 优惠券减免金额
  21. * - couponConflict 优惠券是否与促销冲突
  22. * - conflictNote 冲突说明
  23. * - couponProductItems 商品券参与的商品明细(名称/原价/优惠后价)
  24. * - details 优惠明细列表
  25. * - availableCoupons 可用优惠券列表
  26. */
  27. @Data
  28. @JsonInclude(JsonInclude.Include.NON_NULL)
  29. public class PromotionCalcResponse {
  30. /** 商品原价总额 */
  31. private BigDecimal originalAmount;
  32. /** 路径A(折扣/第二份半价) */
  33. private PathResult pathA;
  34. /** 路径B(满减) */
  35. private PathResult pathB;
  36. /** 最优路径 "A" 或 "B" */
  37. private String optimalPath;
  38. /** 最终实付金额(最低¥0.01) */
  39. private BigDecimal finalAmount;
  40. /** 新客立减金额(新客时返回) */
  41. private BigDecimal newCustomerReduce;
  42. /** 使用的优惠券ID(选券时返回) */
  43. private Long couponId;
  44. /** 使用的券名称 */
  45. private String couponName;
  46. /** 优惠券减免金额 */
  47. private BigDecimal couponReduce;
  48. /** 优惠券是否与促销冲突 */
  49. private Boolean couponConflict;
  50. /** 冲突说明 */
  51. private String conflictNote;
  52. /** 优惠明细列表 */
  53. private List<PromotionDetail> details;
  54. /** 可用优惠券列表 */
  55. private List<AvailableCoupon> availableCoupons;
  56. /** 优惠券批次ID(使用券时返回, 对应 promotion_coupon_batch.id) */
  57. private Long couponBatchId;
  58. /** 商品券参与优惠的商品明细(仅商品券生效时返回, 含名称/原价/优惠后价) */
  59. private List<LineItem> couponProductItems;
  60. // ==================== 满额免运完整配送报价扩展(2026-10-19,pricingVersion=2) ====================
  61. /** 完整配送报价版本;新流程固定2,旧接口不返回 */
  62. private Integer pricingVersion;
  63. /** 原配送费 R(整数元,骑手毛配送费基数) */
  64. private BigDecimal deliveryFee;
  65. /** 满额免运减免额 F(不从商品金额扣除) */
  66. private BigDecimal deliveryDiscountAmount;
  67. /** 客户实际支付配送费 D */
  68. private BigDecimal customerDeliveryFee;
  69. /** 客户整单应付 A = finalAmount(G) + D */
  70. private BigDecimal payableAmount;
  71. /** 命中的满额免运活动ID(未命中为null) */
  72. private Long freeDeliveryActivityId;
  73. /** 命中的满额免运原价门槛(未命中为null) */
  74. private BigDecimal freeDeliveryThreshold;
  75. /** 总优惠预算 B(限制开关关闭时为null表示无限,不用0表示) */
  76. private BigDecimal discountBudget;
  77. /** 全部受限优惠分配后剩余预算(开关关闭时为null) */
  78. private BigDecimal remainingDiscountBudget;
  79. /** 实际生效且实减>0的优惠券ID(核销以此为准;couponId仅表示用户选择意图) */
  80. private Long appliedCouponId;
  81. /**
  82. * 路径结果
  83. */
  84. @Data
  85. @JsonInclude(JsonInclude.Include.NON_NULL)
  86. public static class PathResult {
  87. /** 路径标签(折扣/第二份半价/满减) */
  88. private String label;
  89. /** 促销子类型(仅路径A): 2=折扣 3=第二份半价 */
  90. private Integer appliedType;
  91. /** 路径小计金额 */
  92. private BigDecimal subtotal;
  93. /** 促销减免金额 */
  94. private BigDecimal promotionReduce;
  95. /** 商品行明细 */
  96. private List<LineItem> items;
  97. /** 匹配到的满减规则(仅路径B) */
  98. private MatchedRule matchedRule;
  99. }
  100. /**
  101. * 商品行明细
  102. */
  103. @Data
  104. @JsonInclude(JsonInclude.Include.NON_NULL)
  105. public static class LineItem {
  106. private Long productId;
  107. private Integer quantity;
  108. private BigDecimal unitPrice;
  109. private String name;
  110. private BigDecimal originalLineTotal;
  111. private BigDecimal finalLineTotal;
  112. /** 折扣率(仅折扣路径, 如 0.70=7折) */
  113. private BigDecimal discountRate;
  114. /** 是否命中第二份半价 */
  115. private Boolean halfPriceApplied;
  116. }
  117. /**
  118. * 匹配到的满减规则(仅路径B)
  119. */
  120. @Data
  121. @JsonInclude(JsonInclude.Include.NON_NULL)
  122. public static class MatchedRule {
  123. private Long id;
  124. private Long activityId;
  125. private String activityName;
  126. private BigDecimal threshold;
  127. private BigDecimal reduceAmount;
  128. }
  129. /**
  130. * 优惠明细
  131. */
  132. @Data
  133. @JsonInclude(JsonInclude.Include.NON_NULL)
  134. public static class PromotionDetail {
  135. /** 优惠类型: promotion=促销, coupon=优惠券 */
  136. private String type;
  137. /** 促销子类型: 1=满减 2=折扣 3=第二份半价 4=新客立减 5=满额免运 (coupon时为0) */
  138. private Integer subType;
  139. /** 优惠名称 */
  140. private String name;
  141. /** 减免金额 */
  142. private BigDecimal reduce;
  143. /** 关联ID: 促销活动ID(promo_type=1) 或 券批次ID(promo_type=2) */
  144. private Long refId;
  145. /** 是否被优惠幅度限制封顶(仅封顶时返回, 对应"已达优惠上限") */
  146. private Boolean limitCapped;
  147. /** 商品原价合计 O(type=5满额免运快照扩展字段) */
  148. private BigDecimal originalAmount;
  149. /** 原配送费 R(type=5满额免运快照扩展字段) */
  150. private BigDecimal deliveryFee;
  151. /** 客户实付配送费 D(type=5满额免运快照扩展字段) */
  152. private BigDecimal customerDeliveryFee;
  153. /** 免运门槛(type=5满额免运快照扩展字段) */
  154. private BigDecimal threshold;
  155. }
  156. /**
  157. * 可用优惠券
  158. */
  159. @Data
  160. @JsonInclude(JsonInclude.Include.NON_NULL)
  161. public static class AvailableCoupon {
  162. private Long id;
  163. private String name;
  164. /** 券类型: 1=满减券 2=商品券 3=免配送费券 */
  165. private Integer couponType;
  166. /** 是否互斥: 0=同享 1=互斥 */
  167. private Integer isMutex;
  168. private BigDecimal threshold;
  169. private BigDecimal amount;
  170. private BigDecimal discountRate;
  171. /** 是否可用 */
  172. private Boolean usable;
  173. /** 是否与当前促销冲突 */
  174. private Boolean conflictWithPromotion;
  175. /** 商品券预估优惠金额(仅商品券, 预览) */
  176. private BigDecimal couponPreviewReduce;
  177. /** 商品券作用于的商品预览明细(仅商品券: 名称/原价/优惠后价) */
  178. private List<LineItem> productPreview;
  179. /** 不可用原因(目前仅: 本单优惠已达优惠上限) */
  180. private String unusableReason;
  181. /** 过期时间 */
  182. @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Taipei")
  183. private Date expireTime;
  184. }
  185. }