update
This commit is contained in:
parent
d45ea0a48f
commit
69e16d04c1
@ -50,6 +50,8 @@ from app.models.community_timeperiod import CommunityTimePeriodDB
|
|||||||
from app.models.community_profit_sharing import CommunityProfitSharing
|
from app.models.community_profit_sharing import CommunityProfitSharing
|
||||||
from app.core.qcloud import QCloudManager
|
from app.core.qcloud import QCloudManager
|
||||||
from app.core.wechat import WeChatClient
|
from app.core.wechat import WeChatClient
|
||||||
|
from app.models.community import CommunityStatus
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
def calculate_price(price_request: OrderPriceCalculateRequest,user: UserDB,db: Session) -> OrderPriceResult:
|
def calculate_price(price_request: OrderPriceCalculateRequest,user: UserDB,db: Session) -> OrderPriceResult:
|
||||||
@ -208,27 +210,28 @@ async def pre_order(
|
|||||||
if request.delivery_date and request.delivery_date < datetime.now().date():
|
if request.delivery_date and request.delivery_date < datetime.now().date():
|
||||||
return error_response(code=400, message="配送日期不能选择过去的时间")
|
return error_response(code=400, message="配送日期不能选择过去的时间")
|
||||||
|
|
||||||
# 检查是否在服务时间
|
|
||||||
community = db.query(CommunityDB).filter(
|
community = db.query(CommunityDB).filter(
|
||||||
CommunityDB.id == request.community_id
|
CommunityDB.id == request.community_id
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if community:
|
# 检查是否在服务时间
|
||||||
# 检查是否在服务时间
|
if community and community.status != CommunityStatus.OPENING:
|
||||||
if community.weekdays and request.delivery_date:
|
return error_response(code=400, message="服务暂未开放")
|
||||||
if request.delivery_date.isoweekday() not in community.weekdays:
|
|
||||||
|
|
||||||
#排序
|
# 检查是否在服务时间
|
||||||
sorted_weekdays = sorted(community.weekdays)
|
if community and community.weekdays and request.delivery_date:
|
||||||
|
if request.delivery_date.isoweekday() not in community.weekdays:
|
||||||
|
#排序
|
||||||
|
sorted_weekdays = sorted(community.weekdays)
|
||||||
|
|
||||||
if has_consecutive_weekdays(sorted_weekdays):
|
if has_consecutive_weekdays(sorted_weekdays):
|
||||||
message = f"服务时间为: 周{sorted_weekdays[0]}-{sorted_weekdays[-1]}"
|
message = f"服务时间为: 周{sorted_weekdays[0]}-{sorted_weekdays[-1]}"
|
||||||
else:
|
else:
|
||||||
message = f"服务时间为: "
|
message = f"服务时间为: "
|
||||||
for day in sorted_weekdays:
|
for day in sorted_weekdays:
|
||||||
message += f"周{day}, "
|
message += f"周{day}, "
|
||||||
message = message[:-2]
|
message = message[:-2]
|
||||||
return error_response(code=400, message=message)
|
return error_response(code=400, message=message)
|
||||||
|
|
||||||
# 检查是否有未支付的订单
|
# 检查是否有未支付的订单
|
||||||
unpay_order = db.query(ShippingOrderDB).filter(
|
unpay_order = db.query(ShippingOrderDB).filter(
|
||||||
|
|||||||
BIN
jobs.sqlite
BIN
jobs.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user