Files
zszq-trs/YLErpDAL/Helpers/UndelyingHelper.cs
T
2024-05-09 14:06:26 +08:00

55 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YLErp.Modules;
namespace YLErp.Helpers
{
public static class UndelyingHelper
{
public static bool IsCodesExistsCommoditySpot(IEnumerable<string> codes, Func<underlying_manager, bool> func)
{
if (func is null)
{
throw new ArgumentNullException(nameof(func));
}
var flag = false;
foreach (var item in codes)
{
var um = DataCacheProvider.GetUnderlyingDataSource().GetData(item);
if (um != null)
{
if (um.UnderlyingType == "组合标的")
{
var syntheticUnderlying = DataCacheProvider.GetUnderlyingDataSource().GetSyntheticUnderlying(um.UnderlyingCode);
var syntheticCodes = syntheticUnderlying.GetUnderlyingCodes();
if (IsCodesExistsCommoditySpot(syntheticCodes, func))
{
flag = true;
break;
}
}
if (func?.Invoke(um) ?? false)
{
flag = true;
break;
}
}
}
return flag;
}
}
}