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

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.integraltransferlog.vo.IntegralTransferLogPageReqVO;
import cn.newfeifan.mall.module.distri.dal.dataobject.integraltransferlog.IntegralTransferLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 消费分转让记录 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface IntegralTransferLogMapper extends BaseMapperX<IntegralTransferLogDO> {

    default PageResult<IntegralTransferLogDO> selectPage(IntegralTransferLogPageReqVO reqVO) {
        LambdaQueryWrapperX<IntegralTransferLogDO> queryWrapper = new LambdaQueryWrapperX<IntegralTransferLogDO>()
                .likeIfPresent(IntegralTransferLogDO::getTransferUserName, reqVO.getTransferUserName())
                .eqIfPresent(IntegralTransferLogDO::getConsumptionPoints, reqVO.getConsumptionPoints())
                .eqIfPresent(IntegralTransferLogDO::getIntegralType, reqVO.getIntegralType())
                .likeIfPresent(IntegralTransferLogDO::getRecipientUserName, reqVO.getRecipientUserName())
                .betweenIfPresent(IntegralTransferLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IntegralTransferLogDO::getId);
        queryWrapper.apply("(transfer_user_id = '"+reqVO.getTransferUserId()+"' or recipient_user_id = '"+reqVO.getTransferUserId()+"')");
        return selectPage(reqVO, queryWrapper);
    }

}