diff --git a/README.md b/README.md deleted file mode 100644 index 0a31f73..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ - python3.9 flask - diff --git a/doc/“及食”已到软件设计文档.docx b/doc/“及食”已到软件设计文档.docx deleted file mode 100644 index b483038..0000000 Binary files a/doc/“及食”已到软件设计文档.docx and /dev/null differ diff --git a/doc/“及食”已到软件需求规格说明书.docx b/doc/“及食”已到软件需求规格说明书.docx deleted file mode 100644 index 6f2be5f..0000000 Binary files a/doc/“及食”已到软件需求规格说明书.docx and /dev/null differ diff --git a/doc/校园“及食”已到.docx b/doc/校园“及食”已到.docx deleted file mode 100644 index deae3ae..0000000 Binary files a/doc/校园“及食”已到.docx and /dev/null differ diff --git a/src/.idea/.gitignore b/src/.idea/.gitignore deleted file mode 100644 index 359bb53..0000000 --- a/src/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml diff --git a/src/.idea/.name b/src/.idea/.name deleted file mode 100644 index aa15e3e..0000000 --- a/src/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -app.py \ No newline at end of file diff --git a/src/.idea/dbDesign.iml b/src/.idea/dbDesign.iml deleted file mode 100644 index 9f42b41..0000000 --- a/src/.idea/dbDesign.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/.idea/dbnavigator.xml b/src/.idea/dbnavigator.xml deleted file mode 100644 index 2b5baf2..0000000 --- a/src/.idea/dbnavigator.xml +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
\ No newline at end of file diff --git a/src/.idea/inspectionProfiles/Project_Default.xml b/src/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 06bb031..0000000 --- a/src/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml deleted file mode 100644 index 9b68eb2..0000000 --- a/src/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml deleted file mode 100644 index 477dcf4..0000000 --- a/src/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/.idea/vcs.xml b/src/.idea/vcs.xml deleted file mode 100644 index 830a534..0000000 --- a/src/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/__pycache__/app.cpython-36.pyc b/src/__pycache__/app.cpython-36.pyc deleted file mode 100644 index d96c4fd..0000000 Binary files a/src/__pycache__/app.cpython-36.pyc and /dev/null differ diff --git a/src/app.py b/src/app.py deleted file mode 100644 index 7a04e8f..0000000 --- a/src/app.py +++ /dev/null @@ -1,2931 +0,0 @@ -# -*- coding=utf-8 -*- -import importlib -import sys -from flask import Flask -importlib.reload(sys) -app = Flask(__name__) # -*- coding=utf-8 -*- -from flask import Flask, render_template, request -from werkzeug.utils import secure_filename -import MySQLdb -import sys -import importlib - -importlib.reload(sys) - -app = Flask(__name__) - -# 全局变量 -username = "TJU" -# TODO: username变量的赋值 方法1:全局变量实现,随登录进行修改 方法2:给每个页面传递username -userRole = "CUSTOMER" -notFinishedNum = 0 -# 上传文件要储存的目录 -UPLOAD_FOLDER = '/static/images/' -# 允许上传的文件扩展名的集合 -ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg']) - - -def allowed_file(filename): - return '.' in filename and \ - filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS - - -@app.route('/') -@app.route('/index') -# 首页 -def indexpage(): - return render_template('index.html') - - -# 注册 -@app.route('/register', methods=['GET', 'POST']) -def registerPage(): - global username - global userRole - msg = "" - if request.method == 'GET': - return render_template('Register.html') - if request.method == 'POST': - username = request.form.get('username') - password = request.form.get('password') - phone = request.form.get('phone') - addr = request.form.get('addr') - userRole = request.form.get('userRole') - print(userRole) - print(username) - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - if userRole == 'RESTAURANT': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from RESTAURANT where username = '{}' ".format(username) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已经存在该商家 - if num == 1: - print("失败!商家已注册!") - msg = "fail1" - else: - sql2 = "insert into RESTAURANT (username, password, address, phone) values ('{}', '{}', '{}', '{}') ".format( - username, password, addr, phone) - - try: - cursor.execute(sql2) - db.commit() - print("商家注册成功") - msg = "done1" - except ValueError as e: - print("--->", e) - print("注册出错,失败") - msg = "fail1" - return render_template('Register.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'CUSTOMER': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from CUSTOMER where username = '{}'".format(username) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已存在该用户 - if num == 1: - print("用户已注册!请直接登录。") - msg = "fail2" - else: - sql2 = "insert into CUSTOMER (username, password, address, phone) values ('{}', '{}', '{}', '{}') ".format( - username, password, addr, phone) - - try: - cursor.execute(sql2) - db.commit() - print("商家注册成功") - msg = "done2" - except ValueError as e: - print("--->", e) - print("注册出错,失败") - msg = "fail2" - return render_template('Register.html', messages=msg, username=username, userRole=userRole) - - -# 登录 -@app.route('/logIn', methods=['GET', 'POST']) -def logInPage(): - global username - global userRole - msg = "" - if request.method == 'GET': - return render_template('logIn.html') - if request.method == 'POST': - username = request.form.get('username') - password = request.form.get('password') - userRole = request.form.get('userRole') - print(userRole) - print(username) - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - if userRole == 'ADMIN': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from ADMIN where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该管理员且密码正确 - if num == 1: - print("登录成功!欢迎管理员!") - msg = "done1" - else: - print("您没有管理员权限或登录信息出错。") - msg = "fail1" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'RESTAURANT': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from RESTAURANT where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该商家且密码正确 - if num == 1: - print("登录成功!欢迎商家用户!") - msg = "done2" - else: - print("您没有商家用户权限或登录信息出错。") - msg = "fail2" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'CUSTOMER': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from CUSTOMER where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该用户且密码正确 - if num == 1: - print("登录成功!欢迎用户!") - msg = "done3" - else: - print("您没有用户权限,未注册或登录信息出错。") - msg = "fail3" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - -# 管理员的店铺列表页面 -@app.route('/adminRestList', methods=['GET', 'POST']) -def adminRestListPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM RESTAURANT" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('adminRestList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminRestList.html', username=username, messages=msg) - elif request.form["action"] == "移除": - RESTName = request.form.get('RESTName') - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # TODO: 点击移除后显示移除成功,但数据库里没有删掉 - # 删除dishes的 - sql1 = "DELETE FROM DISHES WHERE restaurant = '{}'".format(RESTName) - cursor.execute(sql1) - db.commit() - # 删除订单表里的 - sql2 = "DELETE FROM ORDER_COMMENT WHERE restaurant = '{}'".format(RESTName) - cursor.execute(sql2) - db.commit() - # 删除shoppingCart的 - - # 删除restaurant的 - sql4 = "DELETE FROM RESTAURANT WHERE username = '{}'".format(RESTName) - cursor.execute(sql4) - db.commit() - print(sql4) - - msg = "delete" - print(msg) - - return render_template('adminRestList.html', username=username, messages=msg) - - -# 管理员查看评论列表 -@app.route('/adminCommentList', methods=['GET', 'POST']) -def adminCommentPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE isFinished = 1 and text <> ''" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('adminCommentList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminCommentList.html', username=username, messages=msg) - elif request.form["action"] == "按评分升序排列": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE isFinished = 1 AND text is not null Order BY c_rank" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('adminCommentList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminCommentList.html', username=username, messages=msg) - - -# 用户登录后显示商家列表 -@app.route('/UserRestList', methods=['GET', 'POST']) -def UserRestListPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appdb", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM RESTAURANT" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('UserRestList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('UserRestList.html', username=username, messages=msg) - - -# 选择商家进入菜单列表 -@app.route('/Menu', methods=['GET', 'POST']) -def menu(): - msg = "" - global restaurant - if request.form["action"] == "进入本店": - restaurant = request.form['restaurant'] - print(restaurant) - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM DISHES WHERE restaurant = '%s'" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "特色菜": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' AND isSpecialty = 1" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "按销量排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY sales DESC" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY price DESC" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 查看商家评论 -@app.route('/ResComment', methods=['GET', 'POST']) -def resComment(): - msg = "" - global restaurant - if request.form["action"] == "查看评价": - restaurant = request.form['restaurant'] - print(restaurant) - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 1 AND text <> '' " % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('ResComment.html', username=username, RESTAURANT=restaurant, result=res, - messages=msg) - else: - print("NULL") - msg = "none" - return render_template('ResComment.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 商家查看评论 -@app.route('/ResCommentList', methods=['GET', 'POST']) -def ResCommentList(): - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - restaurant = username - print(restaurant) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 1 AND text <> '' " % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('ResCommentList.html', username=username, RESTAURANT=restaurant, result=res, - messages=msg) - else: - print("NULL") - msg = "none" - return render_template('ResCommentList.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 购物车 -@app.route('/myOrder', methods=['GET', 'POST']) -def shoppingCartPage(): - if request.method == 'GET': - print("myOrder-->GET") - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM SHOPPINGCART" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('myOrder.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('myOrder.html', username=username, messages=msg) - elif request.form["action"] == "加入购物车": - print("myOrder-->加入购物车") - restuarant = request.form['restaurant'] - dishname = request.form['dishname'] - price = request.form['price'] - img_res = request.form['img_res'] - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "insert into SHOPPINGCART values ('{}','{}','{}','{}','{}') ".format(username, restuarant, dishname, - price, img_res) - cursor.execute(sql1) - res1 = cursor.fetchall() - print(len(res1)) - sql = "SELECT * FROM SHOPPINGCART" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('myOrder.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('myOrder.html', username=username, messages=msg) - - elif request.form["action"] == "结算": - print("结算啦") - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - restuarant = request.form['restaurant'] - print(restaurant) - dishname = request.form['dishname'] - price = request.form['price'] - img_res = request.form['img_res'] - mode = request.form['mode'] - sql2 = "insert into ORDER_COMMENT values ({},'{}','{}', '{}','{}','{}','{}', {},'{}','{}','{}','{}','{}',{}) ".format( - 0, username, dishname, restuarant, mode, '0', '0', 0, img_res, '1', '1', '1', '1', price) - cursor.execute(sql2) - db.commit() - if mode == 1: - print("堂食") - - else: - print("外送") - return render_template('index.html') - else: - print("") - return render_template('index.html') - - -# 个人中心页面 -@app.route('/personal') -def personalPage(): - return render_template('personal.html') - - -# 修改个人信息页面 -@app.route('/ModifyPersonalInfo', methods=['GET', 'POST']) -def ModifyPersonalInfo(): - msg = "" - if request.method == 'GET': - return render_template('ModifyPersonalInfo.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - address = request.form['address'] - phonenum = request.form['phonenum'] - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET address = '{}', phone = '{}' where username = '{}'".format(userRole, address, phonenum, - username) - try: - cursor.execute(sql) - db.commit() - # print("修改个人信息成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改个人信息失败") - msg = "fail" - return render_template('ModifyPersonalInfo.html', messages=msg, username=username) - - -# 修改密码页面 -@app.route('/ModifyPassword', methods=['GET', 'POST']) -def ModifyPassword(): - msg = "" - if request.method == 'GET': - return render_template('ModifyPassword.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - psw1 = request.form['psw1'] - psw2 = request.form['psw2'] - # 两次输入密码是否相同 - if psw1 == psw2: - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET password = '{}' where username = '{}'".format(userRole, psw1, username) - try: - cursor.execute(sql) - db.commit() - # print("修改密码成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改密码失败") - msg = "fail" - return render_template('ModifyPassword.html', messages=msg, username=username) - else: - msg = "not equal" - return render_template('ModifyPassword.html', messages=msg, username=username) - -#用户订单界面 -@app.route('/OrderPage', methods=['GET', 'POST']) -def OrderPage(): - msg = "" - global notFinishedNum - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0" % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s'" % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "确认收货": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - print("用户要确认收货啦") - orderID = request.form['orderID'] - print(orderID) - sql1 = "Update ORDER_COMMENT SET isFinished = 1, text = '' WHERE orderID = '%s' " % orderID - print(sql1) - cursor.execute(sql1) - db.commit() - - sql2 = "select * from ORDER_COMMENT WHERE orderID = '%s' " % orderID - cursor.execute(sql2) - res1 = cursor.fetchone() - restaurant = res1[1] - dishname = res1[2] - print("{} {} 销量+1".format(dishname, restaurant)) - - sql = "Update DISHES SET sales = sales+1 WHERE dishname = '{}' AND restaurant = '{}'".format(dishname, - restaurant) - print(sql) - cursor.execute(sql) - res = cursor.fetchall() - print(res) - msg = "UpdateSucceed" - return render_template('OrderPage.html', username=username, messages=msg) - - else: - return render_template('OrderPage.html', username=username, messages=msg) - -#用户评价界面 -@app.route('/MyComments', methods=['GET', 'POST']) -def MyCommentsPage(): - msg = "" - global notFinishedNum - - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成及未评论订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' and isFinished = 1 and text <> '' " % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text is not null Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text is not null Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "待评价订单": - # 未评价订单跳转到写评论中 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print("MyCommentsPage - 未评价订单: {}".format(len(res))) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("MyCommentsPage - 待评价订单 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=len(res)) - - else: - return render_template('MyComments.html', username=username, messages=msg) - - -@app.route('/WriteComments', methods=['GET', 'POST']) -def WriteCommentsPage(): - msg = "" - if request.method == 'GET': - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - # presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0" % username - # cursor.execute(presql) - # res1 = cursor.fetchall() - # notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg) - else: - print("WriteCommentsPage - GET - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg) - elif request.form["action"] == "按交易时间排序": - # TODO: 排序之后显示的是空的,不显示的问题没有解决 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - print(username) - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg) - else: - print("WriteCommentsPage - 按交易时间排序 -NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("WriteCommentsPage - 按价格排序 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("WriteCommentsPage - 未完成订单 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - else: - return render_template('WriteComments.html', username=username, messages=msg) - - -@app.route('/CommentForm', methods=['GET', 'POST']) -def CommentFormPage(): - msg = "" - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "写评论": - orderID = request.form['orderID'] - print(orderID) - msg = "WriteRequest" - print(msg) - return render_template('CommentForm.html', username=username, orderID=orderID, messages=msg) - elif request.form["action"] == "提交评论": - print("提交评论!") - orderID = request.form.get('orderID') - c_rank = request.form.get('rank') - text = request.form.get('text') - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update ORDER_COMMENT SET text = '{}', c_rank = {} where orderID = '{}'".format(text, c_rank, orderID) - print(sql) - try: - cursor.execute(sql) - db.commit() - print("用户评论成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("用户评论失败") - msg = "fail" - return render_template('CommentForm.html', messages=msg, username=username) - - -# 商家查看菜品信息 -@app.route('/MerchantMenu', methods=['GET', 'POST']) -def MerchantMenu(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM DISHES WHERE restaurant = '%s'" % username - - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - if request.method == 'POST': - if request.form["action"] == "删除该菜品": - dishname = request.form.get('dishname') - rest = request.form.get('restaurant') - print(rest) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "DELETE FROM dishes where dishname = '{}' and restaurant = '{}'".format(dishname, rest) - print(sql) - try: - cursor.execute(sql) - db.commit() - print("菜品删除成功") - dmsg = "done" - except ValueError as e: - print("--->", e) - print("菜品删除失败") - dmsg = "fail" - return render_template('MerchantMenu.html', dishname=dishname, rest=rest, dmessages=dmsg) - elif request.form["action"] == "按销量排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY sales DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY price DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - - -# 商家修改菜品信息 -@app.route('/MenuModify', methods=['GET', 'POST']) -def MenuModify(): - msg = "" - - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "修改菜品信息": - dishname = request.form['dishname'] # 传递过去菜品名 - rest = request.form['restaurant'] # 传递过去商家名 - dishinfo = request.form['dishinfo'] - nutriention = request.form.get('nutriention') - price = request.form.get('price') - isSpecialty = request.form.get('isSpecialty') - # imagesrc = request.form['imagesrc'] - print(dishname) - print(isSpecialty) - print(type(isSpecialty)) - - return render_template('MenuModify.html', dishname=dishname, rest=rest, dishinfo=dishinfo, - nutriention=nutriention, price=price, username=username, messages=msg, - isSpecialty=isSpecialty) - elif request.form["action"] == "提交修改": - - dishname = request.form.get('dishname') - rest = request.form.get('rest') - - dishinfo = request.form['dishinfo'] - nutriention = request.form.get('nutriention') - price = request.form.get('price') - isSpecialty = int(request.form.get('isSpecialty')) - f = request.files['imagesrc'] - filename = '' - - if f != '' and allowed_file(f.filename): - filename = secure_filename(f.filename) - - if filename != '': - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - - print(isSpecialty) - print(type(isSpecialty)) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - if filename == '': - sql = "Update dishes SET dishinfo = '{}', nutriention = '{}', price = {} , isSpecialty = {} where dishname = '{}' and restaurant = '{}'".format( - dishinfo, nutriention, price, isSpecialty, dishname, rest) - else: - sql = "Update dishes SET dishinfo = '{}', nutriention = '{}', price = {} ,imagesrc = '{}', isSpecialty = {} where dishname = '{}' and restaurant = '{}'".format( - dishinfo, nutriention, price, imgsrc, isSpecialty, dishname, rest) - print(sql) - - try: - cursor.execute(sql) - db.commit() - print("菜品信息修改成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("菜品信息修改失败失败") - msg = "fail" - return render_template('MenuModify.html', dishname=dishname, rest=rest, username=username, messages=msg) - - -@app.route('/MenuAdd', methods=['GET', 'POST']) -def MenuAdd(): - msg = "" - rest = "" - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "增加菜品": - rest = request.form['restaurant'] # 传递过去商家名 - return render_template('MenuAdd.html', rest=rest) - elif request.form["action"] == "确认增加": - dishname = request.form.get('dishname') - rest = request.form.get('rest') - dishinfo = request.form.get('dishinfo') - nutriention = request.form.get('nutriention') - price = request.form.get('price') - f = request.files['imagesrc'] - print(f) - isSpecialty = int(request.form.get('isSpecialty')) - if f and allowed_file(f.filename): - filename = secure_filename(f.filename) - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from DISHES where dishname = '{}' ".format(dishname) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已经存在该商家 - if num == 1: - print("失败!该菜品已经添加过!") - msg = "fail1" - else: - sql2 = "insert into DISHES values ('{}', '{}','{}', '{}',{},{},'{}', {}) ".format(dishname, rest, dishinfo, - nutriention, price,0, imgsrc, - isSpecialty) - print(sql2) - try: - cursor.execute(sql2) - db.commit() - print("菜品添加成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("菜品添加失败") - msg = "fail" - return render_template('MenuAdd.html', messages=msg, username=username) - - -@app.route('/MerchantIndex') -def Merchantindexpage(): - return render_template('MerchantIndex.html') - - -# 个人中心页面 -@app.route('/MerchantPersonal') -def MpersonalPage(): - return render_template('MerchantPersonal.html') - - -# 修改个人信息页面 -@app.route('/MerchantModifyPerInfo', methods=['GET', 'POST']) -def MerchantModifyPerInfo(): - msg = "" - if request.method == 'GET': - return render_template('MerchantModifyPerInfo.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - address = request.form['address'] - phonenum = request.form['phonenum'] - - f = request.files['imagesrc'] - filename = '' - - if f != '' and allowed_file(f.filename): - filename = secure_filename(f.filename) - - if filename != '': - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - if filename == '': - sql = "Update {} SET address = '{}', phone = '{}' where username = '{}'".format(userRole, address, phonenum, - username) - else: - sql = "Update {} SET address = '{}', phone = '{}',imageRes = '{}' where username = '{}'".format(userRole, - address, - phonenum, - imgsrc, - username) - try: - cursor.execute(sql) - db.commit() - # print("修改个人信息成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改个人信息失败") - msg = "fail" - return render_template('MerchantModifyPerInfo.html', messages=msg, username=username) - - -# 修改密码页面 -@app.route('/MerchantModifyPwd', methods=['GET', 'POST']) -def MerModifyPassword(): - msg = "" - if request.method == 'GET': - return render_template('MerchantModifyPwd.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - psw1 = request.form['psw1'] - psw2 = request.form['psw2'] - # 两次输入密码是否相同 - if psw1 == psw2: - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET password = '{}' where username = '{}'".format(userRole, psw1, username) - try: - cursor.execute(sql) - db.commit() - # print("修改密码成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改密码失败") - msg = "fail" - return render_template('MerchantModifyPwd.html', messages=msg, username=username) - else: - msg = "not equal" - return render_template('MerchantModifyPwd.html', messages=msg, username=username) - - -# 商家查看订单 -@app.route('/MerchantOrderPage', methods=['GET', 'POST']) -def MerchantOrderPage(): - msg = "" - global notFinishedNum - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 0" % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s'" % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - else: - return render_template('MerchantOrderPage.html', username=username, messages=msg) - - -if __name__ == '__main__': - app.run(host='localhost', port='9090') - -# 全局变量 -username = "TJU" -# TODO: username变量的赋值 方法1:全局变量实现,随登录进行修改 方法2:给每个页面传递username -userRole = "CUSTOMER" -notFinishedNum = 0 -# 上传文件要储存的目录 -UPLOAD_FOLDER = '/static/images/' -# 允许上传的文件扩展名的集合 -ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg']) - - -def allowed_file(filename): - return '.' in filename and \ - filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS - - -@app.route('/') -@app.route('/index') -# 首页 -def indexpage(): - return render_template('index.html') - - -# 注册 -@app.route('/register', methods=['GET', 'POST']) -def registerPage(): - global username - global userRole - msg = "" - if request.method == 'GET': - return render_template('Register.html') - if request.method == 'POST': - username = request.form.get('username') - password = request.form.get('password') - phone = request.form.get('phone') - addr = request.form.get('addr') - userRole = request.form.get('userRole') - print(userRole) - print(username) - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - if userRole == 'RESTAURANT': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from RESTAURANT where username = '{}' ".format(username) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已经存在该商家 - if num == 1: - print("失败!商家已注册!") - msg = "fail1" - else: - sql2 = "insert into RESTAURANT (username, password, address, phone) values ('{}', '{}', '{}', '{}') ".format( - username, password, addr, phone) - - try: - cursor.execute(sql2) - db.commit() - print("商家注册成功") - msg = "done1" - except ValueError as e: - print("--->", e) - print("注册出错,失败") - msg = "fail1" - return render_template('Register.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'CUSTOMER': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from CUSTOMER where username = '{}'".format(username) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已存在该用户 - if num == 1: - print("用户已注册!请直接登录。") - msg = "fail2" - else: - sql2 = "insert into CUSTOMER (username, password, address, phone) values ('{}', '{}', '{}', '{}') ".format( - username, password, addr, phone) - - try: - cursor.execute(sql2) - db.commit() - print("商家注册成功") - msg = "done2" - except ValueError as e: - print("--->", e) - print("注册出错,失败") - msg = "fail2" - return render_template('Register.html', messages=msg, username=username, userRole=userRole) - - -# 登录 -@app.route('/logIn', methods=['GET', 'POST']) -def logInPage(): - global username - global userRole - msg = "" - if request.method == 'GET': - return render_template('logIn.html') - if request.method == 'POST': - username = request.form.get('username') - password = request.form.get('password') - userRole = request.form.get('userRole') - print(userRole) - print(username) - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - if userRole == 'ADMIN': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from ADMIN where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该管理员且密码正确 - if num == 1: - print("登录成功!欢迎管理员!") - msg = "done1" - else: - print("您没有管理员权限或登录信息出错。") - msg = "fail1" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'RESTAURANT': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from RESTAURANT where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该商家且密码正确 - if num == 1: - print("登录成功!欢迎商家用户!") - msg = "done2" - else: - print("您没有商家用户权限或登录信息出错。") - msg = "fail2" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - elif userRole == 'CUSTOMER': - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "SELECT * from CUSTOMER where username = '{}' and password='{}'".format(username, password) - cursor.execute(sql) - db.commit() - res = cursor.fetchall() - num = 0 - for row in res: - num = num + 1 - # 如果存在该用户且密码正确 - if num == 1: - print("登录成功!欢迎用户!") - msg = "done3" - else: - print("您没有用户权限,未注册或登录信息出错。") - msg = "fail3" - return render_template('logIn.html', messages=msg, username=username, userRole=userRole) - - -# 管理员的店铺列表页面 -@app.route('/adminRestList', methods=['GET', 'POST']) -def adminRestListPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM RESTAURANT" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('adminRestList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminRestList.html', username=username, messages=msg) - elif request.form["action"] == "移除": - RESTName = request.form.get('RESTName') - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # TODO: 点击移除后显示移除成功,但数据库里没有删掉 - # 删除dishes的 - sql1 = "DELETE FROM DISHES WHERE restaurant = '{}'".format(RESTName) - cursor.execute(sql1) - db.commit() - # 删除订单表里的 - sql2 = "DELETE FROM ORDER_COMMENT WHERE restaurant = '{}'".format(RESTName) - cursor.execute(sql2) - db.commit() - # 删除shoppingCart的 - sql3 = "DELETE FROM shoppingCart WHERE restaurant = '{}'".format(RESTName) - cursor.execute(sql3) - db.commit() - # 删除restaurant的 - sql4 = "DELETE FROM RESTAURANT WHERE username = '{}'".format(RESTName) - cursor.execute(sql4) - db.commit() - print(sql4) - - msg = "delete" - print(msg) - - return render_template('adminRestList.html', username=username, messages=msg) - - -# 管理员查看评论列表 -@app.route('/adminCommentList', methods=['GET', 'POST']) -def adminCommentPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE isFinished = 1 and text <> ''" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('adminCommentList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminCommentList.html', username=username, messages=msg) - elif request.form["action"] == "按评分升序排列": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE isFinished = 1 AND text is not null Order BY c_rank" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('adminCommentList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('adminCommentList.html', username=username, messages=msg) - - -# 用户登录后显示商家列表 -@app.route('/UserRestList', methods=['GET', 'POST']) -def UserRestListPage(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appdb", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - # 查询 - sql = "SELECT * FROM RESTAURANT" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - return render_template('UserRestList.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('UserRestList.html', username=username, messages=msg) - - -# 选择商家进入菜单列表 -@app.route('/Menu', methods=['GET', 'POST']) -def menu(): - msg = "" - global restaurant - if request.form["action"] == "进入本店": - restaurant = request.form['restaurant'] - print(restaurant) - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM DISHES WHERE restaurant = '%s'" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "特色菜": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' AND isSpecialty = 1" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "按销量排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY sales DESC" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY price DESC" % restaurant - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('Menu.html', username=username, RESTAURANT=restaurant, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('Menu.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 查看商家评论 -@app.route('/ResComment', methods=['GET', 'POST']) -def resComment(): - msg = "" - global restaurant - if request.form["action"] == "查看评价": - restaurant = request.form['restaurant'] - print(restaurant) - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 1 AND text <> '' " % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('ResComment.html', username=username, RESTAURANT=restaurant, result=res, - messages=msg) - else: - print("NULL") - msg = "none" - return render_template('ResComment.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 商家查看评论 -@app.route('/ResCommentList', methods=['GET', 'POST']) -def ResCommentList(): - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - restaurant = username - print(restaurant) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 1 AND text <> '' " % restaurant - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('ResCommentList.html', username=username, RESTAURANT=restaurant, result=res, - messages=msg) - else: - print("NULL") - msg = "none" - return render_template('ResCommentList.html', username=username, RESTAURANT=restaurant, messages=msg) - - -# 购物车 -@app.route('/myOrder', methods=['GET', 'POST']) -def shoppingCartPage(): - if request.method == 'GET': - print("myOrder-->GET") - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM SHOPPINGCART" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('myOrder.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('myOrder.html', username=username, messages=msg) - elif request.form["action"] == "加入购物车": - print("myOrder-->加入购物车") - restuarant = request.form['restaurant'] - dishname = request.form['dishname'] - price = request.form['price'] - img_res = request.form['img_res'] - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "insert into SHOPPINGCART values ('{}','{}','{}','{}','{}') ".format(username, restuarant, dishname, - price, img_res) - cursor.execute(sql1) - res1 = cursor.fetchall() - print(len(res1)) - sql = "SELECT * FROM SHOPPINGCART" - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('myOrder.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('myOrder.html', username=username, messages=msg) - - elif request.form["action"] == "结算": - print("结算啦") - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - ''' - 这下面 - ''' - restuarant = request.form['restaurant'] - print(restaurant) - dishname = request.form['dishname'] - price = request.form['price'] - img_res = request.form['img_res'] - mode = request.form['mode'] - print("==*==") - print(mode) - - if mode == 1: - print("堂食") - - else: - print("外送") - return render_template('index.html') - else: - print("咋回事") - return render_template('index.html') - - -# 个人中心页面 -@app.route('/personal') -def personalPage(): - return render_template('personal.html') - - -# 修改个人信息页面 -@app.route('/ModifyPersonalInfo', methods=['GET', 'POST']) -def ModifyPersonalInfo(): - msg = "" - if request.method == 'GET': - return render_template('ModifyPersonalInfo.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - address = request.form['address'] - phonenum = request.form['phonenum'] - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET address = '{}', phone = '{}' where username = '{}'".format(userRole, address, phonenum, - username) - try: - cursor.execute(sql) - db.commit() - # print("修改个人信息成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改个人信息失败") - msg = "fail" - return render_template('ModifyPersonalInfo.html', messages=msg, username=username) - - -# 修改密码页面 -@app.route('/ModifyPassword', methods=['GET', 'POST']) -def ModifyPassword(): - msg = "" - if request.method == 'GET': - return render_template('ModifyPassword.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - psw1 = request.form['psw1'] - psw2 = request.form['psw2'] - # 两次输入密码是否相同 - if psw1 == psw2: - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET password = '{}' where username = '{}'".format(userRole, psw1, username) - try: - cursor.execute(sql) - db.commit() - # print("修改密码成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改密码失败") - msg = "fail" - return render_template('ModifyPassword.html', messages=msg, username=username) - else: - msg = "not equal" - return render_template('ModifyPassword.html', messages=msg, username=username) - - -@app.route('/OrderPage', methods=['GET', 'POST']) -def OrderPage(): - msg = "" - global notFinishedNum - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0" % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s'" % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('OrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("NULL") - msg = "none" - return render_template('OrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "确认收货": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - print("用户要确认收货啦") - orderID = request.form['orderID'] - print(orderID) - sql1 = "Update ORDER_COMMENT SET isFinished = 1, text = '' WHERE orderID = '%s' " % orderID - print(sql1) - cursor.execute(sql1) - db.commit() - - sql2 = "select * from ORDER_COMMENT WHERE orderID = '%s' " % orderID - cursor.execute(sql2) - res1 = cursor.fetchone() - restaurant = res1[1] - dishname = res1[2] - print("{} {} 销量+1".format(dishname, restaurant)) - - sql = "Update DISHES SET sales = sales+1 WHERE dishname = '{}' AND restaurant = '{}'".format(dishname, - restaurant) - print(sql) - cursor.execute(sql) - res = cursor.fetchall() - print(res) - msg = "UpdateSucceed" - return render_template('OrderPage.html', username=username, messages=msg) - - else: - return render_template('OrderPage.html', username=username, messages=msg) - - -@app.route('/MyComments', methods=['GET', 'POST']) -def MyCommentsPage(): - msg = "" - global notFinishedNum - - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成及未评论订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' and isFinished = 1 and text <> '' " % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text is not null Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text is not null Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MyComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MyComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "待评价订单": - # 未评价订单跳转到写评论中 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print("MyCommentsPage - 未评价订单: {}".format(len(res))) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("MyCommentsPage - 待评价订单 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=len(res)) - - else: - return render_template('MyComments.html', username=username, messages=msg) - - -@app.route('/WriteComments', methods=['GET', 'POST']) -def WriteCommentsPage(): - msg = "" - if request.method == 'GET': - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - # presql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0" % username - # cursor.execute(presql) - # res1 = cursor.fetchall() - # notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg) - else: - print("WriteCommentsPage - GET - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg) - elif request.form["action"] == "按交易时间排序": - # TODO: 排序之后显示的是空的,不显示的问题没有解决 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - print(username) - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg) - else: - print("WriteCommentsPage - 按交易时间排序 -NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 1 AND text = '' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("WriteCommentsPage - 按价格排序 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 AND text = '' " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('WriteComments.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("WriteCommentsPage - 未完成订单 - NULL") - msg = "none" - return render_template('WriteComments.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - else: - return render_template('WriteComments.html', username=username, messages=msg) - - -@app.route('/CommentForm', methods=['GET', 'POST']) -def CommentFormPage(): - msg = "" - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "写评论": - orderID = request.form['orderID'] - print(orderID) - msg = "WriteRequest" - print(msg) - return render_template('CommentForm.html', username=username, orderID=orderID, messages=msg) - elif request.form["action"] == "提交评论": - print("提交评论!") - orderID = request.form.get('orderID') - c_rank = request.form.get('rank') - text = request.form.get('text') - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update ORDER_COMMENT SET text = '{}', c_rank = {} where orderID = '{}'".format(text, c_rank, orderID) - print(sql) - try: - cursor.execute(sql) - db.commit() - print("用户评论成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("用户评论失败") - msg = "fail" - return render_template('CommentForm.html', messages=msg, username=username) - - -# 商家查看菜品信息 -@app.route('/MerchantMenu', methods=['GET', 'POST']) -def MerchantMenu(): - msg = "" - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询 - sql = "SELECT * FROM DISHES WHERE restaurant = '%s'" % username - - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res) != 0: - msg = "done" - print(msg) - print(len(res)) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - if request.method == 'POST': - if request.form["action"] == "删除该菜品": - dishname = request.form.get('dishname') - rest = request.form.get('restaurant') - print(rest) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "DELETE FROM dishes where dishname = '{}' and restaurant = '{}'".format(dishname, rest) - print(sql) - try: - cursor.execute(sql) - db.commit() - print("菜品删除成功") - dmsg = "done" - except ValueError as e: - print("--->", e) - print("菜品删除失败") - dmsg = "fail" - return render_template('MerchantMenu.html', dishname=dishname, rest=rest, dmessages=dmsg) - elif request.form["action"] == "按销量排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY sales DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM DISHES WHERE restaurant = '%s' Order BY price DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantMenu.html', username=username, result=res, messages=msg) - else: - print("NULL") - msg = "none" - return render_template('MerchantMenu.html', username=username, messages=msg) - - -# 商家修改菜品信息 -@app.route('/MenuModify', methods=['GET', 'POST']) -def MenuModify(): - msg = "" - - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "修改菜品信息": - dishname = request.form['dishname'] # 传递过去菜品名 - rest = request.form['restaurant'] # 传递过去商家名 - dishinfo = request.form['dishinfo'] - nutriention = request.form.get('nutriention') - price = request.form.get('price') - isSpecialty = request.form.get('isSpecialty') - # imagesrc = request.form['imagesrc'] - print(dishname) - print(isSpecialty) - print(type(isSpecialty)) - - return render_template('MenuModify.html', dishname=dishname, rest=rest, dishinfo=dishinfo, - nutriention=nutriention, price=price, username=username, messages=msg, - isSpecialty=isSpecialty) - elif request.form["action"] == "提交修改": - - dishname = request.form.get('dishname') - rest = request.form.get('rest') - - dishinfo = request.form['dishinfo'] - nutriention = request.form.get('nutriention') - price = request.form.get('price') - isSpecialty = int(request.form.get('isSpecialty')) - f = request.files['imagesrc'] - filename = '' - - if f != '' and allowed_file(f.filename): - filename = secure_filename(f.filename) - - if filename != '': - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - - print(isSpecialty) - print(type(isSpecialty)) - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - if filename == '': - sql = "Update dishes SET dishinfo = '{}', nutriention = '{}', price = {} , isSpecialty = {} where dishname = '{}' and restaurant = '{}'".format( - dishinfo, nutriention, price, isSpecialty, dishname, rest) - else: - sql = "Update dishes SET dishinfo = '{}', nutriention = '{}', price = {} ,imagesrc = '{}', isSpecialty = {} where dishname = '{}' and restaurant = '{}'".format( - dishinfo, nutriention, price, imgsrc, isSpecialty, dishname, rest) - print(sql) - - try: - cursor.execute(sql) - db.commit() - print("菜品信息修改成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("菜品信息修改失败失败") - msg = "fail" - return render_template('MenuModify.html', dishname=dishname, rest=rest, username=username, messages=msg) - - -@app.route('/MenuAdd', methods=['GET', 'POST']) -def MenuAdd(): - msg = "" - rest = "" - print(request.method) - # print(request.form["action"]) - if request.form["action"] == "增加菜品": - rest = request.form['restaurant'] # 传递过去商家名 - return render_template('MenuAdd.html', rest=rest) - elif request.form["action"] == "确认增加": - dishname = request.form.get('dishname') - rest = request.form.get('rest') - dishinfo = request.form.get('dishinfo') - nutriention = request.form.get('nutriention') - price = request.form.get('price') - f = request.files['imagesrc'] - print(f) - isSpecialty = int(request.form.get('isSpecialty')) - if f and allowed_file(f.filename): - filename = secure_filename(f.filename) - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql1 = "SELECT * from DISHES where dishname = '{}' ".format(dishname) - cursor.execute(sql1) - db.commit() - res1 = cursor.fetchall() - num = 0 - for row in res1: - num = num + 1 - # 如果已经存在该商家 - if num == 1: - print("失败!该菜品已经添加过!") - msg = "fail1" - else: - sql2 = "insert into DISHES values ('{}', '{}','{}', '{}',{},{},'{}', {}) ".format(dishname, rest, dishinfo, - nutriention, price, 0, - imgsrc, - isSpecialty) - print(sql2) - try: - cursor.execute(sql2) - db.commit() - print("菜品添加成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("菜品添加失败") - msg = "fail" - return render_template('MenuAdd.html', messages=msg, username=username) - - -@app.route('/MerchantIndex') -def Merchantindexpage(): - return render_template('MerchantIndex.html') - - -# 个人中心页面 -@app.route('/MerchantPersonal') -def MpersonalPage(): - return render_template('MerchantPersonal.html') - - -# 修改个人信息页面 -@app.route('/MerchantModifyPerInfo', methods=['GET', 'POST']) -def MerchantModifyPerInfo(): - msg = "" - if request.method == 'GET': - return render_template('MerchantModifyPerInfo.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - address = request.form['address'] - phonenum = request.form['phonenum'] - - f = request.files['imagesrc'] - filename = '' - - if f != '' and allowed_file(f.filename): - filename = secure_filename(f.filename) - - if filename != '': - f.save('static/images/' + filename) - imgsrc = 'static/images/' + filename - - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - if filename == '': - sql = "Update {} SET address = '{}', phone = '{}' where username = '{}'".format(userRole, address, phonenum, - username) - else: - sql = "Update {} SET address = '{}', phone = '{}',imageRes = '{}' where username = '{}'".format(userRole, - address, - phonenum, - imgsrc, - username) - try: - cursor.execute(sql) - db.commit() - # print("修改个人信息成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改个人信息失败") - msg = "fail" - return render_template('MerchantModifyPerInfo.html', messages=msg, username=username) - - -# 修改密码页面 -@app.route('/MerchantModifyPwd', methods=['GET', 'POST']) -def MerModifyPassword(): - msg = "" - if request.method == 'GET': - return render_template('MerchantModifyPwd.html', username=username) - if request.method == 'POST': - # username = request.form['username'] - psw1 = request.form['psw1'] - psw2 = request.form['psw2'] - # 两次输入密码是否相同 - if psw1 == psw2: - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - sql = "Update {} SET password = '{}' where username = '{}'".format(userRole, psw1, username) - try: - cursor.execute(sql) - db.commit() - # print("修改密码成功") - msg = "done" - except ValueError as e: - print("--->", e) - print("修改密码失败") - msg = "fail" - return render_template('MerchantModifyPwd.html', messages=msg, username=username) - else: - msg = "not equal" - return render_template('MerchantModifyPwd.html', messages=msg, username=username) - - -# 商家查看订单 -@app.route('/MerchantOrderPage', methods=['GET', 'POST']) -def MerchantOrderPage(): - msg = "" - global notFinishedNum - if request.method == 'GET': - msg = "" - # 连接数据库,默认数据库用户名root,密码空 - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - # 查询未完成订单数量 - presql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s' AND isFinished = 0" % username - cursor.execute(presql) - res1 = cursor.fetchall() - notFinishedNum = len(res1) - # 查询其他信息 - sql = "SELECT * FROM ORDER_COMMENT WHERE restaurant = '%s'" % username - cursor.execute(sql) - res = cursor.fetchall() - # print(res) - # print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按时间排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY tansactiontime DESC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg) - elif request.form["action"] == "按价格排序": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' Order BY cost ASC" % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=notFinishedNum) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - elif request.form["action"] == "未完成订单": - db = MySQLdb.connect("localhost", "root", "root", "appDB", charset='utf8') - cursor = db.cursor() - try: - cursor.execute("use appDB") - except: - print("Error: unable to use database!") - - sql = "SELECT * FROM ORDER_COMMENT WHERE username = '%s' AND isFinished = 0 " % username - cursor.execute(sql) - res = cursor.fetchall() - print(res) - print(len(res)) - if len(res): - msg = "done" - print(msg) - return render_template('MerchantOrderPage.html', username=username, result=res, messages=msg, - notFinishedNum=len(res)) - else: - print("NULL") - msg = "none" - return render_template('MerchantOrderPage.html', username=username, messages=msg, notFinishedNum=notFinishedNum) - else: - return render_template('MerchantOrderPage.html', username=username, messages=msg) - - -if __name__ == '__main__': - app.run(host='localhost', port='9090') diff --git a/src/src b/src/src deleted file mode 100644 index e69de29..0000000 diff --git a/src/templates/CommentForm.html b/src/templates/CommentForm.html deleted file mode 100644 index 351a58e..0000000 --- a/src/templates/CommentForm.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/Menu.html b/src/templates/Menu.html deleted file mode 100644 index d0f2957..0000000 --- a/src/templates/Menu.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - 菜单界面 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

