feat(billing): 计费商业化重构(积分制)+ 团队差异化调价
统一计价引擎 apps/billing/pricing.py:1积分=¥0.1,平台成本(¥)与用户价(积分)双记账, 视频按火山真实 usage.total_tokens 结算(true-up,终结¥1/段倒贴)+ 首发×1.5毛利系数。 Team.price_multiplier 差异化调价(jimeng同款):挂牌价×系数两步HALF_UP取整,视频类 按下单时的价格/汇率快照结算(中途改配不影响在途任务)。 BillingConfig 单例(汇率/毛利系数/预留buffer,admin可调即刻生效)。存量数据 ×10 rescale 迁移(RunPython+atomic,MySQL 迁移不可中断重跑)。开户赠送归零(DEFAULT_TRIAL_CREDITS=0, 商业决策)。audit_billing 加 I9(卖亏审计)。271 条测试 + tsc/build 全绿。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,25 @@ def audit_account(acct):
|
||||
else:
|
||||
print(" ✓ I8 流水完整(开户额度有凭证)")
|
||||
|
||||
# I9 毛利审计(积分制新增,先 warning 不计入失败):succeeded 且 base_cost>0(成本已知)的任务,
|
||||
# 用户实收 actual_cost/points_per_yuan(¥)不应低于平台成本 base_cost —— 低于即「卖亏」。
|
||||
# 注:充值赠送积分会稀释实际实现汇率(paid/credited < 名义 0.1),此处按名义汇率近似。
|
||||
from apps.billing.pricing import get_billing_config
|
||||
|
||||
rate = get_billing_config().points_per_yuan
|
||||
loss_tasks = []
|
||||
for t in AITask.objects.filter(team=team, status="succeeded", base_cost__gt=0).only("id", "task_type", "actual_cost", "base_cost"):
|
||||
revenue_yuan = (t.actual_cost or Z) / rate
|
||||
if revenue_yuan < t.base_cost:
|
||||
loss_tasks.append((t, revenue_yuan))
|
||||
if loss_tasks:
|
||||
for t, revenue_yuan in loss_tasks[:5]:
|
||||
print(f" ⚠ I9 卖亏任务(warning) {t.task_type}:{t.id} 实收¥{revenue_yuan:.2f} < 成本¥{t.base_cost}")
|
||||
if len(loss_tasks) > 5:
|
||||
print(f" ⚠ I9 …另有 {len(loss_tasks) - 5} 条卖亏任务")
|
||||
else:
|
||||
print(" ✓ I9 无卖亏任务(base_cost>0 口径)")
|
||||
|
||||
|
||||
def main():
|
||||
accts = CreditAccount.objects.select_related("team").all()
|
||||
|
||||
Reference in New Issue
Block a user