使用餐饮点餐外卖小程序源码,您可以建立一个系统,让您的餐厅或咖啡馆可以远程接受订单并接受付款 - 在线和面对面。有了这个系统,客户只需通过移动订购访问菜单。这可以通过扫描二维码或在搜索栏中输入链接来完成。一旦您的客户做出选择,他们就会提交订单并一次性付款。一旦在餐厅端收到订单,剩下的就是将订单带到客户的餐桌上或打包准备交付。这大大加快了整个在线订购过程。一切都通过智能手机进行,而不是与员工不断来回进行。
餐饮点餐外卖小程序源码开发环境
演示: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=<restaurant_name>
Return
{
"id": <restaurant_id>,
"name": <restaurant_name>
}
创建餐厅
POST localhost:8001/api/restaurants
Request Body
{
"name": <restaurant_name>
}
Return HttpStatus.CREATED
通过餐厅 id 获取所有菜单项
GET localhost:8001/api/restaurants/{restaurantId}/menuItems
Return
[
{
"id": <menu_item_id>,
"restaurantId": <restaurantId>,
"name": <menu_item_name>,
"description": <menu_item_description>,
"price": <menu_item_price>
},
...
]
创建菜单项
POST localhost:8001/api/restaurants/{restaurantId>/menuItems
Request Body
{
"restaurantId": <restaurantId>,
"name": <menu_item_name>,
"description": <menu_item_description>,
"price": <menu_item_price>
}
Return HttpStatus.CREATED
批量上传菜单项
POST localhost:8001/api/restaurants/bulk/menuItems
Request Body
[
{
"restaurantId": <restaurantId>,
"name": <menu_item_name>,
"description": <menu_item_description>,
"price": <menu_item_price>
}
]
Return HttpStatus.CREATED
订购服务
创建订单
POST localhost:8002/api/restaurants/{rid}/orders
{
"restaurantId": <restaurant_id>,
"items":
[
{
"name": <menu_item_name>,
"price": <menu_item_price>,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": <customer_first_name>,
"lastName": <customer_last_name>,
"phone": <customer_phone>,
"address": <customer_address>
},
"specialNote": <special_note>
}
Return:
HttpStatus.CREATED
{
"id": <order_id>,
"restaurantId": <restaurant_id>,
"items":
[
{
"name": <menu_item_name>,
"price": <menu_item_price>,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": <customer_first_name>,
"lastName": <customer_last_name>,
"phone": <customer_phone>,
"address": <customer_address>
},
"specialNote": <special_note>,
"totalPrice": <total_price>,
"orderTime": <order_time_in_milliseconds>
}
支付分发服务
付款分配
POST localhost:8003/api/payments
{
"orderId": <order_id>,
"amount": <payment_amount>,
"creditCardInfo":
{
"firstName": <first_name>,
"lastName": <lastName>,
"expiredMonth": <month>,
"expiredYear": <year>,
"securityCode": <security_code>
}
}
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": <order_id>,
"amount": <payment_amount>,
"creditCardInfo":
{
"firstName": <first_name>,
"lastName": <lastName>,
"expiredMonth": <month>,
"expiredYear": <year>,
"securityCode": <security_code>
}
}
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": <order_id>,
"items":
[
{
"name": <menu_item_name>,
"price": <menu_item_price>,
"quantity": <# of items>
},
...
],
"userInfo":
{
"firstName": <customer_first_name>,
"lastName": <customer_last_name>,
"phone": <customer_phone>,
"address": <customer_address>
},
"specialNote": <special_note>,
"totalPrice": <total_order_price>,
"orderTime": <order_time>,
"deliveryTime": <food_delivery_time>,
"paymentId": <payment_id>
}
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. 降低成本
使用卡终端,您会看到一些可能会严重降低您的底线的伴随费用。小型企业的订购系统要便宜得多,因为它都是数字化的,而且在许多情况下,唯一的成本是交易的少量处理费。
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr
我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R
如何检查Ruby文件是否是通过“require”或“load”导入的,而不是简单地从命令行执行的?例如:foo.rb的内容:puts"Hello"bar.rb的内容require'foo'输出:$./foo.rbHello$./bar.rbHello基本上,我想调用bar.rb以不执行puts调用。 最佳答案 将foo.rb改为:if__FILE__==$0puts"Hello"end检查__FILE__-当前ruby文件的名称-与$0-正在运行的脚本的名称。 关于ruby-检查是否
是否可以在应用程序中包含的gem代码中知道应用程序的Rails文件系统根目录?这是gem来源的示例:moduleMyGemdefself.included(base)putsRails.root#returnnilendendActionController::Base.send:include,MyGem谢谢,抱歉我的英语不好 最佳答案 我发现解决类似问题的解决方案是使用railtie初始化程序包含我的模块。所以,在你的/lib/mygem/railtie.rbmoduleMyGemclassRailtie使用此代码,您的模块将在
前言作为一名程序员,自己的本质工作就是做程序开发,那么程序开发的时候最直接的体现就是代码,检验一个程序员技术水平的一个核心环节就是开发时候的代码能力。众所周知,程序开发的水平提升是一个循序渐进的过程,每一位程序员都是从“菜鸟”变成“大神”的,所以程序员在程序开发过程中的代码能力也是根据平时开发中的业务实践来积累和提升的。提高代码能力核心要素程序员要想提高自身代码能力,尤其是新晋程序员的代码能力有很大的提升空间的时候,需要针对性的去提高自己的代码能力。提高代码能力其实有几个比较关键的点,只要把握住这些方面,就能很好的、快速的提高自己的一部分代码能力。1、多去阅读开源项目,如有机会可以亲自参与开源