update
This commit is contained in:
parent
3e683e9708
commit
80ce826884
@ -25,6 +25,38 @@ async def create_community(
|
||||
db.refresh(db_community)
|
||||
return success_response(data=CommunityInfo.model_validate(db_community))
|
||||
|
||||
@router.get("/{community_id}/qrcode", response_model=ResponseModel)
|
||||
async def get_community_qrcode(
|
||||
community_id: int,
|
||||
latitude: Optional[float] = None,
|
||||
longitude: Optional[float] = None,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""获取社区二维码"""
|
||||
community = db.query(CommunityDB).filter(CommunityDB.id == community_id).first()
|
||||
if not community:
|
||||
return error_response(code=404, message="社区不存在")
|
||||
|
||||
show_qrcode = False
|
||||
|
||||
# 如果提供了经纬度,则计算距离
|
||||
if latitude is not None and longitude is not None:
|
||||
distance = calculate_distance(
|
||||
latitude, longitude,
|
||||
community.latitude, community.longitude
|
||||
)
|
||||
community.distance = distance
|
||||
|
||||
# 如果距离小于100 公里,则显示二维码
|
||||
if distance < 100000:
|
||||
show_qrcode = True
|
||||
|
||||
return success_response(data={
|
||||
"community": CommunityInfo.model_validate(community),
|
||||
"show_qrcode": show_qrcode
|
||||
})
|
||||
|
||||
|
||||
@router.get("", response_model=ResponseModel)
|
||||
async def get_communities(
|
||||
latitude: Optional[float] = None,
|
||||
|
||||
@ -82,7 +82,7 @@ async def apply_partner(
|
||||
user_id=current_user.userid,
|
||||
name=apply_data.name,
|
||||
phone=apply_data.phone,
|
||||
type=apply_data.type,
|
||||
type=apply_data.type_display,
|
||||
service_target=apply_data.service_target
|
||||
)
|
||||
|
||||
|
||||
@ -17,12 +17,6 @@ class FeedbackCommunityApplyDB(Base):
|
||||
create_time = Column(DateTime(timezone=True), server_default=func.now())
|
||||
update_time = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
class PartnerType(str, enum.Enum):
|
||||
"""合伙人类型"""
|
||||
COMMUNITY = "社区合伙人" # 社区合伙人
|
||||
BUSINESS = "商家合伙人" # 商家合伙人
|
||||
DELIVERY = "配送合伙人" # 配送合伙人
|
||||
|
||||
class FeedbackPartnerApplyDB(Base):
|
||||
"""合伙人申请表"""
|
||||
__tablename__ = "feedback_partner_apply"
|
||||
@ -69,6 +63,14 @@ class PartnerApplyInfo(BaseModel):
|
||||
service_target: str
|
||||
create_time: datetime
|
||||
update_time: Optional[datetime] = None
|
||||
|
||||
|
||||
@property
|
||||
def type_display(self):
|
||||
if self.type == "community":
|
||||
return "社区合伙人"
|
||||
elif self.type == "city":
|
||||
return "城市合伙人"
|
||||
else:
|
||||
return self.type
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Loading…
Reference in New Issue
Block a user