- packs (20 / 60 / 150 questions for 45,000 / 119,000 / 259,000 toman) never expire and give 7 / 30 / 60 days of unlimited hearts; old subscription plans stay for existing subscribers but are no longer on sale - credit ledger (subscription.QuestionCredit): +N per paid pack (once per order), -1 per tutor question that reaches the API; the free daily questions are spent first; questions stopped by the server filter, cached answers and failed answers cost nothing - unlimited hearts from packs live in HeartsPass, so buying a pack never rewrites a running subscription - Message.charge records how each question was paid; GET /api/ai/quota and the ask responses report free-left-today and credits - HEARTS_ENFORCED now defaults to on: zero hearts stops answering until refill or a pack Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.6 KiB
Python
51 lines
2.6 KiB
Python
"""
|
||
بستههای سوال بهجای اشتراکِ ماهانه/سالانه (۲۰۲۶-۱۰-۰۲، تصمیمِ صاحبِ پروژه).
|
||
|
||
چرا: همه هر روز نمیآیند و با اقتصادِ امروز ۱۷۹ هزار تومان در ماه برای خیلیها زیاد است. با بسته
|
||
هر کس به اندازهی مصرفش میخرد و هر سوال جدا سود دارد؛ مشترکی که سقف را هر روز پر میکرد دیگر
|
||
زیان نمیسازد. هزینهی هر سوال برای ما ~۶۰۰ تومان است (دبیرستان ~۷۷۰)؛ سهمِ هزینه از درآمدِ خالص
|
||
پس از ۱۵٪یِ کافهبازار: ۲۰ سوال ۳۱٪، ۶۰ سوال ۳۶٪، ۱۵۰ سوال ۴۱٪. قیمتها عمداً دستِ بالا گرفته شدهاند.
|
||
|
||
اعتبار منقضی نمیشود. هر بسته چند روز قلبِ نامحدود هم میدهد (۷ / ۳۰ / ۶۰ روز)، که از همان روز
|
||
کم شدنِ قلب روشن است (HEARTS_ENFORCED) واقعاً ارزش دارد.
|
||
|
||
پلنهای اشتراکی پاک نمیشوند؛ فقط از صفحهی خرید برداشته میشوند (on_sale=False) تا اشتراکِ
|
||
فعالِ کسی که پیشتر خریده با همان سقفِ روزانه بماند.
|
||
"""
|
||
from django.db import migrations
|
||
|
||
PACKS = [
|
||
{'title': '۲۰ سوال', 'price': 45_000, 'question_credits': 20, 'hearts_days': 7,
|
||
'badge': '', 'popular': False},
|
||
{'title': '۶۰ سوال', 'price': 119_000, 'question_credits': 60, 'hearts_days': 30,
|
||
'badge': 'محبوبترین', 'popular': True},
|
||
{'title': '۱۵۰ سوال', 'price': 259_000, 'question_credits': 150, 'hearts_days': 60,
|
||
'badge': 'بهصرفهترین', 'popular': False},
|
||
]
|
||
|
||
|
||
def seed(apps, schema_editor):
|
||
Plan = apps.get_model('subscription', 'Plan')
|
||
Plan.objects.filter(kind='subscription').update(on_sale=False)
|
||
for pack in PACKS:
|
||
if not Plan.objects.filter(kind='pack', question_credits=pack['question_credits']).exists():
|
||
Plan.objects.create(kind='pack', currency='IRT', discount_percent=0, duration_days=0,
|
||
ai_daily_quota=0, features=[], on_sale=True, **pack)
|
||
|
||
|
||
def undo(apps, schema_editor):
|
||
Plan = apps.get_model('subscription', 'Plan')
|
||
Plan.objects.filter(kind='pack', subscriptions__isnull=True).delete()
|
||
Plan.objects.filter(kind='subscription').update(on_sale=True)
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
|
||
dependencies = [
|
||
('subscription', '0009_question_packs'),
|
||
]
|
||
|
||
operations = [
|
||
migrations.RunPython(seed, undo),
|
||
]
|