| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- package com.ruoyi.system.dto;
- import java.math.BigDecimal;
- import java.util.Date;
- import java.util.List;
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.fasterxml.jackson.annotation.JsonInclude;
- import lombok.Data;
- /**
- * 优惠算价响应DTO
- *
- * 返回字段:
- * - originalAmount 商品原价总额
- * - pathA 路径A(折扣/第二份半价)
- * - pathB 路径B(满减)
- * - optimalPath 最优路径 "A" 或 "B"
- * - finalAmount 最终实付金额(最低¥0.01)
- * - newCustomerReduce 新客立减金额(新客时返回)
- * - couponId 使用的优惠券ID(选券时返回)
- * - couponName 使用的券名称
- * - couponReduce 优惠券减免金额
- * - couponConflict 优惠券是否与促销冲突
- * - conflictNote 冲突说明
- * - couponProductItems 商品券参与的商品明细(名称/原价/优惠后价)
- * - details 优惠明细列表
- * - availableCoupons 可用优惠券列表
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public class PromotionCalcResponse {
- /** 商品原价总额 */
- private BigDecimal originalAmount;
- /** 路径A(折扣/第二份半价) */
- private PathResult pathA;
- /** 路径B(满减) */
- private PathResult pathB;
- /** 最优路径 "A" 或 "B" */
- private String optimalPath;
- /** 最终实付金额(最低¥0.01) */
- private BigDecimal finalAmount;
- /** 新客立减金额(新客时返回) */
- private BigDecimal newCustomerReduce;
- /** 使用的优惠券ID(选券时返回) */
- private Long couponId;
- /** 使用的券名称 */
- private String couponName;
- /** 优惠券减免金额 */
- private BigDecimal couponReduce;
- /** 优惠券是否与促销冲突 */
- private Boolean couponConflict;
- /** 冲突说明 */
- private String conflictNote;
- /** 优惠明细列表 */
- private List<PromotionDetail> details;
- /** 可用优惠券列表 */
- private List<AvailableCoupon> availableCoupons;
- /** 优惠券批次ID(使用券时返回, 对应 promotion_coupon_batch.id) */
- private Long couponBatchId;
- /** 商品券参与优惠的商品明细(仅商品券生效时返回, 含名称/原价/优惠后价) */
- private List<LineItem> couponProductItems;
- // ==================== 满额免运完整配送报价扩展(2026-10-19,pricingVersion=2) ====================
- /** 完整配送报价版本;新流程固定2,旧接口不返回 */
- private Integer pricingVersion;
- /** 原配送费 R(整数元,骑手毛配送费基数) */
- private BigDecimal deliveryFee;
- /** 满额免运减免额 F(不从商品金额扣除) */
- private BigDecimal deliveryDiscountAmount;
- /** 客户实际支付配送费 D */
- private BigDecimal customerDeliveryFee;
- /** 客户整单应付 A = finalAmount(G) + D */
- private BigDecimal payableAmount;
- /** 命中的满额免运活动ID(未命中为null) */
- private Long freeDeliveryActivityId;
- /** 命中的满额免运原价门槛(未命中为null) */
- private BigDecimal freeDeliveryThreshold;
- /** 总优惠预算 B(限制开关关闭时为null表示无限,不用0表示) */
- private BigDecimal discountBudget;
- /** 全部受限优惠分配后剩余预算(开关关闭时为null) */
- private BigDecimal remainingDiscountBudget;
- /** 实际生效且实减>0的优惠券ID(核销以此为准;couponId仅表示用户选择意图) */
- private Long appliedCouponId;
- /**
- * 路径结果
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static class PathResult {
- /** 路径标签(折扣/第二份半价/满减) */
- private String label;
- /** 促销子类型(仅路径A): 2=折扣 3=第二份半价 */
- private Integer appliedType;
- /** 路径小计金额 */
- private BigDecimal subtotal;
- /** 促销减免金额 */
- private BigDecimal promotionReduce;
- /** 商品行明细 */
- private List<LineItem> items;
- /** 匹配到的满减规则(仅路径B) */
- private MatchedRule matchedRule;
- }
- /**
- * 商品行明细
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static class LineItem {
- private Long productId;
- private Integer quantity;
- private BigDecimal unitPrice;
- private String name;
- private BigDecimal originalLineTotal;
- private BigDecimal finalLineTotal;
- /** 折扣率(仅折扣路径, 如 0.70=7折) */
- private BigDecimal discountRate;
- /** 是否命中第二份半价 */
- private Boolean halfPriceApplied;
- }
- /**
- * 匹配到的满减规则(仅路径B)
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static class MatchedRule {
- private Long id;
- private Long activityId;
- private String activityName;
- private BigDecimal threshold;
- private BigDecimal reduceAmount;
- }
- /**
- * 优惠明细
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static class PromotionDetail {
- /** 优惠类型: promotion=促销, coupon=优惠券 */
- private String type;
- /** 促销子类型: 1=满减 2=折扣 3=第二份半价 4=新客立减 5=满额免运 (coupon时为0) */
- private Integer subType;
- /** 优惠名称 */
- private String name;
- /** 减免金额 */
- private BigDecimal reduce;
- /** 关联ID: 促销活动ID(promo_type=1) 或 券批次ID(promo_type=2) */
- private Long refId;
- /** 是否被优惠幅度限制封顶(仅封顶时返回, 对应"已达优惠上限") */
- private Boolean limitCapped;
- /** 商品原价合计 O(type=5满额免运快照扩展字段) */
- private BigDecimal originalAmount;
- /** 原配送费 R(type=5满额免运快照扩展字段) */
- private BigDecimal deliveryFee;
- /** 客户实付配送费 D(type=5满额免运快照扩展字段) */
- private BigDecimal customerDeliveryFee;
- /** 免运门槛(type=5满额免运快照扩展字段) */
- private BigDecimal threshold;
- }
- /**
- * 可用优惠券
- */
- @Data
- @JsonInclude(JsonInclude.Include.NON_NULL)
- public static class AvailableCoupon {
- private Long id;
- private String name;
- /** 券类型: 1=满减券 2=商品券 3=免配送费券 */
- private Integer couponType;
- /** 是否互斥: 0=同享 1=互斥 */
- private Integer isMutex;
- private BigDecimal threshold;
- private BigDecimal amount;
- private BigDecimal discountRate;
- /** 是否可用 */
- private Boolean usable;
- /** 是否与当前促销冲突 */
- private Boolean conflictWithPromotion;
- /** 商品券预估优惠金额(仅商品券, 预览) */
- private BigDecimal couponPreviewReduce;
- /** 商品券作用于的商品预览明细(仅商品券: 名称/原价/优惠后价) */
- private List<LineItem> productPreview;
- /** 不可用原因(目前仅: 本单优惠已达优惠上限) */
- private String unusableReason;
- /** 过期时间 */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Taipei")
- private Date expireTime;
- }
- }
|