
package com.czg.order.dto;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 订单表 实体类。
 *
 * @author ww
 * @since 2025-02-13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CheckOrderPay implements Serializable {

    //限时折扣部分
    private LimitRateDTO limitRate;

    /**
     * 是否霸王餐
     */
    private boolean isFreeDine;
    private boolean withCoupon = true;
    private boolean withPoints = true;

    /**
     * 用餐模式 堂食 dine-in  外带 take-out 外卖 take-away
     */
    private String dineMode;

    @NotNull(message = "订单id不可为空")
    private Long orderId;

    private Long userId;

    private Integer vipPrice;
    /**
     * 是否整单打包
     */
    private Integer allPack;
    /**
     * 用户端 使用 全打包 或者 全不打包
     */
    private Integer userAllPack;

    /**
     * 用餐人数
     */
    private Integer seatNum;

    /**
     * 订单原金额（包含打包费+餐位费） 不含折扣价格
     */
    private BigDecimal originAmount;

    /**
     * 手动优惠金额
     */
    private BigDecimal discountAmount;
    /**
     * 新客立减
     */
    private Long newCustomerDiscountId;
    private BigDecimal newCustomerDiscountAmount;

    /**
     * 商品优惠券抵扣金额
     */
    private BigDecimal productCouponDiscountAmount;
    /**
     * 满减活动抵扣金额
     */
    private BigDecimal discountActAmount;
    /**
     * 满减活动Id
     */
    private Long discountActId;
    /**
     * 其它优惠券抵扣金额
     */
    private BigDecimal otherCouponDiscountAmount;
    /**
     * 用户使用的卡券
     */
    private List<Long> couponList;

    /**
     * 订单金额
     */
    private BigDecimal orderAmount;
    /**
     * 抹零金额 减免多少钱
     */
    private BigDecimal roundAmount;

    /**
     * 积分抵扣金额(tb_points_basic_setting表)
     */
    private BigDecimal pointsDiscountAmount;
    /**
     * 会员折扣减免金额
     */
    private BigDecimal vipDiscountAmount;

    /**
     * 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
     */
    private Integer pointsNum;
    /**
     * 是否打票
     */
    private Integer isPrint;

    private String remark;

    private String extend;


    public Integer getSeatNum() {
        return seatNum == null ? 0 : seatNum;
    }

    public Integer getIsPrint() {
        return isPrint == null ? 1 : isPrint;
    }

    public Integer getPointsNum() {
        return pointsNum == null ? 0 : pointsNum;
    }

    /**
     * 新客立减金额
     */
    public BigDecimal getNewCustomerDiscountAmount() {
        return newCustomerDiscountAmount == null ? BigDecimal.ZERO : newCustomerDiscountAmount;
    }

    /**
     * 满减活动抵扣金额
     */
    public BigDecimal getDiscountActAmount() {
        return discountActAmount == null ? BigDecimal.ZERO : discountActAmount;
    }

    public BigDecimal getOtherCouponDiscountAmount() {
        return otherCouponDiscountAmount == null ? BigDecimal.ZERO : otherCouponDiscountAmount;
    }

    public BigDecimal getProductCouponDiscountAmount() {
        return productCouponDiscountAmount == null ? BigDecimal.ZERO : productCouponDiscountAmount;
    }

    public BigDecimal getDiscountAmount() {
        return discountAmount == null ? BigDecimal.ZERO : discountAmount;
    }

    public BigDecimal getPointsDiscountAmount() {
        return pointsDiscountAmount == null ? BigDecimal.ZERO : pointsDiscountAmount;
    }

    public BigDecimal getRoundAmount() {
        return roundAmount == null ? BigDecimal.ZERO : roundAmount;
    }

    public BigDecimal getVipDiscountAmount() {
        return vipDiscountAmount == null ? BigDecimal.ZERO : vipDiscountAmount;
    }


    public boolean isVipPrice() {
        return vipPrice != null && vipPrice == 1;
    }

    public boolean isAllPack() {
        return allPack != null && allPack == 1;
    }
}
