mirror of
https://git.auk.su/Dinect/bonus-import-tools.git
synced 2025-12-28 18:10:01 +00:00
Merge pull request 'bonus_payment' (#1) from bonus_payment into main
Reviewed-on: Dinect/bonus-import-tools#1
This commit is contained in:
2
app.py
2
app.py
@@ -67,7 +67,7 @@ def run_import():
|
|||||||
if file_extension == '.csv':
|
if file_extension == '.csv':
|
||||||
files.append(os.path.join(r, file))
|
files.append(os.path.join(r, file))
|
||||||
|
|
||||||
print('Scan .scv files: ', files)
|
print('Scan .csv files: ', files)
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
log_file_name = f'{f}-{time.strftime("%Y%m%d-%H%M%S", time.localtime())}.log'
|
log_file_name = f'{f}-{time.strftime("%Y%m%d-%H%M%S", time.localtime())}.log'
|
||||||
|
|||||||
2
csv/transaction-1.csv.20241227-175031.old
Normal file
2
csv/transaction-1.csv.20241227-175031.old
Normal 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
|
||||||
@@ -191,7 +191,7 @@ def bonuses_update(
|
|||||||
base_url = url + 'users/' + str(user_id) + '/purchases/'
|
base_url = url + 'users/' + str(user_id) + '/purchases/'
|
||||||
params = {
|
params = {
|
||||||
"doc_id": doc_id,
|
"doc_id": doc_id,
|
||||||
"bonus_amount": bonus_amount,
|
# "bonus_amount": bonus_amount,
|
||||||
"sum_total": summ_total,
|
"sum_total": summ_total,
|
||||||
"sum_discount": sum_discount,
|
"sum_discount": sum_discount,
|
||||||
"sum_with_discount ": sum_with_discount,
|
"sum_with_discount ": sum_with_discount,
|
||||||
@@ -200,6 +200,12 @@ def bonuses_update(
|
|||||||
"override": 'True'
|
"override": 'True'
|
||||||
# "date": '2024-08-03 12:53:07',
|
# "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)
|
r = requests.post(base_url, headers=headers, json=params)
|
||||||
if r.status_code == 201:
|
if r.status_code == 201:
|
||||||
return True, r.json()
|
return True, r.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user