/// <summary> /// 查询历史分红 /// </summary> public JsonResult GetHisCoins(string useraddress, int?page, int?rows) { if (page == null) { page = 1; } if (rows == null) { rows = 20; } var total = 0; var list = UserInComesHisBLL.GetInComesHisBySome(useraddress, null, null, rows.Value, page.Value, ref total); var result = new { total = total, rows = list }; return(Json(result)); }
private IndexViewModel GetModel(string useraddress) { var list = LBTCNodesBLL.Get101Nodes(-1); decimal votessum = NodeVotesBLL.GetPoolNodeVotesSum(); votessum = votessum / Strings.CoinToCong; votessum = Math.Round(votessum, 2); return(new IndexViewModel { HisSumCoins = Math.Round(UserInComesHisBLL.GetInComesSum(useraddress, null, null), 2), NowSumCoins = Math.Round(UserInComesOnlineBLL.GetOnlineInComesSum(useraddress, null), 6), NodeAllCount = PoolNodesBLL.GetPoolNodeCount(), NodeCount = list.Count, VotesSum = votessum, UsersSum = UserAddressesBLL.GetAllUserCount() }); }
public static void ShareCoins(object source, ElapsedEventArgs e) { //Console.WriteLine("Share Begin!"); log.Info("循环执行时间:" + DateTime.Now.ToString() + ""); string listnodess = RunScript("listdelegates"); listhasnodes = LBTCNodesBLL.GetAllNodes(); var newlisthasnodes = new List <LBTCNodes>(); var addlist = new List <LBTCNodes>(); var alllist = new List <LBTCNodes>(); var onenode = new LBTCNodes(); poolnodes = PoolNodesBLL.GetPoolNodesByGroupID(0); var datarunInt = -1; #region 30秒更新一次节点投票信息 if (Strings.ScriptTrue(listnodess)) { try { try { var listnodes = JsonConvert.DeserializeObject <List <NodeInfo> >(listnodess); string nodevotess = ""; long nodevotes = 0;//节点投票数 foreach (var node in listnodes) { var thisname = node.name.Replace(Environment.NewLine, ""); //thisname = thisname.Trim(); if (!string.IsNullOrWhiteSpace(thisname)) { nodevotess = RunScript("getdelegatevotes \"" + thisname + "\""); if (Strings.ScriptTrue(nodevotess)) { nodevotes = long.Parse(nodevotess); } var GroupID = GetGorupID(node.address); alllist.Add(new LBTCNodes { NodeID = node.id, NodeAddress = node.address, NodeName = thisname, NodeVotes = nodevotes, GroupID = GroupID, GetRate = 0.0000m }); if (IsInHasList(node.address)) { newlisthasnodes.Add(new LBTCNodes { NodeID = node.id, NodeAddress = node.address, NodeName = thisname, NodeVotes = nodevotes, GroupID = GroupID }); } else { addlist.Add(new LBTCNodes { NodeID = node.id, NodeAddress = node.address, NodeName = thisname, NodeVotes = nodevotes, GroupID = GroupID, GetRate = 0.0000m }); } } } if (newlisthasnodes.Count > 0) { datarunInt = LBTCNodesBLL.UpdateNodesWithOutRate(newlisthasnodes); } if (addlist.Count > 0) { datarunInt = LBTCNodesBLL.InsertNodes(addlist); } } catch (Exception er) { log.Error(er.ToString()); } } catch (Exception ee) { log.Error(ee.ToString()); } } #endregion #region 每周五9点按时发放分红 var publictime = DateTime.Now; bool isintime = Strings.WeekDayToInt(publictime.DayOfWeek) == conf.ShareCoinsWeekDay && publictime.Hour == conf.ShareCoinsHour && publictime.Minute <= conf.GetNodesTimerSpan / 60 && publictime.Second < conf.GetNodesTimerSpan % 60; //isintime = publictime.Hour == 13 && publictime.Minute == 43 && publictime.Second < 30; if (isintime) { //统计节点分红率 var allpoolnodes = PoolNodesBLL.GetPoolNodesByGroupID(0); var publicnodes = new List <LBTCNodes>(); foreach (var node in allpoolnodes) { var getcoinsAll = UserInComesOnlineBLL.GetOnlineInComesSum(null, node.NodeAddress); var thisnode = alllist.Find(x => x.NodeAddress == node.NodeAddress); if (thisnode != null) { if (thisnode.NodeVotes > 0) { thisnode.GetRate = Math.Round(getcoinsAll * Strings.CoinToCong * 10000.00m / thisnode.NodeVotes, 4); } else { thisnode.GetRate = 0.0000m; } } publicnodes.Add(thisnode); } datarunInt = LBTCNodesBLL.UpdateNodesWithAll(publicnodes); //发放分红 var listusers = UserAddressesBLL.GetAllUserAddress(); //poolgroups = PoolGroupBLL.GetAllPoolGroup(); var hislist = new List <UserInComesHis>(); foreach (var user in listusers) { var getcoinsAll = UserInComesOnlineBLL.GetOnlineInComesSum(user.UserAddress, null); if (getcoinsAll >= conf.ShareMin) { //7044 5ad6 5891 8824 85d2 1c6c 2014 35cc 921b 9e17 1e30 3cb1 30f5 1539 0649 3a2e //执行转账脚本 string txhash = RunScript("sendtoaddress " + user.UserAddress + " " + getcoinsAll.ToString()); //string txhash = RunScript("sendtoaddress 12CacXV2WvdUNBu9K3Z1CUBvfEizPq9r4D 0.005"); log.Info("分红:sendtoaddress " + user.UserAddress + " " + getcoinsAll.ToString() + "------txid:" + txhash); if (Strings.ScriptTrue(txhash) && txhash.Length == 64) { string listhis = ""; foreach (var poolnode in poolnodes) { var getcoinsone = UserInComesOnlineBLL.GetOnlineInComesSum(user.UserAddress, poolnode.NodeAddress); listhis += "|" + poolnode.NodeAddress + "-" + getcoinsone.ToString(); } listhis = listhis.Trim('|'); hislist.Add(new UserInComesHis { InComeID = Guid.NewGuid().ToString(), NodeAddresses = listhis, UserAddress = user.UserAddress, SetTime = publictime, GetCoins = getcoinsAll, TransactionHash = txhash }); datarunInt = UserInComesOnlineBLL.DelOnlineInComesByUserAddress(user.UserAddress); } } } if (hislist.Count > 0) { datarunInt = UserInComesHisBLL.InsertInComesHis(hislist); } datarunInt = PoolNodesBLL.CleanOnlineCoins();//还原所有矿池节点周期统计 } #endregion log.Info("循环结束时间:" + DateTime.Now.ToString() + ""); }