今日菜单

- -
-
- -
-
- - - -
-
-

- -
-
- {% if messages == "done" %} - {% for item in result %} -
-
-
- Image -
-
- {% if item[7] == 1 %} -

特色菜

- {% endif %} -

菜品:{{ item[0] }}

-

菜品描述:{{ item[2] }}

-

营养成分:{{ item[3] }}

-

销量:{{item[5] }}

-

价格:¥{{ item[4]}}

-
- - - - - - -
-
-
-
- {% endfor %} - - - {% elif messages == "none" %} - - - {% elif messages == "fail" %} - - {% endif %} - -
- - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MenuAdd.html b/src/templates/MenuAdd.html deleted file mode 100644 index 6b8ca48..0000000 --- a/src/templates/MenuAdd.html +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MenuModify.html b/src/templates/MenuModify.html deleted file mode 100644 index 8a114ea..0000000 --- a/src/templates/MenuModify.html +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantIndex.html b/src/templates/MerchantIndex.html deleted file mode 100644 index 6c7ff47..0000000 --- a/src/templates/MerchantIndex.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - 商家首页 - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
- Hotel business -

Weclome to the Online Management System

- -
-
- - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantMenu.html b/src/templates/MerchantMenu.html deleted file mode 100644 index f3ceb82..0000000 --- a/src/templates/MerchantMenu.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - 菜单界面 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

