package cn.newfeifan.mall.module.distri.dal.mysql.ptprofitdailystatisticslog;

import java.time.LocalDate;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.newfeifan.mall.module.distri.controller.admin.ptprofitdailystatisticslog.vo.*;

/**
 * 平台利润每日统计记录 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface PtProfitDailyStatisticsLogMapper extends BaseMapperX<PtProfitDailyStatisticsLogDO> {

    default PageResult<PtProfitDailyStatisticsLogDO> selectPage(PtProfitDailyStatisticsLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitDailyStatisticsLogDO>()
                .eqIfPresent(PtProfitDailyStatisticsLogDO::getEveryday, reqVO.getEveryday())
                .eqIfPresent(PtProfitDailyStatisticsLogDO::getTotalCollisionAmount, reqVO.getTotalCollisionAmount())
                .eqIfPresent(PtProfitDailyStatisticsLogDO::getTotalRemainingAmount, reqVO.getTotalRemainingAmount())
                .betweenIfPresent(PtProfitDailyStatisticsLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PtProfitDailyStatisticsLogDO::getEveryday));
    }

    default PtProfitDailyStatisticsLogDO selectByEveryday(LocalDate now) {
        return selectOne(new LambdaQueryWrapper<PtProfitDailyStatisticsLogDO>()
                .eq(PtProfitDailyStatisticsLogDO::getEveryday, now)
        );
    }
}