This repository was archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAffiliatesTools.py
More file actions
89 lines (68 loc) · 2.79 KB
/
AffiliatesTools.py
File metadata and controls
89 lines (68 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import random
import string
from datetime import datetime
def build_invites_chain(invited_by,users_collection):
level1 = []
level2 = []
level3 = []
level4 = []
# ricerca degli utenti invitati dal diretto inviatore
for user in users_collection.find({'InvitedBy': invited_by}):
level1.append(user)
# ricerca degli utenti invitati dal livello 1
for user2 in level1:
for x in users_collection.find({'InvitedBy': user2['AffiliateCode']}):
if x not in level2:
level2.append(x)
# ricerca degli utenti invitati dal livello 2
for user3 in level2:
for y in users_collection.find({'InvitedBy': user3['AffiliateCode']}):
if y not in level3:
level3.append(y)
# ricerca degli utenti invitati dal livello 3
for user4 in level3:
for w in users_collection.find({'InvitedBy': user4['AffiliateCode']}):
if w not in level4:
level4.append(w)
# interrompe il ciclo se level4 è vuota
if not level4:
break
return level1, level2, level3, level4
def BuildNetworkBalances(invited_by,users_collection):
level1 = []
level2 = []
level3 = []
level4 = []
level1Balance = 0.0
level2Balance = 0.0
level3Balance = 0.0
level4Balance = 0.0
# ricerca degli utenti invitati dal diretto inviatore
for user in users_collection.find({'InvitedBy': invited_by}):
level1.append(user)
level1Balance= level1Balance+user["Current_balance"]
# ricerca degli utenti invitati dal livello 1
for user2 in level1:
for x in users_collection.find({'InvitedBy': user2['AffiliateCode']}):
if x not in level2:
level2.append(x)
level2Balance = level2Balance+ x["Current_balance"]
# ricerca degli utenti invitati dal livello 2
for user3 in level2:
for y in users_collection.find({'InvitedBy': user3['AffiliateCode']}):
if y not in level3:
level3.append(y)
level3Balance = level3Balance+ y["Current_balance"]
# ricerca degli utenti invitati dal livello 3
for user4 in level3:
for w in users_collection.find({'InvitedBy': user4['AffiliateCode']}):
if w not in level4:
level4.append(w)
level4Balance = level4Balance+ w["Current_balance"]
# interrompe il ciclo se level4 è vuota
if not level4:
break
return round(level1Balance,2), round(level2Balance,2), round(level3Balance,2), round(level4Balance,2)
def GenerateAffiliateCode():
caratteri = string.ascii_letters + string.digits
return ''.join(random.choice(caratteri) for _ in range(10))