我的菜单

- -
-
- -
-
- - -
-
- - -
-
-

- -
-
- {% if messages == "done" %} - {% for item in result %} -
-
-
- Image -
-
- {% if item[7] == 1 %} -

特色菜

- {% endif %} -

菜品:{{ item[0] }}

-

菜品描述:{{ item[2] }}

-

营养成分:{{ item[3] }}

-

销量:{{item[5] }}

-

价格:¥{{ item[4]}}

-
- - - - - - - -
-
- - - -
- -
-
-
- {% endfor %} - - - - {% elif messages == "none" %} - - - {% endif %} - - {% if dmessages == "done" %} - - - {% elif dmessages == "fail" %} - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantModifyPerInfo.html b/src/templates/MerchantModifyPerInfo.html deleted file mode 100644 index b1fcc1e..0000000 --- a/src/templates/MerchantModifyPerInfo.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - 修改个人信息 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantModifyPwd.html b/src/templates/MerchantModifyPwd.html deleted file mode 100644 index ac5ca49..0000000 --- a/src/templates/MerchantModifyPwd.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - 修改密码 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantOrderPage.html b/src/templates/MerchantOrderPage.html deleted file mode 100644 index cdb5b9d..0000000 --- a/src/templates/MerchantOrderPage.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

收到的订单

