Exemple #1
0
        /// <summary>
        /// 带事务更新持仓
        /// </summary>
        /// <param name="baseTable"></param>
        /// <param name="db"></param>
        /// <param name="transaction"></param>
        public void PersistBase(XH_AccountHoldTableInfo baseTable, Database db, DbTransaction transaction)
        {
            XH_AccountHoldTableDal dal = new XH_AccountHoldTableDal();

            dal.Update(baseTable, db, transaction);
        }
Exemple #2
0
        /// <summary>
        /// 更新过户记录
        /// </summary>
        /// <param name="tm">TransactionManager</param>
        /// <param name="cash">分红信息</param>
        /// <param name="tables">登记列表</param>
        private static bool UpdateStockCut(ReckoningTransaction tm, List <XH_MelonCutRegisterTableInfo> tables)
        {
            #region old code 李健华 2010-06-11 改为因为在每天开市时处理那么生成为当日委托我成交
            //List<XH_AccountHoldTableInfo> accountHoldList = new List<XH_AccountHoldTableInfo>();
            //List<XH_HistoryTradeTableInfo> historyTradeList = new List<XH_HistoryTradeTableInfo>();

            ////add 2010-1-15 因为数据库表有的成交记录是根据委托编号有外键关系,所以这里要生成委托记录
            //List<XH_HistoryEntrustTableInfo> historyEntrustList = new List<XH_HistoryEntrustTableInfo>();
            ////========

            //foreach (XH_MelonCutRegisterTableInfo registerTable in tables)
            //{
            //    //更新持仓表
            //    List<XH_AccountHoldTableInfo> accountHoldTables = GetAccountHoldList(
            //        registerTable.UserAccountDistributeLogo,
            //        registerTable.TradeCurrencyType, registerTable.Code);
            //    if (Utils.IsNullOrEmpty(accountHoldTables))
            //        continue;

            //    //过户的量
            //    decimal num = registerTable.RegisterAmount;
            //    //四舍五入
            //    num = Math.Round(num);
            //    int intNum = decimal.ToInt32(num);

            //    XH_AccountHoldTableInfo accountTable = accountHoldTables[0];
            //    SetAccountTable(accountTable, intNum);

            //    accountHoldList.Add(accountTable);

            //    //更新委托记录表
            //    XH_HistoryEntrustTableInfo historyEntrustTable = GetHistoryEntrustTable(registerTable, intNum);
            //    historyEntrustList.Add(historyEntrustTable);
            //    //更新历史成交表
            //    XH_HistoryTradeTableInfo historyTradeTable = GetHistoryTradeTable(registerTable, intNum);
            //    historyTradeTable.EntrustNumber = historyEntrustTable.EntrustNumber;
            //    historyTradeTable.CapitalAccount = historyEntrustTable.CapitalAccount;
            //    historyTradeList.Add(historyTradeTable);

            //    string format = "MelonCutService.UpdateStockCut进行股票分红[商品代码={0},持仓帐号={1},分红金额={2}]";
            //    string desc = string.Format(format, registerTable.Code, registerTable.UserAccountDistributeLogo, num);
            //    LogHelper.WriteDebug(desc);
            //}


            //XH_AccountHoldTableDal xh_AccountHoldTableDal = new XH_AccountHoldTableDal();
            //if (accountHoldList.Count > 0)
            //{
            //    foreach (var holdTableInfo in accountHoldList)
            //    {
            //        xh_AccountHoldTableDal.Update(holdTableInfo, tm.Database, tm.Transaction);
            //    }
            //}

            ////先添加委托记录
            //XH_HistoryEntrustTableDal xh_HistoryEntrustTableDal = new XH_HistoryEntrustTableDal();
            //if (historyEntrustList.Count > 0)
            //{
            //    foreach (XH_HistoryEntrustTableInfo item in historyEntrustList)
            //    {

            //        xh_HistoryEntrustTableDal.Add(item, tm.Database, tm.Transaction);
            //    }
            //}
            ////添加成交记录
            ////DataRepository.XhAccountHoldTableProvider.Update(tm, accountHoldList);

            ////DataRepository.XhHistoryTradeTableProvider.BulkInsert(historyTradeList);
            //XH_HistoryTradeTableDal xh_HistoryTradeTableDal = new XH_HistoryTradeTableDal();
            //if (historyTradeList.Count > 0)
            //{
            //    foreach (XH_HistoryTradeTableInfo historyTradeTable in historyTradeList)
            //    {
            //        //DataRepository.XhHistoryTradeTableProvider.Insert(tm, historyTradeTable);
            //        xh_HistoryTradeTableDal.Add(historyTradeTable, tm.Database, tm.Transaction);
            //    }
            //}


            ////删除对应的登记记录
            ////DataRepository.XhMelonCutRegisterTableProvider.Delete(tm, tables);
            //XH_MelonCutRegisterTableDal xh_MelonCutRegisterTableDal = new XH_MelonCutRegisterTableDal();
            //if (tables.Count > 0)
            //{
            //    foreach (var data in tables)
            //    {
            //        xh_MelonCutRegisterTableDal.Delete(data, tm.Database, tm.Transaction);
            //    }
            //}
            #endregion

            #region new code 李健华 2010-06-11 改为因为在每天开市时处理那么生成为当日委托我成交
            bool issuc = true;
            try
            {
                List <XH_AccountHoldTableInfo> accountHoldList = new List <XH_AccountHoldTableInfo>();
                List <XH_TodayTradeTableInfo>  todayTradeList  = new List <XH_TodayTradeTableInfo>();

                //add 2010-1-15 因为数据库表有的成交记录是根据委托编号有外键关系,所以这里要生成委托记录
                List <XH_TodayEntrustTableInfo>  todayEntrustList = new List <XH_TodayEntrustTableInfo>();
                UA_UserAccountAllocationTableDal dal = new UA_UserAccountAllocationTableDal();

                //========

                foreach (XH_MelonCutRegisterTableInfo registerTable in tables)
                {
                    //更新持仓表
                    List <XH_AccountHoldTableInfo> accountHoldTables = GetAccountHoldList(registerTable.UserAccountDistributeLogo, registerTable.TradeCurrencyType, registerTable.Code);
                    if (Utils.IsNullOrEmpty(accountHoldTables))
                    {
                        continue;
                    }

                    //过户的量
                    decimal num = registerTable.RegisterAmount;
                    //四舍五入
                    num = Math.Round(num);
                    int intNum = decimal.ToInt32(num);

                    XH_AccountHoldTableInfo accountTable = accountHoldTables[0];
                    SetAccountTable(accountTable, intNum);

                    accountHoldList.Add(accountTable);

                    //更新委托记录表
                    XH_TodayEntrustTableInfo todayEntrustTable = GetHistoryEntrustTable(registerTable, intNum);
                    todayEntrustList.Add(todayEntrustTable);
                    //更新历史成交表
                    XH_TodayTradeTableInfo todayTradeTable = GetTodayTradeTable(registerTable, intNum);
                    todayTradeTable.EntrustNumber  = todayEntrustTable.EntrustNumber;
                    todayTradeTable.CapitalAccount = todayEntrustTable.CapitalAccount;
                    todayTradeList.Add(todayTradeTable);
                    UA_UserAccountAllocationTableInfo userModel = dal.GetModel(registerTable.UserAccountDistributeLogo);
                    #region 回推相关成交记录信息
                    ReckonEndObject <XH_TodayEntrustTableInfo, XH_TodayTradeTableInfo> reckonEndObject = new ReckonEndObject <XH_TodayEntrustTableInfo, XH_TodayTradeTableInfo>();
                    reckonEndObject.IsSuccess    = true;
                    reckonEndObject.EntrustTable = todayEntrustTable;
                    List <XH_TodayTradeTableInfo> tradeModels = new List <XH_TodayTradeTableInfo>();
                    tradeModels.Add(todayTradeTable);
                    reckonEndObject.TradeTableList = tradeModels;
                    if (userModel != null)
                    {
                        reckonEndObject.TradeID = userModel.UserID;
                    }
                    reckonEndObject.Message = "分红委托成交";

                    CounterOrderService.Instance.AcceptStockDealOrder(reckonEndObject);
                    #endregion

                    string format = "MelonCutService.UpdateStockCut进行股票分红[商品代码={0},持仓帐号={1},分红金额={2}]";
                    string desc   = string.Format(format, registerTable.Code, registerTable.UserAccountDistributeLogo, num);
                    LogHelper.WriteDebug(desc);
                }


                XH_AccountHoldTableDal xh_AccountHoldTableDal = new XH_AccountHoldTableDal();
                if (accountHoldList.Count > 0)
                {
                    foreach (var holdTableInfo in accountHoldList)
                    {
                        xh_AccountHoldTableDal.Update(holdTableInfo, tm.Database, tm.Transaction);
                    }
                }

                //先添加委托记录
                XH_TodayEntrustTableDal xh_HistoryEntrustTableDal = new XH_TodayEntrustTableDal();
                if (todayEntrustList.Count > 0)
                {
                    foreach (XH_TodayEntrustTableInfo item in todayEntrustList)
                    {
                        xh_HistoryEntrustTableDal.Add(item, tm.Database, tm.Transaction);
                    }
                }
                //添加成交记录
                //DataRepository.XhAccountHoldTableProvider.Update(tm, accountHoldList);

                //DataRepository.XhHistoryTradeTableProvider.BulkInsert(historyTradeList);
                XH_TodayTradeTableDal xh_todayTradeTableDal = new XH_TodayTradeTableDal();
                if (todayTradeList.Count > 0)
                {
                    foreach (XH_TodayTradeTableInfo todayTradeTable in todayTradeList)
                    {
                        //DataRepository.XhHistoryTradeTableProvider.Insert(tm, historyTradeTable);
                        xh_todayTradeTableDal.Add(todayTradeTable, tm);
                    }
                }


                //删除对应的登记记录
                //DataRepository.XhMelonCutRegisterTableProvider.Delete(tm, tables);
                XH_MelonCutRegisterTableDal xh_MelonCutRegisterTableDal = new XH_MelonCutRegisterTableDal();
                if (tables.Count > 0)
                {
                    foreach (var data in tables)
                    {
                        xh_MelonCutRegisterTableDal.Delete(data, tm.Database, tm.Transaction);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("过户分红异常" + ex.Message, ex);
                issuc = false;
            }
            return(issuc);

            #endregion
        }
Exemple #3
0
        /// <summary>
        /// 更新持仓
        /// </summary>
        /// <param name="baseTable"></param>
        public void PersistBase(XH_AccountHoldTableInfo baseTable)
        {
            XH_AccountHoldTableDal dal = new XH_AccountHoldTableDal();

            dal.Update(baseTable);
        }