当前位置:   article > 正文

餐饮点餐外卖小程序源码(外卖订餐系统源码)

外卖小程序源码

  使用餐饮点餐外卖小程序源码,您可以建立一个系统,让您的餐厅或咖啡馆可以远程接受订单并接受付款 - 在线和面对面。有了这个系统,客户只需通过移动订购访问菜单。这可以通过扫描二维码或在搜索栏中输入链接来完成。一旦您的客户做出选择,他们就会提交订单并一次性付款。一旦在餐厅端收到订单,剩下的就是将订单带到客户的餐桌上或打包准备交付。这大大加快了整个在线订购过程。一切都通过智能手机进行,而不是与员工不断来回进行。
  
  餐饮点餐外卖小程序源码开发环境
  
  演示: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用于在微服务之间进行通信。
  
  餐厅服务
  
  按名称搜索餐厅

  1.   GET localhost:8001/api/restaurants?name=<restaurant_name>
  2. Return
  3. {
  4. "id": <restaurant_id>,
  5. "name": <restaurant_name>
  6. }

  创建餐厅

  1. POST localhost:8001/api/restaurants
  2. Request Body
  3. {
  4. "name": <restaurant_name>
  5. }
  6. Return HttpStatus.CREATED

  通过餐厅 id 获取所有菜单项

  1. GET localhost:8001/api/restaurants/{restaurantId}/menuItems
  2. Return
  3. [
  4. {
  5. "id": <menu_item_id>,
  6. "restaurantId": <restaurantId>,
  7. "name": <menu_item_name>,
  8. "description": <menu_item_description>,
  9. "price": <menu_item_price>
  10. },
  11. ...
  12. ]  

  创建菜单项 

  1. POST localhost:8001/api/restaurants/{restaurantId>/menuItems
  2. Request Body
  3. {
  4. "restaurantId": <restaurantId>,
  5. "name": <menu_item_name>,
  6. "description": <menu_item_description>,
  7. "price": <menu_item_price>
  8. }
  9. Return HttpStatus.CREATED

  批量上传菜单项

  1. POST localhost:8001/api/restaurants/bulk/menuItems
  2. Request Body
  3. [
  4. {
  5. "restaurantId": <restaurantId>,
  6. "name": <menu_item_name>,
  7. "description": <menu_item_description>,
  8. "price": <menu_item_price>
  9. }
  10. ]
  11. Return HttpStatus.CREATED

  订购服务
  
  创建订单 

  1. POST localhost:8002/api/restaurants/{rid}/orders
  2. {
  3. "restaurantId": <restaurant_id>,
  4. "items":
  5. [
  6. {
  7. "name": <menu_item_name>,
  8. "price": <menu_item_price>,
  9. "quantity": <# of items>
  10. },
  11. ...
  12. ],
  13. "userInfo":
  14. {
  15. "firstName": <customer_first_name>,
  16. "lastName": <customer_last_name>,
  17. "phone": <customer_phone>,
  18. "address": <customer_address>
  19. },
  20. "specialNote": <special_note>
  21. }
  22. Return:
  23. HttpStatus.CREATED
  24. {
  25. "id": <order_id>,
  26. "restaurantId": <restaurant_id>,
  27. "items":
  28. [
  29. {
  30. "name": <menu_item_name>,
  31. "price": <menu_item_price>,
  32. "quantity": <# of items>
  33. },
  34. ...
  35. ],
  36. "userInfo":
  37. {
  38. "firstName": <customer_first_name>,
  39. "lastName": <customer_last_name>,
  40. "phone": <customer_phone>,
  41. "address": <customer_address>
  42. },
  43. "specialNote": <special_note>,
  44. "totalPrice": <total_price>,
  45. "orderTime": <order_time_in_milliseconds>
  46. }  

  支付分发服务
  
  付款分配 

  1. POST localhost:8003/api/payments
  2. {
  3. "orderId": <order_id>,
  4. "amount": <payment_amount>,
  5. "creditCardInfo":
  6. {
  7. "firstName": <first_name>,
  8. "lastName": <lastName>,
  9. "expiredMonth": <month>,
  10. "expiredYear": <year>,
  11. "securityCode": <security_code>
  12. }
  13. }
  14. 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.

  支付服务
  
  处理付款 

  1. POST localhost:8004/api/payments
  2. {
  3. "orderId": <order_id>,
  4. "amount": <payment_amount>,
  5. "creditCardInfo":
  6. {
  7. "firstName": <first_name>,
  8. "lastName": <lastName>,
  9. "expiredMonth": <month>,
  10. "expiredYear": <year>,
  11. "securityCode": <security_code>
  12. }
  13. }
  14. Return
  15. HttpStatus.CREATED
  16. Note: **Hystrix** fallbackMethod is added in case processPayment() fails.
  17. 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. 

  订购完整的更新程序服务
  
  订单完成  

  1. POST localhost:8005/api/orders
  2. {
  3. "id": <order_id>,
  4. "items":
  5. [
  6. {
  7. "name": <menu_item_name>,
  8. "price": <menu_item_price>,
  9. "quantity": <# of items>
  10. },
  11. ...
  12. ],
  13. "userInfo":
  14. {
  15. "firstName": <customer_first_name>,
  16. "lastName": <customer_last_name>,
  17. "phone": <customer_phone>,
  18. "address": <customer_address>
  19. },
  20. "specialNote": <special_note>,
  21. "totalPrice": <total_order_price>,
  22. "orderTime": <order_time>,
  23. "deliveryTime": <food_delivery_time>,
  24. "paymentId": <payment_id>
  25. }
  26. 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 命令。  

  1. docker exec -it 9cd bash
  2. # mongo // open mongo shell
  3. > use test // Spring boot use test db as default
  4. > show collections // show all collections inside test db
  5. > db.restaurant.find().pretty() // show all data inside restaurant table
  6. > exit // quit mongo shell
  7. > 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

  上传测试菜单项

  1. cd restaurant-service
  2. sh ./upload-menu-items.sh
  3. Note: default restaurant id for testing: "11111111-1111-1111-11111111111111111".

  通过 HAL 浏览器探索

  1. http://localhost:8001/browser/index.html
  2. port: 8001 can be changed for different services.

  调查 Eureka 中的注册服务

http://localhost:8761

  调查 RabbitMQ 中的消息队列

  1. http://localhost:15762
  2. Go to Queues -> binder.payments

  结帐应用程序指标

  1. http://localhost:8005/health
  2. http://localhost:8005/env
  3. http://localhost:8005/metrics
  4. http://localhost:8005/mappings
  5. Note: 8005 can be changed for different services. 

  使用 PostMan 测试工作流程
  
  创建订单 

  1. POST localhost:8002/api/restaurants/11111111-1111-1111-11111111111111111/orders
  2. {
  3. "restaurantId": "11111111-1111-1111-11111111111111111",
  4. "items": [
  5. {
  6. "name": "menuItem 1",
  7. "price": 11,
  8. "quantity": 2
  9. },
  10. {
  11. "name": "menuItem 2",
  12. "price": 12,
  13. "quantity": 3
  14. }
  15. ],
  16. "userInfo": {
  17. "firstName": "first1",
  18. "lastName": "last1",
  19. "phone": "14081234567",
  20. "address": "123 stree1 ave, San Jose, CA 95123"
  21. }
  22. }
  23. Returns:
  24. Returns:
  25. {
  26. "id": "5903e81327b884525eb9a5be",
  27. ...
  28. "totalPrice": 58,
  29. ...
  30. }

  发布订单付款

  1. POST localhost:8003/api/payments
  2. {
  3. "amount": 58,
  4. "orderId": "5903e81327b884525eb9a5be",
  5. "creditCardInfo": {
  6. "firstName": "first 1",
  7. "lastName": "last 1",
  8. "expiredMonth": "02",
  9. "expiredYear": "2019",
  10. "securityCode": "231"
  11. }
  12. }  

  检查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 的消息:

  1. localhost:8005
  2. Click on "Subscribe to Order Complete Updates" to subscribe the channel.
  3. Click on "Send Test Message" to send out the test JSON object. 

  查看在底部文本框中收到的消息。 

  1. Subscribed to /topic/orders
  2. sendMessage triggered
  3. {
  4. "id": "5903e81327b884525eb9a5be",
  5. "restaurantId": "11111111-1111-1111-11111111111111111",
  6. "items": [
  7. {
  8. "name": "menuItem 1",
  9. "price": 11,
  10. "quantity": 2
  11. },
  12. {
  13. "name": "menuItem 2",
  14. "price": 12,
  15. "quantity": 3
  16. }
  17. "totalPrice": 58,
  18. "orderTime": 1493428243933,
  19. "specialNote": "",
  20. "deliveryTime": 1493486808730,
  21. "paymentId": "",
  22. "userInfo": {
  23. "id": "",
  24. "firstName": "first1",
  25. "lastName": "last1",
  26. "phone": "14081234567",
  27. "address": "123 stree1 ave, San Jose, CA 95123"
  28. }
  29. }  

  测试回退
  
  打开 Hystrix 仪表板

localhost:7979

  监控订单完成更新程序  

http://localhost:8004/hystrix.stream

  停止订单完成更新程序。将付款过帐到付款服务。 错误率从 0.0 跃升至 100%。在日志中查看来自回退方法的错误消息。一次又一次地发布相同的付款,最终,看到电路状态从“关闭”变为“打开”。
  
  餐饮点餐外卖小程序源码特征
  
  用户可以根据餐厅名称搜索餐厅。
  
  用户可以通过选择不同的菜单项、数量和添加关于他/她的饮食限制等的注释来订购食物。
  
  用户可以填写收货地址。
  
  用户下单后,订单应包含用户订购的食品、数量、价格和订购时间。
  
  用户需要通过提供信用卡号、有效期和安全码来支付他/她的订单。
  
  支付成功后,返回支付ID,timesatmp,然后订单被认为完成,用户可以看到预计的交货时间。
  
  预计交货时间为 5 分钟至 1 小时之间的随机时间。  


  餐饮点餐外卖小程序源码好处
  
  1. 更安全、更健康
  
  要重新开业,食品企业需要开设一家商店以满足健康和安全法规。业主必须保持社交距离,使用非接触式订购/付款方式,并确保定期清洁表面。
  
  即使您经营一家小商店,保持社交距离也不必感到压力。转向企业在线订购网站意味着走进的新客户可以在店外或店内餐桌上订购和付款。
  
  2. 犯错的空间更小
  
  餐饮点餐外卖小程序源码的优势之一是它可以确保价格准确,并且在结账时出错的空间更小。这是因为顾客需要亲自从菜单上选择相应价格的商品,以确保始终支付正确的金额。这对您的业务有一些好处。错误收费的可能性更小,清理错误所浪费的时间更少,为安抚客户而发放的免费产品也更少!
  
  3. 更多客户
  
  随着社交距离的继续,在线订购和支付正变得越来越被接受和期待。如果您的菜单和支付系统没有任何麻烦,您的老客户就会将您推荐给他们的朋友,并在社交媒体上分享。只需提供无缝的客户体验,将订单实时发送到后端团队,您就可以增加客户和利润。
  
  4. 提高客户忠诚度
  
  如果您给他们一个继续回来的理由,客户会选择您的商店而不是竞争对手的商店。伟大的产品可能就是这个原因,但您也可以通过订购应用程序上的奖励计划来鼓励他们的忠诚度。借助餐饮点餐外卖小程序源码,您可以发送个性化优惠、请求评论以提高您的评分并接收有关您的服务的反馈。
  
  5. 更高的客户支出
  
  我们知道,现在有比以往任何时候都更多的客户参与数字产品和服务。当客户在线订购时,订单价值会增加。那是因为学习在线菜单不同于排队。客户有更多时间做出明智的决定。那些有食物不耐受的人可以清楚地阅读所有必要的信息并慢慢来。
  
  6.高度可定制
  
  菜单应用程序是高度可定制的,因此您可以轻松宣传您的徽标、品牌颜色或其他使您的业务与众不同的功能。另外,如果您想在菜单中删除或添加项目,您只需登录,进行更改即可完成!
  
  7. 降低成本
  
  使用卡终端,您会看到一些可能会严重降低您的底线的伴随费用。小型企业的订购系统要便宜得多,因为它都是数字化的,而且在许多情况下,唯一的成本是交易的少量处理费。

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/565148
推荐阅读
相关标签
  

闽ICP备14008679号