- -
-
- -
-
- - - {{ notFinishedNum }} -
-
-

- - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MerchantPersonal.html b/src/templates/MerchantPersonal.html deleted file mode 100644 index 2e809ee..0000000 --- a/src/templates/MerchantPersonal.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
- - - -

修改个人信息

-

Modify personal information

-
-
-
-
- - - -

修改密码

-

Modify my password

-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/ModifyPassword.html b/src/templates/ModifyPassword.html deleted file mode 100644 index 7bad85d..0000000 --- a/src/templates/ModifyPassword.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - 修改密码 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/ModifyPersonalInfo.html b/src/templates/ModifyPersonalInfo.html deleted file mode 100644 index 7286be3..0000000 --- a/src/templates/ModifyPersonalInfo.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - 修改个人信息 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/MyComments.html b/src/templates/MyComments.html deleted file mode 100644 index 18918b9..0000000 --- a/src/templates/MyComments.html +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

我的评价

- -
-
- -
-
- - - {{ notFinishedNum }} -
-
-

- -
-
- {% if messages == "done" %} - {% for item in result %} - -
- -
- -

订单号:{{ item[0] }}

-

交易时间:{{ item[9] }}

-

评价时间:{{ item[12] }}

-

菜品:{{ item[2] }}

- - {% if item[4] == 1 %} -

