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

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

/**
 * 积分相关计算浮动百分比设置 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface OrderPercentageMapper extends BaseMapperX<OrderPercentageDO> {

    default PageResult<OrderPercentageDO> selectPage(OrderPercentagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderPercentageDO>()
                .eqIfPresent(OrderPercentageDO::getGrossProfitPerc, reqVO.getGrossProfitPerc())
                .eqIfPresent(OrderPercentageDO::getGrossProfitAncestorQuotaPerc, reqVO.getGrossProfitAncestorQuotaPerc())
                .eqIfPresent(OrderPercentageDO::getGrossProfitBonusQuotaPerc, reqVO.getGrossProfitBonusQuotaPerc())
                .eqIfPresent(OrderPercentageDO::getGrossProfitPlatformQuotaPerc, reqVO.getGrossProfitPlatformQuotaPerc())
                .eqIfPresent(OrderPercentageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(OrderPercentageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderPercentageDO::getId));
    }

}