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

import java.util.*;


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.system.controller.admin.discount.vo.DiscountRulePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.discount.DiscountRuleDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 长者优惠规则 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface DiscountRuleMapper extends BaseMapperX<DiscountRuleDO> {

    default PageResult<DiscountRuleDO> selectPage(DiscountRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DiscountRuleDO>()
                .eqIfPresent(DiscountRuleDO::getElderId, reqVO.getElderId())
                .likeIfPresent(DiscountRuleDO::getElderName, reqVO.getElderName())
                .likeIfPresent(DiscountRuleDO::getRuleName, reqVO.getRuleName())
                .eqIfPresent(DiscountRuleDO::getItemId, reqVO.getItemId())
                .likeIfPresent(DiscountRuleDO::getItemName, reqVO.getItemName())
                .eqIfPresent(DiscountRuleDO::getPrice, reqVO.getPrice())
                .eqIfPresent(DiscountRuleDO::getDiscount, reqVO.getDiscount())
                .eqIfPresent(DiscountRuleDO::getDiscountAmount, reqVO.getDiscountAmount())
                .eqIfPresent(DiscountRuleDO::getDiscountedAmount, reqVO.getDiscountedAmount())
                .betweenIfPresent(DiscountRuleDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(DiscountRuleDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(DiscountRuleDO::getStatus, reqVO.getStatus())
                .inIfPresent(DiscountRuleDO::getTenantId, reqVO.getTenantIds())
                .eqIfPresent(DiscountRuleDO::getRemarks, reqVO.getRemarks())
                .betweenIfPresent(DiscountRuleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DiscountRuleDO::getId));
    }

}