question packs instead of monthly/yearly plans; hearts are real
- 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>
This commit is contained in:
58
subscription/migrations/0009_question_packs.py
Normal file
58
subscription/migrations/0009_question_packs.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# Generated by Django 5.2.17 on 2026-10-02 07:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('subscription', '0008_paid_quota_ten_a_day'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HeartsPass',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('user_id', models.IntegerField(db_index=True, unique=True)),
|
||||
('expires_at', models.DateTimeField()),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='plan',
|
||||
name='hearts_days',
|
||||
field=models.PositiveSmallIntegerField(default=0, help_text='فقط بسته: چند روز قلبِ نامحدود هدیه.'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='plan',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('pack', 'بسته\u200cی سوال'), ('subscription', 'اشتراکِ زمانی')], default='subscription', max_length=15),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='plan',
|
||||
name='on_sale',
|
||||
field=models.BooleanField(default=True, help_text='در صفحه\u200cی خرید نشان داده شود.'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='plan',
|
||||
name='question_credits',
|
||||
field=models.PositiveIntegerField(default=0, help_text='فقط بسته: چند سوال از دستیار به اعتبارِ خریدار اضافه می\u200cشود.'),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='QuestionCredit',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('user_id', models.IntegerField(db_index=True)),
|
||||
('delta', models.IntegerField()),
|
||||
('reason', models.CharField(choices=[('purchase', 'خرید'), ('question', 'سوال'), ('grant', 'هدیه\u200cی ادمین')], max_length=10)),
|
||||
('order_id', models.IntegerField(blank=True, null=True)),
|
||||
('message_id', models.IntegerField(blank=True, db_index=True, null=True)),
|
||||
('note', models.CharField(blank=True, max_length=100)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
'constraints': [models.UniqueConstraint(condition=models.Q(('reason', 'purchase')), fields=('order_id',), name='uniq_credit_per_paid_order')],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user