# RevenueDailySummaryManagerFlashServiceImpl.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.util.DateTimeUtils;
    import cloud.wconnect.rateshop.entity.revenue.RevenueDailySummaryManagerFlash;
    import cloud.wconnect.rateshop.mapper.revenue.RevenueDailySummaryManagerFlashMapper;
    import cloud.wconnect.rateshop.pojo.bo.revenue.ManagerFlashBO;
    import cloud.wconnect.rateshop.service.revenue.IRevenueDailySummaryManagerFlashService;
    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.apache.commons.collections.CollectionUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import java.util.List;

    /**
     * <p>
     * Daily Sumamry Final使用的Manager Flash报告中数据No Show/Cancelled/ADR 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2025-01-10
     */
    @Service
    @DS("rate_shop")
    public class RevenueDailySummaryManagerFlashServiceImpl extends ServiceImpl<RevenueDailySummaryManagerFlashMapper, RevenueDailySummaryManagerFlash> implements IRevenueDailySummaryManagerFlashService {

        @Autowired
        private BeanMapper beanMapper;
        @Autowired
        private RevenueDailySummaryManagerFlashMapper revenueDailySummaryManagerFlashMapper;

        /**
         * 保存Manager Flash报告中的数据No Show/Cancelled/ADR
         *
         * @param propertyDTO     资产DTO
         * @param managerFlashBOS Manager Flash报告中的数据No Show/Cancelled/ADR集合
         * @return void
         * @author lichen
         * @date 2025/1/10
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void saveOrUpdate(PropertyDTO propertyDTO, List<ManagerFlashBO> managerFlashBOS) {
            if (CollectionUtils.isEmpty(managerFlashBOS)) return;
            long nowTimestamp = DateTimeUtils.nowTimestamp();
            List<RevenueDailySummaryManagerFlash> revenueDailySummaryManagerFlashs = beanMapper.mapList(managerFlashBOS, RevenueDailySummaryManagerFlash.class, (bo, entity) -> {
                entity.setPropertyId(propertyDTO.getId());
                entity.setSyncTime(nowTimestamp);
            });
            //根据唯一索引新增或修改
            revenueDailySummaryManagerFlashMapper.saveOrUpdateByUnique(revenueDailySummaryManagerFlashs);
        }

        /**
         * 根据资产ID和日期查询No Show/Cancelled/ADR
         *
         * @param propertyId 资产ID
         * @param targetDate 指定日期
         * @return cloud.wconnect.rateshop.entity.revenue.RevenueDailySummaryManagerFlash
         * @author lichen
         * @date 2025/1/10
         */
        @Override
        public RevenueDailySummaryManagerFlash getByDate(Integer propertyId, long targetDate) {
            return getOne(new LambdaQueryWrapper<RevenueDailySummaryManagerFlash>()
                    .eq(RevenueDailySummaryManagerFlash::getPropertyId, propertyId)
                    .eq(RevenueDailySummaryManagerFlash::getTheDate, targetDate));
        }
    }