package com.ruoyi.web.modules.trading.support;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.web.modules.trading.mapper.BizSupplierSettlementMapper;

/**
 * 供应商下游业务引用检查。
 */
@Component
public class SupplierReferenceChecker
{
    @Autowired
    private BizSupplierSettlementMapper bizSupplierSettlementMapper;

    /**
     * 是否存在未删除的待结算结算单。
     */
    public boolean hasUnsettledSettlement(Long supplierId)
    {
        if (supplierId == null)
        {
            return false;
        }
        Long count = bizSupplierSettlementMapper.countPendingBySupplierId(supplierId);
        return count != null && count > 0;
    }

    /**
     * 是否存在阻止删除的下游引用（本期：未结算结算单）。
     */
    public boolean hasReference(Long supplierId)
    {
        return hasUnsettledSettlement(supplierId);
    }
}
