04/06/23 - 23h
parent
19eb883b37
commit
e87572aa8d
|
@ -1,10 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/05/23 - 22h">
|
||||
<change afterPath="$PROJECT_DIR$/code_promo_mgt.py" afterDir="false" />
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/06/23 - 22h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/code_promo_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/code_promo_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -278,7 +282,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1685477842033</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="31" />
|
||||
<task id="LOCAL-00031" summary="02/06/23 - 22h">
|
||||
<created>1685735947619</created>
|
||||
<option name="number" value="00031" />
|
||||
<option name="presentableId" value="LOCAL-00031" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1685735947619</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="32" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -293,7 +304,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="10/04/23 - 17h" />
|
||||
<MESSAGE value="14/04/23 - 23h" />
|
||||
<MESSAGE value="15/04/23 - 14h" />
|
||||
<MESSAGE value="15/04/23 - 22h" />
|
||||
|
@ -318,6 +328,7 @@
|
|||
<MESSAGE value="28/05/23 - 15h" />
|
||||
<MESSAGE value="29/0523 - 20h" />
|
||||
<MESSAGE value="30/05/23 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="30/05/23 - 22h" />
|
||||
<MESSAGE value="02/06/23 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="02/06/23 - 22h" />
|
||||
</component>
|
||||
</project>
|
|
@ -277,7 +277,14 @@ if (MYSY_ENV == "PROD"):
|
|||
|
||||
elif (MYSY_ENV == "DEV"):
|
||||
STRIPE_GOLD_PRICE_ID = "price_1MT3FmAbmaEugrFTZ5vyJRcZ"
|
||||
STRIPE_GOLD_PRICE_ID_50_OFF = "price_1NEpALAbmaEugrFTCDhlJyo3"
|
||||
STRIPE_GOLD_PRICE_ID_100_OFF = "price_1NEpeJAbmaEugrFTXT5OFciX"
|
||||
|
||||
STRIPE_STANDARD_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
|
||||
STRIPE_STANDARD_PRICE_ID_50_OFF = "price_1NEpCOAbmaEugrFTcBnOf89X"
|
||||
STRIPE_STANDARD_PRICE_ID_100_OFF = "price_1NEpbrAbmaEugrFTgLABbIOF"
|
||||
|
||||
|
||||
STRIPE_TEST_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
|
||||
STRIPE_CONFIG_KEY_PUB = "pk_test_51LUUfAAbmaEugrFTI25uZBD3IFjbtaL6jUfRV83diDf7nco8worna4NGKhMHbPP71WCwT5EHFRdDNatxPrJWwgZ300kgH5EO4p"
|
||||
STRIPE_CONFIG_API_KEY = "sk_test_51LUUfAAbmaEugrFTrWsfcBWZtbBh9r3HCa2sgeyikG808LjSk3bAdFhV6KxgRZ3vFxooa6RE0c5zBkTuOUrKkyjy00BrsIXAPs"
|
||||
|
@ -286,7 +293,12 @@ elif (MYSY_ENV == "DEV"):
|
|||
|
||||
elif (MYSY_ENV == "REC"):
|
||||
STRIPE_GOLD_PRICE_ID = "price_1MT3FmAbmaEugrFTZ5vyJRcZ"
|
||||
STRIPE_GOLD_PRICE_ID_50_OFF = "price_1NEpALAbmaEugrFTCDhlJyo3"
|
||||
|
||||
STRIPE_STANDARD_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
|
||||
STRIPE_STANDARD_PRICE_ID_50_OFF = "price_1NEpCOAbmaEugrFTcBnOf89X"
|
||||
|
||||
|
||||
STRIPE_TEST_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
|
||||
STRIPE_CONFIG_KEY_PUB = "pk_test_51LUUfAAbmaEugrFTI25uZBD3IFjbtaL6jUfRV83diDf7nco8worna4NGKhMHbPP71WCwT5EHFRdDNatxPrJWwgZ300kgH5EO4p"
|
||||
STRIPE_CONFIG_API_KEY = "sk_test_51LUUfAAbmaEugrFTrWsfcBWZtbBh9r3HCa2sgeyikG808LjSk3bAdFhV6KxgRZ3vFxooa6RE0c5zBkTuOUrKkyjy00BrsIXAPs"
|
||||
|
@ -373,4 +385,11 @@ CLASS_DURATION_UNIT = ['heure', 'jour', 'semaine', 'mois', 'annee', 'user_rythme
|
|||
"""
|
||||
Varibale definit la taille maximiale des repertoire à créer par mysy
|
||||
"""
|
||||
DIRECTORY_MAX_LENGTH = 50
|
||||
DIRECTORY_MAX_LENGTH = 50
|
||||
|
||||
|
||||
"""
|
||||
Variable defini les type de remise (code promo) acceptés:
|
||||
percent ou fix
|
||||
"""
|
||||
CODE_PROMO_TYPE = ['fix', 'percent']
|
1458
Log/log_file.log
1458
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -30,6 +30,7 @@ Elle verifie que ce code n'existe pas deja
|
|||
"""
|
||||
def Add_Code_Promo(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
|
@ -61,6 +62,13 @@ def Add_Code_Promo(diction):
|
|||
if diction['code']:
|
||||
code = diction['code']
|
||||
|
||||
if (len(code) > 255):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'description' fait plus de 255 caracteres ")
|
||||
|
||||
return False, " - Le champ 'description' fait plus de 255 caracteres "
|
||||
|
||||
my_type = ""
|
||||
if ("type" in diction.keys()):
|
||||
if diction['type']:
|
||||
|
@ -218,7 +226,7 @@ def Get_Valide_Code_Promo(diction):
|
|||
# print(" ##### retval = " + str(retval))
|
||||
debut_debut = datetime.strptime(str(retval['date_debut']).strip(), '%d/%m/%Y')
|
||||
date_fin = datetime.strptime(str(retval['date_fin']).strip(), '%d/%m/%Y')
|
||||
if (debut_debut <= datetime.now() and date_fin >= datetime.now()):
|
||||
if (debut_debut <= datetime.now() and date_fin >= datetime.now() and retval['type'] in ['fix', 'percent'] ):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(retval))
|
||||
|
||||
|
||||
|
@ -228,7 +236,7 @@ def Get_Valide_Code_Promo(diction):
|
|||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de recuperer la session de formation"
|
||||
return False, "Impossible de recuperer la liste des codes promo"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -285,7 +293,7 @@ def Get_All_Code_Promo(diction):
|
|||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de recuperer la session de formation"
|
||||
return False, "Impossible de recuperer la liste des codes promo"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -444,3 +452,77 @@ def Update_Code_Promo(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de mettre à jour le code promo "
|
||||
|
||||
"""
|
||||
Cette fonction prend un code promo, verifie sa validité et retourne les valeurs / type associées
|
||||
"""
|
||||
def Get_Given_Code_Promo(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
field_list = ['token','code_promo']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, "Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token','code_promo']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - : La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, "Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
code_promo = ""
|
||||
if ("code_promo" in diction.keys()):
|
||||
if diction['code_promo']:
|
||||
code_promo = diction['code_promo']
|
||||
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
|
||||
return False, " Les données de connexion sont incorrectes "
|
||||
|
||||
coll_session = MYSY_GV.dbname['code_promo']
|
||||
myquery = {}
|
||||
myquery['valide'] = "1"
|
||||
myquery['locked'] = "0"
|
||||
|
||||
myquery['code'] = code_promo
|
||||
|
||||
print(" ##### myquery = " + str(myquery))
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
for retval in coll_session.find(myquery):
|
||||
print(" ##### retval = " + str(retval))
|
||||
debut_debut = datetime.strptime(str(retval['date_debut']).strip(), '%d/%m/%Y')
|
||||
date_fin = datetime.strptime(str(retval['date_fin']).strip(), '%d/%m/%Y')
|
||||
if (debut_debut <= datetime.now() and date_fin >= datetime.now() and retval['type'] in ['fix', 'percent'] ):
|
||||
RetObject.append(mycommon.JSONEncoder().encode(retval))
|
||||
nb_val = nb_val + 1
|
||||
|
||||
# Si aucun code valide trouvé, on retourne false aussi.
|
||||
if( nb_val == 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le code promo '"+str(code_promo)+"' n'est pas valide ")
|
||||
return False, " - Le code promo '"+str(code_promo)+"' n'est pas valide "
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de recuperer le code promo"
|
||||
|
||||
|
|
|
@ -3006,4 +3006,15 @@ def RemoveAllNonAlphaNumeric(sentence):
|
|||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de RemoveAllNonAlphaNumeric "
|
||||
return False, " Impossible de RemoveAllNonAlphaNumeric "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction nettoie un dictionnaire python :
|
||||
Pour chaque mot, il va supprimer les espaces en debut et en fin de mot.
|
||||
"""
|
||||
def strip_dictionary(d):
|
||||
"""
|
||||
Strip all leading and trailing whitespace in dictionary keys and values.
|
||||
"""
|
||||
return dict((k.strip(), v.strip()) for k, v in d.items())
|
|
@ -514,7 +514,20 @@ def Schedule_Stripe_Payement(diction):
|
|||
|
||||
def create_subscription(diction):
|
||||
try:
|
||||
"""
|
||||
Controle des champs autorisés
|
||||
"""
|
||||
field_list = ['customerid', 'pack', 'qty', 'discount_code', 'discount_type','discount_valeur']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas. ")
|
||||
return False, " Les informations fournies sont incorrecte",
|
||||
|
||||
"""
|
||||
Controle des champs Obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['customerid', 'pack', 'qty']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
|
@ -534,13 +547,39 @@ def create_subscription(diction):
|
|||
if diction['pack']:
|
||||
pack = diction['pack']
|
||||
|
||||
discount_code = ""
|
||||
if ("discount_code" in diction.keys()):
|
||||
if diction['discount_code']:
|
||||
discount_code = diction['discount_code']
|
||||
|
||||
discount_type = ""
|
||||
if ("discount_type" in diction.keys()):
|
||||
if diction['discount_type']:
|
||||
discount_type = diction['discount_type']
|
||||
|
||||
discount_valeur = ""
|
||||
if ("discount_valeur" in diction.keys()):
|
||||
if diction['discount_valeur']:
|
||||
discount_valeur = diction['discount_valeur']
|
||||
|
||||
|
||||
price_id = ""
|
||||
if( str(pack).lower() == "gold"):
|
||||
if( str(pack).lower() == "gold" ):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if( str(discount_valeur) == "50" and str(discount_type) == "percent"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF
|
||||
elif( str(discount_valeur) == "100" and str(discount_type) == "percent"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF
|
||||
|
||||
|
||||
elif( str(pack).lower() == "standard"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if (str(discount_valeur) == "50" and str(discount_type) == "percent"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF
|
||||
elif (str(discount_valeur) == "100" and str(discount_type) == "percent"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF
|
||||
|
||||
elif (str(pack).lower() == "test"):
|
||||
price_id = MYSY_GV.STRIPE_TEST_PRICE_ID
|
||||
|
@ -781,6 +820,20 @@ par exemple lorqu'un partenaire change de nombre de formation sur le meme pack
|
|||
|
||||
def strip_update_subscription_qty(diction):
|
||||
try:
|
||||
"""
|
||||
Controle des champs autorisés
|
||||
"""
|
||||
field_list = ['token','qty', 'old_qty','discount_code', 'discount_type','discount_valeur']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas. ")
|
||||
return False, " Les informations fournies sont incorrecte",
|
||||
|
||||
"""
|
||||
Controle des champs Obligatoires
|
||||
"""
|
||||
|
||||
field_list_obligatoire = ['token','qty', 'old_qty']
|
||||
for val in field_list_obligatoire:
|
||||
|
@ -830,12 +883,28 @@ def strip_update_subscription_qty(diction):
|
|||
if local_ret_val['pack_service']:
|
||||
pack = local_ret_val['pack_service']
|
||||
|
||||
discount = ""
|
||||
if ("discount" in diction.keys()):
|
||||
if diction['discount']:
|
||||
discount = diction['discount']
|
||||
|
||||
price_id = ""
|
||||
if (str(pack).lower() == "gold"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if (str(discount) == "50"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF
|
||||
elif (str(discount) == "100"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF
|
||||
|
||||
|
||||
elif (str(pack).lower() == "standard"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if (str(discount) == "50"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF
|
||||
elif (str(discount) == "100"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF
|
||||
|
||||
elif (str(pack).lower() == "test"):
|
||||
price_id = MYSY_GV.STRIPE_TEST_PRICE_ID
|
||||
|
@ -898,6 +967,21 @@ les nouvelles conditions de son abonnement.
|
|||
def strip_update_subscription_plan(diction):
|
||||
try:
|
||||
|
||||
"""
|
||||
Controle des champs autorisés
|
||||
"""
|
||||
field_list = ['token','pack', 'qty', 'discount_code', 'discount_type','discount_valeur']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas. ")
|
||||
return False, " Les informations fournies sont incorrecte",
|
||||
|
||||
"""
|
||||
Controle des champs Obligatoires
|
||||
"""
|
||||
|
||||
field_list_obligatoire = ['token','pack', 'qty']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -953,12 +1037,28 @@ def strip_update_subscription_plan(diction):
|
|||
if local_ret_val['nb_formation']:
|
||||
qty = local_ret_val['nb_formation']
|
||||
"""
|
||||
|
||||
discount = ""
|
||||
if ("discount" in diction.keys()):
|
||||
if diction['discount']:
|
||||
discount = diction['discount']
|
||||
|
||||
price_id = ""
|
||||
if (str(pack).lower() == "gold"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if (str(discount) == "50"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_50_OFF
|
||||
elif (str(discount) == "100"):
|
||||
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID_100_OFF
|
||||
|
||||
elif (str(pack).lower() == "standard"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
|
||||
# On ecrase la valeur celle du discount si il existe une discount
|
||||
if (str(discount) == "50"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_50_OFF
|
||||
elif (str(discount) == "100"):
|
||||
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID_100_OFF
|
||||
|
||||
elif (str(pack).lower() == "test"):
|
||||
price_id = MYSY_GV.STRIPE_TEST_PRICE_ID
|
||||
|
|
Loading…
Reference in New Issue