140 lines
5.2 KiB
C#
140 lines
5.2 KiB
C#
using YLErp.BLL;
|
|
using YLErp.DBModels;
|
|
using YLErp.Helpers;
|
|
using YLErp.Model;
|
|
|
|
namespace YLErp.Tests
|
|
{
|
|
public class TestEntryexitQuery : TestBase
|
|
{
|
|
public override void Execute()
|
|
{
|
|
var req = new EntryExitReq
|
|
{
|
|
DirectionTypes = "出金,入金,权利金支出,权利金收入,平仓/行权支出,平仓/行权收入,票息支出,票息收入,其他支出,其他收入",
|
|
rows = 0
|
|
};
|
|
|
|
#region 预处理查询条件
|
|
|
|
if (!req.DirectionTypes.IsNullOrWhiteSpace())
|
|
{
|
|
var directionList = new List<string>();
|
|
var tradeActionList = new List<string>();
|
|
var inOutList = new List<string>();
|
|
void addWhenNotContains(List<string> list, string str)
|
|
{
|
|
if (!list.Contains(str))
|
|
{
|
|
list.Add(str);
|
|
}
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("出金"))
|
|
{
|
|
addWhenNotContains(directionList, "出金");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("入金"))
|
|
{
|
|
addWhenNotContains(directionList, "入金");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("其他收入"))
|
|
{
|
|
addWhenNotContains(directionList, "其他收入");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("其他支出"))
|
|
{
|
|
addWhenNotContains(directionList, "其他支出");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("权利金支出"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_期权费);
|
|
addWhenNotContains(inOutList, "应付");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("权利金收入"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_期权费);
|
|
addWhenNotContains(inOutList, "应收");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("平仓/行权收入"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_平仓费);
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_行权费);
|
|
addWhenNotContains(inOutList, "应收");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("平仓/行权支出"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_平仓费);
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_行权费);
|
|
addWhenNotContains(inOutList, "应付");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("票息收入"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_票息);
|
|
addWhenNotContains(inOutList, "应收");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("票息支出"))
|
|
{
|
|
addWhenNotContains(tradeActionList, ClientCashInCashOut.系统操作_票息);
|
|
addWhenNotContains(inOutList, "应付");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("实收保证金"))
|
|
{
|
|
addWhenNotContains(directionList, "实收保证金");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("实付保证金"))
|
|
{
|
|
addWhenNotContains(directionList, "实付保证金");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("实收权利金"))
|
|
{
|
|
addWhenNotContains(directionList, "实收权利金");
|
|
}
|
|
|
|
if (req.DirectionTypeList.Contains("实付权利金"))
|
|
{
|
|
addWhenNotContains(directionList, "实付权利金");
|
|
}
|
|
|
|
req.Direction = string.Join(",", directionList);
|
|
req.TradeAction = string.Join(",", tradeActionList);
|
|
req.InOut = string.Join(",", inOutList);
|
|
}
|
|
|
|
req.IsMoneyNotEqualsZero = true;
|
|
#endregion
|
|
var sList = new EntryExitBLL().SearchListExtend(req, out var gsum, false);
|
|
var tradeIds = sList.rows.Select(x => x.TradeId).Distinct().ToList();
|
|
using (var db = new YLContext())
|
|
using (var sw = new StreamWriter("e:\\_debug\\test.txt"))
|
|
{
|
|
//db.Database.Log = log =>
|
|
//{
|
|
// sw.WriteLine(log);
|
|
// sw.Flush();
|
|
//};
|
|
|
|
var trades = db.trade.Where(x => tradeIds.Contains(x.id));
|
|
|
|
foreach (var x in sList.rows)
|
|
{
|
|
var trade = trades.FirstOrDefault(y => y.id == x.TradeId);
|
|
x.TradeNumber = trade == null ? "" : trade.TradeNumber;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|