DmitrMakeev
commited on
Commit
•
6d73e16
1
Parent(s):
8eff249
Update app.py
Browse files
app.py
CHANGED
@@ -1817,8 +1817,10 @@ def insert_data_ss(data):
|
|
1817 |
conn.commit()
|
1818 |
conn.close()
|
1819 |
|
1820 |
-
|
1821 |
@app.route('/order', methods=['GET'])
|
|
|
|
|
1822 |
def from_shop_st():
|
1823 |
try:
|
1824 |
api_sys_control = request.args.get('api_sys')
|
@@ -1826,18 +1828,23 @@ def from_shop_st():
|
|
1826 |
if api_sys_control != api_key_sys:
|
1827 |
return json.dumps({"error": "Unauthorized access"}), 403
|
1828 |
|
|
|
1829 |
email = request.args.get('email', '')
|
|
|
1830 |
order = request.args.get('order', '')
|
1831 |
status = request.args.get('status', '')
|
1832 |
del_flag = request.args.get('del', '')
|
1833 |
|
1834 |
-
if not email:
|
1835 |
-
return json.dumps({"error": "Email
|
|
|
|
|
|
|
1836 |
|
1837 |
conn = sqlite3.connect(DATABASE6)
|
1838 |
cursor = conn.cursor()
|
1839 |
|
1840 |
-
cursor.execute("SELECT shop_st FROM contacts WHERE email = ?", (email,))
|
1841 |
result = cursor.fetchone()
|
1842 |
|
1843 |
if result:
|
@@ -1854,9 +1861,9 @@ def from_shop_st():
|
|
1854 |
shop_st_json = json.dumps(shop_st_data)
|
1855 |
|
1856 |
if result:
|
1857 |
-
cursor.execute("UPDATE contacts SET shop_st = ? WHERE email = ?", (shop_st_json, email))
|
1858 |
else:
|
1859 |
-
cursor.execute("INSERT INTO contacts (email, shop_st) VALUES (?, ?)", (email, shop_st_json))
|
1860 |
|
1861 |
conn.commit()
|
1862 |
conn.close()
|
@@ -1919,6 +1926,7 @@ def from_shop_st():
|
|
1919 |
|
1920 |
|
1921 |
|
|
|
1922 |
|
1923 |
|
1924 |
@app.route('/gc_in', methods=['GET'])
|
|
|
1817 |
conn.commit()
|
1818 |
conn.close()
|
1819 |
|
1820 |
+
DATABASE6 = 'data_gc.db'
|
1821 |
@app.route('/order', methods=['GET'])
|
1822 |
+
|
1823 |
+
|
1824 |
def from_shop_st():
|
1825 |
try:
|
1826 |
api_sys_control = request.args.get('api_sys')
|
|
|
1828 |
if api_sys_control != api_key_sys:
|
1829 |
return json.dumps({"error": "Unauthorized access"}), 403
|
1830 |
|
1831 |
+
name = request.args.get('name', '')
|
1832 |
email = request.args.get('email', '')
|
1833 |
+
phone = request.args.get('phone', '').lstrip('+')
|
1834 |
order = request.args.get('order', '')
|
1835 |
status = request.args.get('status', '')
|
1836 |
del_flag = request.args.get('del', '')
|
1837 |
|
1838 |
+
if not email or not phone:
|
1839 |
+
return json.dumps({"error": "Email and phone are required"}), 400
|
1840 |
+
|
1841 |
+
# Очистка номера телефона
|
1842 |
+
phone = clean_phone_number_ss(phone)
|
1843 |
|
1844 |
conn = sqlite3.connect(DATABASE6)
|
1845 |
cursor = conn.cursor()
|
1846 |
|
1847 |
+
cursor.execute("SELECT shop_st FROM contacts WHERE email = ? OR phone = ?", (email, phone))
|
1848 |
result = cursor.fetchone()
|
1849 |
|
1850 |
if result:
|
|
|
1861 |
shop_st_json = json.dumps(shop_st_data)
|
1862 |
|
1863 |
if result:
|
1864 |
+
cursor.execute("UPDATE contacts SET name = ?, phone = ?, email = ?, shop_st = ? WHERE email = ? OR phone = ?", (name, phone, email, shop_st_json, email, phone))
|
1865 |
else:
|
1866 |
+
cursor.execute("INSERT INTO contacts (name, phone, email, shop_st) VALUES (?, ?, ?, ?)", (name, phone, email, shop_st_json))
|
1867 |
|
1868 |
conn.commit()
|
1869 |
conn.close()
|
|
|
1926 |
|
1927 |
|
1928 |
|
1929 |
+
|
1930 |
|
1931 |
|
1932 |
@app.route('/gc_in', methods=['GET'])
|