使用餐饮点餐外卖小程序源码,您可以建立一个系统,让您的餐厅或咖啡馆可以远程接受订单并接受付款 - 在线和面对面。有了这个系统,客户只需通过移动订购访问菜单。这可以通过扫描二维码或在搜索栏中输入链接来完成。一旦您的客户做出选择,他们就会提交订单并一次性付款。一旦在餐厅端收到订单,剩下的就是将订单带到客户的餐桌上或打包准备交付。这大大加快了整个在线订购过程。一切都通过智能手机进行,而不是与员工不断来回进行。
餐饮点餐外卖小程序源码开发环境
演示:c.ymzan.top
餐饮点餐外卖小程序源码在docker上运行,镜像在docker-compose.yml文件中指定,并由 docker -compose启动。
Spring Data Rest用于快速数据库访问和验证。
Spring Boot用于快速 REST API 开发和独立部署。
Spring Boot Actuator用于提供监控信息。
HAL 浏览器用于快速的存储库探索。
Lombok用于消除构造函数和 getter/setter 实现,以实现更简洁的编码风格。
Spring Cloud用于提供基础设施服务。
Eureka用于微服务注册和发现。
当系统发生雪崩失败时, Hystrix用作断路器。
RabbitMQ用于解耦微服务。
WebSocket用于向 UI 发送消息。
RestTemplate用于在微服务之间进行通信。
餐厅服务
按名称搜索餐厅
GET localhost:8001/api/restaurants?name=
Return
{
"id": ,
"name":
}
创建餐厅
POST localhost:8001/api/restaurants
Request Body
{
"name":
}
Return HttpStatus.CREATED
通过餐厅 id 获取所有菜单项
GET localhost:8001/api/restaurants/{restaurantId}/menuItems
Return
[
{
"id": ,
"restaurantId": ,
"name": ,
"description": ,
"price":
},
...
]
创建菜单项
POST localhost:8001/api/restaurants/{restaurantId>/menuItems
Request Body
{
"restaurantId": ,
"name": ,
"description": ,
"price":
}
Return HttpStatus.CREATED
批量上传菜单项
POST localhost:8001/api/restaurants/bulk/menuItems
Request Body
[
{
"restaurantId": ,
"name": ,
"description": ,
"price":
}
]
Return HttpStatus.CREATED
订购服务
创建订单
POST localhost:8002/api/restaurants/{rid}/orders
{
"restaurantId": ,
"items":
[
{
"name": ,
"price": ,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": ,
"lastName": ,
"phone": ,
"address":
},
"specialNote":
}
Return:
HttpStatus.CREATED
{
"id": ,
"restaurantId": ,
"items":
[
{
"name": ,
"price": ,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": ,
"lastName": ,
"phone": ,
"address":
},
"specialNote": ,
"totalPrice": ,
"orderTime":
}
支付分发服务
付款分配
POST localhost:8003/api/payments
{
"orderId": ,
"amount": ,
"creditCardInfo":
{
"firstName": ,
"lastName": ,
"expiredMonth": ,
"expiredYear": ,
"securityCode":
}
}
Note: Since payment process can be slow and become a bottleneck in a busy environment, this API will send the payment information to message queue for Payment Service to process.
支付服务
处理付款
POST localhost:8004/api/payments
{
"orderId": ,
"amount": ,
"creditCardInfo":
{
"firstName": ,
"lastName": ,
"expiredMonth": ,
"expiredYear": ,
"securityCode":
}
}
Return
HttpStatus.CREATED
Note: **Hystrix** fallbackMethod is added in case processPayment() fails.
Note: this API will store the payment into DB, find the matching order and update the order paymentId, deliveryTime, and notify Order Complete Service with RestTemplate.
订购完整的更新程序服务
订单完成
POST localhost:8005/api/orders
{
"id": ,
"items":
[
{
"name": ,
"price": ,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": ,
"lastName": ,
"phone": ,
"address":
},
"specialNote": ,
"totalPrice": ,
"orderTime": ,
"deliveryTime": ,
"paymentId":
}
Note: This API will serialize the order to WebSocket channel: "topic/orders", UI can subscribe to this channel to receive message and display to user.
入门
docker-compose up -d
在 Docker 上启动 MongoDB、RabbitMQ
检查MongoDB中的数据
查找 mongodb 容器 id
docker ps
通过键入容器 id 的前 3 个字符(例如:'9cd')进入 mongodb 容器,然后在容器内键入 mongo 以使用 mongodb shell 命令。
docker exec -it 9cd bash
# mongo // open mongo shell
> use test // Spring boot use test db as default
> show collections // show all collections inside test db
> db.restaurant.find().pretty() // show all data inside restaurant table
> exit // quit mongo shell
> exit // exit container shell
安装
mvn clean install
启动
sh ./start-eureka.sh
启动 Hystrix
sh ./start-hystrix.sh
开始餐厅服务
sh ./start-restaurant-service.sh
启动订单服务
sh ./start-order-service.sh
开始付款分配
sh ./start-payment-distribution.sh
启动支付服务
sh ./start-payment-service.sh
启动订单完成更新程序
sh ./start-order-complete-updater.sh
上传测试菜单项
cd restaurant-service
sh ./upload-menu-items.sh
Note: default restaurant id for testing: "11111111-1111-1111-11111111111111111".
通过 HAL 浏览器探索
http://localhost:8001/browser/index.html
port: 8001 can be changed for different services.
调查 Eureka 中的注册服务
http://localhost:8761
调查 RabbitMQ 中的消息队列
http://localhost:15762
Go to Queues -> binder.payments
结帐应用程序指标
http://localhost:8005/health
http://localhost:8005/env
http://localhost:8005/metrics
http://localhost:8005/mappings
Note: 8005 can be changed for different services.
使用 PostMan 测试工作流程
创建订单
POST localhost:8002/api/restaurants/11111111-1111-1111-11111111111111111/orders
{
"restaurantId": "11111111-1111-1111-11111111111111111",
"items": [
{
"name": "menuItem 1",
"price": 11,
"quantity": 2
},
{
"name": "menuItem 2",
"price": 12,
"quantity": 3
}
],
"userInfo": {
"firstName": "first1",
"lastName": "last1",
"phone": "14081234567",
"address": "123 stree1 ave, San Jose, CA 95123"
}
}
Returns:
Returns:
{
"id": "5903e81327b884525eb9a5be",
...
"totalPrice": 58,
...
}
发布订单付款
POST localhost:8003/api/payments
{
"amount": 58,
"orderId": "5903e81327b884525eb9a5be",
"creditCardInfo": {
"firstName": "first 1",
"lastName": "last 1",
"expiredMonth": "02",
"expiredYear": "2019",
"securityCode": "231"
}
}
检查RabbitMQ,你会看到一条消息被payment-distribution 排队并被payment-service 消费。
在 order-complet-updater 的日志中,您将看到以下消息:“Receive order = Order(id=5903e81327b884525eb9a5be, ...” "WebSocketSession[1 current WS(1)-HttpStream(0)-HttpPoll(0) ,共3个……”
所以消息已经被order-complete-updater通过WebSocket发送出去了。
要查看带有测试 UI 的消息:
localhost:8005
Click on "Subscribe to Order Complete Updates" to subscribe the channel.
Click on "Send Test Message" to send out the test JSON object.
查看在底部文本框中收到的消息。
Subscribed to /topic/orders
sendMessage triggered
{
"id": "5903e81327b884525eb9a5be",
"restaurantId": "11111111-1111-1111-11111111111111111",
"items": [
{
"name": "menuItem 1",
"price": 11,
"quantity": 2
},
{
"name": "menuItem 2",
"price": 12,
"quantity": 3
}
"totalPrice": 58,
"orderTime": 1493428243933,
"specialNote": "",
"deliveryTime": 1493486808730,
"paymentId": "",
"userInfo": {
"id": "",
"firstName": "first1",
"lastName": "last1",
"phone": "14081234567",
"address": "123 stree1 ave, San Jose, CA 95123"
}
}
测试回退
打开 Hystrix 仪表板
localhost:7979
监控订单完成更新程序
http://localhost:8004/hystrix.stream
停止订单完成更新程序。将付款过帐到付款服务。 错误率从 0.0 跃升至 100%。在日志中查看来自回退方法的错误消息。一次又一次地发布相同的付款,最终,看到电路状态从“关闭”变为“打开”。
餐饮点餐外卖小程序源码特征
用户可以根据餐厅名称搜索餐厅。
用户可以通过选择不同的菜单项、数量和添加关于他/她的饮食限制等的注释来订购食物。
用户可以填写收货地址。
用户下单后,订单应包含用户订购的食品、数量、价格和订购时间。
用户需要通过提供信用卡号、有效期和安全码来支付他/她的订单。
支付成功后,返回支付ID,timesatmp,然后订单被认为完成,用户可以看到预计的交货时间。
预计交货时间为 5 分钟至 1 小时之间的随机时间。
餐饮点餐外卖小程序源码好处
1. 更安全、更健康
要重新开业,食品企业需要开设一家商店以满足健康和安全法规。业主必须保持社交距离,使用非接触式订购/付款方式,并确保定期清洁表面。
即使您经营一家小商店,保持社交距离也不必感到压力。转向企业在线订购网站意味着走进的新客户可以在店外或店内餐桌上订购和付款。
2. 犯错的空间更小
餐饮点餐外卖小程序源码的优势之一是它可以确保价格准确,并且在结账时出错的空间更小。这是因为顾客需要亲自从菜单上选择相应价格的商品,以确保始终支付正确的金额。这对您的业务有一些好处。错误收费的可能性更小,清理错误所浪费的时间更少,为安抚客户而发放的免费产品也更少!
3. 更多客户
随着社交距离的继续,在线订购和支付正变得越来越被接受和期待。如果您的菜单和支付系统没有任何麻烦,您的老客户就会将您推荐给他们的朋友,并在社交媒体上分享。只需提供无缝的客户体验,将订单实时发送到后端团队,您就可以增加客户和利润。
4. 提高客户忠诚度
如果您给他们一个继续回来的理由,客户会选择您的商店而不是竞争对手的商店。伟大的产品可能就是这个原因,但您也可以通过订购应用程序上的奖励计划来鼓励他们的忠诚度。借助餐饮点餐外卖小程序源码,您可以发送个性化优惠、请求评论以提高您的评分并接收有关您的服务的反馈。
5. 更高的客户支出
我们知道,现在有比以往任何时候都更多的客户参与数字产品和服务。当客户在线订购时,订单价值会增加。那是因为学习在线菜单不同于排队。客户有更多时间做出明智的决定。那些有食物不耐受的人可以清楚地阅读所有必要的信息并慢慢来。
6.高度可定制
菜单应用程序是高度可定制的,因此您可以轻松宣传您的徽标、品牌颜色或其他使您的业务与众不同的功能。另外,如果您想在菜单中删除或添加项目,您只需登录,进行更改即可完成!
7. 降低成本
使用卡终端,您会看到一些可能会严重降低您的底线的伴随费用。小型企业的订购系统要便宜得多,因为它都是数字化的,而且在许多情况下,唯一的成本是交易的少量处理费。