# RevenueRateReviewNotifyLogServiceImpl.java

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

    import cloud.wconnect.commonlib.component.BeanMapper;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.redis.PropertyI18nRedisService;
    import cloud.wconnect.commonlib.service.UserInternalService;
    import cloud.wconnect.rateshop.entity.revenue.RevenueRateReviewNotifyLog;
    import cloud.wconnect.rateshop.mapper.revenue.RevenueRateReviewNotifyLogMapper;
    import cloud.wconnect.rateshop.pojo.dto.revenue.RateReviewNotifyLogDTO;
    import cloud.wconnect.rateshop.service.revenue.IRevenueRateReviewNotifyLogService;
    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 java.util.Objects;

    /**
     * <p>
     * Rate Review 通知记录 服务实现类
     * </p>
     *
     * @author yyt
     * @since 2025-03-14
     */
    @Service
    @DS("rate_shop")
    public class RevenueRateReviewNotifyLogServiceImpl extends ServiceImpl<RevenueRateReviewNotifyLogMapper, RevenueRateReviewNotifyLog> implements IRevenueRateReviewNotifyLogService {

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

        /**
         * 获取当天 Rate Review 通知记录
         *
         * @param propertyId 资产 id
         * @param date       指定日期
         * @return 通知记录
         * @author yyt
         * @date 2025/3/14
         **/
        @Override
        public RevenueRateReviewNotifyLog get(Integer propertyId, long date) {
            return getOne(new QueryWrapper<RevenueRateReviewNotifyLog>().lambda()
                    .eq(RevenueRateReviewNotifyLog::getPropertyId, propertyId)
                    .eq(RevenueRateReviewNotifyLog::getTheDate, date)
                    .orderByDesc(RevenueRateReviewNotifyLog::getId)
                    .last("limit 1"));
        }

        /**
         * 获取当天 Rate Review 通知记录
         *
         * @param propertyId 资产 id
         * @param date       指定日期
         * @return 通知记录
         * @author yyt
         * @date 2025/3/14
         **/
        @Override
        public RateReviewNotifyLogDTO getDTO(Integer propertyId, long date) {
            RevenueRateReviewNotifyLog rateReviewNotifyLog = get(propertyId, date);
            if (Objects.isNull(rateReviewNotifyLog)) return new RateReviewNotifyLogDTO();

            RateReviewNotifyLogDTO rateReviewNotifyLogDTO = beanMapper.map(rateReviewNotifyLog, RateReviewNotifyLogDTO.class);

            if (rateReviewNotifyLogDTO.getConfirmBy() > 0) {
                PropertyDTO propertyDTO = propertyI18nRedisService.get(propertyId);
                rateReviewNotifyLogDTO.setConfirmName(userInternalService.getOne(propertyDTO.getTenantId(), rateReviewNotifyLogDTO.getConfirmBy()).getName());
            }

            return rateReviewNotifyLogDTO;
        }

    }