package com.sunxung.factoring.service.underlying;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sunxung.factoring.entity.underlying.UnderlyingGoodsInfo;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author liutao
 * @date 2021.10.11
 */
public interface UnderlyingGoodsInfoService extends IService<UnderlyingGoodsInfo> {

    /**
     * 根据业务编号计算对应货物的销售质保金之和
     *
     * @param businessNumber 业务编号
     * @return
     */
    BigDecimal sumSalesGuaranteeMoney(String businessNumber);

    /**
     * 根据业务编号计算对应货物的采购质保金之和
     *
     * @param businessNumber 业务编号
     * @param supplierId     供应商Id
     * @return
     */
    BigDecimal sumPurchGuaranteeMoney(String businessNumber, Long supplierId);

    /**
     * 根据业务基础信息Id计算对应货物的销售总价
     *
     * @param underlyingBasicInfoId 底层基础信息Id
     * @return
     */
    BigDecimal sumSalesTotalPrice(Long underlyingBasicInfoId);

    /**
     * 根据业务基础信息Id计算对应货物的采购总价
     *
     * @param underlyingBasicInfoId 底层基础信息Id
     * @return
     */
    BigDecimal sumPurchaseTotalPrice(Long underlyingBasicInfoId);

    /**
     * 根据底层基础信息Id获取对应验收单号
     *
     * @param underlyingBasicInfoId
     * @return
     */
    List<Long> findAcceptanceIdByBasicId(Long underlyingBasicInfoId);

    /**
     * 根据底层基础信息Id获取对应结算单号
     *
     * @param underlyingBasicInfoId
     * @return
     */
    List<Long> findSettlementIdByBasicId(Long underlyingBasicInfoId);


    /**
     * 是否存在同一批验收单或结算单未驳回的货物
     *
     * @param acceptanceBasicInfoIds 验收单基础信息Id
     * @param settlementBasicInfoIds 结算单基础信息Id
     * @return
     */
    Boolean existSameGoods(List<Long> acceptanceBasicInfoIds, List<Long> settlementBasicInfoIds);

    /**
     *  根据验收单id获取底层货物
     * @param acceptanceBasicInfoId
     * @return
     */
    List<UnderlyingGoodsInfo> listByAcceptanceId(Long acceptanceBasicInfoId);
}
