update
This commit is contained in:
parent
94e48983da
commit
2587b307f9
@ -178,22 +178,6 @@ def format_delivery_time(delivery_date: datetime, time_period_name: str) -> str:
|
|||||||
else:
|
else:
|
||||||
return f"{delivery_date.strftime('%m-%d')} {time_period_name}"
|
return f"{delivery_date.strftime('%m-%d')} {time_period_name}"
|
||||||
|
|
||||||
def has_consecutive_weekdays(weekdays):
|
|
||||||
if not weekdays or len(weekdays) <= 1:
|
|
||||||
return True
|
|
||||||
|
|
||||||
days = sorted(weekdays)
|
|
||||||
|
|
||||||
# 处理环绕情况
|
|
||||||
if 1 in days and 7 in days and abs(days.index(1) - days.index(7)) == 1:
|
|
||||||
# 特殊处理周日和周一的连接
|
|
||||||
temp = days.copy()
|
|
||||||
temp.remove(1 if days.index(1) == 0 else 7)
|
|
||||||
return all(temp[i] - temp[i-1] == 1 for i in range(1, len(temp)))
|
|
||||||
|
|
||||||
# 普通情况
|
|
||||||
return all(days[i] - days[i-1] == 1 for i in range(1, len(days)))
|
|
||||||
|
|
||||||
@router.post("/pre-order", response_model=ResponseModel)
|
@router.post("/pre-order", response_model=ResponseModel)
|
||||||
async def pre_order(
|
async def pre_order(
|
||||||
request: OrderPriceCalculateRequest,
|
request: OrderPriceCalculateRequest,
|
||||||
@ -211,9 +195,6 @@ async def pre_order(
|
|||||||
# 检查是否在服务时间
|
# 检查是否在服务时间
|
||||||
if community.weekdays and request.delivery_date:
|
if community.weekdays and request.delivery_date:
|
||||||
if request.delivery_date.isoweekday() not in community.weekdays:
|
if request.delivery_date.isoweekday() not in community.weekdays:
|
||||||
if has_consecutive_weekdays(community.weekdays):
|
|
||||||
message = f"本小区的服务时间为: 周{community.weekdays[0]}-{community.weekdays[-1]}"
|
|
||||||
else:
|
|
||||||
message = f"本小区的服务时间为: "
|
message = f"本小区的服务时间为: "
|
||||||
for day in community.weekdays:
|
for day in community.weekdays:
|
||||||
message += f"周{day}, "
|
message += f"周{day}, "
|
||||||
|
|||||||
BIN
jobs.sqlite
BIN
jobs.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user