OnlyBiggg commited on
Commit
ef9fcc8
·
1 Parent(s): 0fa3b38

add response

Browse files
Files changed (1) hide show
  1. app/api/routes.py +17 -13
app/api/routes.py CHANGED
@@ -80,19 +80,22 @@ async def route(request: Request):
80
  if total > 0:
81
  price = data[0]["price"]
82
  list_raw_departure_times = sorted(list(set([ trip["raw_departure_time"] for trip in data])))
 
 
83
  schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
 
84
  link = f'https://stag.futabus.vn/dat-ve?from={departure_code}&fromTime={date}&isReturn=false&ticketCount={ticket_count}&to={destination_code}&toTime='
85
- text = [f"Lộ trình **{raw_departure_city}** - **{raw_destination_city}**: **{total}** tuyến xe.\n \
86
- Thời gian các tuyến xe khởi hành: {schedule_time_trip}\n \
87
- Giá vé: **{price}** VND.\n \
88
- Quý khách vui lòng truy cập vào [**tại đây**]({link}) để xem chi tiết lịch trình."]
89
  payload = {
90
  "richContent": [
91
  [
92
  {
93
  "type": "chips",
94
  "options": [
95
- {"text": "Đặt "},
96
  {"text": "Xem lịch trình khác"},
97
  {"text": "Không, cảm ơn"}
98
  ]
@@ -103,7 +106,7 @@ async def route(request: Request):
103
 
104
  return DialogFlowResponseAPI(text=text, payload=payload)
105
 
106
- text = [f"Hệ thống không tìm thấy tuyến xe nào phù hợp với lộ trình **{raw_departure_city}** - **{raw_destination_city}** của quý khách.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
107
  payload = {
108
  "richContent": [
109
  [
@@ -149,8 +152,9 @@ async def price(request: Request):
149
  total = respone["data"]["total"]
150
  if total > 0:
151
  price = respone["data"]["items"][0]["price"]
152
- text = [f"Lộ trình **{raw_departure_city}** - **{raw_destination_city}**\n"
153
- f"Giá vé: **{price}** VND.\nBạn có muốn đặt vé không?"
 
154
  ]
155
  payload = {
156
  "richContent": [
@@ -159,7 +163,7 @@ async def price(request: Request):
159
  "type": "chips",
160
  "options": [
161
  {"text": "Có, tôi muốn đặt vé"},
162
- {"text": "Xem giá vé lịch trình khác"},
163
  {"text": "Không, cảm ơn"}
164
  ]
165
  }
@@ -167,7 +171,7 @@ async def price(request: Request):
167
  ]
168
  }
169
  return DialogFlowResponseAPI(text=text, payload=payload)
170
- text = [f"Hệ thống không tìm thấy tuyến xe nào phù hợp với lộ trình **{raw_departure_city}** - **{raw_destination_city}** của quý khách.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
171
  payload={
172
  "richContent": [
173
  [
@@ -218,20 +222,20 @@ async def booking_trip(request: Request) -> Response:
218
  schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
219
  link = f'https://stag.futabus.vn/dat-ve?from={departure_code}&fromTime={date}&isReturn=false&ticketCount={ticket_count}&to={destination_code}&toTime='
220
 
221
- text= [f"Lộ trình **{raw_departure_city}** - **{raw_destination_city}**: **{total}** tuyến xe.\n"
222
  f"Thời gian các tuyến xe khởi hành: {schedule_time_trip}\n"
223
  f"Giá vé: **{price}** VND.\n"
224
  f"Quý khách vui lòng truy cập vào [**tại đây**]({link}) để tiến hành đặt vé."]
225
  return DialogFlowResponseAPI(text=text)
226
 
227
- text = [f"Hệ thống không tìm thấy tuyến xe nào phù hợp với lộ trình **{raw_departure_city}** - **{raw_destination_city}** của quý khách.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
228
  payload={
229
  "richContent": [
230
  [
231
  {
232
  "type": "chips",
233
  "options": [
234
- {"text": "Xem lịch trình khác"},
235
  {"text": "Không, cảm ơn"}
236
  ]
237
  }
 
80
  if total > 0:
81
  price = data[0]["price"]
82
  list_raw_departure_times = sorted(list(set([ trip["raw_departure_time"] for trip in data])))
83
+ list_raw_seat_type = list(set([ trip["seat_type_name"] for trip in data]))
84
+ seat_type_trip_string = "**" + "** | **".join(map(str, list_raw_seat_type)) + "**"
85
  schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
86
+ duration = data[0]["duration"]
87
  link = f'https://stag.futabus.vn/dat-ve?from={departure_code}&fromTime={date}&isReturn=false&ticketCount={ticket_count}&to={destination_code}&toTime='
88
+ text = [f"Tuyến xe **{raw_departure_city}** - **{raw_destination_city}**\n \
89
+ Loại xe: {seat_type_trip_string} \n \
90
+ Thời gian hành trình: {duration} giờ \n \
91
+ Giá vé: **{price}** VND"]
92
  payload = {
93
  "richContent": [
94
  [
95
  {
96
  "type": "chips",
97
  "options": [
98
+ {"text": "Tìm tuyến xe"},
99
  {"text": "Xem lịch trình khác"},
100
  {"text": "Không, cảm ơn"}
101
  ]
 
106
 
107
  return DialogFlowResponseAPI(text=text, payload=payload)
108
 
109
+ text = [f"Hệ thống không tìm thấy tuyến xe **{raw_departure_city}** - **{raw_destination_city}**.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
110
  payload = {
111
  "richContent": [
112
  [
 
152
  total = respone["data"]["total"]
153
  if total > 0:
154
  price = respone["data"]["items"][0]["price"]
155
+ text = [f"Tuyến xe **{raw_departure_city}** - **{raw_destination_city}**\n"
156
+ f"Giá vé: **{price}** VND.\n \
157
+ Bạn có muốn đặt vé không?"
158
  ]
159
  payload = {
160
  "richContent": [
 
163
  "type": "chips",
164
  "options": [
165
  {"text": "Có, tôi muốn đặt vé"},
166
+ {"text": "Xem giá vé tuyến xe khác"},
167
  {"text": "Không, cảm ơn"}
168
  ]
169
  }
 
171
  ]
172
  }
173
  return DialogFlowResponseAPI(text=text, payload=payload)
174
+ text = [f"Hệ thống không tìm thấy tuyến xe **{raw_departure_city}** - **{raw_destination_city}**.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
175
  payload={
176
  "richContent": [
177
  [
 
222
  schedule_time_trip = "**" + "** | **".join(map(str, list_raw_departure_times)) + "**"
223
  link = f'https://stag.futabus.vn/dat-ve?from={departure_code}&fromTime={date}&isReturn=false&ticketCount={ticket_count}&to={destination_code}&toTime='
224
 
225
+ text= [f"Tuyến xe **{raw_departure_city}** - **{raw_destination_city}**: **{total}** chuyến.\n"
226
  f"Thời gian các tuyến xe khởi hành: {schedule_time_trip}\n"
227
  f"Giá vé: **{price}** VND.\n"
228
  f"Quý khách vui lòng truy cập vào [**tại đây**]({link}) để tiến hành đặt vé."]
229
  return DialogFlowResponseAPI(text=text)
230
 
231
+ text = [f"Hệ thống không tìm thấy tuyến xe **{raw_departure_city}** - **{raw_destination_city}**.\n Quý khách vui lòng thử lại với lộ trình khác hoặc liên hệ Trung tâm tổng đài 1900 6067 để được hỗ trợ."]
232
  payload={
233
  "richContent": [
234
  [
235
  {
236
  "type": "chips",
237
  "options": [
238
+ {"text": "Xem chuyến xe khác"},
239
  {"text": "Không, cảm ơn"}
240
  ]
241
  }