就餐方式:堂食

-

餐厅地址:{{ item[6] }}

- {% elif item[4] == 0 %} -

就餐方式:外卖

-

配送地址:{{ item[6] }}

- {% endif %} - -

订单总价格:¥{{ item[13]}}

- -
-
- -
-
-

- - {% if item[11] == 5 %} - 评分: {{ item[11] }} - {% elif item[11] == 4 %} - 评分: {{ item[11] }} - {% elif item[11] == 3 %} - 评分: {{ item[11] }} - {% elif item[11] == 2 %} - 评分: {{ item[11] }} - {% elif item[11] == 1 %} - 评分: {{ item[11] }} - {% elif item[11] == 0 %} - 评分: {{ item[11] }} - {% endif %} -

-

评价:{{ item[10] }}

-
-
- -
-
- - {% endfor %} - - {% elif messages == "none" %} - - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/OrderPage.html b/src/templates/OrderPage.html deleted file mode 100644 index 40f0b76..0000000 --- a/src/templates/OrderPage.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

我的订单

- -
-
- -
-
- - - {{ notFinishedNum }} -
-
-

- -
-
- {% if messages == "done" %} - {% for item in result %} -
-
-
- Image -
-
-

菜品:{{ item[2] }}

-

订单号:{{ item[0] }}

