This commit is contained in:
aaron 2025-03-14 23:10:40 +08:00
parent ab57d868b6
commit a67c41817a
3 changed files with 14 additions and 3 deletions

View File

@ -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)

View File

@ -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())

Binary file not shown.