This commit is contained in:
aaron 2025-03-09 00:49:36 +08:00
parent f06c6c7c69
commit 73418553c7

View File

@ -410,10 +410,12 @@ async def get_order_detail(
# 计算配送员分账金额
deliveryman_share = 0
if current_user.delivery_commission_rate is not None:
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:
if current_user.delivery_commission_fixed > 0:
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则获取配送员信息
if order.deliveryman_user_id:
@ -1166,12 +1168,15 @@ async def deliveryman_complete_order(
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
else:
elif current_user.delivery_commission_fixed > 0:
deliveryman_share = current_user.delivery_commission_fixed
else:
deliveryman_share = 0
# 使用账户管理器处理分账
if deliveryman_share > 0:
account_manager = AccountManager(db)
account_manager.change_balance(
user_id=order.deliveryman_user_id,
@ -1179,6 +1184,7 @@ async def deliveryman_complete_order(
description=f"配送订单收益",
transaction_id=orderid
)
db.commit()
# 如果当前订单是首单,如果有邀请人,给邀请人发放优惠券