fix bug
This commit is contained in:
parent
f06c6c7c69
commit
73418553c7
@ -410,10 +410,12 @@ async def get_order_detail(
|
|||||||
|
|
||||||
# 计算配送员分账金额
|
# 计算配送员分账金额
|
||||||
deliveryman_share = 0
|
deliveryman_share = 0
|
||||||
if current_user.delivery_commission_rate is not None:
|
if current_user.delivery_commission_fixed > 0:
|
||||||
deliveryman_share = round(order.original_amount_with_additional_fee * (current_user.delivery_commission_rate / 100.0), 2)
|
|
||||||
if current_user.delivery_commission_fixed is not None:
|
|
||||||
deliveryman_share = current_user.delivery_commission_fixed
|
deliveryman_share = current_user.delivery_commission_fixed
|
||||||
|
elif current_user.delivery_commission_rate > 0:
|
||||||
|
deliveryman_share = round(order.original_amount_with_additional_fee * (current_user.delivery_commission_rate / 100.0), 2)
|
||||||
|
else:
|
||||||
|
deliveryman_share = 0
|
||||||
|
|
||||||
# 如果有配送员 id,则获取配送员信息
|
# 如果有配送员 id,则获取配送员信息
|
||||||
if order.deliveryman_user_id:
|
if order.deliveryman_user_id:
|
||||||
@ -1166,19 +1168,23 @@ async def deliveryman_complete_order(
|
|||||||
order.completed_time = datetime.now()
|
order.completed_time = datetime.now()
|
||||||
|
|
||||||
# 计算配送员分账金额
|
# 计算配送员分账金额
|
||||||
if current_user.delivery_commission_rate is not None:
|
if current_user.delivery_commission_rate > 0:
|
||||||
deliveryman_share = order.original_amount_with_additional_fee * current_user.delivery_commission_rate / 100
|
deliveryman_share = order.original_amount_with_additional_fee * current_user.delivery_commission_rate / 100
|
||||||
else:
|
elif current_user.delivery_commission_fixed > 0:
|
||||||
deliveryman_share = current_user.delivery_commission_fixed
|
deliveryman_share = current_user.delivery_commission_fixed
|
||||||
|
else:
|
||||||
|
deliveryman_share = 0
|
||||||
|
|
||||||
# 使用账户管理器处理分账
|
# 使用账户管理器处理分账
|
||||||
account_manager = AccountManager(db)
|
if deliveryman_share > 0:
|
||||||
account_manager.change_balance(
|
account_manager = AccountManager(db)
|
||||||
user_id=order.deliveryman_user_id,
|
account_manager.change_balance(
|
||||||
amount=deliveryman_share,
|
user_id=order.deliveryman_user_id,
|
||||||
description=f"配送订单收益",
|
amount=deliveryman_share,
|
||||||
transaction_id=orderid
|
description=f"配送订单收益",
|
||||||
)
|
transaction_id=orderid
|
||||||
|
)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# 如果当前订单是首单,如果有邀请人,给邀请人发放优惠券
|
# 如果当前订单是首单,如果有邀请人,给邀请人发放优惠券
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user