Пример #1
0
        /// <summary>
        /// Kiszámolja a Jutalékot és a vásárlásokat.
        /// </summary>
        /// <returns></returns>
        public List <PartnersCommission> GetCommissions()
        {
            var partnersCommissionList = new List <PartnersCommission>();

            var partners   = GetPartners();
            var financials = GetFinancialItems();

            foreach (var item in partners)
            {
                _team = new List <Partner>();

                GetTeam(item.PARTNER_ID, partners);

                var partner = new PartnersCommission()
                {
                    Team          = _team,
                    PARTNER_ID    = item.PARTNER_ID,
                    TEAM_PURCHASE = CalculateTeamAmountSum(_team)
                };

                partner.PARENT       = item;
                partner.ALL_PURCHASE = partner.TEAM_PURCHASE + CalculateParnterAmountSum(item);
                partner.OWN_PURCHASE = CalculateOwnPurchase(item);

                partnersCommissionList.Add(partner);
            }

            foreach (var item in partnersCommissionList)
            {
                item.CHILDREN_PURCHASE = CalculateChildrenPurchase(partnersCommissionList, item);
                item.COMMISSION        = item.CHILDREN_PURCHASE + item.OWN_PURCHASE;
            }

            return(partnersCommissionList);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="partner"></param>
        /// <returns></returns>
        public decimal CalculateChildrenPurchase(List <PartnersCommission> list, PartnersCommission partner)
        {
            decimal sum = 0;

            var nearChildren = partner.Team.Where(p => p.PARENT_PARTNER_ID == partner.PARTNER_ID);

            decimal fee = 0;

            foreach (var item in nearChildren)
            {
                if (item.FEE_PERCENT < partner.PARENT.FEE_PERCENT)
                {
                    fee = partner.PARENT.FEE_PERCENT - item.FEE_PERCENT;

                    sum = list.Where(f => f.PARTNER_ID == item.PARTNER_ID).FirstOrDefault().ALL_PURCHASE;
                }
            }

            return(sum * (1 + (fee / 100)));
        }