Spaces:
Sleeping
Sleeping
OnlyBiggg
commited on
Commit
·
1c16907
1
Parent(s):
377b8bd
fix
Browse files
app/dialogflow/api/v1/dialogflow.py
CHANGED
|
@@ -62,16 +62,16 @@ async def confirm(request: Request):
|
|
| 62 |
ticket_number = int(raw_ticket_number) if raw_ticket_number else 1
|
| 63 |
date = dialog_service.to_datetime_from_Dialogflow(raw_date)
|
| 64 |
date, week_day = get_weekday_name(date)
|
| 65 |
-
text = [f"""Ngày
|
| 66 |
temp = ""
|
| 67 |
if origin_office and dest_office:
|
| 68 |
-
temp = f"""
|
| 69 |
elif origin_office and destination_city:
|
| 70 |
-
temp = f"""
|
| 71 |
elif dest_office and departure_city:
|
| 72 |
-
temp = f"""
|
| 73 |
elif departure_city and destination_city:
|
| 74 |
-
temp = f"""
|
| 75 |
text[0] = temp + text[0]
|
| 76 |
payload = {
|
| 77 |
"richContent": [
|
|
@@ -473,7 +473,7 @@ async def is_valid_select_time(request: Request) -> Response:
|
|
| 473 |
"departure_date": departure_date,
|
| 474 |
"trip": trip,
|
| 475 |
}
|
| 476 |
-
text = [f' Quý khách chọn chuyến {time_select} | {route_name}']
|
| 477 |
return DialogFlowResponseAPI(text=text, parameters=parameters)
|
| 478 |
|
| 479 |
parameters = {
|
|
@@ -547,13 +547,13 @@ async def is_valid_select_seat(request: Request) -> Response:
|
|
| 547 |
"is_valid_seat": True,
|
| 548 |
"seat": seat
|
| 549 |
}
|
| 550 |
-
text = [f"Quý khách chọn ghế {seat}"]
|
| 551 |
else:
|
| 552 |
parameters = {
|
| 553 |
"is_valid_seat": False,
|
| 554 |
"seat": None
|
| 555 |
}
|
| 556 |
-
text = [f"Ghế {seat} đã được đặt. Quý khách vui lòng chọn ghế khác"]
|
| 557 |
return DialogFlowResponseAPI(text=text, parameters=parameters)
|
| 558 |
|
| 559 |
except Exception as e:
|
|
@@ -610,7 +610,7 @@ async def is_valid_select_pickup(request: Request) -> Response:
|
|
| 610 |
"is_valid_pickup": True,
|
| 611 |
"pick_up": pickup
|
| 612 |
}
|
| 613 |
-
text = [f"Quý khách chọn điểm đón {pickup}"]
|
| 614 |
else:
|
| 615 |
parameters = {
|
| 616 |
"is_valid_pickup": False,
|
|
@@ -670,7 +670,7 @@ async def is_valid_select_dropoff(request: Request) -> Response:
|
|
| 670 |
"is_valid_dropoff": True,
|
| 671 |
"drop_off": dropoff
|
| 672 |
}
|
| 673 |
-
text = [f"Quý khách chọn điểm trả khách {dropoff}"]
|
| 674 |
else:
|
| 675 |
parameters = {
|
| 676 |
"is_valid_dropoff": False,
|
|
@@ -702,20 +702,18 @@ async def response_ticket_info(request: Request) -> Response:
|
|
| 702 |
|
| 703 |
text = [
|
| 704 |
f" \
|
| 705 |
-
**Thông tin hành khách**\
|
| 706 |
-
\n\
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
**
|
| 712 |
-
\n\
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
Điểm trả khách {dropoff} \
|
| 718 |
-
Tổng tiền lượt đi {price} VND \
|
| 719 |
"
|
| 720 |
]
|
| 721 |
|
|
|
|
| 62 |
ticket_number = int(raw_ticket_number) if raw_ticket_number else 1
|
| 63 |
date = dialog_service.to_datetime_from_Dialogflow(raw_date)
|
| 64 |
date, week_day = get_weekday_name(date)
|
| 65 |
+
text = [f"""**Ngày:** {date} {week_day}\n**Số vé:** {ticket_number}"""]
|
| 66 |
temp = ""
|
| 67 |
if origin_office and dest_office:
|
| 68 |
+
temp = f"""**Điểm đi:** {origin_office}\n**Điểm đến:** {dest_office}\n"""
|
| 69 |
elif origin_office and destination_city:
|
| 70 |
+
temp = f"""**Điểm đi:** {origin_office}\n**Điểm đến:** {destination_city}\n"""
|
| 71 |
elif dest_office and departure_city:
|
| 72 |
+
temp = f"""**Điểm đi:** {departure_city}\n**Điểm đến:** {dest_office}\n"""
|
| 73 |
elif departure_city and destination_city:
|
| 74 |
+
temp = f"""**Điểm đi:** {departure_city}\n**Điểm đến:** {destination_city}\n"""
|
| 75 |
text[0] = temp + text[0]
|
| 76 |
payload = {
|
| 77 |
"richContent": [
|
|
|
|
| 473 |
"departure_date": departure_date,
|
| 474 |
"trip": trip,
|
| 475 |
}
|
| 476 |
+
text = [f' Quý khách chọn chuyến **{time_select}** | **{route_name}**']
|
| 477 |
return DialogFlowResponseAPI(text=text, parameters=parameters)
|
| 478 |
|
| 479 |
parameters = {
|
|
|
|
| 547 |
"is_valid_seat": True,
|
| 548 |
"seat": seat
|
| 549 |
}
|
| 550 |
+
text = [f"Quý khách chọn ghế **{seat}**"]
|
| 551 |
else:
|
| 552 |
parameters = {
|
| 553 |
"is_valid_seat": False,
|
| 554 |
"seat": None
|
| 555 |
}
|
| 556 |
+
text = [f"Ghế **{seat}** đã được đặt. Quý khách vui lòng chọn ghế khác"]
|
| 557 |
return DialogFlowResponseAPI(text=text, parameters=parameters)
|
| 558 |
|
| 559 |
except Exception as e:
|
|
|
|
| 610 |
"is_valid_pickup": True,
|
| 611 |
"pick_up": pickup
|
| 612 |
}
|
| 613 |
+
text = [f"Quý khách chọn điểm đón **{pickup}**"]
|
| 614 |
else:
|
| 615 |
parameters = {
|
| 616 |
"is_valid_pickup": False,
|
|
|
|
| 670 |
"is_valid_dropoff": True,
|
| 671 |
"drop_off": dropoff
|
| 672 |
}
|
| 673 |
+
text = [f"Quý khách chọn điểm trả khách **{dropoff}**"]
|
| 674 |
else:
|
| 675 |
parameters = {
|
| 676 |
"is_valid_dropoff": False,
|
|
|
|
| 702 |
|
| 703 |
text = [
|
| 704 |
f" \
|
| 705 |
+
**Thông tin hành khách**\n\
|
| 706 |
+
**Họ và tên** {user_name} \n\
|
| 707 |
+
**Số điện thoại** {phone_number}\n \
|
| 708 |
+
**Email** {email} \n\
|
| 709 |
+
\n\n\
|
| 710 |
+
**Thông tin lượt đi**\n\
|
| 711 |
+
**Tuyến xe** {route_name} \n\
|
| 712 |
+
**Thời gian xuất bến** {time} {date} \n\
|
| 713 |
+
**Số ghế** {seat} \n\
|
| 714 |
+
**Điểm lên xe** {pickup} \n\
|
| 715 |
+
**Điểm trả khách** {dropoff} \n \
|
| 716 |
+
**Tổng tiền lượt đi** {price} VND \
|
|
|
|
|
|
|
| 717 |
"
|
| 718 |
]
|
| 719 |
|