Для срабатывания триггера
This commit is contained in:
@@ -72,13 +72,6 @@ def button_click(request):
|
||||
print(session['waybill'])
|
||||
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'):
|
||||
# decreasing count in waybill
|
||||
|
||||
@@ -101,23 +94,25 @@ def transaction_order_model(user_id: int, current_date: date):
|
||||
with DBContextManager(db_config) as cursor:
|
||||
|
||||
data = dict(e_user_id=user_id, e_order_date=current_date, e_total=total)
|
||||
|
||||
_sql = sql_provider.get('create_order.sql', data)
|
||||
try:
|
||||
_sql = sql_provider.get('create_order.sql', data)
|
||||
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:
|
||||
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])
|
||||
clear()
|
||||
|
||||
1
App/Waybill/sql/good_price.sql
Normal file
1
App/Waybill/sql/good_price.sql
Normal file
@@ -0,0 +1 @@
|
||||
SELECT price FROM workpiece WHERE work_id = $e_prod_id
|
||||
@@ -1,2 +1 @@
|
||||
INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id,
|
||||
(SELECT price FROM workpiece WHERE work_id = $e_prod_id), $e_amount);
|
||||
INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id, $e_price, $e_amount);
|
||||
Reference in New Issue
Block a user