Esempio n. 1
0
        private static List <XH_MelonCutRegisterTableInfo> GetMeloncutRegisterList(string code, DateTime regDate,
                                                                                   DateTime cutDate,
                                                                                   Types.MeloncutType cutType)
        {
            if (String.IsNullOrEmpty(code))
            {
                return(null);
            }
            XH_MelonCutRegisterTableDal dal = new XH_MelonCutRegisterTableDal();

            string where = string.Format("Code = '{0}' AND RegisterDate = '{1}' AND CutDate ='{2}' AND CutType ='{3}'",
                                         code, regDate, cutDate, (int)cutType);
            return(dal.GetListArray(where));
            // return DataRepository.XhMelonCutRegisterTableProvider.Find(where);
        }
Esempio n. 2
0
        /// <summary>
        /// 处理股票分红(分红过户)
        /// </summary>
        private static bool ProcessCStockMelonStock()
        {
            XH_MelonCutRegisterTableDal dal = new XH_MelonCutRegisterTableDal();

            string where = string.Format(" CutType ='{0}'", (int)Types.MeloncutType.Stock);
            List <XH_MelonCutRegisterTableInfo> list = dal.GetListArray(where);

            //选出今日需要分红的股票分红信息
            var q = from c in list
                    where
                    CheckDate(c.CutDate) && c.RegisterAmount > 0 && !string.IsNullOrEmpty(c.Code)
                    select c;
            bool issum = true;

            if (q != null)
            {
                //2.如果今日有需要现金分红的就进行分红
                issum = ProcessStockCut(q.ToList <XH_MelonCutRegisterTableInfo>());
            }

            return(issum);
        }
Esempio n. 3
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
        }
Esempio n. 4
0
        /// <summary>
        /// 更新分红记录
        /// </summary>
        /// <param name="tm">TransactionManager</param>
        /// <param name="cash">分红信息</param>
        /// <param name="tables">登记列表</param>
        private static bool UpdateCashCut(ReckoningTransaction tm, IList <XH_MelonCutRegisterTableInfo> tables)
        {
            bool issuss = true;
            List <XH_CapitalAccountTableInfo> capitalList = new List <XH_CapitalAccountTableInfo>();
            List <UA_CapitalFlowTableInfo>    flowList    = new List <UA_CapitalFlowTableInfo>();

            XH_CapitalAccountTableDal dal = new XH_CapitalAccountTableDal();

            try
            {
                foreach (XH_MelonCutRegisterTableInfo registerTable in tables)
                {
                    //分红的现金额
                    decimal num = registerTable.RegisterAmount;

                    UA_UserAccountAllocationTableInfo capitalAccount = Utils.GetCapitalAccountByHoldAccount(registerTable.UserAccountDistributeLogo, registerTable.Code);

                    XH_CapitalAccountTableInfo accountTable = dal.GetXHCapitalAccount(capitalAccount.UserAccountDistributeLogo, registerTable.TradeCurrencyType);

                    if (accountTable == null)
                    {
                        continue;
                    }


                    accountTable.TodayOutInCapital += num;


                    accountTable.AvailableCapital += num;

                    capitalList.Add(accountTable);


                    //更新资金流水表
                    UA_CapitalFlowTableInfo flowTable = GetFlowTable(registerTable, capitalAccount.UserAccountDistributeLogo, num);
                    flowList.Add(flowTable);


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

                XH_CapitalAccountTableDal xh_AccountTableDal = new XH_CapitalAccountTableDal();

                if (capitalList.Count > 0)
                {
                    foreach (var accountTableInfo in capitalList)
                    {
                        xh_AccountTableDal.Update(accountTableInfo, tm.Database, tm.Transaction);
                    }
                }
                if (flowList.Count > 0)
                {
                    UA_CapitalFlowTableDal flowTableDal = new UA_CapitalFlowTableDal();
                    foreach (var historyTradeTableInfo in flowList)
                    {
                        flowTableDal.Add(historyTradeTableInfo, tm.Database, tm.Transaction);
                    }
                }
                if (tables.Count > 0)
                {
                    XH_MelonCutRegisterTableDal melonCutRegisterTableDal = new XH_MelonCutRegisterTableDal();
                    foreach (var registerTableInfo in tables)
                    {
                        melonCutRegisterTableDal.Delete(registerTableInfo, tm.Database, tm.Transaction);
                    }
                }
            }
            catch (Exception ex)
            {
                issuss = false;
                LogHelper.WriteError("分红出现问题 ", ex);
            }
            return(issuss);
        }