update
This commit is contained in:
parent
bd39472624
commit
aae96d1a6e
@ -15,15 +15,15 @@ router = APIRouter()
|
||||
# 请求和响应模型
|
||||
class CommunitySetCreate(BaseModel):
|
||||
set_name: str = Field(..., min_length=1, max_length=100, description="集合名称")
|
||||
user_id: int = Field(..., description="用户ID")
|
||||
user_id: Optional[int] = Field(None, description="用户ID")
|
||||
class CommunitySetUpdate(BaseModel):
|
||||
set_name: str = Field(..., min_length=1, max_length=100, description="集合名称")
|
||||
user_id: int = Field(..., description="用户ID")
|
||||
user_id: Optional[int] = Field(None, description="用户ID")
|
||||
|
||||
class CommunitySetInfo(BaseModel):
|
||||
id: int
|
||||
set_name: str
|
||||
user_id: int
|
||||
user_id: Optional[int] = None
|
||||
create_time: datetime
|
||||
update_time: datetime
|
||||
user_name: Optional[str] = None
|
||||
@ -101,7 +101,7 @@ async def get_all_community_sets(
|
||||
"""管理员获取所有社区集合"""
|
||||
|
||||
# 获取所有社区集合, join 社区名字和 用户名字
|
||||
sets = db.query(CommunitySet, UserDB.nickname.label("user_name")).join(UserDB, CommunitySet.user_id == UserDB.userid).offset(skip).limit(limit).all()
|
||||
sets = db.query(CommunitySet, UserDB.nickname.label("user_name")).outerjoin(UserDB, CommunitySet.user_id == UserDB.userid).offset(skip).limit(limit).all()
|
||||
|
||||
results = []
|
||||
for set in sets:
|
||||
|
||||
@ -19,6 +19,7 @@ from app.core.config import settings
|
||||
from app.core.qcloud import qcloud_manager
|
||||
from fastapi import BackgroundTasks
|
||||
from app.core.mpmessage import sent_order_status_change_message
|
||||
from app.api.endpoints.order import calculate_delivery_share
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@ -163,6 +164,13 @@ async def accept_additional_fee(
|
||||
if order:
|
||||
order.additional_fee_amount += float(fee_request.additional_fee_amount)
|
||||
order.final_amount += float(fee_request.additional_fee_amount)
|
||||
|
||||
# 重新计算配送员配送费用
|
||||
deliveryman = db.query(UserDB).filter(
|
||||
UserDB.userid == order.deliveryman_user_id
|
||||
).first()
|
||||
if deliveryman:
|
||||
order.delivery_share = calculate_delivery_share(order, deliveryman)
|
||||
|
||||
try:
|
||||
db.commit()
|
||||
|
||||
@ -9,6 +9,6 @@ class CommunitySet(Base):
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
set_name = Column(String(100), nullable=False, comment="集合名称")
|
||||
user_id = Column(Integer, ForeignKey("users.userid"), nullable=False, comment="创建用户ID")
|
||||
user_id = Column(Integer, nullable=True, comment="创建用户ID")
|
||||
create_time = Column(DateTime, default=datetime.datetime.now, comment="创建时间")
|
||||
update_time = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment="更新时间")
|
||||
Loading…
Reference in New Issue
Block a user