This commit is contained in:
aaron 2025-03-07 20:02:20 +08:00
parent 6dcf697fee
commit 9d53afef9e
3 changed files with 9 additions and 6 deletions

View File

@ -397,7 +397,7 @@ 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_rate is not None:
deliveryman_share = round(order.original_amount * (current_user.delivery_commission_rate / 100.0), 2) 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 is not None:
deliveryman_share = current_user.delivery_commission_fixed deliveryman_share = current_user.delivery_commission_fixed
@ -942,8 +942,7 @@ async def deliveryman_orders(
UserDB.phone.label("deliveryman_phone"), UserDB.phone.label("deliveryman_phone"),
UserDB.avatar.label("deliveryman_avatar")).join(UserDB, UserDB.avatar.label("deliveryman_avatar")).join(UserDB,
OrderAdditionalFeeDB.deliveryman_id == UserDB.userid).filter( OrderAdditionalFeeDB.deliveryman_id == UserDB.userid).filter(
OrderAdditionalFeeDB.orderid == order.orderid, OrderAdditionalFeeDB.orderid == order.orderid
OrderAdditionalFeeDB.result == AdditionalFeeResult.ACCEPTED
).all() ).all()
order_additional_fees = [] order_additional_fees = []
@ -1169,7 +1168,7 @@ async def deliveryman_complete_order(
# 计算配送员分账金额 # 计算配送员分账金额
if current_user.delivery_commission_rate is not None: if current_user.delivery_commission_rate is not None:
deliveryman_share = order.original_amount * current_user.delivery_commission_rate / 100 deliveryman_share = order.original_amount_with_additional_fee * current_user.delivery_commission_rate / 100
else: else:
deliveryman_share = current_user.delivery_commission_fixed deliveryman_share = current_user.delivery_commission_fixed

View File

@ -137,8 +137,8 @@ async def accept_additional_fee(
).first() ).first()
if order: if order:
order.additional_fee_amount = float(fee_request.additional_fee_amount) order.additional_fee_amount += float(fee_request.additional_fee_amount)
order.final_amount = float(order.final_amount) + float(fee_request.additional_fee_amount) order.final_amount += float(fee_request.additional_fee_amount)
try: try:
db.commit() db.commit()

View File

@ -104,6 +104,10 @@ class ShippingOrderDB(Base):
return [process_image(image).format(ImageFormat.WEBP).build() for image in self.pickup_images.split(",")] return [process_image(image).format(ImageFormat.WEBP).build() for image in self.pickup_images.split(",")]
return [] return []
@property
def original_amount_with_additional_fee(self):
return self.original_amount + self.additional_fee_amount
class ShippingOrderPackageDB(Base): class ShippingOrderPackageDB(Base):
__tablename__ = "shipping_order_packages" __tablename__ = "shipping_order_packages"