Beispiel #1
0
        private void CalculateBonusOfQl5(ManagerL5 newManager)
        {
            // Hoa hong quan ly
            m_PersistenceManager.SaveAccountBonus(newManager.ParentId, ConstUtil.BONUS_TYPE_QL5.Amount,
                                                  ConstUtil.BONUS_TYPE_QL5.Type);

            var managerLevel = (ManagerL5)m_PersistenceManager.GetManagerLevel <ManagerL5>(newManager.ParentId);

            if (managerLevel != null && managerLevel.ParentId != -1)
            {
                m_PersistenceManager.SaveAccountBonus(managerLevel.ParentId, ConstUtil.BONUS_TYPE_QL5.Amount,
                                                      ConstUtil.BONUS_TYPE_QL5.Type);
            }
            // Can cap
            if ((newManager.LevelIndex % 3) != 1)
            {
                m_PersistenceManager.SaveAccountBonus(newManager.ParentId, ConstUtil.BONUS_TYPE_CCL5.Amount,
                                                      ConstUtil.BONUS_TYPE_CCL5.Type);
                if (managerLevel != null && managerLevel.ParentId != -1)
                {
                    m_PersistenceManager.SaveAccountBonus(managerLevel.ParentId, ConstUtil.BONUS_TYPE_CCL5.Amount,
                                                          ConstUtil.BONUS_TYPE_CCL5.Type);
                }
            }

            // move to QL6 approved queue
            if (newManager.LevelIndex % 9 == 0)
            {
                if (managerLevel != null && managerLevel.ParentId != -1)
                {
                    InsertToQlApproveQueue(managerLevel.ParentId, 6);
                }
            }
        }
Beispiel #2
0
        private ManagerL5 AddToQl5Tree(long calcAccountId)
        {
            // Get level and level_index
            var lastestChild = (ManagerL5)m_PersistenceManager.GetQlLatestChild <ManagerL5>();

            // Find Parent account
            if (lastestChild == null)
            {
                var root = new ManagerL5
                {
                    AccountId   = calcAccountId,
                    ChildIndex  = 0,
                    Level       = 0,
                    LevelIndex  = 0,
                    IsActive    = "Y",
                    ParentId    = -1,
                    CreatedBy   = "JOB",
                    CreatedDate = DateTime.Now
                };
                m_PersistenceManager.Save(root);
                return(root);
            }
            else
            {
                var newLevel      = lastestChild.Level;
                var newLevelIndex = lastestChild.LevelIndex + 1;

                if (Math.Pow(3, lastestChild.Level) == lastestChild.LevelIndex)
                {
                    newLevel      = lastestChild.Level + 1;
                    newLevelIndex = 1;
                }

                var parentLevel      = newLevel - 1;
                var parentLevelIndex = (newLevelIndex % 3 > 0) ? ((newLevelIndex / 3) + 1) : (newLevelIndex / 3);

                var managerParent = (ManagerL5)m_PersistenceManager.FindQlByLocation <ManagerL5>(parentLevel, parentLevelIndex);

                // Insert into QL5 tree
                var newNode = new ManagerL5
                {
                    AccountId   = calcAccountId,
                    ChildIndex  = (newLevelIndex % 3) == 0 ? 3 : newLevelIndex % 3,
                    Level       = newLevel,
                    LevelIndex  = newLevelIndex,
                    IsActive    = "Y",
                    ParentId    = managerParent.AccountId,
                    CreatedBy   = "JOB",
                    CreatedDate = DateTime.Now
                };
                m_PersistenceManager.Save(newNode);

                return(newNode);
            }
        }