7bbf9fbc63
Adds a comprehensive tasks system where users earn rewards for completing configurable goals: purchase_tariff, subscribe_channel, traffic_used, referrals_invited, purchase_period, spend_amount, multi_tariff, gift_purchased, gifts_count. Reward types: balance kopeks or subscription_days (with optional fallback to Tariff.bonus_days_per_purchase). Highlights: - Multi-level chains via parent_task_id (cycle detection up to 10 hops) - Promo group + audience (telegram/email/both) filters - Trial users blocked from progress/claim via _user_eligible - Calendar-month windowing for traffic_used (UTC, per-user aggregate) - BigInteger for monetary fields, UNIQUE(user_id, task_id) constraint - FOR UPDATE locks on progress/user/subscription for atomic claim - chosen_reward_type gated by task.allow_user_choice - Atomic upsert via PG ON CONFLICT DO NOTHING (SQLite fallback via savepoint) - Triggers wired into: cabinet submit_purchase, bot tariff_purchase (custom + preset), subscription_renewal, 5 auto-purchase paths, daily_subscription, channel_member ChatMemberUpdated, gift purchase, referral first_topup, spend_amount in create_transaction commit=True path, traffic sync (multi-tariff + single-tariff) - Admin CRUD endpoints for tasks + partner channels (tasks:read/edit perms) - Adds Tariff.bonus_days_per_purchase column Migration: 0075_create_tasks.py