package co.yixiang.yshop.module.distributor.dal.mysql.distributorwageslog;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.distributor.dal.dataobject.distributorwageslog.DistributorWagesLogDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.distributor.controller.admin.distributorwageslog.vo.*;

/**
 * 分销商佣金记录 Mapper
 *
 * @author admin
 */
@Mapper
public interface DistributorWagesLogMapper extends BaseMapperX<DistributorWagesLogDO> {

    default PageResult<DistributorWagesLogDO> selectPage(DistributorWagesLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DistributorWagesLogDO>()
                .eqIfPresent(DistributorWagesLogDO::getWagesId, reqVO.getWagesId())
                .eqIfPresent(DistributorWagesLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(DistributorWagesLogDO::getType, reqVO.getType())
                .eqIfPresent(DistributorWagesLogDO::getAmount, reqVO.getAmount())
                .betweenIfPresent(DistributorWagesLogDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DistributorWagesLogDO::getDistributorId, reqVO.getDistributorId())
                .eqIfPresent(DistributorWagesLogDO::getStatus, reqVO.getStatus())
                .likeIfPresent(DistributorWagesLogDO::getUserName, reqVO.getUserName())
                .likeIfPresent(DistributorWagesLogDO::getDistributorName, reqVO.getDistributorName())
                .inIfPresent(DistributorWagesLogDO::getType, reqVO.getTypeList())
                .eqIfPresent(DistributorWagesLogDO::getOrderId, reqVO.getOrderId())
                .orderByDesc(DistributorWagesLogDO::getId));
    }

    default List<DistributorWagesLogDO> selectList(DistributorWagesLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DistributorWagesLogDO>()
                .eqIfPresent(DistributorWagesLogDO::getWagesId, reqVO.getWagesId())
                .eqIfPresent(DistributorWagesLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(DistributorWagesLogDO::getType, reqVO.getType())
                .eqIfPresent(DistributorWagesLogDO::getAmount, reqVO.getAmount())
                .betweenIfPresent(DistributorWagesLogDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DistributorWagesLogDO::getDistributorId, reqVO.getDistributorId())
                .eqIfPresent(DistributorWagesLogDO::getStatus, reqVO.getStatus())
                .likeIfPresent(DistributorWagesLogDO::getUserName, reqVO.getUserName())
                .likeIfPresent(DistributorWagesLogDO::getDistributorName, reqVO.getDistributorName())
                .inIfPresent(DistributorWagesLogDO::getDistributorOrderId, reqVO.getDistributorOrderIds())
                .inIfPresent(DistributorWagesLogDO::getType, reqVO.getTypeList())
                .eqIfPresent(DistributorWagesLogDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(DistributorWagesLogDO::getMethodType, reqVO.getMethodType())
                .orderByDesc(DistributorWagesLogDO::getId));
    }

}
