Exemple #1
0
    public static void ValidatePayoutNotConnectedToAmount(Member user)
    {
        //Check the status
        if (user.Status == MemberStatus.VacationMode)
        {
            throw new MsgException(U4000.YOUAREINVACATIONMODE);
        }

        //Account verification
        if (AppSettings.Authentication.IsDocumentVerificationEnabled && user.VerificationStatus != VerificationStatus.Verified)
        {
            throw new MsgException(U5006.ACCOUNTNOTVERIFIED);
        }

        if (user.NumberOfPayoutsToday + 1 > user.Membership.MaxDailyPayouts)
        {
            throw new MsgException(string.Format(U6000.TOOMANYWITHDRAWSTODAY, user.Membership.MaxDailyPayouts));
        }

        //Payout Days
        if (!AppSettings.Representatives.RepresentativesIgnoreWitdrawalRules || !user.IsRepresentative())
        {
            PayoutManager.CheckPayoutsDays();
        }

        //Check negative balance
        if (user.IsAnyBalanceIsNegative())
        {
            throw new MsgException(U6012.NEGATIVEBALANCEWITHDRAWAL);
        }

        //Validate Credit Loans
        if (CreditLineManager.UserHasUnpaidLoans(user.Id))
        {
            throw new MsgException(U6008.REPAYCREDITLINETOWITHDRAW);
        }

        //Special Check amount of collected offers from different levels
        if (TitanFeatures.IsBobbyDonev && CPAOffer.CheckCollectedLevelsAmount(user.Name) < 20)
        {
            throw new MsgException(String.Format("You didn't collect enaugh CPA/GPT offers from different levels yet. You have already collected and confirmed {0} levels.", CPAOffer.CheckCollectedLevelsAmount(user.Name)));
        }

        //Special Check amount of collected offers from different levels
        if (TitanFeatures.IsBobbyDonev && user.CashoutsProceed > 0)
        {
            throw new MsgException("You already did one payout. You can't do more.");
        }

        //Check days restriction between each withdrawals
        var lastWidthdrawalDate = user.GetLastWithdrawalDate();

        if (lastWidthdrawalDate != null && lastWidthdrawalDate > AppSettings.ServerTime.AddDays(-user.Membership.BlockPayoutDays))
        {
            throw new MsgException(string.Format(U6013.TIMEBETWEENPAYOUTERROR, user.Membership.BlockPayoutDays));
        }
    }