Files
zszq-trs/YLErpDAL/Modules/UnderlyingModule/ExchangeOptionDataService.cs
T
2024-05-09 14:06:26 +08:00

105 lines
3.0 KiB
C#

using System.Data;
namespace YLErp.Modules.UnderlyingModule
{
/// <summary>
/// 场内期权数据服务
/// </summary>
public class ExchangeOptionDataService : YLBaseService
{
public ExchangeOptionDataService(OptUserInfo userInfo) : base(userInfo)
{
}
public ExchangeOptionDataService(YLBaseService baseService) : base(baseService)
{
}
/// <summary>
/// 查询exchange_list_option
/// </summary>
public IPagedList<ExchangeListOption> SearchList(ExchangeOptionReq req)
{
var predicate = PredicateBuilder.True<ExchangeListOption>();
if (!string.IsNullOrEmpty(req.ContractCode))
{
predicate = predicate.And(d => d.ContractCode.Contains(req.ContractCode));
}
if (!string.IsNullOrEmpty(req.UnderlyingCode))
{
predicate = predicate.And(d => d.UnderlyingCode.Contains(req.UnderlyingCode));
}
if (!string.IsNullOrEmpty(req.OptionType))
{
predicate = predicate.And(d => d.OptionType.Contains(req.OptionType));
}
if (!string.IsNullOrEmpty(req.ExerciseMode))
{
predicate = predicate.And(d => d.ExerciseMode.Contains(req.ExerciseMode));
}
if (req.MaturityDateStart != DateTime.MinValue)
{
predicate = predicate.And(d => d.MaturityDate >= req.MaturityDateStart);
}
if (req.MaturityDateEnd != DateTime.MinValue)
{
predicate = predicate.And(d => d.MaturityDate <= req.MaturityDateEnd);
}
if (!string.IsNullOrEmpty(req.MarketCode))
{
predicate = predicate.And(d => d.MarketCode == req.MarketCode);
}
var query = DbContext.exchange_list_option.Where(predicate);
return query.ToPagedList(req);
}
public IEnumerable<ExchangeListOption> GetSelectItems(string underlyingCode)
{
return DbContext.exchange_list_option.Where(n => n.UnderlyingCode == underlyingCode).OrderByDescending(n => n.id).ToArray();
}
}
public class ExchangeOptionReq : PagedQueryModel
{
/// <summary>
/// 合约代码
/// </summary>
public string ContractCode { get; set; }
/// <summary>
/// 标的代码
/// </summary>
public string UnderlyingCode { get; set; }
/// <summary>
/// 看涨看跌
/// </summary>
public string OptionType { get; set; }
/// <summary>
/// 行权方式
/// </summary>
public string ExerciseMode { get; set; }
public DateTime MaturityDateStart { get; set; }
public DateTime MaturityDateEnd { get; set; }
/// <summary>
/// 市场代码
/// </summary>
public string MarketCode { get; set; }
}
}