支付配送订单完成,增加配送员分账。
This commit is contained in:
parent
2ab88b9fca
commit
ebe74e2f7f
@ -568,7 +568,7 @@ async def complete_order(
|
||||
account_manager.change_balance(
|
||||
user_id=order.deliveryman_user_id,
|
||||
amount=deliveryman_share,
|
||||
description=f"订单 {orderid} 配送费分账",
|
||||
description=f"配送订单收益",
|
||||
transaction_id=orderid
|
||||
)
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ from app.models.merchant_pay_order import MerchantPayOrderDB, MerchantPayOrderSt
|
||||
import enum
|
||||
from app.core.point_manager import PointManager
|
||||
from app.core.point_manager import PointRecordType
|
||||
from app.core.account import AccountManager
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@ -220,6 +221,19 @@ async def payment_notify(
|
||||
order.status = OrderStatus.COMPLETED # 支付成功后状态为已完成
|
||||
order.transaction_id = transaction_id
|
||||
order.pay_time = datetime.fromisoformat(success_time.replace('Z', '+00:00'))
|
||||
|
||||
# 计算配送员分账金额
|
||||
deliveryman_share = order.final_amount * settings.ORDER_DELIVERYMAN_SHARE_RATIO
|
||||
|
||||
# 使用账户管理器处理分账
|
||||
account_manager = AccountManager(db)
|
||||
account_manager.change_balance(
|
||||
user_id=order.deliveryman_user_id,
|
||||
amount=deliveryman_share,
|
||||
description=f"配送订单收益",
|
||||
transaction_id=order.orderid
|
||||
)
|
||||
|
||||
|
||||
elif out_trade_no.startswith("M"): # 商家商品订单
|
||||
# 查询商户订单
|
||||
|
||||
Loading…
Reference in New Issue
Block a user