前言
💖💖作者:计算机程序员小杨 💙💙个人简介:我是一名计算机相关专业的从业者,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。热爱技术,喜欢钻研新工具和框架,也乐于通过代码解决实际问题,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💕💕文末获取源码联系 计算机程序员小杨 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目 计算机毕业设计选题 💜💜
一.开发工具简介
后端开发语言:Java+Python(两个版本都支持) 后端框架:Spring Boot(Spring+SpringMVC+Mybatis)+Django(两个版本都支持) 前端:uni-app+微信小程序+安卓 数据库:MySQL 系统架构:C/S + B/S 开发工具:IDEA(Java的)或者PyCharm(Python的)+微信小程序开发工具
二.系统内容简介
Django连锁火锅智慧餐饮管理系统是一套基于Python+Django框架开发的全栈餐饮管理解决方案,采用uni-app构建跨平台前端界面,支持微信小程序和安卓应用双端部署。系统以MySQL为数据存储核心,通过C/S和B/S混合架构实现多终端协同管理。该系统专门针对连锁火锅餐饮企业的运营特点,提供从用户管理、商家管理到供应商协调的完整业务流程支持。系统集成了火锅类型管理、食材类型分类、火锅信息维护、食材采购跟踪、厨房设备监控等12大核心功能模块,形成了涵盖前台服务、后台管理、供应链协调的闭环管理体系。通过智能化的充值记录管理和优惠券发放机制,系统能够有效提升客户粘性和消费体验,为连锁火锅企业提供数字化转型的技术支撑和管理工具。
三.系统功能演示
前端后端都要做?uni-app+Python全栈火锅餐饮系统开发方案来了
四.系统界面展示
五.系统源码展示
from pyspark.sql import SparkSession
from django.shortcuts import render, redirect
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required
from .models import FoodMaterial, Supplier, PurchaseOrder, HotpotInfo, User, Coupon
from django.db import transaction
from datetime import datetime, timedelta
from decimal import Decimal
import json
spark = SparkSession.builder.appName("HotpotRestaurantSystem").config("spark.sql.adaptive.enabled", "true").getOrCreate()
@csrf_exempt
@login_required
def food_material_purchase_management(request):
if request.method == 'POST':
data = json.loads(request.body)
supplier_id = data.get('supplier_id')
material_list = data.get('material_list', [])
expected_delivery_date = data.get('expected_delivery_date')
total_amount = Decimal('0.00')
with transaction.atomic():
try:
supplier = Supplier.objects.get(id=supplier_id, status='active')
purchase_order = PurchaseOrder.objects.create(
supplier=supplier,
order_date=datetime.now(),
expected_delivery_date=datetime.strptime(expected_delivery_date, '%Y-%m-%d'),
status='pending',
created_by=request.user
)
for item in material_list:
material = FoodMaterial.objects.get(id=item['material_id'])
if material.stock_quantity < item['quantity']:
material.stock_quantity += item['quantity']
material.last_purchase_date = datetime.now()
material.last_purchase_price = Decimal(str(item['unit_price']))
material.save()
item_total = Decimal(str(item['quantity'])) * Decimal(str(item['unit_price']))
total_amount += item_total
purchase_order.items.create(
material=material,
quantity=item['quantity'],
unit_price=Decimal(str(item['unit_price'])),
total_price=item_total
)
purchase_order.total_amount = total_amount
purchase_order.save()
supplier.total_purchase_amount += total_amount
supplier.last_order_date = datetime.now()
supplier.save()
return JsonResponse({'status': 'success', 'order_id': purchase_order.id, 'message': '采购订单创建成功'})
except Exception as e:
return JsonResponse({'status': 'error', 'message': f'采购订单创建失败: {str(e)}'})
elif request.method == 'GET':
orders = PurchaseOrder.objects.select_related('supplier').prefetch_related('items__material').filter(
created_by=request.user
).order_by('-order_date')[:20]
order_data = []
for order in orders:
order_items = []
for item in order.items.all():
order_items.append({
'material_name': item.material.name,
'quantity': float(item.quantity),
'unit_price': float(item.unit_price),
'total_price': float(item.total_price)
})
order_data.append({
'order_id': order.id,
'supplier_name': order.supplier.name,
'order_date': order.order_date.strftime('%Y-%m-%d %H:%M'),
'expected_delivery_date': order.expected_delivery_date.strftime('%Y-%m-%d'),
'status': order.status,
'total_amount': float(order.total_amount),
'items': order_items
})
return JsonResponse({'status': 'success', 'orders': order_data})
@csrf_exempt
@login_required
def hotpot_info_management(request):
if request.method == 'POST':
data = json.loads(request.body)
hotpot_name = data.get('hotpot_name')
hotpot_type = data.get('hotpot_type')
base_price = data.get('base_price')
spice_level = data.get('spice_level', 'medium')
description = data.get('description', '')
required_materials = data.get('required_materials', [])
preparation_time = data.get('preparation_time', 15)
with transaction.atomic():
try:
hotpot = HotpotInfo.objects.create(
name=hotpot_name,
hotpot_type=hotpot_type,
base_price=Decimal(str(base_price)),
spice_level=spice_level,
description=description,
preparation_time=preparation_time,
is_available=True,
created_date=datetime.now()
)
total_cost = Decimal('0.00')
for material_data in required_materials:
material = FoodMaterial.objects.get(id=material_data['material_id'])
required_quantity = Decimal(str(material_data['quantity']))
if material.stock_quantity >= required_quantity:
hotpot.required_materials.create(
material=material,
required_quantity=required_quantity,
cost_per_unit=material.last_purchase_price or Decimal('0.00')
)
total_cost += required_quantity * (material.last_purchase_price or Decimal('0.00'))
else:
return JsonResponse({
'status': 'error',
'message': f'食材 {material.name} 库存不足,当前库存:{material.stock_quantity}'
})
hotpot.total_material_cost = total_cost
profit_margin = ((Decimal(str(base_price)) - total_cost) / Decimal(str(base_price))) * 100
hotpot.profit_margin = profit_margin
hotpot.save()
return JsonResponse({
'status': 'success',
'hotpot_id': hotpot.id,
'profit_margin': float(profit_margin),
'message': '火锅信息创建成功'
})
except Exception as e:
return JsonResponse({'status': 'error', 'message': f'火锅信息创建失败: {str(e)}'})
elif request.method == 'GET':
hotpots = HotpotInfo.objects.prefetch_related('required_materials__material').filter(
is_available=True
).order_by('-created_date')
hotpot_data = []
for hotpot in hotpots:
materials_info = []
for req_material in hotpot.required_materials.all():
materials_info.append({
'material_name': req_material.material.name,
'required_quantity': float(req_material.required_quantity),
'cost_per_unit': float(req_material.cost_per_unit),
'current_stock': float(req_material.material.stock_quantity)
})
hotpot_data.append({
'hotpot_id': hotpot.id,
'name': hotpot.name,
'hotpot_type': hotpot.hotpot_type,
'base_price': float(hotpot.base_price),
'spice_level': hotpot.spice_level,
'preparation_time': hotpot.preparation_time,
'total_material_cost': float(hotpot.total_material_cost),
'profit_margin': float(hotpot.profit_margin),
'materials': materials_info,
'description': hotpot.description
})
return JsonResponse({'status': 'success', 'hotpots': hotpot_data})
@csrf_exempt
@login_required
def coupon_management_system(request):
if request.method == 'POST':
data = json.loads(request.body)
coupon_type = data.get('coupon_type')
discount_value = data.get('discount_value')
minimum_amount = data.get('minimum_amount', 0)
max_usage_count = data.get('max_usage_count', 100)
valid_days = data.get('valid_days', 30)
target_user_type = data.get('target_user_type', 'all')
with transaction.atomic():
try:
start_date = datetime.now()
end_date = start_date + timedelta(days=valid_days)
coupon = Coupon.objects.create(
coupon_type=coupon_type,
discount_value=Decimal(str(discount_value)),
minimum_amount=Decimal(str(minimum_amount)),
max_usage_count=max_usage_count,
current_usage_count=0,
start_date=start_date,
end_date=end_date,
target_user_type=target_user_type,
is_active=True,
created_by=request.user
)
if target_user_type == 'new_user':
eligible_users = User.objects.filter(
date_joined__gte=datetime.now() - timedelta(days=7),
is_active=True
)
elif target_user_type == 'vip':
eligible_users = User.objects.filter(
user_level='vip',
is_active=True
)
else:
eligible_users = User.objects.filter(is_active=True)
distributed_count = 0
for user in eligible_users[:max_usage_count]:
user.available_coupons.create(
coupon=coupon,
obtained_date=datetime.now(),
is_used=False,
user=user
)
distributed_count += 1
if coupon_type == 'discount_percentage':
user.total_saved_amount += (user.total_consumption_amount * discount_value / 100)
else:
user.total_saved_amount += discount_value
user.save()
coupon.distributed_count = distributed_count
coupon.save()
return JsonResponse({
'status': 'success',
'coupon_id': coupon.id,
'distributed_count': distributed_count,
'message': f'优惠券创建成功,已分发给{distributed_count}位用户'
})
except Exception as e:
return JsonResponse({'status': 'error', 'message': f'优惠券创建失败: {str(e)}'})
elif request.method == 'GET':
coupons = Coupon.objects.filter(created_by=request.user).order_by('-start_date')
coupon_data = []
for coupon in coupons:
usage_rate = (coupon.current_usage_count / coupon.max_usage_count * 100) if coupon.max_usage_count > 0 else 0
coupon_data.append({
'coupon_id': coupon.id,
'coupon_type': coupon.coupon_type,
'discount_value': float(coupon.discount_value),
'minimum_amount': float(coupon.minimum_amount),
'max_usage_count': coupon.max_usage_count,
'current_usage_count': coupon.current_usage_count,
'distributed_count': coupon.distributed_count,
'usage_rate': round(usage_rate, 2),
'start_date': coupon.start_date.strftime('%Y-%m-%d'),
'end_date': coupon.end_date.strftime('%Y-%m-%d'),
'target_user_type': coupon.target_user_type,
'is_active': coupon.is_active,
'remaining_days': (coupon.end_date - datetime.now()).days
})
return JsonResponse({'status': 'success', 'coupons': coupon_data})
六.系统文档展示
结束
💕💕文末获取源码联系 计算机程序员小杨