package com.yc.ship.module.trade.dal.mysql.invoiceinventory;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.trade.controller.admin.invoice.inventory.InvoiceInventoryPageReqVO;
import com.yc.ship.module.trade.dal.dataobject.invoiceinventory.InvoiceInventoryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 发票清单 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface InvoiceInventoryMapper extends BaseMapperX<InvoiceInventoryDO> {

    List<InvoiceInventoryDO> selectListByInvoiceId(@Param("invoiceId") Long invoiceId);

    default PageResult<InvoiceInventoryDO> selectPage(InvoiceInventoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceInventoryDO>()
                .eqIfPresent(InvoiceInventoryDO::getInvoiceId, reqVO.getInvoiceId())
                .eqIfPresent(InvoiceInventoryDO::getSort, reqVO.getSort())
                .eqIfPresent(InvoiceInventoryDO::getAmount, reqVO.getAmount())
                .eqIfPresent(InvoiceInventoryDO::getTax, reqVO.getTax())
                .eqIfPresent(InvoiceInventoryDO::getCode, reqVO.getCode())
                .likeIfPresent(InvoiceInventoryDO::getName, reqVO.getName())
                .eqIfPresent(InvoiceInventoryDO::getTaxRate, reqVO.getTaxRate())
                .eqIfPresent(InvoiceInventoryDO::getDeductionAmount, reqVO.getDeductionAmount())
                .eqIfPresent(InvoiceInventoryDO::getFphxz, reqVO.getFphxz())
                .eqIfPresent(InvoiceInventoryDO::getHsbz, reqVO.getHsbz())
                .eqIfPresent(InvoiceInventoryDO::getLslbs, reqVO.getLslbs())
                .eqIfPresent(InvoiceInventoryDO::getYhzcbs, reqVO.getYhzcbs())
                .betweenIfPresent(InvoiceInventoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InvoiceInventoryDO::getId));
    }

}
