Для срабатывания триггера

This commit is contained in:
2024-12-04 18:05:08 +03:00
parent 7fdc20f3e5
commit e28ccaab14
3 changed files with 17 additions and 22 deletions

View File

@@ -72,13 +72,6 @@ def button_click(request):
print(session['waybill']) print(session['waybill'])
session.modified = True session.modified = True
# elif request.form.get('product_display_plus'):
# # increasing count in waybill
# amount = int(session['waybill'][str(product['work_id'])])
# session['waybill'][str(product['work_id'])] = str(amount + 1)
# session.modified = True
elif request.form.get('product_display_minus'): elif request.form.get('product_display_minus'):
# decreasing count in waybill # decreasing count in waybill
@@ -101,23 +94,25 @@ def transaction_order_model(user_id: int, current_date: date):
with DBContextManager(db_config) as cursor: with DBContextManager(db_config) as cursor:
data = dict(e_user_id=user_id, e_order_date=current_date, e_total=total) data = dict(e_user_id=user_id, e_order_date=current_date, e_total=total)
_sql = sql_provider.get('create_order.sql', data)
try: try:
_sql = sql_provider.get('create_order.sql', data)
cursor.execute(_sql) cursor.execute(_sql)
order_id = cursor.lastrowid
for key, value in waybill.items():
_sql = sql_provider.get('good_price.sql', dict(
e_prod_id = int(key)
))
price = select_list(db_config, _sql)[0][0]
_sql = sql_provider.get('insert_order_line.sql',
dict(e_order_id = order_id,
e_price = price,
e_prod_id = int(key),
e_amount = int(value)))
cursor.execute(_sql)
except: except:
return InfoRespronse((), error_message="Заказ не был создан", status=False) return InfoRespronse((), error_message="Заказ не был создан", status=False)
order_id = cursor.lastrowid
for key, value in waybill.items():
_sql = sql_provider.get('insert_order_line.sql',
dict(e_order_id = order_id,
e_prod_id = int(key),
e_amount = int(value)))
try:
cursor.execute(_sql)
except:
return InfoRespronse((), error_message="Заказ не был создан", status=False)
result = tuple([order_id]) result = tuple([order_id])
clear() clear()

View File

@@ -0,0 +1 @@
SELECT price FROM workpiece WHERE work_id = $e_prod_id

View File

@@ -1,2 +1 @@
INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id, INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id, $e_price, $e_amount);
(SELECT price FROM workpiece WHERE work_id = $e_prod_id), $e_amount);