private bool IsCalculated(AccountPreCalc accountPreCalc) { if (accountPreCalc.AccountLevel == -1) { return(false); } if (accountPreCalc.AccountLevel == 1 && accountPreCalc.BonusType == ConstUtil.BONUS_TYPE_TT.Type) { return(true); } if (accountPreCalc.AccountLevel == 1 && accountPreCalc.BonusType == "LK" && accountPreCalc.LevelIndex > 1) { return(true); } return(m_PersistenceManager.CountUpLevel(accountPreCalc.CalcAccountId, accountPreCalc.AccountLevel - 1) == Math.Pow(3, accountPreCalc.AccountLevel - 1) /*&& m_PersistenceManager.CountLeft(accountPreCalc.CalcAccountId, accountPreCalc.AccountLevel, accountPreCalc.LevelIndex) == (accountPreCalc.LevelIndex - 1)s*/); }
private void PutToPreCalcQueue(Account account, Account calculatedAccount, int level, long levelIndex) { // insert preparation calculated queue var preCalc = new AccountPreCalc { AccountId = account.AccountId, CalcAccountId = calculatedAccount.AccountId, AccountLevel = level, IsCalculated = "N", LevelIndex = levelIndex, CreatedDate = DateTime.Now, BonusType = (account.ParentId == account.ParentDirectId && account.ParentDirectId == calculatedAccount.AccountId) ? ConstUtil.BONUS_TYPE_TT.Type : "LK" }; m_PersistenceManager.Save(preCalc); if (account.ParentDirectId == calculatedAccount.AccountId && account.ParentId != account.ParentDirectId) { preCalc = new AccountPreCalc { AccountId = account.AccountId, CalcAccountId = calculatedAccount.AccountId, AccountLevel = -1, IsCalculated = "N", LevelIndex = -1, CreatedDate = DateTime.Now, BonusType = ConstUtil.BONUS_TYPE_TT.Type }; m_PersistenceManager.Save(preCalc); } // calculate next level Account nextLevelAccount = m_PersistenceManager.GetAccount(calculatedAccount.ParentId); if (nextLevelAccount == null || nextLevelAccount.AccountId == calculatedAccount.AccountId) { return; } int nextLevel = level + 1; var nextLevelIndex = (long)((calculatedAccount.ChildIndex - 1) * Math.Pow(3, nextLevel - 1) + levelIndex); PutToPreCalcQueue(account, nextLevelAccount, nextLevel, nextLevelIndex); }
private void CalculateHtBonus(AccountPreCalc accountPreCalc) { double bonusAmmount; switch (accountPreCalc.AccountLevel) { case 2: bonusAmmount = 0.2; break; case 3: bonusAmmount = 0.2; break; case 4: bonusAmmount = 0.03; break; case 5: bonusAmmount = 0.01; break; case 6: bonusAmmount = 0.005; break; case 7: bonusAmmount = 0.003; break; default: bonusAmmount = 0.001; break; } m_PersistenceManager.SaveAccountBonus(accountPreCalc.CalcAccountId, bonusAmmount, ConstUtil.BONUS_TYPE_HE_THONG.Type); }
private void CalculateTtBonus(AccountPreCalc accountPreCalc) { m_PersistenceManager.SaveAccountBonus(accountPreCalc.CalcAccountId, ConstUtil.BONUS_TYPE_TT.Amount, ConstUtil.BONUS_TYPE_TT.Type); }