Ejemplo n.º 1
0
        /// <summary>
        /// 组装港股委托过滤条件
        /// </summary>
        /// <param name="filter">港股委托过滤条件实体</param>
        /// <param name="userID">用户ID</param>
        /// <param name="accountType">账号类型(数据库中BD_AccountType的九种) 如果传为0时查询对应的港股持仓账号类别(3--证券股东代码,9--港股股东代码)</param>
        /// <param name="isToday">是否为查询今日委托</param>
        /// <returns></returns>
        string BuildHKEntrustQueryWhere(HKEntrustConditionFindEntity filter, string userID, int accountType, bool isToday)
        {
            #region 过滤条件组装
            StringBuilder sbFilter = new StringBuilder("1=1 ");
            if (filter != null)
            {
                # region  0.资金账号
                if (!string.IsNullOrEmpty(filter.HKCapitalAccount))
                {
                    sbFilter.AppendFormat(" AND CapitalAccount='{0}'", filter.HKCapitalAccount.Trim());
                }
                else //不指定可能有多个账号
                {
                    sbFilter.Append(" And CapitalAccount in( select useraccountdistributelogo from dbo.UA_UserAccountAllocationTable   ");
                    if (accountType == 0)
                    {
                        sbFilter.AppendFormat("  where accounttypelogo in (select accounttypelogo from BD_AccountType where atcid='{0}')  and userid='{1}')", (int)Types.AccountAttributionType.SpotCapital, userID);
                    }
                    else
                    {
                        sbFilter.AppendFormat("  where accounttypelogo='{0}'  and userid='{1}')", accountType, userID);
                    }
                }
                # endregion

                # region  1.买卖方向

                if (filter.BuySellDirection != 0)
Ejemplo n.º 2
0
        /// <summary>
        ///  Title:根据用户和密码查询该用户所拥有的港股资金帐户今日期货委托信息
        ///  Des.:此方法因为一个用户(交易员)可能拥有多个港股资金账号(如:-商品港股资金帐号,-股指港股资金帐号)
        ///  所以返回的数据会回多个资金账号的数据
        /// </summary>
        /// <param name="userID">用户(交易员)ID</param>
        /// <param name="pwd">用户(交易员)密码--如果密码为空时不验证密码</param>
        /// <param name="accountType">账号类型(数据库中BD_AccountType的九种) 如果传为0时查询对应的港股持仓账号类别(3--证券股东代码,9--港股股东代码)</param>
        /// <param name="filter">过滤条件数据</param>
        /// <param name="pageInfo">分页信息</param>
        /// <param name="total">返回数页数</param>
        /// <param name="errorMsg">异常信息</param>
        /// <returns>返回当日期货委托信息</returns>
        public List <HK_TodayEntrustInfo> PagingHK_TodayEntrustByFilter(string userID, string pwd, int accountType, HKEntrustConditionFindEntity filter, PagingInfo pageInfo, out int total, out string errorMsg)
        {
            List <HK_TodayEntrustInfo> list = null;
            HK_TodayEntrustDal         dal  = new HK_TodayEntrustDal();

            errorMsg = "";
            total    = 0;

            #region 密码不为空时先验证用户
            if (string.IsNullOrEmpty(userID))
            {
                errorMsg = "查询失败!失败原因为:交易员ID不能为空!";
                return(list);
            }
            if (!string.IsNullOrEmpty(pwd))
            {
                #region 从数据库中判断
                //UA_UserBasicInformationTableDal usDal = new UA_UserBasicInformationTableDal();
                //if (!usDal.Exists(userID, pwd))
                //{
                //    errorMsg = "查询失败!失败原因为:交易员ID或密码输入错误 !";
                //    return list;
                //}
                #endregion

                #region 从缓存中判断
                UA_UserBasicInformationTableInfo userInfo = AccountManager.Instance.GetBasicUserByUserId(userID);
                if (userInfo == null)
                {
                    errorMsg = "交易员对应类型的帐号不存在";
                    return(list);
                }
                if (userInfo.Password != pwd)
                {
                    errorMsg = "交易员密码错误";
                    return(list);
                }
                #endregion
            }
            #endregion

            if (filter != null && !string.IsNullOrEmpty(filter.EntrustNumber))  //委托单号(当只根据委托单号查询时)
            {
                #region 如果有委托单号直接查询唯一记录
                try
                {
                    list = dal.GetListArray(" EntrustNumber='" + filter.EntrustNumber + "'");
                    if (!Utils.IsNullOrEmpty(list))
                    {
                        total = 1;
                    }
                }
                catch (Exception ex)
                {
                    errorMsg = ex.Message;
                    LogHelper.WriteError(ex.ToString(), ex);
                }
                #endregion
            }
            else //当不带委托单号时
            {
                #region 如果分页信息为空返回异常
                if (pageInfo == null)
                {
                    errorMsg = "分页信息不能为空!";
                    return(null);
                }
                #endregion

                #region 分页存储过程相关信息组装
                PagingProceduresInfo ppInfo = new PagingProceduresInfo();
                ppInfo.IsCount    = pageInfo.IsCount;
                ppInfo.PageNumber = pageInfo.CurrentPage;
                ppInfo.PageSize   = pageInfo.PageLength;
                ppInfo.Fields     = "  EntrustNumber,PortfolioLogo,EntrustPrice,EntrustAmount,Code,TradeAmount,TradeAveragePrice,CancelAmount,CancelLogo,BuySellTypeID,HoldAccount,CapitalAccount,OrderStatusID,OrderPriceType,OrderMessage,CurrencyTypeID,TradeUnitID,CallbackChannlID,McOrderID,HasDoneProfit,OfferTime,EntrustTime,IsModifyOrder,ModifyOrderNumber";

                ppInfo.PK = "EntrustNumber";
                if (pageInfo.Sort == 0)
                {
                    ppInfo.Sort = " EntrustTime asc ";
                }
                else
                {
                    ppInfo.Sort = " EntrustTime desc ";
                }
                ppInfo.Tables = "HK_TodayEntrust";
                #endregion

                #region 过滤条件组装
                ppInfo.Filter = BuildHKEntrustQueryWhere(filter, userID, accountType, true);
                #endregion

                #region 执行查询
                try
                {
                    CommonDALOperate <HK_TodayEntrustInfo> com = new CommonDALOperate <HK_TodayEntrustInfo>();
                    list = com.PagingQueryProcedures(ppInfo, out total, dal.ReaderBind);
                    //list = dal.PagingXH_TodayEntrustByFilter(ppInfo, out total);
                }
                catch (Exception ex)
                {
                    errorMsg = ex.Message;
                    LogHelper.WriteError(ex.ToString(), ex);
                }
                #endregion
            }
            return(list);
        }