update
This commit is contained in:
parent
5e8ba2203b
commit
ef8ad72322
@ -266,9 +266,16 @@ async def create_order(
|
||||
for package in order.price_request.packages:
|
||||
# 如果包裹有取件码,则创建包裹
|
||||
if len(package.pickup_codes) > 0:
|
||||
station = db.query(StationDB).filter(
|
||||
StationDB.id == package.station_id
|
||||
).first()
|
||||
if not station_name:
|
||||
station = db.query(StationDB).filter(
|
||||
StationDB.id == package.station_id
|
||||
).first()
|
||||
if station:
|
||||
station_name = station.name
|
||||
else:
|
||||
station_name = "未知驿站"
|
||||
else:
|
||||
station_name = package.station_name
|
||||
|
||||
# 对package.pickup_codes中分割的取件码,进行排序
|
||||
sorted_pickup_codes = CommonUtils.sort_strings_by_first_number(package.pickup_codes.split(","))
|
||||
@ -276,7 +283,7 @@ async def create_order(
|
||||
db_package = ShippingOrderPackageDB(
|
||||
orderid=orderid,
|
||||
station_id=package.station_id,
|
||||
station_name=station.name,
|
||||
station_name=station_name,
|
||||
pickup_codes=','.join(sorted_pickup_codes)
|
||||
)
|
||||
db.add(db_package)
|
||||
|
||||
@ -120,7 +120,8 @@ class ShippingOrderPackageDB(Base):
|
||||
|
||||
# Pydantic 模型
|
||||
class OrderPackage(BaseModel):
|
||||
station_id: int
|
||||
station_id: int = 0
|
||||
station_name: Optional[str] = None
|
||||
pickup_codes: str = Field(..., max_length=100)
|
||||
|
||||
# 先定义 OrderPriceCalculateRequest
|
||||
|
||||
Loading…
Reference in New Issue
Block a user