-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
前端酒店预定的时候需要用户先登录, 能微信直接登录最好。登录之后用户选择酒店, 选择房间, 选择住宿时间,输入用户姓名和手机号码,然后进行…
…支付, 完成支付之后即预定成功。同时用户可以取消订单,申请退款,订单管理等操作。另外用户还可以优惠券管理,推荐酒店,等级提升等功能可以操作。后端的酒店管理包括两个部分, 一个是总后台,包括酒店设置,酒店增加,审核等。另一个是酒店方的后台, 酒店方登录后可以设置酒店的详细信息, 包括订单管理, 房型管理,财务核算等。
- Loading branch information
1 parent
b146038
commit 23db126
Showing
1 changed file
with
170 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,171 @@ | ||
from flask import request, jsonify | ||
from app import app, db | ||
from app.models import Demo | ||
|
||
# 添加用户 | ||
@app.route('/demos', methods=['POST']) | ||
def add_demo(): | ||
data = request.get_json() | ||
new_demo = Demo(info1=data['info1'], info2=data['info2']) | ||
db.session.add(new_demo) | ||
db.session.commit() | ||
return jsonify({'message': 'Demo added successfully'}) | ||
|
||
# 获取所有用户 | ||
@app.route('/demos', methods=['GET']) | ||
def get_demos(): | ||
demos = Demo.query.all() | ||
demo_list = [] | ||
for demo in demos: | ||
demo_data = {'id': demo.id, 'info1': demo.info1, 'info2': demo.info2} | ||
demo_list.append(demo_data) | ||
return jsonify({'demos': demo_list}) | ||
|
||
# 获取单个用户 | ||
@app.route('/demos/<int:demo_id>', methods=['GET']) | ||
def get_demo(demo_id): | ||
demo = Demo.query.get(demo_id) | ||
if demo: | ||
demo_data = {'id': demo.id, 'info1': demo.info1, 'info2': demo.info2} | ||
return jsonify(demo_data) | ||
return jsonify({'message': 'Demo not found'}), 404 | ||
|
||
# 更新用户信息 | ||
@app.route('/demos/<int:demo_id>', methods=['PUT']) | ||
def update_demo(demo_id): | ||
demo = Demo.query.get(demo_id) | ||
if not demo: | ||
return jsonify({'message': 'Demo not found'}), 404 | ||
|
||
data = request.get_json() | ||
demo.info1 = data['info1'] | ||
demo.info2 = data['info2'] | ||
db.session.commit() | ||
return jsonify({'message': 'Demo updated successfully'}) | ||
|
||
# 删除用户 | ||
@app.route('/demos/<int:demo_id>', methods=['DELETE']) | ||
def delete_demo(demo_id): | ||
demo = Demo.query.get(demo_id) | ||
if not demo: | ||
return jsonify({'message': 'Demo not found'}), 404 | ||
|
||
db.session.delete(demo) | ||
db.session.commit() | ||
return jsonify({'message': 'Demo deleted successfully'}) | ||
from app import app | ||
|
||
@app.route('/login_wechat', methods=['POST']) | ||
def login_wechat(): | ||
code = request.form.get('code') | ||
# Call WeChat login API | ||
# ... | ||
user_id = '123' | ||
username = 'wechat_user' | ||
return jsonify({'user_id': user_id, 'username': username}) | ||
|
||
@app.route('/login', methods=['POST']) | ||
def login(): | ||
username = request.form.get('username') | ||
password = request.form.get('password') | ||
# Call username password login API | ||
# ... | ||
user_id = '456' | ||
username = 'user' | ||
return jsonify({'user_id': user_id, 'username': username}) | ||
|
||
@app.route('/select_hotel', methods=['POST']) | ||
def select_hotel(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call select hotel API | ||
# ... | ||
hotel_info = {'name': 'hotel', 'address': 'address', 'phone': '1234567890'} | ||
room_info = {'room_id': '123', 'room_type': 'single', 'capacity': 1} | ||
price_info = {'price': 100} | ||
return jsonify({'hotel_info': hotel_info, 'room_info': room_info, 'price_info': price_info}) | ||
|
||
@app.route('/select_room', methods=['POST']) | ||
def select_room(): | ||
room_id = request.form.get('room_id') | ||
# Call select room API | ||
# ... | ||
room_info = {'room_id': '123', 'room_type': 'single', 'capacity': 1} | ||
price_info = {'price': 100} | ||
return jsonify({'room_info': room_info, 'price_info': price_info}) | ||
|
||
@app.route('/select_dates', methods=['POST']) | ||
def select_dates(): | ||
check_in_date = request.form.get('check_in_date') | ||
check_out_date = request.form.get('check_out_date') | ||
# Call select dates API | ||
# ... | ||
price_info = {'price': 100} | ||
return jsonify({'price_info': price_info}) | ||
|
||
@app.route('/calculate_price', methods=['POST']) | ||
def calculate_price(): | ||
hotel_id = request.form.get('hotel_id') | ||
room_id = request.form.get('room_id') | ||
check_in_date = request.form.get('check_in_date') | ||
check_out_date = request.form.get('check_out_date') | ||
# Call calculate price API | ||
# ... | ||
price_info = {'price': 100} | ||
return jsonify({'price_info': price_info}) | ||
|
||
@app.route('/complete_payment', methods=['POST']) | ||
def complete_payment(): | ||
order_id = request.form.get('order_id') | ||
payment_method = request.form.get('payment_method') | ||
# Call complete payment API | ||
# ... | ||
payment_result = 'success' | ||
return jsonify({'payment_result': payment_result}) | ||
|
||
@app.route('/cancel_order', methods=['POST']) | ||
def cancel_order(): | ||
order_id = request.form.get('order_id') | ||
# Call cancel order API | ||
# ... | ||
cancel_result = 'success' | ||
return jsonify({'cancel_result': cancel_result}) | ||
|
||
@app.route('/apply_refund', methods=['POST']) | ||
def apply_refund(): | ||
order_id = request.form.get('order_id') | ||
reason = request.form.get('reason') | ||
# Call apply refund API | ||
# ... | ||
refund_result = 'success' | ||
return jsonify({'refund_result': refund_result}) | ||
|
||
@app.route('/receive_coupon', methods=['POST']) | ||
def receive_coupon(): | ||
coupon_id = request.form.get('coupon_id') | ||
# Call receive coupon API | ||
# ... | ||
receive_result = 'success' | ||
return jsonify({'receive_result': receive_result}) | ||
|
||
@app.route('/use_coupon', methods=['POST']) | ||
def use_coupon(): | ||
coupon_id = request.form.get('coupon_id') | ||
# Call use coupon API | ||
# ... | ||
use_result = 'success' | ||
return jsonify({'use_result': use_result}) | ||
|
||
@app.route('/recommend_hotel', methods=['POST']) | ||
def recommend_hotel(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call recommend hotel API | ||
# ... | ||
recommend_result = {'hotel_id': '123', 'hotel_name': 'hotel'} | ||
return jsonify({'recommend_result': recommend_result}) | ||
|
||
@app.route('/upgrade_level', methods=['POST']) | ||
def upgrade_level(): | ||
referral_count = request.form.get('referral_count') | ||
# Call upgrade level API | ||
# ... | ||
upgrade_result = 'success' | ||
return jsonify({'upgrade_result': upgrade_result}) | ||
|
||
@app.route('/set_hotel_info', methods=['POST']) | ||
def set_hotel_info(): | ||
hotel_id = request.form.get('hotel_id') | ||
name = request.form.get('name') | ||
address = request.form.get('address') | ||
phone = request.form.get('phone') | ||
# Call set hotel info API | ||
# ... | ||
set_result = 'success' | ||
return jsonify({'set_result': set_result}) | ||
|
||
@app.route('/add_hotel', methods=['POST']) | ||
def add_hotel(): | ||
name = request.form.get('name') | ||
address = request.form.get('address') | ||
phone = request.form.get('phone') | ||
# Call add hotel API | ||
# ... | ||
add_result = 'success' | ||
return jsonify({'add_result': add_result}) | ||
|
||
@app.route('/audit_hotel', methods=['POST']) | ||
def audit_hotel(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call audit hotel API | ||
# ... | ||
audit_result = 'success' | ||
return jsonify({'audit_result': audit_result}) | ||
|
||
@app.route('/manage_orders', methods=['POST']) | ||
def manage_orders(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call manage orders API | ||
# ... | ||
order_list = [{'order_id': '123', 'status': 'confirmed'}, {'order_id': '456', 'status': 'cancelled'}] | ||
return jsonify({'order_list': order_list}) | ||
|
||
@app.route('/manage_rooms', methods=['POST']) | ||
def manage_rooms(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call manage rooms API | ||
# ... | ||
room_list = [{'room_id': '123', 'room_type': 'single', 'capacity': 1}, {'room_id': '456', 'room_type': 'double', 'capacity': 2}] | ||
return jsonify({'room_list': room_list}) | ||
|
||
@app.route('/perform_accounting', methods=['POST']) | ||
def perform_accounting(): | ||
hotel_id = request.form.get('hotel_id') | ||
# Call perform accounting API | ||
# ... | ||
accounting_info = {'revenue': 1000, 'expenses': 500, 'profit': 500} | ||
return jsonify({'accounting_info': accounting_info}) |