# PriceCacheKeyDTO.java

    package cloud.wconnect.rateshop.pojo.dto.rateshop;

    import lombok.Data;
    import lombok.experimental.Accessors;
    import org.apache.commons.lang3.StringUtils;

    import java.util.Arrays;
    import java.util.List;

    /**
     * 房价缓存Key所需的字段
     *
     * @author lichen
     * @date 2025/4/4
     */
    @Data
    @Accessors(chain = true)
    public class PriceCacheKeyDTO {

        /**
         * 酒店id
         */
        private Integer hotelId;

        /**
         * 销售地区。us：美国 tw：台湾
         */
        private String pos;

        /**
         * 币种id
         */
        private Integer currencyId;

        /**
         * 入住日期（yyyyMMdd）
         */
        private Long checkInDate;

        /**
         * 房价抓取数据源ID
         */
        private Integer datasourceId;

        /**
         * 平台id（0表示官网）
         */
        private Integer platformId;

        /**
         * 房价类型
         */
        private Integer rateType;

        /**
         * 含税标志
         */
        private Integer containTaxFlag;

        /**
         * 最低房价的缓存key前缀
         */
        public static final String LOWEST_RATE_CACHE_KEY_PREFIX = "lowest-rate";
        /**
         * 有效的最低房价缓存key前缀（忽略sold out 和 no data的最低价格）
         */
        public static final String VALID_LOWEST_RATE_CACHE_KEY_PREFIX = "valid-lowest-rate";
        /**
         * 最低房价调涨次数的缓存key前缀
         */
        public static final String LOWEST_RATE_RISE_TIMES_CACHE_KEY_PREFIX = "lowest-rate-rise-times";

        /**
         * 生成最低房价的缓存key
         * lowest-rate:{hotleId}:{pos}:{currencyId}:{checkInDate}:{datasourceId}:{platformId}:{房价类型}:{含税标志}
         *
         * @return java.lang.String
         * @author lichen
         * @date 2025/4/4
         */
        public String generateLowestRateCacheKey() {
            Integer hotelId = this.getHotelId();
            String pos = this.getPos();
            Integer currencyId = this.getCurrencyId();
            Long checkInDate = this.getCheckInDate();
            Integer datasourceId = this.getDatasourceId();
            Integer platformId = this.getPlatformId();
            Integer rateType = this.getRateType();
            Integer containTaxFlag = this.getContainTaxFlag();

            List<String> list = Arrays.asList(LOWEST_RATE_CACHE_KEY_PREFIX, hotelId.toString(), pos, currencyId.toString(),
                    checkInDate.toString(), datasourceId.toString(), platformId.toString(), rateType.toString(), containTaxFlag.toString());
            return StringUtils.join(list, ":");
        }

        /**
         * 生成有效最低房价的缓存key
         * valid-lowest-rate:{hotleId}:{pos}:{currencyId}:{checkInDate}:{datasourceId}:{platformId}:{房价类型}:{含税标志}
         *
         * @return java.lang.String
         * @author lichen
         * @date 2025/4/4
         */
        public String generateValidLowestRateCacheKey() {
            Integer hotelId = this.getHotelId();
            String pos = this.getPos();
            Integer currencyId = this.getCurrencyId();
            Long checkInDate = this.getCheckInDate();
            Integer datasourceId = this.getDatasourceId();
            Integer platformId = this.getPlatformId();
            Integer rateType = this.getRateType();
            Integer containTaxFlag = this.getContainTaxFlag();

            List<String> list = Arrays.asList(VALID_LOWEST_RATE_CACHE_KEY_PREFIX, hotelId.toString(), pos, currencyId.toString(),
                    checkInDate.toString(), datasourceId.toString(), platformId.toString(), rateType.toString(), containTaxFlag.toString());
            return StringUtils.join(list, ":");
        }

        /**
         * 生成最低房价调涨次数的缓存key
         * lowest-rate-rise-times:{hotleId}:{pos}:{currencyId}:{checkInDate}:{datasourceId}:{platformId}:{房价类型}:{含税标志}
         *
         * @return java.lang.String
         * @author lichen
         * @date 2025/4/4
         */
        public String generateLowestRateRiseTimesCacheKey() {
            Integer hotelId = this.getHotelId();
            String pos = this.getPos();
            Integer currencyId = this.getCurrencyId();
            Long checkInDate = this.getCheckInDate();
            Integer datasourceId = this.getDatasourceId();
            Integer platformId = this.getPlatformId();
            Integer rateType = this.getRateType();
            Integer containTaxFlag = this.getContainTaxFlag();

            List<String> list = Arrays.asList(LOWEST_RATE_RISE_TIMES_CACHE_KEY_PREFIX, hotelId.toString(), pos, currencyId.toString(),
                    checkInDate.toString(), datasourceId.toString(), platformId.toString(), rateType.toString(), containTaxFlag.toString());
            return StringUtils.join(list, ":");
        }

    }