This commit is contained in:
Alex55 2026-03-19 19:03:33 +02:00
parent 6f7bd73520
commit 7c028e5069
3 changed files with 53 additions and 10 deletions

View File

@ -165,17 +165,35 @@ def add_product():
def update_prices():
with open("./files/prices.json", "r") as f:
prices = json.load(f)
cursor = conn.cursor()
data = [(item["price"], item["sku"]) for item in prices]
data = []
for item in prices:
sku = item["sku"]
price = item.get("basePrice")
price_gg = item.get("baseSuggestedRetailPrice")
price_sales =item.get("discountPercentage")
is_sale = item.get("isSale")
data.append((
price,
price_gg,
price_sales,
is_sale,
sku
))
cursor.executemany("""
UPDATE products
SET price = ?
WHERE sku = ?
UPDATE products
SET
price = ?,
price_gg = ?,
price_sales = ?,
insale = ?
WHERE sku = ?
""", data)
conn.commit()
@ -183,4 +201,4 @@ def update_prices():
# decrypt_and_unpack("prices")
# decrypt_and_unpack("products")
# add_product()
# update_prices()
update_prices()

View File

@ -1,5 +1,6 @@
from flask import Blueprint, request, jsonify
import sqlite3
import json
# from services.rokky import ones
# from API.rok import get_order_content
import logging
@ -20,10 +21,34 @@ def index1():
params = request.args.to_dict()
logging.warn(f"newOrder: {params}")
# Просто выводим на экран (в ответ клиенту)
# парсим данные
sku = params.get("id_d")
product_id = params.get("id_i")
email = params.get("email")
price = params.get("amount")
return f"Received params: {params}", 200
# всё остальное сохраняем как JSON
content = json.dumps(params, ensure_ascii=False)
return "Hello GET"
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
try:
cursor.execute("""
INSERT INTO orders (sku, product_id, email, price, content)
VALUES (?, ?, ?, ?, ?)
""", (sku, product_id, email, price, content))
conn.commit()
except Exception as e:
conn.close()
return jsonify({"error": str(e)}), 500
conn.close()
return jsonify({"success": True}), 200
# return "Hello GET"
@main.route("/sales", methods=["POST", "GET"])
def index2():
@ -52,7 +77,7 @@ def new_order():
return jsonify({"status": "ok"}), 200
@main.route("/sku", methods=["POST"])
@main.route("/skuChanged", methods=["POST"])
def sku():
if not request.is_json:
return jsonify({"error": "Invalid content type"}), 400