package cn.iocoder.yudao.module.mes.dal.mysql.saleorder;

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.mes.controller.admin.saleorder.vo.SaleOrderPageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.saleorder.SaleOrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 销售订单 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface SaleOrderMapper2 extends BaseMapperX<SaleOrderDO> {

    default PageResult<SaleOrderDO> selectPage(SaleOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SaleOrderDO>()
                .eqIfPresent(SaleOrderDO::getNo, reqVO.getNo())
                .eqIfPresent(SaleOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SaleOrderDO::getCustomerId, reqVO.getCustomerId())
                .betweenIfPresent(SaleOrderDO::getOrderTime, reqVO.getOrderTime())
                .eqIfPresent(SaleOrderDO::getTotalCount, reqVO.getTotalCount())
                .eqIfPresent(SaleOrderDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(SaleOrderDO::getTotalProductPrice, reqVO.getTotalProductPrice())
                .eqIfPresent(SaleOrderDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SaleOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SaleOrderDO::getId));
    }

}