-

交易时间:{{ item[9] }}

- - {% if item[4] == 1 %} -

就餐方式:堂食

-

餐厅地址:{{ item[6] }}

-

取餐时间:{{ item[5] }}

- {% elif item[4] == 0 %} -

就餐方式:外卖

-

配送地址:{{ item[6] }}

-

送达时间:{{ item[5] }}

- {% endif %} - {% if item[7] == 1 %} -

订单状态:已完成

- {% elif item[7] == 0 %} -

订单状态:未完成

- {% endif %} -

订单总价格:¥{{ item[13]}}

-
- - {% if item[7] == 0 %} - - {% endif %} -
-
-
-
- {% endfor %} - - {% elif messages == "UpdateSucceed" %} - - - - - {% elif messages == "none" %} - - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/Register.html b/src/templates/Register.html deleted file mode 100644 index d98e769..0000000 --- a/src/templates/Register.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - 注册 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/ResComment.html b/src/templates/ResComment.html deleted file mode 100644 index 03e5ccf..0000000 --- a/src/templates/ResComment.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - 商家评价 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

商家评价

- -
-
- -

- -
-
- {% if messages == "done" %} - {% for item in result %} - -
- -
- -

订单号:{{ item[0] }}

-

交易时间:{{ item[9] }}

-

