package com.zt.plat.module.contractorder.dal.mysql.salesorder;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;

import com.zt.plat.module.contractorder.controller.admin.salesorder.vo.SalesOrderPageReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PurchaseOrderDO;
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 采购订单 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface SalesOrderMapper extends BaseMapperX<SalesOrderDO> {

    default PageResult<SalesOrderDO> selectPage(SalesOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SalesOrderDO>()
                .likeIfPresent(SalesOrderDO::getOrderSAPNumber, reqVO.getOrderSAPNumber())
                .likeIfPresent(SalesOrderDO::getSystemOrderNumber, reqVO.getSystemOrderNumber())
                .eqIfPresent(SalesOrderDO::getCpNum, reqVO.getCpNum())
                .eqIfPresent(SalesOrderDO::getSupplierNumber, reqVO.getSupplierNumber())
                .likeIfPresent(SalesOrderDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(SalesOrderDO::getType, reqVO.getType())
                .eqIfPresent(SalesOrderDO::getMeteringType, reqVO.getMeteringType())
                .betweenIfPresent(SalesOrderDO::getVoucherDate, reqVO.getVoucherDate())
                .eqIfPresent(SalesOrderDO::getPurchaseOrganizationCustomsDeclaration, reqVO.getPurchaseOrganizationCustomsDeclaration())
                .likeIfPresent(SalesOrderDO::getReceiveFactoryName, reqVO.getReceiveFactoryName())
                .eqIfPresent(SalesOrderDO::getReceiveFactoryNumber, reqVO.getReceiveFactoryNumber())
                .likeIfPresent(SalesOrderDO::getReceiveWarehouseName, reqVO.getReceiveWarehouseName())
                .eqIfPresent(SalesOrderDO::getReceiveWarehouseNumber, reqVO.getReceiveWarehouseNumber())
                .eqIfPresent(SalesOrderDO::getPurchaseGroup, reqVO.getPurchaseGroup())
                .eqIfPresent(SalesOrderDO::getCurrencyNumber, reqVO.getCurrencyNumber())
                .eqIfPresent(SalesOrderDO::getExchangeRate, reqVO.getExchangeRate())
                .likeIfPresent(SalesOrderDO::getPaperContractNumber, reqVO.getPaperContractNumber())
                .likeIfPresent(SalesOrderDO::getAgreementNumber, reqVO.getAgreementNumber())
                .eqIfPresent(SalesOrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SalesOrderDO::getAgentNumber, reqVO.getAgentNumber())
                .likeIfPresent(SalesOrderDO::getAgentName, reqVO.getAgentName())
                .eqIfPresent(SalesOrderDO::getSaleOrgzCd, reqVO.getSaleOrgzCd())
                .likeIfPresent(SalesOrderDO::getSaleOrgzName, reqVO.getSaleOrgzName())
                .likeIfPresent(SalesOrderDO::getSaleAcsName, reqVO.getSaleAcsName())
                .eqIfPresent(SalesOrderDO::getSaleAcsCdg, reqVO.getSaleAcsCdg())
                .likeIfPresent(SalesOrderDO::getPdtGrpName, reqVO.getPdtGrpName())
                .eqIfPresent(SalesOrderDO::getMtrlTp, reqVO.getMtrlTp())
                .likeIfPresent(SalesOrderDO::getPdtGrpCdg, reqVO.getPdtGrpCdg())
                .eqIfPresent(SalesOrderDO::getContractNumber, reqVO.getContractNumber())
                .eqIfPresent(SalesOrderDO::getMaterialNumber, reqVO.getMaterialNumber())
                .likeIfPresent(SalesOrderDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(SalesOrderDO::getContractName, reqVO.getContractName())
                .likeIfPresent(SalesOrderDO::getTenantNumber, reqVO.getTenantNumber())
                .betweenIfPresent(SalesOrderDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SalesOrderDO::getErpPurchaseCompanyNumber, reqVO.getErpPurchaseCompanyNumber())
                .likeIfPresent(SalesOrderDO::getErpPurchaseCompanyName, reqVO.getErpPurchaseCompanyName())
                .eqIfPresent(SalesOrderDO::getErpSalesCompanyNumber, reqVO.getErpSalesCompanyNumber())
                .likeIfPresent(SalesOrderDO::getErpSalesCompanyName, reqVO.getErpSalesCompanyName())
                .likeIfPresent(SalesOrderDO::getPurchaseOrganizationName, reqVO.getPurchaseOrganizationName())
                .eqIfPresent(SalesOrderDO::getErpStatus, reqVO.getErpStatus())
                .eqIfPresent(SalesOrderDO::getSplyBsnTp, reqVO.getSplyBsnTp()!=null?reqVO.getSplyBsnTp():"SALE")
                .eqIfPresent(SalesOrderDO::getCause, reqVO.getCause())
                .eqIfPresent(SalesOrderDO::getStatus, reqVO.getStatus())
                .likeIfPresent(SalesOrderDO::getPurchaseGroupName, reqVO.getPurchaseGroupName())
                .orderByDesc(SalesOrderDO::getId));
    }
}
