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