D
D
DTPlayer2020-06-20 22:55:42
Python
DTPlayer, 2020-06-20 22:55:42

No bonus is given for the referred user, how to solve?

Functions:

def referral_web(user_id, deposit_sum):
    conn = sqlite3.connect("base_ts.sqlite")
    cursor = conn.cursor()

    cursor.execute(f'SELECT * FROM users WHERE user_id = "{user_id}"')
    user = cursor.fetchone()

    if user[4] == '0':
        return
    else:
        info = profile(user_id)
        user2 = cursor.execute(f'SELECT * FROM users WHERE user_id = "{user[4]}"').fetchone()

        profit = int(info[5]) + int(10)

        balance = float(user[5]) + float(profit)

        cursor.execute(f'UPDATE users SET balance = {balance} WHERE user_id = "{user[4]}"')
        conn.commit()

        ref_log(user2[0], profit, user2[1])


def ref_log(user_id, profit, name):
    conn = sqlite3.connect("base_ts.sqlite")
    cursor = conn.cursor()

    cursor.execute(f'SELECT * FROM ref_log WHERE user_id = "{user_id}"')
    user = cursor.fetchall()

    if len(user) == 0:
        cursor.execute(f'INSERT INTO ref_log VALUES ("{user_id}", "{profit}", "{name}")')
        conn.commit()
    else:
        all_profit = user[0][1]

        all_profit = float(all_profit) + float(profit)

        cursor.execute(f'UPDATE ref_log SET all_profit = {all_profit} WHERE user_id = "{user_id}"')
        conn.commit()


Conclusion:
elif message.text == ' Referrals':
            bot_name = bot.get_me().username
            ref_code = func.check_ref_code(chat_id)
            bot.send_message(chat_id, f''' Get bonuses for invited friends.

 Send a link to a friend
https://t.me/{bot_name}?start={ref_code}

➕ 10$ for each friend you invite
➕ 10% of your friends' earnings

Earnings: {func.check_all_profit_user(chat_id)}$''')

When following a referral link, it does not protect the balance, how to solve?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question