wstkeys/services/orders_rokky.py

58 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sqlite3
from API.rok import get_order_content
import requests
# from send_mai import send_html_flow
conn = sqlite3.connect("./files/rokky.db")
cursor = conn.cursor()
def rok_orders():
conn = sqlite3.connect("./files/rokky.db")
cursor = conn.cursor()
cursor.execute("""
SELECT * FROM orders
WHERE key IS NULL OR key = ''
""")
rows = cursor.fetchall()
for row in rows:
order_id = row[12] # ✅ id (а не 12!)
id_i = row[1]
print(f"Обработка заказа {order_id}")
try:
# пример:
new_key = get_order_content(int(order_id))
cursor.execute("""
UPDATE orders
SET key = ?
WHERE id = ?
""", (new_key, order_id))
url = "https://wstkeys.top/newOrder"
# url = "http://0.0.0.0:5205/newOrder"
payload = {"orderId": int(order_id), "partnerSchemaId": 209}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
except Exception as a:
print(a)
print(response.status_code)
print(response.text)
conn.commit()
conn.close()