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

import java.util.*;

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

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

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

}