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 codes, Func 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; } } }