成交簿记搬迁山证fr007
This commit is contained in:
@@ -28,6 +28,101 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询今天是否有FR007的数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
public eod_commodity_future_price SearchTodayFRData(DateTime dateTime)
|
||||
{
|
||||
var data = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime).FirstOrDefault();
|
||||
if (data == null)
|
||||
{
|
||||
data = new eod_commodity_future_price();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询选择的时间是否拥有FR007的数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
public List<eod_commodity_future_price> SearchdateFRData(List<DateTime> date)
|
||||
{
|
||||
var datafr007 = DbContext.eod_commodity_future_price.Where(a => date.Contains(a.ValueDate)).ToList();
|
||||
return datafr007;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除的RF007数据
|
||||
/// </summary>
|
||||
/// <param name="id">要删除的RF007数据Id</param>
|
||||
/// <exception cref="ServiceException"></exception>
|
||||
public bool DeleteFRData(int id)
|
||||
{
|
||||
|
||||
var frdata = DbContext.eod_commodity_future_price.Find(id);
|
||||
if (frdata == null)
|
||||
{
|
||||
throw new ServiceException("未找到FR007流水");
|
||||
}
|
||||
DbContext.eod_commodity_future_price.Remove(frdata);
|
||||
DbContext.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增或者修改FR007数据
|
||||
/// </summary>
|
||||
/// <param name="price">FR007价格</param>
|
||||
/// <param name="dateTime">新增或者修改时间</param>
|
||||
/// <exception cref="ServiceException"></exception>
|
||||
public bool AddOrUpdateFRdata(Double price, DateTime dateTime)
|
||||
{
|
||||
string beforedate = "";
|
||||
var frdata = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime).FirstOrDefault();
|
||||
if (frdata == null)
|
||||
{
|
||||
frdata = new eod_commodity_future_price();
|
||||
}
|
||||
//修改
|
||||
if (frdata != null && frdata?.UnderlyingCode != null)
|
||||
{
|
||||
frdata.ValueDate = dateTime;
|
||||
frdata.HighPrice = 0;
|
||||
frdata.LowPrice = 0;
|
||||
beforedate = JsonHelper.Serialize(frdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
//新增
|
||||
var newestdata = DbContext.eod_commodity_future_price.OrderByDescending(a => a.ValueDate).FirstOrDefault();
|
||||
if (newestdata == null)
|
||||
{
|
||||
var underlyingCode = DbContext.underlying_manager.Where(a => a.UnderlyingCode == "FR007").FirstOrDefault();
|
||||
if (underlyingCode == null)
|
||||
{
|
||||
throw new ServiceException("找不到FR007的标的");
|
||||
}
|
||||
newestdata = new eod_commodity_future_price();
|
||||
newestdata.UnderlyingId = underlyingCode.id;
|
||||
}
|
||||
frdata.ValueDate = dateTime;
|
||||
frdata.UnderlyingCode = "FR007";
|
||||
frdata.UnderlyingId = newestdata.UnderlyingId;
|
||||
frdata.DataSource = "人工";
|
||||
DbContext.Add(frdata);
|
||||
}
|
||||
frdata.ClosePrice = Math.Round(price, 4);
|
||||
frdata.SettlePrice = Math.Round(price, 4);
|
||||
frdata.ReferencePrice = Math.Round(price, 4);
|
||||
frdata.OptId = UserInfo.UserId;
|
||||
frdata.OptName = UserInfo.UserName;
|
||||
frdata.OptDate = DateTime.Now;
|
||||
DbContext.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询互换流水导入
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user