# RevenueDailySummaryMepsServiceImpl.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.RevenueDailySummaryMeps;
    import cloud.wconnect.rateshop.mapper.revenue.RevenueDailySummaryMepsMapper;
    import cloud.wconnect.rateshop.pojo.bo.revenue.MepsGroupTotalBO;
    import cloud.wconnect.rateshop.service.revenue.IRevenueDailySummaryMepsService;
    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使用的Group Business Summary报告中数据MEPS group total 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2025-01-10
     */
    @Service
    @DS("rate_shop")
    public class RevenueDailySummaryMepsServiceImpl extends ServiceImpl<RevenueDailySummaryMepsMapper, RevenueDailySummaryMeps> implements IRevenueDailySummaryMepsService {

        @Autowired
        private RevenueDailySummaryMepsMapper revenueDailySummaryMepsMapper;
        @Autowired
        private BeanMapper beanMapper;

        /**
         * 保存MEPS Group Total
         *
         * @param propertyDTO       资产DTO
         * @param mepsGroupTotalBOS MEPS Group Total 集合
         * @return void
         * @author lichen
         * @date 2025/1/10
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void saveOrUpdate(PropertyDTO propertyDTO, List<MepsGroupTotalBO> mepsGroupTotalBOS) {
            if (CollectionUtils.isEmpty(mepsGroupTotalBOS)) return;
            long nowTimestamp = DateTimeUtils.nowTimestamp();
            List<RevenueDailySummaryMeps> revenueDailySummaryMeps = beanMapper.mapList(mepsGroupTotalBOS, RevenueDailySummaryMeps.class, (bo, entity) -> {
                entity.setPropertyId(propertyDTO.getId());
                entity.setSyncTime(nowTimestamp);
            });
            //根据唯一索引新增或修改
            revenueDailySummaryMepsMapper.saveOrUpdateByUnique(revenueDailySummaryMeps);
        }

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