using System; using System.Collections.Generic; using System.Linq; using System.Text; using Muchinfo.MTPClient.Adapter.Abstract; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Data.Model.Account; using Muchinfo.MTPClient.Data.Model.Report; using Muchinfo.MTPClient.Infrastructure.LinkProxy; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.Resources; using Muchinfo.MTPClient.Service.Utilities; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Infrastructure.Cache; namespace Muchinfo.MTPClient.Service { /// /// 通用查询服务 /// public class CommonQueryService : ICommonQueryService { #region Public Methods /// /// 查询市场运行状态 /// /// The market identifier. /// The success action. /// The error action. public void QueryMarketRun(int marketId, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientSearchMarketRun; var queryParams = new List() { new QueryCommonParam() { ParamKey = "marketId", ParamValue = marketId.ToString()}, }; QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询市场运行状态"); } /// /// 查询结算单-资金账户信息 /// /// Type of the cycle. /// The cycle time. /// The success action. /// The error action. /// public void QueryTaAccount(ReckonReportQueryType cycleType, string cycleTime, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientDayRetortTaaccount; var queryParams = new List() { new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()}, new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime }, }; if (cycleType != ReckonReportQueryType.DayReckon) { //周期报表 statement = QueryStatement.ClientRetortTaaccount; queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() }); } QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-账号资金信息"); } /// /// 查询结算单-资金账户币种信息 /// /// Type of the cycle. /// The cycle time. /// The success action. /// The error action. public void QueryTaAccountCur(ReckonReportQueryType cycleType, string cycleTime, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientReportDayTaAccountCur; var queryParams = new List() { new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()}, new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime }, }; if (cycleType != ReckonReportQueryType.DayReckon) { //周期报表 statement = QueryStatement.ClientReportTaAccountCur; queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() }); } QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-资金账户币种信息"); } /// /// 查询账户止盈止损单 /// /// The account identifier. /// The success action. /// The error action. /// public void QuerySPSLOrder(ulong accountId, Action> successAction, Action errorAction) { var queryParams = new List() { new QueryCommonParam() { ParamKey = "accountid", ParamValue = accountId.ToString()}, }; QueryCommonHelper.QueryCommon(QueryStatement.ClientQuerySpslOrderdetail, queryParams, successAction, errorAction, "查询账户止盈止损单"); } /// /// 查询资管内部委托单 /// /// The query parameters. /// The success action. /// The error action. public void QueryInnerHisOrderDetails(List queryParams, Action> successAction, Action errorAction) { QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerOrderDetail, queryParams, successAction, errorAction, "查询资管内部委托单"); } /// /// 查询资管内部成交单 /// /// The query parameters. /// The success action. /// The error action. public void QueryInnerHisTradeDetails(List queryParams, Action> successAction, Action errorAction) { QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerTradeDetail, queryParams, successAction, errorAction, "查询资管内部成交单"); } /// /// 查询资管内部平仓明细 /// /// The query parameters. /// The success action. /// The error action. /// public void QueryInnerHisCloseDetails(List queryParams, Action> successAction, Action errorAction) { QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerCloseDetail, queryParams, successAction, errorAction, "查询资管内部平仓明细"); } /// /// 查询资管内部持仓单 /// /// The query parameters. /// The success action. /// The error action. public void QueryInnerHisHoldDetails(List queryParams, Action> successAction, Action errorAction) { QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerHolderDetail, queryParams, successAction, errorAction, "查询资管内部持仓单"); } /// /// 查询账户持仓汇总 /// /// Type of the cycle. /// The cycle time. /// The success action. /// The error action. /// public void QueryTradePostion(ReckonReportQueryType cycleType, string cycleTime, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientDayRetortTradePosition; var queryParams = new List() { new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()}, new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime }, }; if (cycleType != ReckonReportQueryType.DayReckon) { //周期报表 statement = QueryStatement.ClientRetortTradePosition; queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() }); } QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询账户持仓汇总"); } #endregion /// /// 查询账户汇率模板 /// /// The ta account identifier list. /// The success action. /// The error action. public void QueryTradeRateTmpConfig(string taAccountIdList, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientInforTradeRateTmpConfig; var queryParams = new List() { new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList}, }; QueryCommonHelper.QueryCommon(statement, queryParams, new Action>((configs) => { UserManager.TradeRateTmpConfigs = configs; if (successAction != null ) successAction(configs); }), errorAction, "查询账户汇率模板"); } /// /// 查询外部汇率模版配置表 /// /// The ta account identifier list. /// 交易日 /// The success action. /// The error action. public void QueryExtenalTradeRateTmpConfig(string taAccountIdList, string tradeDate, Action> successAction, Action errorAction) { var statement = QueryStatement.ClientExtenalExchangeRate; var queryParams = new List() { new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList}, new QueryCommonParam() { ParamKey = "tradeDate", ParamValue = tradeDate}, }; QueryCommonHelper.QueryCommon(statement, queryParams, new Action>((configs) => { UserManager.ExtenalTradeRateTmpConfigs = configs; if (successAction != null) successAction(configs); }), errorAction, "查询外部汇率模版配置表"); } /// /// 查询资金账户汇率 /// /// The ta account identifier list. /// The success action. /// The error action. public void QueryTaAccountExchangeRate(string taAccountIdList, Action> successAction, Action errorAction) { var statement = QueryStatement.TaAccountExchangeRate; var queryParams = new List() { new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList}, }; QueryCommonHelper.QueryCommon(statement, queryParams, new Action>((configs) => { UserManager.TaAccountExchangeRateConfigs = configs; if (successAction != null) successAction(configs); }), errorAction, "查询资金账户汇率"); } /// /// 获取行情交易日 /// /// /// public void QuoteSourceGroupMarketDate(Action> successAction, Action errorAction) { var statement = QueryStatement.QuoteSourceGroupMarketDate; var queryParams = new List() { }; QueryCommonHelper.QueryCommon(statement, queryParams, new Action>((configs) => { CacheManager.QuoteSourceGroupMarketDatas = configs; if (successAction != null) successAction(configs); }), errorAction, "获取行情交易日失败"); } } }