def delete_item(order_id, lineitem_id, username): Orders.delete_from_basket(order_id, lineitem_id) session['basket_data'] = Item.basket_item_data( Customer.get_id_by_name(username)) session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) session['total'] = Sale.get_total(username) session['discount_total'] = Sale.get_discount_total(username) session['overthreshold_total'] = Sale.get_overthreshold_total(username) return redirect(url_for('basket'))
def checkout(username): sale = Sale(username) sale.checkout() session['basket_data'] = Item.basket_item_data( Customer.get_id_by_name(username)) session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) session['total'] = 0 session['discount_total'] = Sale.get_discount_total(username) session['overthreshold_total'] = Sale.get_overthreshold_total(username) return redirect(url_for('payment'))
def add_to_basket(): form = request.form username = form.get('username') item_id = form.get('item_id') if not username: return redirect(url_for('index_to_login')) sale = Sale(username) sale.add_item(item_id) session['basket_data'] = Item.basket_item_data( Customer.get_id_by_name(username)) session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) session['total'] = Sale.get_total(username) session['discount_total'] = Sale.get_discount_total(username) session['overthreshold_total'] = Sale.get_overthreshold_total(username) return redirect(url_for('customer_index'))
def alteruser(user_id): form = request.form username = form.get('username') password = form.get('password') nname = form.get('nickname') telephone = form.get('phone') address = form.get('address') print(user_id) if not Customer.is_repeated(username): Customer.alterusers(user_id, username, password, nname, telephone, address) session['name'] = username session['basket_data'] = Item.basket_item_data( Customer.get_id_by_name(username)) session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) session['customer_data'] = Customer.query() return redirect(url_for('customer_index')) else: flash('用户名重复') return redirect(url_for('customer_index'))
def login(): form = request.form username = form.get('name') password = form.get('pwd') role = form.get('select') if Customer.is_valid(username, password): session['name'] = username session['userId'] = Customer.get_id_by_name(username) if role == u'顾客': session['minute'] = Sale.getMinute(username) session['id'] = Customer.get_id_by_name(username) session['basket_data'] = Item.basket_item_data( Customer.get_id_by_name(username)) session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) session['total'] = Sale.get_total(username) session['discount_total'] = Sale.get_discount_total(username) session['overthreshold_total'] = Sale.get_overthreshold_total( username) return redirect(url_for('customer_index')) else: flash('账号或密码错误') return render_template('login.html') elif Seller.is_valid(username, password): session['name'] = username if role == u'卖家': return redirect(url_for('seller_index')) else: flash('账号或密码错误') return render_template('payment.html') elif Admin.is_valid(username, password): session['name'] = username if role == u'管理员': return redirect(url_for('admin_index')) else: flash('账号或密码错误') return render_template('orders.html') else: flash('该用户不存在,请重新输入') return render_template('login.html')
def order(username): session['order_data'] = Lineitem.get_singleorder_list( Customer.get_id_by_name(username)) return render_template('orders.html')
def seller_index(): session['item_data'] = Item.query(order=None) session['allorder_data'] = Lineitem.get_allorder_list() return render_template('sellerindex.html')
from tools import Customer, Item, Lineitem, Orders, Sale, Admin #print(Customer.alterusers(1,'wf',123,'小愤',123456,'上海')) # print(Customer.query()) # print(Item.query(order=None)) #print(Item.basket_item_data(1)) # print(Customer.is_valid('王帆',123)) # print(Customer.is_repeated('王帆')) # print(Customer.get_id_by_name("王帆") ) # print(Lineitem.get_item_data(2)) # print(Lineitem.get_item_id(9)) # print(Orders(1).get_max_order_list()) # Item.alteritem(1,'人间失物',23,'1.jpg',20,200,0.9) # # print(Sale.get_discount_total('王帆')) # print(Sale.getMinute('王帆')) #print(Admin.saveDB('admin1',123,'管理员',123456,'安徽') ) print(Lineitem.get_singleorder_list(1))