# RevenueOtbRevenueLastYear.java

    package cloud.wconnect.rateshop.entity.revenue;

    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.pojo.dto.internationalization.InternationalizationNumberDTO;
    import cloud.wconnect.commonlib.util.InternationalizationUtils;
    import com.baomidou.mybatisplus.annotation.IdType;
    import com.baomidou.mybatisplus.annotation.TableId;
    import com.baomidou.mybatisplus.annotation.TableName;
    import lombok.Getter;
    import lombok.Setter;
    import lombok.experimental.Accessors;

    import java.io.Serializable;
    import java.math.BigDecimal;
    import java.math.RoundingMode;
    import java.util.Objects;

    /**
     * <p>
     *
     * </p>
     *
     * @author yyt
     * @since 2024-03-23
     */
    @Getter
    @Setter
    @Accessors(chain = true)
    @TableName("revenue_otb_revenue_last_year")
    public class RevenueOtbRevenueLastYear implements Serializable {

        private static final long serialVersionUID = 1L;

        /**
         * 主键id
         */
        @TableId(value = "id", type = IdType.AUTO)
        private Long id;

        /**
         * 资产 id
         */
        private Integer propertyId;

        /**
         * 年份
         */
        private Integer theYear;

        /**
         * 月份
         */
        private Integer theMonth;

        /**
         * OTB Revenue
         */
        private BigDecimal otbRevenue;

        /**
         * OTB Occ%
         */
        private BigDecimal otbOccPercent;

        /**
         * OTB ADR
         */
        private BigDecimal otbAdr;

        /**
         * RevPar
         */
        private BigDecimal otbRevpar;

        /**
         * Banquet Revenue
         */
        private BigDecimal banquetRevenue;

        /**
         * F&B OTB Revenue
         */
        private BigDecimal fbOtbRevenue;

        /**
         * 创建人id
         */
        private Integer createdBy;

        /**
         * 创建时间
         */
        private Long createdTime;

        /**
         * 更新人id
         */
        private Integer updatedBy;

        /**
         * 更新时间
         */
        private Long updatedTime;

        /**
         * 计算 revpar
         *
         * @param number 国际化配置
         * @author yyt
         * @date 2024/4/10
         */
        public void calculateRevpar(InternationalizationNumberDTO number) {
            RoundingMode roundingMode = InternationalizationUtils.getRoundingMode(number.getCalculationRule());

            BigDecimal occPercent = this.otbOccPercent;
            BigDecimal adr = this.otbAdr;
            if (Objects.nonNull(occPercent) && Objects.nonNull(adr)) {
                // revpar = occ * adr
                this.otbRevpar = occPercent.multiply(adr).divide(BigDecimal.valueOf(100L), BaseConstant.DATA_PRECISION, roundingMode);
            } else {
                this.otbRevpar = null;
            }
        }

    }