/// <summary> /// 检查是否存在对应的委托单号 /// </summary> /// <param name="errMsg">错误信息</param> /// <returns>校验结果</returns> private bool CheckDelegateExist(ref string errMsg) { bool result = false; errMsg = ""; try { XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); //todayEntrustTable = DataRepository.XhTodayEntrustTableProvider.GetByEntrustNumber(this.orderNo); todayEntrustTable = dal.GetModel(this.orderNo); } catch (System.Exception ex) { LogHelper.WriteError(ex.Message, ex); } if (todayEntrustTable != null) { result = true; } else { string errCode = "GT-1500"; errMsg = "委托不存在。"; errMsg = errCode + ":" + errMsg; LogHelper.WriteInfo(errMsg); } return(result); }
/// <summary> /// 依据现货委托单号获取委托单对象 /// </summary> /// <param name="strEntrustId"></param> /// <returns></returns> public static XH_TodayEntrustTableInfo GetXHEntrustEntity(string strEntrustId) { XH_TodayEntrustTableInfo result = null; XH_TodayEntrustTableDal xh_TodayEntrustTableDal = new XH_TodayEntrustTableDal(); result = xh_TodayEntrustTableDal.GetModel(strEntrustId); return(result); }
/// <summary> /// 依据现货委托单号获取委托单对象 /// </summary> /// <param name="strEntrustId"></param> /// <param name="tm"></param> /// <returns></returns> public static XH_TodayEntrustTableInfo GetXHEntrustEntity(string strEntrustId, ReckoningTransaction tm) { XH_TodayEntrustTableInfo result = null; XH_TodayEntrustTableDal xh_TodayEntrustTableDal = new XH_TodayEntrustTableDal(); result = xh_TodayEntrustTableDal.GetModel(strEntrustId, tm); return(result); }
/// <summary> /// 更新现货委托单 /// </summary> /// <param name="stockOrder">委托单</param> public static bool UpdateStockOrder(XH_TodayEntrustTableInfo stockOrder) { bool isSuccess = false; XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); try { // var sxtetp = new SqlXhTodayEntrustTableProvider(TransactionFactory.RC_ConnectionString, true, // string.Empty); //sxtetp.Update(stockOrder); dal.Update(stockOrder); isSuccess = true; } catch (Exception ex) { LogHelper.WriteDebug("OrderOfferDataLogic.UpdateStockOrder改使用企业库执行第1次" + ex.Message); } //使用企业库执行第1次 if (!isSuccess) { try { // XhTodayEntrustTableDao.Update(stockOrder); dal.Update(stockOrder); isSuccess = true; } catch (Exception ex) { LogHelper.WriteDebug("OrderOfferDataLogic.UpdateStockOrder使用企业库执行第2次" + ex.Message); } } //使用企业库执行第2次 if (!isSuccess) { try { // XhTodayEntrustTableDao.Update(stockOrder); dal.Update(stockOrder); isSuccess = true; } catch (Exception ex) { LogHelper.WriteError("OrderOfferDataLogic.UpdateStockOrder彻底失败!", ex); } } return(isSuccess); }
/// <summary> /// 更新委托信息 /// </summary> /// <param name="entrustNubmer">委托单号</param> /// <param name="orderMessage">信息</param> /// <returns></returns> public static bool UpdateEntrustOrderMessage(string entrustNubmer, string orderMessage) { try { XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); dal.UpdateOrderMessage(entrustNubmer, orderMessage); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); return(false); } return(true); }
/// <summary> /// 更新委托表(带事务) /// </summary> /// <param name="tet">委托表</param> /// <param name="db"></param> /// <param name="transaction"></param> /// <returns>是否成功</returns> public static bool UpdateEntrustTable(XH_TodayEntrustTableInfo tet, Database db, DbTransaction transaction) { try { XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); dal.Update(tet, db, transaction); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); return(false); } return(true); }
/// <summary> /// 删除当日委托 /// </summary> /// <param name="entrustNumber">委托单号</param> public static bool DeleteTodayEntrust(string entrustNumber) { try { XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); dal.Delete(entrustNumber); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="strMcOrderNo"></param> /// <returns></returns> protected override OrderCacheItem LoadCacheItemFromDB(string strMcOrderNo) { OrderCacheItem result = null; string where = string.Format("McOrderId = '{0}' ", strMcOrderNo); XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); var tets = dal.GetListArrayWithNoLock(where); if (!Utils.IsNullOrEmpty(tets)) { try { var tet = tets[0]; var cacheItem = new OrderCacheItem(tet.CapitalAccount, tet.StockAccount, tet.EntrustNumber, ( GTA.VTS.Common.CommonObject.Types.TransactionDirection) Enum.Parse( typeof( GTA.VTS.Common.CommonObject.Types.TransactionDirection), tet.BuySellTypeId.ToString ())); cacheItem.EntrustAmount = tet.EntrustAmount; cacheItem.Code = tet.SpotCode; var user = AccountManager.Instance.GetUserByAccount(tet.CapitalAccount); if (user != null) { cacheItem.TraderId = user.UserID; } //else //{ // cacheItem.TraderId = GetTraderIdByFundAccount(tet.CapitalAccount); //TODO:需要根据资金账户获取用户ID //} AddOrderMappingInfo(tet.McOrderId, cacheItem); result = cacheItem; } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); } } return(result); }
/// <summary> /// 根据委托单号获取今日委托 /// </summary> /// <param name="entrustNumber">委托单号</param> /// <returns>今日委托</returns> public static XH_TodayEntrustTableInfo GetTodayEntrustTable(string entrustNumber) { XH_TodayEntrustTableInfo tet = null; XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); try { tet = dal.GetModel(entrustNumber); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); } return(tet); }
private void LoadXHOrderFromDB() { string format = "OrderStatusId = '{0}'"; string where = string.Format(format, (int)Entity.Contants.Types.OrderStateType.DOSUnRequired); XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); List <XH_TodayEntrustTableInfo> list = null; try { //list = DataRepository.XhTodayEntrustTableProvider.Find(where); list = dal.GetListArray(where); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); } if (Utils.IsNullOrEmpty(list)) { return; } DateTime now = DateTime.Now; foreach (XH_TodayEntrustTableInfo table in list) { //DateTime entrustTime = table.EntrustTime.Value; //if (entrustTime.Year == now.Year && entrustTime.Month == now.Month && entrustTime.Day == now.Day) //{ // CacheStockOrder(new XhTodayEntrustTableEx(table)); //} //不再判断是否是当天 var order = new XhTodayEntrustTableEx(table); CacheStockOrder(order); } }
/// <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 }
/// <summary> /// 构建现货委托单 /// </summary> /// <param name="order"></param> /// <param name="originalOrder"></param> /// <param name="strHoldingAccount"></param> /// <param name="strCapitalAccount"></param> /// <param name="iCurType"></param> /// <param name="strMessage"></param> /// <returns></returns> public static string BuildXhOrder(ref XH_TodayEntrustTableInfo order, StockOrderRequest originalOrder, string strHoldingAccount, string strCapitalAccount, int iCurType, ref string strMessage) { if (order == null) { order = new XH_TodayEntrustTableInfo(); } order.EntrustNumber = BuildXHOrderNo(); order.CurrencyTypeId = iCurType; order.TradeUnitId = (int)originalOrder.OrderUnitType; order.EntrustAmount = (int)originalOrder.OrderAmount; order.EntrustPrice = Convert.ToDecimal(originalOrder.OrderPrice); order.EntrustTime = DateTime.Now; order.OfferTime = DateTime.Now; order.IsMarketValue = originalOrder.OrderWay == Types.OrderPriceType.OPTMarketPrice ? true : false; order.BuySellTypeId = (int)originalOrder.BuySell; order.OrderStatusId = (int)Types.OrderStateType.DOSUnRequired; if (strHoldingAccount == null) { strHoldingAccount = ""; } order.StockAccount = strHoldingAccount.Trim(); if (strCapitalAccount == null) { strCapitalAccount = ""; } order.CapitalAccount = strCapitalAccount.Trim(); if (originalOrder.PortfoliosId == null) { originalOrder.PortfoliosId = ""; } order.PortfolioLogo = originalOrder.PortfoliosId.Trim(); if (originalOrder.Code == null) { originalOrder.Code = ""; } order.SpotCode = originalOrder.Code.Trim(); order.TradeAmount = 0; order.TradeAveragePrice = 0; order.CancelAmount = 0; order.CancelLogo = true; if (originalOrder.ChannelID == null) { originalOrder.ChannelID = ""; } order.CallbackChannlId = originalOrder.ChannelID.Trim(); order.IsMarketValue = originalOrder.OrderWay == Types.OrderPriceType.OPTMarketPrice ? true : false; order.OrderMessage = ""; order.McOrderId = ""; CheckEntrustLength(order); #if (DEBUG) LogHelper.WriteDebug("XHCommonLogic.BuildXhOrder:" + order); #endif XH_TodayEntrustTableDal dal = new XH_TodayEntrustTableDal(); dal.Add(order); return(order.EntrustNumber); }