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

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.controller.app.consumptionchangelog.vo.ConsumptionChangeLogPageReqVO;
import cn.newfeifan.mall.module.distri.dal.dataobject.consumptionchangelog.ConsumptionChangeLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 平台消费分变动记录 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface ConsumptionChangeLogMapper extends BaseMapperX<ConsumptionChangeLogDO> {

    default PageResult<ConsumptionChangeLogDO> selectPage(ConsumptionChangeLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConsumptionChangeLogDO>()
                .eqIfPresent(ConsumptionChangeLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ConsumptionChangeLogDO::getConsumptionPoints, reqVO.getConsumptionPoints())
                .eqIfPresent(ConsumptionChangeLogDO::getAfterConsumptionPoints, reqVO.getAfterConsumptionPoints())
                .eqIfPresent(ConsumptionChangeLogDO::getConsumptionStatus, reqVO.getConsumptionStatus())
                .betweenIfPresent(ConsumptionChangeLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ConsumptionChangeLogDO::getId));
    }

}