private void handleProjReserveTokenTotal(string projId) { // var whereStr = new JObject { { "projId", projId } }.ToString(); if (mh.GetDataCount(daoConn.connStr, daoConn.connDB, daoFinanceFundPoolCol, whereStr) == 0) { var totalFlag = UnlockFinishFlag.Not; if (getProjReserveInfo(projId, out decimal total, out string address, out string fundName, out string tokenName)) { //totalFlag = UnlockFinishFlag.Yes; } var dbZERO = decimal.Zero.format(); var now = TimeHelper.GetTimeStamp(); var newdata = new FundPoolInfo { projId = projId, tokenName = tokenName, tokenLockTotal = total.format(), tokenLockTotalAddress = address, tokenUnlockNotAmount = total.format(), tokenUnlockYesAmount = dbZERO, tokenUnlockFinishFlag = totalFlag, tokenLastUpdateTime = TimeHelper.GetTimeStamp(), fundName = fundName, fundPoolTotal = dbZERO, fundPoolTotalTp = dbZERO, fundManagePoolTotal = dbZERO, fundManagePoolTotalTp = dbZERO, fundReservePoolTotal = dbZERO, fundReservePoolTotalTp = dbZERO, // fundReserveRatio = dbZERO, priceRaiseSpeed = dbZERO, // hasOnBuyFundTotal = dbZERO, hasOnBuyFundTotalTp = dbZERO, hasIssueTokenTotal = dbZERO, hasIssueTokenTotalTp = dbZERO, time = now, lastUpdateTime = now, }; mh.PutData <FundPoolInfo>(daoConn.connStr, daoConn.connDB, daoFinanceFundPoolCol, newdata); } }
private void handleUnLockToken(FundPoolInfo item, long now) { var projId = item.projId; var findStr = new JObject { { "projId", projId } }.ToString(); var updateStr = ""; if (item.tokenLockTotal.format() == item.tokenUnlockYesAmount.format()) { updateStr = new JObject { { "$set", new JObject { { "tokenUnlockFinishFlag", UnlockFinishFlag.Yes } } } }.ToString(); mh.UpdateData(daoConn.connStr, daoConn.connDB, daoFinanceFundPoolCol, updateStr, findStr); return; } var fieldStr = new JObject { { "tokenAmt", 1 }, { "timestamp", 1 } }.ToString(); var queryRes = mh.GetData(daoConn.connStr, daoConn.connDB, daoFinanceReserveTokenHistCol, findStr, fieldStr); if (queryRes.Count == 0) { return; } var sum = queryRes.Sum(p => decimal.Parse(p["tokenAmt"].ToString())); var unlockY = queryRes.Sum(p => { if (long.Parse(p["timestamp"].ToString()) < now) { return(0); } return(decimal.Parse(p["tokenAmt"].ToString())); }); var unlockN = queryRes.Sum(p => { if (long.Parse(p["timestamp"].ToString()) >= now) { return(0); } return(decimal.Parse(p["tokenAmt"].ToString())); }); bool flag = false; var updateJo = new BsonDocument { }; if (sum != item.tokenLockTotal) { updateJo.Add("tokenLockTotal", sum.format()); flag = true; } if (unlockY != item.tokenUnlockYesAmount) { updateJo.Add("tokenUnlockYesAmount", unlockY.format()); flag = true; } if (unlockN != item.tokenUnlockNotAmount) { updateJo.Add("tokenUnlockNotAmount", unlockN.format()); if (unlockN == decimal.Zero) { updateJo.Add("tokenUnlockFinishFlag", UnlockFinishFlag.Yes); } flag = true; } if (flag) { updateJo.Add("tokenLastUpdateTime", now); var updateBson = new BsonDocument { { "$set", updateJo } }; mh.UpdateDecimal(daoConn.connStr, daoConn.connDB, daoFinanceFundPoolCol, updateBson, findStr); } }