# RevenueRateReviewServiceImpl.java

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

    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.pojo.dto.UserDTO;
    import cloud.wconnect.commonlib.redis.PropertyI18nRedisService;
    import cloud.wconnect.commonlib.service.UserInternalService;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.rateshop.entity.revenue.RevenueRateReview;
    import cloud.wconnect.rateshop.mapper.revenue.RevenueRateReviewMapper;
    import cloud.wconnect.rateshop.pojo.dto.revenue.RateReviewDTO;
    import cloud.wconnect.rateshop.service.revenue.IRevenueRateReviewService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.Objects;

    /**
     * <p>
     * Rate Review 确认记录 服务实现类
     * </p>
     *
     * @author yyt
     * @since 2025-02-11
     */
    @Service
    @DS("rate_shop")
    public class RevenueRateReviewServiceImpl extends ServiceImpl<RevenueRateReviewMapper, RevenueRateReview> implements IRevenueRateReviewService {

        @Autowired
        private UserInternalService userInternalService;
        @Autowired
        private PropertyI18nRedisService propertyI18nRedisService;

        /**
         * 保存 Rate Review 确认记录
         *
         * @param propertyId 资产 id
         * @param date       指定日期
         * @param userId     操作人
         * @author yyt
         * @date 2025/2/11
         **/
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void save(Integer propertyId, long date, int userId) {
            RevenueRateReview revenueRateReview = new RevenueRateReview();
            revenueRateReview.setPropertyId(propertyId);
            revenueRateReview.setTheDate(date);
            revenueRateReview.setUpdatedBy(userId);
            revenueRateReview.setUpdatedTime(DateTimeUtils.nowTimestamp());
            baseMapper.saveOrUpdate(revenueRateReview);
        }

        /**
         * 获取 Rate Review 确认记录
         *
         * @param propertyId 资产 id
         * @param date       指定日期
         * @return Rate Review 确认记录
         * @author yyt
         * @date 2025/2/11
         **/
        @Override
        public RateReviewDTO getDTO(Integer propertyId, long date) {
            RateReviewDTO rateReviewDTO = new RateReviewDTO();

            RevenueRateReview revenueRateReview = get(propertyId, date);
            if (Objects.isNull(revenueRateReview)) return rateReviewDTO;

            PropertyDTO propertyDTO = propertyI18nRedisService.get(propertyId);
            UserDTO user = userInternalService.getOne(propertyDTO.getTenantId(), revenueRateReview.getUpdatedBy());
            rateReviewDTO.setUpdatedBy(revenueRateReview.getUpdatedBy());
            rateReviewDTO.setUpdatedName(user.getName());
            rateReviewDTO.setUpdatedTime(revenueRateReview.getUpdatedTime());
            return rateReviewDTO;
        }

        /**
         * 获取 Rate Review 确认记录
         *
         * @param propertyId 资产 id
         * @param date       指定日期
         * @return Rate Review 确认记录
         * @author yyt
         * @date 2025/2/11
         **/
        @Override
        public RevenueRateReview get(Integer propertyId, long date) {
            return getOne(new QueryWrapper<RevenueRateReview>().lambda()
                    .eq(RevenueRateReview::getPropertyId, propertyId)
                    .eq(RevenueRateReview::getTheDate, date));
        }

    }