package cn.iocoder.yudao.module.member.dal.mysql.user;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberCardPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberCardPageRespVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberCardStatisticReportVO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberCardDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 会员卡 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface MemberCardMapper extends BaseMapperX<MemberCardDO> {
    List<MemberCardDO> getEmployeeMemberCardList();

    List<MemberCardPageRespVO> getCardPage(Page<MemberCardPageRespVO> page, @Param("params") MemberCardPageReqVO pageReqVO);

    default PageResult<MemberCardDO> selectPage(MemberCardPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberCardDO>()
                .eqIfPresent(MemberCardDO::getMemberUserId, reqVO.getMemberUserId())
                .likeIfPresent(MemberCardDO::getMemberCardName, reqVO.getMemberCardName())
                .eqIfPresent(MemberCardDO::getMemberCardNumber, reqVO.getMemberCardNumber())
                .eqIfPresent(MemberCardDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MemberCardDO::getBalanceAmount, reqVO.getBalanceAmount())
                .betweenIfPresent(MemberCardDO::getActivateCardTime, reqVO.getActivateCardTime())
                .eqIfPresent(MemberCardDO::getPermission, reqVO.getPermission())
                .orderByDesc(MemberCardDO::getCreatedTime));
    }

    List<MemberCardStatisticReportVO> getMemberCardStatisticalReportPage(Page<MemberCardStatisticReportVO> page, @Param("params") MemberCardPageReqVO pageReqVO);
}