评价时间:{{ item[12] }}

-

菜品:{{ item[2] }}

- - {% if item[4] == 1 %} -

就餐方式:堂食

-

餐厅地址:{{ item[6] }}

- {% elif item[4] == 0 %} -

就餐方式:外卖

-

配送地址:{{ item[6] }}

- {% endif %} - -

订单总价格:¥{{ item[13]}}

- -
-
- -
-
-

- - {% if item[11] == 5 %} - 评分: {{ item[11] }} - {% elif item[11] == 4 %} - 评分: {{ item[11] }} - {% elif item[11] == 3 %} - 评分: {{ item[11] }} - {% elif item[11] == 2 %} - 评分: {{ item[11] }} - {% elif item[11] == 1 %} - 评分: {{ item[11] }} - {% elif item[11] == 0 %} - 评分: {{ item[11] }} - {% endif %} -

-

评价:{{ item[10] }}

-
-
- -
-
- - {% endfor %} - - {% elif messages == "none" %} - - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/ResCommentList.html b/src/templates/ResCommentList.html deleted file mode 100644 index a2e3d56..0000000 --- a/src/templates/ResCommentList.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - 查看评论 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

我的评价

- -
-
- -

- -
-
- {% if messages == "done" %} - {% for item in result %} - -
- -
- -

