# WeeklyMonthlyRevenueRoomTypeServiceImpl.java

    package cloud.wconnect.rateshop.service.weeklymonthlyrevenue.impl;

    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.rateshop.entity.weeklymonthlyrevenue.WeeklyMonthlyRevenueRoomType;
    import cloud.wconnect.rateshop.mapper.weeklymonthlyrevenue.WeeklyMonthlyRevenueRoomTypeMapper;
    import cloud.wconnect.rateshop.pojo.dto.weeklymonthlyrevenue.WeeklyMonthlyRevenueRoomTypeDTO;
    import cloud.wconnect.rateshop.service.weeklymonthlyrevenue.IWeeklyMonthlyRevenueRoomTypeService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    /**
     * <p>
     * Weekly Monthly Revenue Room type 服务实现类
     * </p>
     *
     * @author zc
     * @since 2024-05-13
     */
    @Service
    @DS("rate_shop")
    public class WeeklyMonthlyRevenueRoomTypeServiceImpl extends ServiceImpl<WeeklyMonthlyRevenueRoomTypeMapper, WeeklyMonthlyRevenueRoomType> implements IWeeklyMonthlyRevenueRoomTypeService {

        /**
         * 获取指定年月的 Room type
         *
         * @param propertyId 资产 id
         * @param theMonth   年月（yyyyMM）
         * @return WeeklyMonthlyRevenueRoomType
         * @author zc
         * @date 2024/5/14
         */
        @Override
        public WeeklyMonthlyRevenueRoomType getByMonth(int propertyId, long theMonth) {
            return getOne(new LambdaQueryWrapper<WeeklyMonthlyRevenueRoomType>()
                    .eq(WeeklyMonthlyRevenueRoomType::getTheMonth, theMonth)
                    .eq(WeeklyMonthlyRevenueRoomType::getPropertyId, propertyId));
        }

        /**
         * 保存指定年月的 Room Type
         *
         * @param propertyId  资产 id
         * @param roomTypeDTO 保存内容 DTO
         * @param operatorId  操作人 id
         * @author zc
         * @date 2024/5/14
         */
        @Override
        public void saveRoomType(int propertyId, WeeklyMonthlyRevenueRoomTypeDTO roomTypeDTO, int operatorId) {
            WeeklyMonthlyRevenueRoomType roomType = new WeeklyMonthlyRevenueRoomType()
                    .setPropertyId(propertyId)
                    .setTheMonth(roomTypeDTO.getTheMonth())
                    .setRoomType(roomTypeDTO.getRoomType())
                    .setUpdatedBy(operatorId)
                    .setUpdatedTime(DateTimeUtils.nowTimestamp());
            baseMapper.insertOrUpdateByUnique(roomType);
        }
    }