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

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

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

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

}