1232w
This commit is contained in:
parent
5c0c0e087e
commit
5adbba5b24
Binary file not shown.
|
|
@ -1,10 +1,12 @@
|
||||||
from flask import Blueprint, request, jsonify
|
from flask import Blueprint, request, jsonify
|
||||||
|
import sqlite3
|
||||||
# from services.rokky import ones
|
# from services.rokky import ones
|
||||||
# from API.rok import get_order_content
|
# from API.rok import get_order_content
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
main = Blueprint("main", __name__)
|
main = Blueprint("main", __name__)
|
||||||
|
DB_PATH = "./files/rokky.db"
|
||||||
|
|
||||||
@main.route("/")
|
@main.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
|
@ -47,4 +49,31 @@ def new_order():
|
||||||
# logging.warn(get_order_content(order_id))
|
# logging.warn(get_order_content(order_id))
|
||||||
logging.warn(f"newOrder: {order_id}")
|
logging.warn(f"newOrder: {order_id}")
|
||||||
|
|
||||||
return jsonify({"status": "ok"}), 200
|
return jsonify({"status": "ok"}), 200
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/product")
|
||||||
|
def product_update():
|
||||||
|
# получаем параметры
|
||||||
|
sku = request.args.get("rokky")
|
||||||
|
ggsale = request.args.get("ggsale")
|
||||||
|
|
||||||
|
if not sku or not ggsale:
|
||||||
|
return jsonify({"error": "Missing parameters"}), 400
|
||||||
|
|
||||||
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# проверяем есть ли продукт с таким SKU
|
||||||
|
cursor.execute("SELECT id FROM products WHERE sku=?", (sku,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
if not row:
|
||||||
|
conn.close()
|
||||||
|
return jsonify({"error": "SKU not found"}), 404
|
||||||
|
|
||||||
|
# обновляем поле gg
|
||||||
|
cursor.execute("UPDATE products SET gg=? WHERE sku=?", (ggsale, sku))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
return jsonify({"success": True, "sku": sku, "ggsale": ggsale})
|
||||||
|
|
@ -19,7 +19,8 @@ CREATE TABLE IF NOT EXISTS products (
|
||||||
price_gg TEXT,
|
price_gg TEXT,
|
||||||
price_sales TEXT,
|
price_sales TEXT,
|
||||||
price_salesgg TEXT,
|
price_salesgg TEXT,
|
||||||
gg TEXT
|
gg TEXT,
|
||||||
|
insale TEXT
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue