private static IList<TAgents> SonAgentMethod(int id, APIDataDataContext db, IList<TAgents> agent) { var sonagents = (from c in db.TAgents where c.DirectAgentID == id select c).ToList(); foreach (var item in sonagents) { agent = SonAgentMethod(item.ID, db, agent); } agent = agent.Concat(sonagents).ToList(); return agent; }
public IList<TOrders> getorder(APIDataDataContext db, int id, string datetime) { var aa = Convert.ToDateTime(datetime); var a1 = Convert.ToDateTime(aa.ToString("yyyy-MM-dd 00:00:00")); var a2 = Convert.ToDateTime(aa.AddDays(1).ToString("yyyy-MM-dd 00:00:00")); var order = (from c in db.TOrders join b in db.TRealAccounts on c.TRealAccountsID equals b.ID where b.AgendID == id && c.OrderState == 2 && c.OrderType == 2 && c.UpdateTime >= a1 && c.UpdateTime < a2 select c).ToList(); return order; }
public IList<zhx> getzhx(APIDataDataContext db, zhx z, IList<zhx> zs, string datetime, IList<TAgentCommission> ac) { IList<zhx> zss = new List<zhx>(); var ag = (from c in db.TAgents where c.DirectAgentID == z.Id select c).ToList(); foreach (var a in ag) { var ab = ac.Where(c => c.agentid == a.ID).FirstOrDefault(); var group = (from c in db.TAgentGroup where c.ID == a.GroupID select c).FirstOrDefault(); double HeadRate = Convert.ToDouble(Converter.ToFloat(group.HeadRate, 0).ToString("f4")) * 0.01; double ProcessRate = Convert.ToDouble(Converter.ToFloat(group.ProcessRate, 0).ToString("f4")) * 0.01; double InterestRate = Convert.ToDouble(Converter.ToFloat(group.InterestRate, 0).ToString("f4")) * 0.01; double NextRate = Convert.ToDouble(Converter.ToFloat(group.NextRate, 0).ToString("f4")) * 0.01; zhx zx = new zhx(); if (ab != null) { zx.Sh = 1; } else { zx.Sh = 0; } zx.Id = a.ID; zx.AgentName = a.AgentName; zx.AccountMoney = a.AccountMoney + ""; zx.Account = a.Account; zx.Num = z.Num + 1; zx.NextRate = NextRate; var order = getorder(db, a.ID, datetime); zx.Yjtc = 0 - Convert.ToDouble((order.Where(c => c.ProfitAndLoss.Value < 0).Select(c => c.ProfitAndLoss.Value).Sum() * HeadRate).ToString("f4")); zx.Yjjgf = Convert.ToDouble((order.Where(c => c.Deposit > 0).Select(c => c.Deposit.Value).Sum() * ProcessRate).ToString("f4")); zx.Yjcx = Convert.ToDouble((order.Where(c => c.Interest > 0).Select(c => c.Interest.Value).Sum() * InterestRate).ToString("f4")); zx.Jsdate = datetime.Substring(0, 10); getzhx(db, zx, zs, datetime, ac); zx.Yjtc1 = zx.Yjtc * (10 - zx.Num) * HeadRate; zx.Yjjgf1 = zx.Yjjgf * (10 - zx.Num) * ProcessRate; zx.Yjcx1 = zx.Yjcx * (10 - zx.Num) * InterestRate; zx.Yjxj1 = zx.Yjxj * (10 - zx.Num) * NextRate; zs.Add(zx); zss.Add(zx); z.Yjxj = z.Yjxj + Convert.ToDouble(((zx.Yjtc + zx.Yjjgf + zx.Yjcx + zx.Yjxj) * z.NextRate).ToString("f4")); } return zs; }
//计算期初期末 public List<double> GetMoney(int id, DateTime? start, List<TAccountMoney> listMoney, APIDataDataContext db) { List<double> mon = new List<double>(); listMoney = listMoney.Where(m => m.RealAccountId == id).ToList(); //如果在该时段内的交易记录没有,就找之前一条交易记录 if (listMoney.Count() == 0) { var m = db.TAccountMoney.Where(t => t.RealAccountId == id && t.CreateTime < start).OrderByDescending(t => t.CreateTime).OrderByDescending(t => t.Id).FirstOrDefault(); if (m == null) { //如果之前的交易记录也没有就期初期末金额都为0 mon.Add(0.0); mon.Add(0.0); } else { //如果有记录就取该记录的值 mon.Add(m.NowMoney.Value); mon.Add(m.NowMoney.Value); } } else { //如果有交易记录就取第一条和最后一条 mon.Add(listMoney.Last().OriginalMoney.Value); mon.Add(listMoney.First().NowMoney.Value); } return mon; }
private bool CloseAllOrder(List<TOrders> orderList, APIDataDataContext db) { try { TOperationLog OLog = new TOperationLog(); if (orderList.Count > 0) { StringBuilder beforevalue=new StringBuilder(); beforevalue.Append("{\"IDlist\":["); foreach (var item in orderList) { beforevalue.Append("{"); beforevalue.AppendFormat("\"id\":\"{0}\"", item.ID); beforevalue.Append("},"); var product = (from c in db.TProducts join b in db.TLastClose on c.ProductCode equals b.ProductCode where c.ID == item.ProductID orderby c.ID select new { c, b.LastClose, b.LastUpdateTime }).FirstOrDefault(); if (product != null) { var Scale = Converter.ToFloat(product.c.Scale, 2); var nowdate = product.LastUpdateTime; #region 加工费 double closedeposit = 0.0; //加工费 if (product.c.DepositType == 1)//固定 { closedeposit = Converter.ToFloat(product.c.CloseDeposit, 0) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0); } else if (product.c.DepositType == 2)//浮动 { if (item.Deal == false) closedeposit = 0.01 * Converter.ToFloat(product.c.CloseDeposit, 0) * (Converter.ToFloat(product.LastClose, 0)) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0); else closedeposit = 0.01 * Converter.ToFloat(product.c.CloseDeposit, 0) * (Converter.ToFloat(product.LastClose, 0) + Converter.ToFloat(product.c.Fixedly, 0)) * Converter.ToFloat(product.c.ContractNumber, 0) * Converter.ToFloat(item.OrderCount, 0); } closedeposit = Converter.ToFloat(closedeposit.ToString("F" + Scale), 0); #endregion item.Deposit = Converter.ToFloat((Converter.ToFloat(item.Deposit, 0) + closedeposit).ToString("F" + Scale), 0); //double LastClose = 0.0; //市场价 收盘价 //double Spread = 0.0; //点数 //计算盈亏 //if (item.Deal == false)//卖出 //{ // LastClose = Converter.ToFloat(product.LastClose, 0) + Converter.ToFloat(product.c.Fixedly, 0); // Spread = Converter.ToFloat(item.OpenPrice, 0) - LastClose; //} //else if (item.Deal == true && item.Profit > 0)//买入 //{ // LastClose = Converter.ToFloat(product.LastClose, 0); // Spread = LastClose - Converter.ToFloat(item.OpenPrice, 0); //} //item.Spread = Converter.ToFloat(Spread.ToString("F" + Scale), 0); //item.ProfitAndLoss = Converter.ToFloat((Converter.ToFloat(Spread * item.OrderCount, 0) * Converter.ToFloat(product.c.ContractNumber, 0)).ToString("F" + Scale), 0); //item.NowPrice = Converter.ToFloat(LastClose.ToString("F" + Scale), 0); //item.NetProfit = Converter.ToFloat((Converter.ToFloat(item.ProfitAndLoss, 0) - Converter.ToFloat(item.Deposit, 0) - Converter.ToFloat(item.Interest, 0)).ToString("F" + Scale), 0); item.CloseType = "清算/交割"; item.UpdateTime = nowdate; item.OrderState = 2; item.OrderType = 2; var user = (from c in db.TRealAccounts where c.ID == item.TRealAccountsID select c).FirstOrDefault(); if (user==null) { db.TOrders.DeleteOnSubmit(item); } else { #region 资金记录 TAccountMoney tam = new TAccountMoney(); tam.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff"); tam.RealAccountId = Converter.ToInt(item.TRealAccountsID, 0); tam.TypeId = 4; tam.OriginalMoney = user.AccountMoney; tam.CreateMoney = item.ProfitAndLoss; tam.NowMoney = user.AccountMoney + item.ProfitAndLoss; if (tam.NowMoney<0) { tam.NowMoney = 0; } tam.CreateTime = nowdate; tam.UpDateTime = nowdate; tam.Status = 2; tam.TOrderId = item.ID; db.TAccountMoney.InsertOnSubmit(tam); TAccountMoney tams = new TAccountMoney(); tams.MoneyOrderNum = DateTime.Now.ToString("yyyyMMddHHmmssfff"); tams.RealAccountId = Converter.ToInt(item.TRealAccountsID, 0); tams.TypeId = 5; tams.OriginalMoney = tam.NowMoney; tams.CreateMoney = item.Deposit; tams.NowMoney = tam.NowMoney - item.Deposit; if (tams.NowMoney<0) { tams.NowMoney = 0; } tams.CreateTime = nowdate; tams.UpDateTime = nowdate; tams.Status = 2; tams.TOrderId = item.ID; db.TAccountMoney.InsertOnSubmit(tams); #endregion user.AccountMoney = user.AccountMoney+item.ProfitAndLoss-item.Deposit; if (user.AccountMoney<0) { user.AccountMoney = 0; } } db.SubmitChanges(); } else { } } //移除最后一个‘,’ beforevalue.Remove(beforevalue.Length - 1, 1); beforevalue.Append("]}"); OLog.BeforeValue = beforevalue.ToString(); OLog.UpdateValue = ""; //写入操作日志 OLog.UserID = Convert.ToInt32(Session["ID"]); OLog.UserType = 2;//0 用户 1 会员 2 员工 OLog.CreateDate = DateTime.Now; OLog.PageName = "财务清算"; Converter.InsertOperationLog(OLog); return true; } else { return false; } } catch { return false; } }
private static int GetSumSon(APIDataDataContext db, List<int> q, int counts) { if (q.Count > 0) { foreach (var item in q) { var s = (from c in db.TAgents where c.DirectAgentID == item select c.ID).ToList(); counts = counts + s.Count; counts = GetSumSon(db, s, counts); } } return counts; }
/// <summary> /// 订单列表查询 /// 10021 请求失败 /// </summary> /// <returns></returns> public string OrderInfo() { //try //{ using (APIDataDataContext db = new APIDataDataContext()) { var orderNum = Converter.ToString(Request["orderNum"], ""); var orderType = Converter.ToInt(Request["orderType"], 1); var orderDeal = Converter.ToString(Request["orderDeal"], ""); var startdate = Converter.ToString(Request["startdate"], ""); var enddate = Converter.ToString(Request["enddate"], ""); var pagesize = Converter.ToInt(Request["pagesize"], 100000000); var pagenum = Converter.ToInt(Request["pagenum"], 1); string sqlwhere = ""; if (orderType < 4) { if (!string.IsNullOrEmpty(orderNum)) sqlwhere = " and OrderNum=" + orderNum; if (!string.IsNullOrEmpty(orderDeal)) { sqlwhere += " and Deal=" + orderDeal; } if (!string.IsNullOrEmpty(startdate)) { sqlwhere += sqlwhere + " and UpdateTime>='" + startdate + "'"; } if (!string.IsNullOrEmpty(enddate)) { sqlwhere += sqlwhere + " and UpdateTime<='" + enddate + "'"; } } else if (orderType == 4) { if (!string.IsNullOrEmpty(orderNum)) sqlwhere = "and MoneyOrderNum=" + orderNum; } DataTable dt = null; string sql2 = ""; if (orderType == 1) //在线订单 { //var sql = "select TOP (" + pagesize + ")*,ProductName from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=1 and OrderState=1" + sqlwhere //+ "and t.id not in(select TOP (" + ((pagenum - 1) * pagesize) + ")o.id from dbo.TOrders as o left join dbo.TProducts as a on(o.ProductID=a.ID) where TRealAccountsID =" + userid + " and OrderType=1 and OrderState=1" + sqlwhere + " order by o.OpenTime) order by t.OpenTime desc"; var sql = "select * from(" + "select ROW_NUMBER() over(order by UpdateTime desc)as rowNumber,t.*,ProductName, ProductCode, ProductTable, ContractNumber, Fixedly, Scale, ProfitSize, LossSize, EntrustSize, IsBuy, IsSell, IsLook, SortNum, DepositType, OpenDeposit, CloseDeposit, OccupyFundsType, InterestType, BuyInterest, SellInterest from dbo.TOrders as t " + "left join dbo.TProducts as p on(t.ProductID=p.ID) " + "where TRealAccountsID =" + userid + " and OrderType=1 and OrderState=1 " + sqlwhere + ")as jj where rownumber between " + ((pagenum - 1) * pagesize + 1) + " and " + pagenum * pagesize; sql2 = "select t.id from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=1 and OrderState=1" + sqlwhere + ""; dt = APIDataContextProxy.GetTable(null, sql, CommandType.Text); } else if (orderType == 2) //委托(按) { //var sql = "select TOP (" + pagesize + ")*,ProductName from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=0 and OrderState=1" + sqlwhere //+ "and t.id not in(select TOP (" + ((pagenum - 1) * pagesize) + ")oid from dbo.TOrders as o left join dbo.TProducts as a on(o.ProductID=a.ID) where TRealAccountsID =" + userid + " and OrderType=0 and OrderState=1" + sqlwhere + " order by o.OpenTime) order by t.OpenTime desc "; var sql = "select * from(" + "select ROW_NUMBER() over(order by UpdateTime desc)as rowNumber,t.*,ProductName, ProductCode, ProductTable, ContractNumber, Fixedly, Scale, ProfitSize, LossSize, EntrustSize, IsBuy, IsSell, IsLook, SortNum, DepositType, OpenDeposit, CloseDeposit, OccupyFundsType, InterestType, BuyInterest, SellInterest from dbo.TOrders as t " + "left join dbo.TProducts as p on(t.ProductID=p.ID) " + "where TRealAccountsID =" + userid + " and OrderType=0 and OrderState=1 " + sqlwhere + ")as jj where rownumber between " + ((pagenum - 1) * pagesize + 1) + " and " + pagenum * pagesize; sql2 = "select t.id from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=0 and OrderState=1" + sqlwhere; dt = APIDataContextProxy.GetTable(null, sql, CommandType.Text); } else if (orderType == 3) //历史订单 { //var sql = "select TOP (" + pagesize + ")*,ProductName from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=2 and OrderState=2" + sqlwhere //+ "and t.id not in(select TOP (" + ((pagenum - 1) * pagesize) + ")o.id from dbo.TOrders as o left join dbo.TProducts as a on(o.ProductID=a.ID) where TRealAccountsID =" + userid + " and OrderType=2 and OrderState=2" + sqlwhere + " order by o.OpenTime) order by t.UpdateTime desc"; var sql = "select * from(" + "select ROW_NUMBER() over(order by UpdateTime desc)as rowNumber,t.*,ProductName, ProductCode, ProductTable, ContractNumber, Fixedly, Scale, ProfitSize, LossSize, EntrustSize, IsBuy, IsSell, IsLook, SortNum, DepositType, OpenDeposit, CloseDeposit, OccupyFundsType, InterestType, BuyInterest, SellInterest from dbo.TOrders as t " + "left join dbo.TProducts as p on(t.ProductID=p.ID) " + "where TRealAccountsID =" + userid + " and OrderType=2 and OrderState=2 " + sqlwhere + ")as jj where rownumber between " + ((pagenum - 1) * pagesize + 1) + " and " + pagenum * pagesize; sql2 = "select t.id from dbo.TOrders as t left join dbo.TProducts as p on(t.ProductID=p.ID) where TRealAccountsID =" + userid + " and OrderType=2 and OrderState=2" + sqlwhere; dt = APIDataContextProxy.GetTable(null, sql, CommandType.Text); } else if (orderType == 4)//资金 { //var sql = "SELECT TOP (" + pagesize + ")* FROM TAccountMoney where RealAccountId =" + userid + " and [Status]=2" + sqlwhere //+ "and id not in(select TOP (" + ((pagenum - 1) * pagesize) + ")id FROM TAccountMoney where RealAccountId =" + userid + " and [Status]=2" + sqlwhere + " order by CreateTime) order by CreateTime desc"; var sql = "select * from(" + "select ROW_NUMBER() over(order by CreateTime desc) as rowNumber, * FROM TAccountMoney where RealAccountId =" + userid + " and [Status]=2" + sqlwhere + ")as jj where rownumber between " + ((pagenum - 1) * pagesize + 1) + " and " + pagenum * pagesize; //order by CreateTime desc"; sql2 = "select id FROM TAccountMoney where RealAccountId =" + userid + " and [Status]=2" + sqlwhere; dt = APIDataContextProxy.GetTable(null, sql, CommandType.Text); } else if (orderType == 5)//日志 { //var sql = "SELECT TOP (" + pagesize + ")* FROM TSysLog desc where RealAccountId =" + userid // + "and id not in(select TOP (" + ((pagenum - 1) * pagesize) + ")id FROM TSysLog where RealAccountId =" + userid + " order by CreateTime) order by CreateTime"; var sql = "select * from(" + "select ROW_NUMBER() over(order by CreateTime desc) as rowNumber,* FROM TSysLog desc where RealAccountId =" + userid + ")as jj where rownumber between " + ((pagenum - 1) * pagesize + 1) + " and " + pagenum * pagesize; sql2 = "select id FROM TSysLog where RealAccountId =" + userid; dt = APIDataContextProxy.GetTable(null, sql, CommandType.Text); } APIDataDataContext dbs = APIDataContextProxy.APIDB; var priceList = (from c in dbs.TLastClose select c).ToList();//查询现在所有产品 DateTime NowDate = DateTime.Now; //现在时间 JArray ja = new JArray(); foreach (DataRow dr in dt.Rows) { JObject jb = new JObject(); if (orderType < 4) { var Fixedly = Converter.ToFloat(dr["Fixedly"]); //点差; var ContractNumber = Converter.ToFloat(dr["ContractNumber"], 1); //合约数; var OpenPrice = Converter.ToFloat(dr["OpenPrice"], 0); //开仓价格; var ProductID = Converter.ToInt(dr["ProductID"], 0); //产品id; var OrderCount = Converter.ToFloat(dr["OrderCount"], 1); //手数; var Deposit = Converter.ToFloat(dr["Deposit"], 1); //加工费; var Interest = Converter.ToFloat(dr["Interest"], 1); //仓息; var Scale = Converter.ToInt(dr["Scale"], 2); var LastCloses = (from c in priceList where c.ProductCode == dr["ProductCode"].ToString() select c.LastClose).FirstOrDefault(); var LastClose=Convert.ToDouble(Converter.ToFloat(LastCloses).ToString("F" + Scale)); double Point = 0.0; if (dr["Deal"].ToString().ToLower() == "true")//买 Point = Convert.ToDouble((LastClose - OpenPrice).ToString("F" + Scale)); else Point = Convert.ToDouble((OpenPrice - LastClose - Fixedly).ToString("F" + Scale)); var ProfitAndLoss = Convert.ToDouble((Point * ContractNumber * OrderCount).ToString("F" + Scale)); if (orderType == 1) //在线订单 { jb["IsBuy"] = dr["IsBuy"] + ""; jb["IsSell"] = dr["IsSell"] + ""; jb["ProfitSize"] = dr["ProfitSize"] + ""; //最后操时间 jb["LossSize"] = dr["LossSize"] + ""; //最后操时间 jb["ProductCode"] = dr["ProductCode"] + ""; jb["ProductID"] = ProductID + ""; jb["OrderID"] = dr["ID"] + ""; jb["OrderNum"] = dr["OrderNum"] + ""; //订单号 jb["OpenTime"] = dr["OpenTime"] + ""; //开仓时间 jb["ProductName"] = dr["ProductName"] + ""; //交易商品 jb["OrderCount"] = OrderCount + ""; //交易数量 jb["Deal"] = dr["Deal"] + ""; //交易类型 jb["OpenPrice"] = OpenPrice.ToString("F" + Scale); //开仓价 jb["Profit"] = Converter.ToFloat(dr["Profit"]).ToString("F" + Scale) + ""; //止盈 jb["Loss"] = Converter.ToFloat(dr["Loss"]).ToString("F" + Scale) + ""; //止损 jb["Deposit"] = Deposit.ToString("F" + Scale) + ""; //加工费 jb["OccupyFunds"] = Converter.ToFloat(dr["OccupyFunds"]).ToString("F" + Scale); //保证金 jb["Interest"] = Interest.ToString("F" + Scale) + ""; //仓息 隔夜利息 jb["Point"] = Point.ToString("F" + Scale) + ""; //点数 jb["ProfitAndLoss"] = ProfitAndLoss.ToString("F" + Scale) + ""; //浮动盈亏 jb["NetProfit"] = (ProfitAndLoss - Deposit - Interest).ToString("F" + Scale); //盈亏净利 jb["AllowTwoWayTrade"] = (userGroup.AllowTwoWayTrade) + ""; //是否可以双向交易 jb["AllowOneWayTrade"] = (userGroup.AllowOneWayTrade) + ""; //是否可以单向交易 if (dr["Deal"].ToString().ToLower() == "true")//买 jb["LastClose"] = Converter.ToFloat(LastClose, 0).ToString("F" + Scale); else jb["LastClose"] = Converter.ToFloat(LastClose + Fixedly, 0).ToString("F" + Scale); //现在价格 jb["UpdateTime"] = dr["UpdateTime"] + ""; //最后操时间 } else if (orderType == 2) //委托 { jb["IsBuy"] = dr["IsBuy"] + ""; jb["IsSell"] = dr["IsSell"] + ""; jb["ProfitSize"] = dr["ProfitSize"] + ""; //最后操时间 jb["LossSize"] = dr["LossSize"] + ""; //最后操时间 jb["ProductCode"] = dr["ProductCode"] + ""; jb["ProductID"] = ProductID + ""; var Distance = ""; if (dr["Deal"].ToString().ToLower() == "true")//买 Distance = Converter.ToFloat(OpenPrice - LastClose - Fixedly).ToString("F" + Scale); else Distance = Converter.ToFloat(LastClose - OpenPrice).ToString("F" + Scale); jb["UpdateTime"] = dr["UpdateTime"] + ""; //最后操作时间 jb["OrderID"] = dr["ID"] + ""; jb["OrderNum"] = dr["OrderNum"] + ""; //订单号 jb["Deal"] = dr["Deal"] + ""; //交易类型 jb["EntrustType"] = dr["EntrustType"] + ""; //订单类别 委托类型 0限价交易 1止损交易 jb["OpenTime"] = dr["OpenTime"] + ""; //提交时间 jb["ProductName"] = dr["ProductName"] + ""; //交易商品 jb["OrderCount"] = dr["OrderCount"] + ""; //交易数量 jb["OpenPrice"] = OpenPrice.ToString("F" + Scale); //提交的价位 jb["Distance"] = Distance + ""; //距离 jb["Profit"] = dr["Profit"] + ""; //止盈 jb["Loss"] = dr["Loss"] + ""; //止损 } else if (orderType == 3) { Point = 0.0; if (dr["Deal"].ToString().ToLower() == "true")//买 Point = (Converter.ToFloat(dr["NowPrice"]) - OpenPrice); else Point = (OpenPrice - Converter.ToFloat(dr["NowPrice"]) - Fixedly); jb["ProfitSize"] = dr["ProfitSize"] + ""; //最后操时间 jb["LossSize"] = dr["LossSize"] + ""; //最后操时间 jb["ProductCode"] = dr["ProductCode"] + ""; jb["ProductID"] = ProductID + ""; jb["OrderID"] = dr["ID"] + ""; jb["OrderNum"] = dr["OrderNum"] + ""; //订单号 jb["ProductName"] = dr["ProductName"] + ""; //交易商品 jb["Deal"] = dr["Deal"] + ""; //交易类型 jb["OpenTime"] = dr["OpenTime"] + ""; //开仓时间 jb["UpdateTime"] = dr["UpdateTime"] + ""; //平仓时间 jb["OpenPrice"] = OpenPrice.ToString("F" + Scale); //开仓价 jb["NowPrice"] = Converter.ToFloat(dr["NowPrice"]).ToString("F" + Scale) + ""; //平仓价 jb["OrderCount"] = dr["OrderCount"] + ""; //交易数量 jb["Interest"] = Interest.ToString("F" + Scale) + ""; //仓息 隔夜利息 jb["Deposit"] = Deposit.ToString("F" + Scale) + ""; //加工费 jb["ProfitAndLoss"] = Converter.ToFloat(dr["ProfitAndLoss"]).ToString("F" + Scale); //浮动盈亏 jb["NetProfit"] = Converter.ToFloat(dr["NetProfit"]).ToString("F" + Scale); //盈亏净利 jb["Point"] = Point.ToString("F" + Scale); //点数 jb["Profit"] = dr["Profit"] + ""; //止盈 jb["Loss"] = dr["Loss"] + ""; //止损 } } else if (orderType == 4) { jb["MoneyOrderNum"] = dr["MoneyOrderNum"] + ""; //订单号 jb["TypeId"] = dr["TypeId"] + ""; //类型 用户操作类型 1入金 2赠金 3出金 4盈亏 5加工费 6仓息 jb["OriginalMoney"] = dr["OriginalMoney"] + ""; //原来余额 jb["CreateMoney"] = dr["CreateMoney"] + ""; //变动金额 jb["NowMoney"] = dr["NowMoney"] + ""; //交易后余额 jb["CreateTime"] = dr["CreateTime"] + ""; //时间 } else if (orderType == 5) { jb["CreateTime"] = dr["CreateTime"] + ""; //时间 jb["LogMsg"] = dr["LogMsg"] + ""; //备注信息 } ja.Add(jb); } //总条数 DataTable dt2 = APIDataContextProxy.GetTable(null, sql2, CommandType.Text); JObject job = new JObject(); job["success"] = "TRUE"; JObject jobzhx = new JObject(); jobzhx["content"] = ja; jobzhx["allnum"] = dt2.Rows.Count; //var allpagenum = dt2.Rows.Count / pagesize + dt2.Rows.Count % pagesize > 0 ? 1 : 0; //jobzhx["allpagenum"] = allpagenum; jobzhx["pagesize"] = pagesize; jobzhx["pagenum"] = pagenum; job["content"] = jobzhx; return job.ToString(); } //} //catch //{ // return ErrMsg(10021, "请求失败!"); //} }
/// <summary> /// 提交对数据库的更改 /// 当产生并发冲突时,用数据库的值强制更新当前值 /// </summary> /// <param name="db"></param> public static void SubmitChangesByDatabase(APIDataDataContext db) { try { db.SubmitChanges(ConflictMode.ContinueOnConflict); } catch (ChangeConflictException e) { Console.WriteLine(e.Message); foreach (ObjectChangeConflict occ in db.ChangeConflicts) { occ.Resolve(RefreshMode.OverwriteCurrentValues); } } }