Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
d00bf5f
1
Parent(s):
53e9f0b
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -309,7 +309,6 @@ async def get_trip_list(request: Request) -> Response:
|
|
| 309 |
################################## bug choox nay
|
| 310 |
|
| 311 |
if origin_office and dest_office:
|
| 312 |
-
|
| 313 |
## Chưa tìm được
|
| 314 |
trip_by_time_office = dialog_service.get_trip_by_time_and_office_id(data, time, origin_ids, dest_ids)
|
| 315 |
# Nếu có chuyến xe theo thời gian và văn phòng chỉ định
|
|
@@ -322,24 +321,24 @@ async def get_trip_list(request: Request) -> Response:
|
|
| 322 |
}
|
| 323 |
return DialogFlowResponseAPI(parameters=parameters)
|
| 324 |
|
|
|
|
| 325 |
# Danh sách chuyến xe khớp với văn phòng đón hoặc văn phòng trả
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
trip_dialogflow = []
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
"richContent": [
|
| 344 |
[
|
| 345 |
{
|
|
@@ -351,11 +350,11 @@ async def get_trip_list(request: Request) -> Response:
|
|
| 351 |
]
|
| 352 |
]
|
| 353 |
}
|
| 354 |
-
|
| 355 |
"trip_select": trip_dialogflow,
|
| 356 |
"trips": trip_surrounding_time,
|
| 357 |
}
|
| 358 |
-
|
| 359 |
|
| 360 |
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ợ."]
|
| 361 |
payload={
|
|
|
|
| 309 |
################################## bug choox nay
|
| 310 |
|
| 311 |
if origin_office and dest_office:
|
|
|
|
| 312 |
## Chưa tìm được
|
| 313 |
trip_by_time_office = dialog_service.get_trip_by_time_and_office_id(data, time, origin_ids, dest_ids)
|
| 314 |
# Nếu có chuyến xe theo thời gian và văn phòng chỉ định
|
|
|
|
| 321 |
}
|
| 322 |
return DialogFlowResponseAPI(parameters=parameters)
|
| 323 |
|
| 324 |
+
# Nếu không có chuyến xe theo thời gian và văn phòng chỉ định
|
| 325 |
# Danh sách chuyến xe khớp với văn phòng đón hoặc văn phòng trả
|
| 326 |
+
data_by_office = dialog_service.get_all_trip_by_office(data, origin_ids, dest_ids)
|
| 327 |
+
elif origin_office:
|
| 328 |
+
data_by_office = dialog_service.get_all_trip_by_office(data,origin_id=origin_ids)
|
| 329 |
+
elif dest_office:
|
| 330 |
+
data_by_office = dialog_service.get_all_trip_by_office(data, dest_id=dest_ids)
|
| 331 |
+
else:
|
| 332 |
+
data_by_office = data
|
| 333 |
+
# Tìm 4 chuyến xe gần thời gian chỉ định nhất
|
| 334 |
+
trip_surrounding_time = dialog_service.get_4_surrounding_trip(data_by_office, time)
|
| 335 |
+
trip_dialogflow = []
|
|
|
|
| 336 |
|
| 337 |
+
for trip in trip_surrounding_time:
|
| 338 |
+
if ticket_count <= trip["empty_seat_quantity"]:
|
| 339 |
+
trip_dialogflow.append({"trip_id": trip["id"], "route":f'{trip["raw_departure_time"]} | {trip["route"]["origin_hub_name"]} => {trip["route"]["dest_hub_name"]}'})
|
| 340 |
+
text = ["Quý khách vui lòng lựa chọn chuyến xe\n" + "\n".join(f'{i+1}. {trip["route"]}' for i, trip in enumerate(trip_dialogflow))]
|
| 341 |
+
payload={
|
| 342 |
"richContent": [
|
| 343 |
[
|
| 344 |
{
|
|
|
|
| 350 |
]
|
| 351 |
]
|
| 352 |
}
|
| 353 |
+
parameters = {
|
| 354 |
"trip_select": trip_dialogflow,
|
| 355 |
"trips": trip_surrounding_time,
|
| 356 |
}
|
| 357 |
+
return DialogFlowResponseAPI(text=text, payload=payload,parameters=parameters)
|
| 358 |
|
| 359 |
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ợ."]
|
| 360 |
payload={
|