package cn.iocoder.yudao.module.system.dal.mysql.tenantpoints;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 租户积分记录 Mapper
 *
 * @author 总后台
 */
@Mapper
public interface TenantPointsMapper extends BaseMapperX<TenantPointsDO> {

    default PageResult<TenantPointsDO> selectPage(TenantPointsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TenantPointsDO>()
                .eqIfPresent(TenantPointsDO::getPoints, reqVO.getPoints())
                .eqIfPresent(TenantPointsDO::getBalance, reqVO.getBalance())
                .eqIfPresent(TenantPointsDO::getType, reqVO.getType())
                .eqIfPresent(TenantPointsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(TenantPointsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(TenantPointsDO::getBizNo, reqVO.getBizNo())
                .eqIfPresent(TenantPointsDO::getOperatorId, reqVO.getOperatorId())
                .eqIfPresent(TenantPointsDO::getTargetTenantId, reqVO.getTargetTenantId())
                .eqIfPresent(TenantPointsDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(TenantPointsDO::getId));
    }

    default PageResult<TenantPointsDO> TenantTransactionHistoryPointsPage(PageParam pageReqVO, Long tenantId){
        return selectPage(pageReqVO, new LambdaQueryWrapperX<TenantPointsDO>()
                .eq(TenantPointsDO::getTenantId, tenantId)
                .orderByDesc(TenantPointsDO::getCreatedAt));
    }

    default PageResult<TenantPointsDO> selectPageWithTenantId(TenantPointsPageReqVO reqVO, Long tenantId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TenantPointsDO>()
                .eq(TenantPointsDO::getTenantId, tenantId)
                .eqIfPresent(TenantPointsDO::getPoints, reqVO.getPoints())
                .eqIfPresent(TenantPointsDO::getBalance, reqVO.getBalance())
                .eqIfPresent(TenantPointsDO::getType, reqVO.getType())
                .eqIfPresent(TenantPointsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(TenantPointsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(TenantPointsDO::getBizNo, reqVO.getBizNo())
                .eqIfPresent(TenantPointsDO::getOperatorId, reqVO.getOperatorId())
                .eqIfPresent(TenantPointsDO::getTargetTenantId, reqVO.getTargetTenantId())
                .eqIfPresent(TenantPointsDO::getCreatedAt, reqVO.getCreatedAt())
                .orderByDesc(TenantPointsDO::getId));
    }

    IPage<TenantPointsPageRespVO> selectPageWithXML(@Param("iPage") IPage<TenantPointsPageRespVO> iPage, @Param("pageReqVO") TenantPointsPageReqVO pageReqVO);

    IPage<TenantPointsPageRespVO> selectPageWithTenantIdXML(@Param("iPage")IPage<TenantPointsPageRespVO> iPage,@Param("pageReqVO") TenantPointsPageReqVO pageReqVO,@Param("tenantId") Long tenantId);
}