package com.jeeplus.assess.invoice.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.assess.invoice.domain.FinanceInvoice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jeeplus.assess.invoice.domain.FinanceInvoiceTaxClassificationCode;
import com.jeeplus.assess.invoice.service.dto.FinanceInvoiceDTO;
import com.jeeplus.assess.invoice.service.dto.WorkInvoiceReceipt;
import com.jeeplus.assess.invoice.service.dto.WorkInvoiceReceiptInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Entity
 */
@Mapper
//@InterceptorIgnore(tenantLine = "true")
public interface FinanceInvoiceMapper extends BaseMapper<FinanceInvoice> {

    IPage<FinanceInvoiceDTO> findList(Page<FinanceInvoiceDTO> page, @Param(Constants.WRAPPER) QueryWrapper<FinanceInvoice> queryWrapper);
    Long findListCount(@Param(Constants.WRAPPER) QueryWrapper<FinanceInvoice> queryWrapper);

    //查询红字发票数据
    IPage<FinanceInvoiceDTO> findRedList(Page<FinanceInvoiceDTO> page, @Param(Constants.WRAPPER) QueryWrapper<FinanceInvoice> queryWrapper);
    //@InterceptorIgnore(tenantLine = "true")
    FinanceInvoiceDTO queryById(@Param("id") String id);

    /**
     * 根据发票id清空发票的收款日期
     * @param id
     */
    void setReceivablesDateNull(@Param("id") String id);

    List<FinanceInvoiceDTO> getExceedFinance();

    String getInvoiceNumberStr(String id);



    /**
     * 修改开票获取accesstoken失败结果
     * @param workInvoice
     * @return
     */
    Integer updateAccessTokenErrorById(FinanceInvoiceDTO workInvoice);

    /**
     * 修改开票获取的url以及发票号结果
     * @param workInvoice
     * @return
     */
    Integer updateOmsUrlById(FinanceInvoiceDTO workInvoice);

    /**
     * 修改订单提交接口返回值信息
     * @param workInvoice
     * @return
     */
    Integer updateOrderForGoodsResultStrById(FinanceInvoiceDTO workInvoice);

    /**
     * 修改红字确认单返回结果信息
     * @param workInvoice
     * @return
     */
    Integer updateConfirmationSlipResultStr(FinanceInvoiceDTO workInvoice);

    /**
     * 查询税收分类对应信息
     * @param workInvoice
     * @return
     */
    FinanceInvoiceTaxClassificationCode getBillingContentDetail(FinanceInvoiceDTO workInvoice);

    /**
     * 修改开票信息对应个节点redis保存的数据
     * @param workInvoice
     * @return
     */
    Integer updateRedInvoiceJsonByWorkInvoiceId(FinanceInvoiceDTO workInvoice);


    /**
     * 根据项目id查询发票信息
     * @param programIdList
     * @return
     */
    List<FinanceInvoiceDTO> getFinanceInvoiceByProgramId(@Param("programIdList") List<String> programIdList);


    /**
     * 根据发票编号查询已经收款的信息
     * @param invoiceNumberList
     * @return
     */
    List<WorkInvoiceReceipt> getByInvoiceNumber(@Param("list") List<String> invoiceNumberList);


    /**
     * 批量导入
     * @param list
     */
    void batchInsert(@Param("list") List<WorkInvoiceReceipt> list);


    /**
     * 批量修改（拼接多条UPDATE）
     * @param list 待修改的数据集（moneyEqualList/moneyPartialList）
     * @return 影响的行数
     */
    int batchUpdateByForeach(@Param("list") List<WorkInvoiceReceiptInfo> list);
}




