fix bug.
This commit is contained in:
parent
556c8773d6
commit
0fb3a28070
@ -46,9 +46,10 @@ def calculate_price(price_request: OrderPriceCalculateRequest,user: UserDB,db: S
|
|||||||
"""
|
"""
|
||||||
# 计算所有包裹中的取件码总数
|
# 计算所有包裹中的取件码总数
|
||||||
package_count = sum(
|
package_count = sum(
|
||||||
len(package.pickup_codes.split(','))
|
# 如果package.pickup_codes是空字符串,则取0
|
||||||
|
0 if len(package.pickup_codes.split(',')) == 0 else len(package.pickup_codes.split(','))
|
||||||
for package in price_request.packages
|
for package in price_request.packages
|
||||||
if package.pickup_codes
|
if package.pickup_codes
|
||||||
)
|
)
|
||||||
|
|
||||||
result = OrderPriceResult(
|
result = OrderPriceResult(
|
||||||
@ -188,18 +189,19 @@ async def create_order(
|
|||||||
|
|
||||||
# 创建订单包裹
|
# 创建订单包裹
|
||||||
for package in order.price_request.packages:
|
for package in order.price_request.packages:
|
||||||
|
# 如果包裹有取件码,则创建包裹
|
||||||
station = db.query(StationDB).filter(
|
if len(package.pickup_codes) > 0:
|
||||||
StationDB.id == package.station_id
|
station = db.query(StationDB).filter(
|
||||||
).first()
|
StationDB.id == package.station_id
|
||||||
|
).first()
|
||||||
|
|
||||||
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=package.pickup_codes
|
pickup_codes=package.pickup_codes
|
||||||
)
|
)
|
||||||
db.add(db_package)
|
db.add(db_package)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 如果使用了优惠券,更新优惠券状态
|
# 如果使用了优惠券,更新优惠券状态
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user