第二轮:客服额度资金闭环与收回额度

- 划额度扣商家余额,客服派单/链接只扣个人额度
- 新增 wallet/revoke 收回未使用额度,权限 wallet_revoke
- 客服额度单撤销/退款只释放额度,不再误退商家余额
- 链接待填单(13)可撤销;总管/财务可划收额度
This commit is contained in:
XingQue
2026-06-20 04:59:29 +08:00
parent b2520726dc
commit d68a1da2c2
10 changed files with 234 additions and 50 deletions

View File

@@ -9,6 +9,7 @@ from django.db.models import F
from backend.utils import update_shangjia_daily
from merchant_ops.constants import STAT_ACTION_DISPATCH, STAT_ACTION_REFUND, STAT_ACTION_SETTLE
from merchant_ops.models import MerchantOrderDispatch, MerchantStaffDailyStats, MerchantStaffMember
from merchant_ops.services.wallet import release_dispatch_quota
logger = logging.getLogger(__name__)
@@ -81,6 +82,11 @@ def sync_staff_stats_by_order_id(order_id, amount, action):
today_dispatch_count=F('today_dispatch_count') + 1,
today_dispatch_amount=F('today_dispatch_amount') + amount,
)
elif action == STAT_ACTION_REFUND:
try:
release_dispatch_quota(order_id, amount, member.staff_user_id)
except Exception:
logger.warning('释放客服派单额度失败 order_id=%s', order_id, exc_info=True)
def update_merchant_and_staff_stats(merchant_id, staff_member, amount, action, order_id=None):