Mục lục
Ứng Dụng Đặt Taxi Nội Bài & Đường Dài
Tổng quan ứng dụng
Ứng dụng đặt xe taxi chuyên phục vụ các tuyến:
-
Taxi sân bay Nội Bài (Hà Nội)
-
Taxi đường dài liên tỉnh
-
Tính toán cước phí tự động dựa trên Google Maps API
-
Tích hợp gửi thông báo đặt xe qua Zalo
Tính năng chính
1. Đặt xe taxi
-
Chọn loại xe: 4 chỗ, 7 chỗ, 16 chỗ
-
Nhập điểm đi/đến: Tự động gợi ý địa điểm
-
Tính cước tự động: Dựa trên khoảng cách từ Google Maps
-
Lịch trình: Đặt xe trước theo giờ
2. Tính toán cước phí
-
Kết nối Google Maps API để:
-
Tính khoảng cách chính xác
-
Ước lượng thời gian di chuyển
-
Dự đoán giá cước theo km
-
-
Hiển thị nhiều phương án giá:
-
Giá tiêu chuẩn
-
Giá giờ cao điểm
-
Giá ban đêm
-
3. Tích hợp Zalo
-
Gửi thông báo đặt xe qua Zalo gồm:
-
Thông tin chuyến đi
-
Biển số xe
-
Tài xế
-
Thời gian dự kiến
-
-
Nhận phản hồi từ khách hàng qua Zalo
4. Quản lý tài xế
-
Hệ thống phân bổ chuyến xe thông minh
-
Theo dõi vị trí tài xế thời gian thực
-
Đánh giá chất lượng dịch vụ
Công nghệ sử dụng
-
Frontend: React Native (iOS/Android) hoặc Flutter
-
Backend: Node.js/Express hoặc Django
-
Database: MongoDB/PostgreSQL
-
APIs:
-
Google Maps/Directions API
-
Zalo OA API
-
Payment Gateway (VNPay, Momo)
-
Quy trình hoạt động
-
Khách đặt xe qua app
-
Hệ thống tính toán cước phí
-
Phân bổ tài xế gần nhất
-
Gửi xác nhận qua Zalo
-
Theo dõi hành trình
-
Thanh toán & đánh giá
Bảo mật
-
Xác thực 2 lớp cho tài khoản
-
Mã hóa thông tin giao dịch
-
Ẩn số điện thoại thật của tài xế/kách
Bạn cần tôi phát triển thêm chi tiết phần nào không? Tôi có thể cung cấp thêm thông tin về:
-
Flow chi tiết từng màn hình
-
Cách tích hợp Google Maps API
-
Quy trình kết nối Zalo OA
-
Mô hình tính giá cước
-
Các case study tương tự
Taxi Booking App with Google Maps and Zalo Integration
Here’s a simplified implementation of a taxi booking app with Google Maps distance calculation and Zalo notification features. This example uses React Native for the frontend and Node.js for the backend.
Frontend (React Native)
// App.js import React, { useState } from 'react'; import { View, Text, TextInput, Button, StyleSheet } from 'react-native'; import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete'; const App = () => { const [pickup, setPickup] = useState(''); const [destination, setDestination] = useState(''); const [distance, setDistance] = useState(0); const [price, setPrice] = useState(0); const [phone, setPhone] = useState(''); const calculateFare = async () => { try { // In a real app, you would call your backend API which uses Google Maps API const response = await fetch('http://your-backend-api/calculate-fare', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ origin: pickup, destination: destination, }), }); const data = await response.json(); setDistance(data.distance); setPrice(data.fare); } catch (error) { console.error(error); } }; const bookTaxi = async () => { try { const response = await fetch('http://your-backend-api/book-taxi', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ origin: pickup, destination: destination, distance: distance, fare: price, phone: phone, }), }); const data = await response.json(); alert(`Taxi booked! Zalo confirmation sent to ${phone}`); } catch (error) { console.error(error); } }; return ( <View style={styles.container}> <Text style={styles.title}>Taxi Nội Bài & Đường Dài</Text> <Text>Điểm đón:</Text> <GooglePlacesAutocomplete placeholder="Nhập điểm đón" onPress={(data, details = null) => setPickup(data.description)} query={{ key: 'YOUR_GOOGLE_API_KEY', language: 'vi', components: 'country:vn', }} styles={{ textInput: styles.input, }} /> <Text>Điểm đến:</Text> <GooglePlacesAutocomplete placeholder="Nhập điểm đến" onPress={(data, details = null) => setDestination(data.description)} query={{ key: 'YOUR_GOOGLE_API_KEY', language: 'vi', components: 'country:vn', }} styles={{ textInput: styles.input, }} /> <Text>Số điện thoại:</Text> <TextInput style={styles.input} placeholder="Nhập số điện thoại" value={phone} onChangeText={setPhone} keyboardType="phone-pad" /> <Button title="Tính cước phí" onPress={calculateFare} /> {distance > 0 && ( <View style={styles.result}> <Text>Khoảng cách: {distance} km</Text> <Text>Cước phí: {price.toLocaleString()} VND</Text> <Button title="Đặt xe ngay" onPress={bookTaxi} /> </View> )} </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, padding: 20, }, title: { fontSize: 24, fontWeight: 'bold', marginBottom: 20, textAlign: 'center', }, input: { height: 40, borderColor: 'gray', borderWidth: 1, marginBottom: 10, paddingHorizontal: 10, }, result: { marginTop: 20, padding: 10, backgroundColor: '#f0f0f0', }, }); export default App;
Backend (Node.js)
// server.js const express = require('express'); const axios = require('axios'); const bodyParser = require('body-parser'); const cors = require('cors'); const app = express(); app.use(cors()); app.use(bodyParser.json()); const GOOGLE_API_KEY = 'YOUR_GOOGLE_API_KEY'; const ZALO_OA_TOKEN = 'YOUR_ZALO_OA_TOKEN'; // Fare calculation rates (VND) const FARE_RATES = { BASE_FARE: 10000, PER_KM: 15000, NOI_BAI_SURCHARGE: 20000, }; // Calculate distance and fare using Google Maps API app.post('/calculate-fare', async (req, res) => { try { const { origin, destination } = req.body; // Get distance from Google Maps const response = await axios.get( `https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=${encodeURIComponent(origin)}&destinations=${encodeURIComponent(destination)}&key=${GOOGLE_API_KEY}` ); const distance = response.data.rows[0].elements[0].distance.value / 1000; // in km const duration = response.data.rows[0].elements[0].duration.text; // Calculate fare let fare = FARE_RATES.BASE_FARE + (distance * FARE_RATES.PER_KM); // Add surcharge for Noi Bai airport if (origin.includes('Nội Bài') || destination.includes('Nội Bài')) { fare += FARE_RATES.NOI_BAI_SURCHARGE; } res.json({ distance: distance.toFixed(1), duration, fare: Math.round(fare), }); } catch (error) { console.error(error); res.status(500).json({ error: 'Failed to calculate fare' }); } }); // Book taxi and send Zalo notification app.post('/book-taxi', async (req, res) => { try { const { origin, destination, distance, fare, phone } = req.body; // In a real app, you would save this booking to a database const bookingId = `TAXI-${Date.now()}`; // Send Zalo notification await sendZaloNotification(phone, bookingId, origin, destination, distance, fare); res.json({ success: true, bookingId, message: 'Taxi booked successfully', }); } catch (error) { console.error(error); res.status(500).json({ error: 'Failed to book taxi' }); } }); // Function to send Zalo notification async function sendZaloNotification(phone, bookingId, origin, destination, distance, fare) { try { // Format phone number (remove +84 or 0 prefix) let formattedPhone = phone.replace(/^\+84|^0/, ''); if (formattedPhone.length === 9) formattedPhone = `84${formattedPhone}`; const message = `✅ Đặt xe thành công! Mã đơn: ${bookingId} Điểm đón: ${origin} Điểm đến: ${destination} Khoảng cách: ${distance} km Cước phí: ${fare.toLocaleString()} VND Tài xế sẽ liên hệ với bạn trong ít phút.`; // Send via Zalo OA API const response = await axios.post( 'https://openapi.zalo.me/v2.0/oa/message', { recipient: { user_id: formattedPhone, }, message: { text: message, }, }, { headers: { 'access_token': ZALO_OA_TOKEN, 'Content-Type': 'application/json', }, } ); return response.data; } catch (error) { console.error('Zalo notification failed:', error.response?.data || error.message); throw error; } } const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });
Setup Instructions
-
Frontend Setup:
-
Install React Native environment
-
Install required packages:
npm install react-native-google-places-autocomplete axios
-
Replace
YOUR_GOOGLE_API_KEY
with your actual Google Maps API key
-
-
Backend Setup:
-
Install Node.js and required packages:
npm install express axios body-parser cors
-
Replace
YOUR_GOOGLE_API_KEY
andYOUR_ZALO_OA_TOKEN
with your actual keys -
Start the server:
node server.js
-
-
Zalo OA Setup:
-
Register for a Zalo Official Account (OA)
-
Get your OA token from Zalo Developer Console
-
Enable messaging permissions
-
-
Google Maps API:
-
Enable Distance Matrix API and Places API
-
Set up billing (these APIs are not free for commercial use)
-
Features Not Included (For Production)
-
Driver Management System:
-
Real-time driver tracking
-
Driver assignment algorithm
-
-
Payment Integration:
-
VNPay, Momo, or ZaloPay integration
-
-
Advanced Features:
-
Booking history
-
User authentication
-
Rating system
-
Promo codes
-
-
Database Integration:
-
MongoDB/PostgreSQL for storing bookings
-
Would you like me to expand on any particular aspect of this implementation?