Merge pull request 'bonus_payment' (#1) from bonus_payment into main

Reviewed-on: Dinect/bonus-import-tools#1
This commit is contained in:
2025-01-21 06:08:17 +00:00
3 changed files with 10 additions and 2 deletions

2
app.py
View File

@@ -67,7 +67,7 @@ def run_import():
if file_extension == '.csv':
files.append(os.path.join(r, file))
print('Scan .scv files: ', files)
print('Scan .csv files: ', files)
for f in files:
log_file_name = f'{f}-{time.strftime("%Y%m%d-%H%M%S", time.localtime())}.log'

View File

@@ -0,0 +1,2 @@
user_id, card, phone, summ_total, summ_discount, sum_with_discount, bonus_amount, transaction_date, transaction_time, doc_id
1003, ,+79609238010,0.0,0.0,0.0,-121,2002-03-11,21:05:36,чек-100

View File

@@ -191,7 +191,7 @@ def bonuses_update(
base_url = url + 'users/' + str(user_id) + '/purchases/'
params = {
"doc_id": doc_id,
"bonus_amount": bonus_amount,
# "bonus_amount": bonus_amount,
"sum_total": summ_total,
"sum_discount": sum_discount,
"sum_with_discount ": sum_with_discount,
@@ -200,6 +200,12 @@ def bonuses_update(
"override": 'True'
# "date": '2024-08-03 12:53:07',
}
bonus_amount_numeric = float(bonus_amount)
if bonus_amount_numeric >= 0:
params["bonus_amount"] = bonus_amount
else:
params["bonus_payment"] = bonus_amount[1:]
r = requests.post(base_url, headers=headers, json=params)
if r.status_code == 201:
return True, r.json()