订单号:{{ item[0] }}

-

交易时间:{{ item[9] }}

-

评价时间:{{ item[12] }}

-

菜品:{{ item[2] }}

- - {% if item[4] == 1 %} -

就餐方式:堂食

-

餐厅地址:{{ item[6] }}

- {% elif item[4] == 0 %} -

就餐方式:外卖

-

配送地址:{{ item[6] }}

- {% endif %} - -

订单总价格:¥{{ item[13]}}

- -
-
- -
-
-

- - {% if item[11] == 5 %} - 评分: {{ item[11] }} - {% elif item[11] == 4 %} - 评分: {{ item[11] }} - {% elif item[11] == 3 %} - 评分: {{ item[11] }} - {% elif item[11] == 2 %} - 评分: {{ item[11] }} - {% elif item[11] == 1 %} - 评分: {{ item[11] }} - {% elif item[11] == 0 %} - 评分: {{ item[11] }} - {% endif %} -

-

评价:{{ item[10] }}

-
-
- -
-
- - {% endfor %} - - {% elif messages == "none" %} - - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/UserRestList.html b/src/templates/UserRestList.html deleted file mode 100644 index 87cb1ed..0000000 --- a/src/templates/UserRestList.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - 用户界面 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
- -
-
-
-
-

中国民航大学食堂欢迎你!

-
-
-
- {% if messages == "done" %} - {% for item in result %} -
-
- -
-
- Image -
-
-
-

{{ item[0] }}

-

ADDRESS:{{ item[2] }}

-

PHONE:{{ item[3] }}

-
-
- - -
-
- - -
-
-
- {% endfor %} - {% elif messages == "none" %} - - - {% endif %} - - -
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/WriteComments.html b/src/templates/WriteComments.html deleted file mode 100644 index 8688ea4..0000000 --- a/src/templates/WriteComments.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

发表评价

- -
-
- -
-
- - -
-
-

- -
-
- {% if messages == "done" %} - {% for item in result %} -
-
- - Image -
-
-

菜品:{{ item[2] }}

-

订单号:{{ item[0] }}

-

交易时间:{{ item[9] }}

- - {% if item[4] == 1 %} -

就餐方式:堂食

-

餐厅地址:{{ item[6] }}

-

取餐时间:{{ item[5] }}

- {% elif item[4] == 0 %} -

就餐方式:外卖

-

配送地址:{{ item[6] }}

-

送达时间:{{ item[5] }}

- {% endif %} - {% if item[7] == 1 %} -

订单状态:已完成

- {% elif item[7] == 0 %} -

订单状态:未完成

- {% endif %} -

订单总价格:¥{{ item[13] }}

-
- - {% if item[7] == 1 %} - - {% endif %} -
-
-
-
- {% endfor %} - - {% elif messages == "none" %} - - - {% endif %} - -
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/adminCommentList.html b/src/templates/adminCommentList.html deleted file mode 100644 index b658c86..0000000 --- a/src/templates/adminCommentList.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - 管理员界面 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

评价

- -
-
-
-
- -
-
-

- -
- {% if messages == "done" %} - {% for item in result %} -
- -
-
-
- Image -
-
- -

{{ item[1] }}

-

订单号:{{ item[0] }}

-

菜品:{{ item[2] }}

-

¥{{ item[13]}}

-

- - {% if item[11] == 5 %} - 评分: {{ item[11] }} - {% elif item[11] == 4 %} - 评分: {{ item[11] }} - {% elif item[11] == 3 %} - 评分: {{ item[11] }} - {% elif item[11] == 2 %} - 评分: {{ item[11] }} - {% elif item[11] == 1 %} - 评分: {{ item[11] }} - {% elif item[11] == 0 %} - 评分: {{ item[11] }} - {% endif %} -

-

评价:{{ item[10] }}

-
- - - - -
-
- {% endfor %} - - {% elif messages == "none" %} - - - {% endif %} - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/adminRestList.html b/src/templates/adminRestList.html deleted file mode 100644 index de1c5b9..0000000 --- a/src/templates/adminRestList.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - 管理员界面 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
-
-
-
-

Restaurant List

-

查看评论后可移除恶意营销商家

-
-
-
- {% if messages == "done" %} - {% for item in result %} -
-
- -
-
- Image -
-
-
-

{{ item[0] }}

-

ADDRESS:{{ item[2] }}

-

PHONE:{{ item[3] }}

-
-
- - -
-
-
- {% endfor %} - {% elif messages == "none" %} - - {% elif messages == "delete" %} - - - {% endif %} - - -
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html deleted file mode 100644 index 1834510..0000000 --- a/src/templates/index.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - 首页 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/logIn.html b/src/templates/logIn.html deleted file mode 100644 index 584b533..0000000 --- a/src/templates/logIn.html +++ /dev/null @@ -1,173 +0,0 @@ - - - - - 登录 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/templates/myOrder.html b/src/templates/myOrder.html deleted file mode 100644 index ab950a0..0000000 --- a/src/templates/myOrder.html +++ /dev/null @@ -1,295 +0,0 @@ - - - - - - - - - 我的购物车 - - - -
- -
-
- -
-
-
- -
- 已选商品(不含运费) - 0.00 - - -
-
-
-
-
-
-
-
- - -
-
-
-
-
商品信息
-
-
-
-
 
-
-
-
单价
-
-
-
数量
-
-
-
金额
-
-
-
操作
-
-
-
- - {% if messages == "done" %} - {% for item in result %} -
-
-
    -
  • -
    - -
    -
  • -
  • -
    - - -
    - -
    -
    - -
    -
    -
    -
  • -
  • -
    -

    店铺:{{ item[1] }}

    -
    -
  • -
  • -
    -

    ¥{{ item[3] }}

    -
    -
  • -
  • -
    - - - - + -
    -
    - 574 -
    -
    - 最多只能购买 - -
    - -
  • -
  • - {{ item[3] }} -
  • -
  • -

    删除

    -
  • -
-
-
- {% endfor %} - {% endif %} - -
-
- -
-
-
-
-
-
- - 堂食 - 外卖 -
-
- -
- -
- - - - - - - \ No newline at end of file diff --git a/src/templates/personal.html b/src/templates/personal.html deleted file mode 100644 index 525b07c..0000000 --- a/src/templates/personal.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - 个人中心 - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
- - - -

修改个人信息

-

Modify personal information

-
-
-
-
- - - -

修改密码

-

Modify my password

-
-
-
-
- - - -

我的订单

-

My orders

-
-
-
-
- - - -

我的评价

-

My review

-
-
-
-
- - - -

发表评价

-

Post a review

-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file