From a67c41817a0d8a8d390fe33f8fbd04820239f65a Mon Sep 17 00:00:00 2001 From: aaron <> Date: Fri, 14 Mar 2025 23:10:40 +0800 Subject: [PATCH] update --- app/api/endpoints/community.py | 13 ++++++++++++- app/models/community.py | 4 ++-- jobs.sqlite | Bin 24576 -> 24576 bytes 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/api/endpoints/community.py b/app/api/endpoints/community.py index 930d3e1..044efa1 100644 --- a/app/api/endpoints/community.py +++ b/app/api/endpoints/community.py @@ -13,7 +13,7 @@ from app.models.community_profit_sharing import CommunityProfitSharing from app.api.endpoints.community_profit_sharing import CommunityProfitSharingResponse from app.core import utils from sqlalchemy import text - +from app.models.community_timeperiod import CommunityTimePeriodDB router = APIRouter() @router.post("", response_model=ResponseModel) @@ -193,6 +193,17 @@ async def update_community( if not db_community: return error_response(code=404, message="社区不存在") + if community.status is not None and community.status == CommunityStatus.OPENING: + # 检查是否设置分润 + existing_profit_sharing = db.query(CommunityProfitSharing).filter(CommunityProfitSharing.community_id == community_id).first() + if not existing_profit_sharing: + return error_response(code=400, message="请先设置分润") + + # 检查是否存在配送时段 + existing_time_periods = db.query(CommunityTimePeriodDB).filter(CommunityTimePeriodDB.community_id == community_id).all() + if not existing_time_periods: + return error_response(code=400, message="请先设置配送时段") + update_data = community.model_dump(exclude_unset=True) for key, value in update_data.items(): setattr(db_community, key, value) diff --git a/app/models/community.py b/app/models/community.py index fd6514e..4e73d75 100644 --- a/app/models/community.py +++ b/app/models/community.py @@ -27,9 +27,9 @@ class CommunityDB(Base): # 小区定价 base_price = Column(DECIMAL(10,2), nullable=False, default=3.0) # 基础费用 - extra_package_price = Column(DECIMAL(10,2), nullable=False, default=1) # 额外包裹费用 + extra_package_price = Column(DECIMAL(10,2), nullable=False, default=1.0) # 额外包裹费用 extra_package_threshold = Column(Integer, nullable=False, default=2) # 额外收费阈值 - more_station_price = Column(DECIMAL(10,2), nullable=False, default=1.0) # 多驿站加价 + more_station_price = Column(DECIMAL(10,2), nullable=False, default=2.0) # 多驿站加价 create_time = Column(DateTime(timezone=True), server_default=func.now()) update_time = Column(DateTime(timezone=True), onupdate=func.now()) diff --git a/jobs.sqlite b/jobs.sqlite index 62d79cb1fb7c51f3b3ed89f5a8a9471ec95ae263..3c26678be24b24aef4f432ecf1649dd821c398bb 100644 GIT binary patch delta 19 acmZoTz}Rqrae_2s??f4A#@>wy3*rGts|QK| delta 19 acmZoTz}Rqrae_2s?L--8#@dYu3*rGsy9X)&