3c729304db
Corrections verified against actual CMS/BackOffice/FrontOffice source code: - ClubActivationFee: 25,200,000 (not 25,000,000) - Tree depth: no limit (15 is commission calculation depth only) - IPG wallet charge: Balance=56M + Discount=56M - DayaLoan wallet charge: Balance=56M + Discount=112M (2×) - Discount: per-product MaxDiscountPercent (not fixed 30%) - VAT: 10% (ShopVAT) vs 9% (discount store PlaceOrder) - Kavenegar template: 'Afrino' only (not verify-foursat) - SMS sender: 1000001110100 - DayaLoan job: every 20min (not 15min) - Commission job: Sunday 00:05 (not Saturday) - Network tree: on User entity (not separate NetworkNode table) - UserWallets entity (not UserWalletBalances) - OTP: 6 digits, 5 attempts, 2min TTL, 60s cooldown - Removed non-existent constants (ClubJoiningPercentage, ClubActivationThreshold) - Fixed Hangfire Chatika interval: every 5min - Removed InventorySync from recurring jobs list
22 KiB
22 KiB
📊 فلوچارتها و دیاگرامهای کلان
دید بالا (Big Picture): فلوی کاربر، مالی و داده
آخرین بروزرسانی: اسفند ۱۴۰۴
۱. فلوی کلان کاربر (User Journey)
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — User Journey │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ [ورود به سایت] │
│ │ │
│ ▼ │
│ ◆ آیا ثبتنام کرده؟ ◆──── خیر ───→ [Landing Page] │
│ │ │ │
│ بله [ثبتنام] │
│ │ موبایل + OTP │
│ ▼ │ │
│ [Login + JWT] ▼ │
│ │ [پروفایل] │
│ ▼ │ │
│ ◆ عضو باشگاه؟ ◆ ▼ │
│ │ │ ┌───────────────┐ │
│ بله خیر │ Regular Store │ │
│ │ │ │ خرید عادی │ │
│ │ └──────────────→│ IPG پرداخت │ │
│ │ └───────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Club Member Dashboard │ │
│ ├──────────┬──────────┬──────────┬─────────────┤ │
│ │ فروشگاه │ درخت شبکه │ کمیسیون │ Chatika AI │ │
│ │ تخفیفی │ باینری │ هفتگی │ │ │
│ │ (per-product) │ │ │ │ │
│ └──────────┴──────────┴──────────┴─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
۲. فلوی مالی (Financial Flow)
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — Financial Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ═══════════════════ ورودی پول ═══════════════════ │
│ │
│ [ZarinPal IPG] ──→ ┐ │
│ [Daya Loan] ──→ ├──→ [PYMS Service] ──→ [DB Transaction] │
│ [Manual Pay] ──→ ┘ │ │
│ ▼ │
│ ═══════════ توزیع به کیفپولها ═══════════ │
│ │
│ ┌────────────────┐ ┌─────────────────┐ ┌──────────────────┐ │
│ │ 💰 Balance │ │ 🌟 NetworkBal │ │ 🏷️ DiscountBal │ │
│ │ (نقدی) │ │ (طلایی/کمیسیون)│ │ (تخفیفی) │ │
│ │ │ │ │ │ │ │
│ │ • IPG: +56M │ │ • شارژ نمیشود │ │ • IPG: +56M │ │
│ │ • Daya: +56M │ │ • فقط برای │ │ • Daya: +112M │ │
│ │ • فعالسازی │ │ محاسبه │ │ (دو برابر) │ │
│ │ -25.2M │ │ کمیسیون │ │ • per-product │ │
│ │ • خرید فروشگاه │ │ • سقف 300/هفته │ │ MaxDiscount% │ │
│ └───────┬────────┘ └────────┬────────┘ └────────┬─────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ═══════════════════ خروجی پول ═══════════════════ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Weekly Commission Pool │ │
│ │ │ │
│ │ Source: هر فعالسازی → 25.2M واریز │ │
│ │ Calculate: sp_CalculateWeeklyBalances │ │
│ │ Distribute: sp_CalculateWeeklyCommissionPool │ │
│ │ Formula: UserShare = UserBalance / TotalBalance │ │
│ │ Cap: MAX 300 per leg per week │ │
│ │ Carryover: به هفته بعد (max 300, else flush) │ │
│ │ │ │
│ │ ┌─ Member A: Balance=150 → Share=150/600 → 25% ─┐ │ │
│ │ │ Member B: Balance=200 → Share=200/600 → 33% │ │ │
│ │ │ Member C: Balance=250 → Share=250/600 → 42% │ │ │
│ │ └─ Total: 600 ─┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
۳. فلوی داده (Data Flow)
┌─────────────────────────────────────────────────────────────────────────┐
│ FourSat — Data Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ [Browser/Client] │
│ │ │
│ │ HTTPS │
│ ▼ │
│ [nginx / K8s Ingress] │
│ │ │
│ ├──→ / ──────────→ [FrontOffice :5003] (Blazor Server) │
│ │ │ │
│ ├──→ /admin ─────→ [BackOffice :5002] (Blazor WASM) │
│ │ │ │
│ └──→ /hangfire ──→ [CMS :5001] (Dashboard) │
│ │ │
│ ┌─────────────────────────────┘ │
│ │ gRPC (Protobuf v3, HTTP/2) │
│ ▼ │
│ [CMS Microservice :5001] │
│ │ │
│ ├──→ [MediatR] ──→ Commands/Queries ──→ Handlers │
│ │ │ │
│ ├──→ [Hangfire] ──→ Background Jobs │ │
│ │ • DayaLoan (15min) │ │
│ │ • Commission (weekly) │ │
│ │ • Chatika (5min) │ │
│ │ • InventorySync (hourly) │ │
│ │ │ │
│ └──→ [External Services] │ │
│ • ZarinPal API │ │
│ • Kavenegar API ▼ │
│ • DayaLoan API [EF Core 9] │
│ • Chatika API │ │
│ ▼ │
│ [SQL Server 2022] │
│ Schema: [CMS] │
│ ~15 main tables │
│ + 3 Stored Procs │
│ │
└─────────────────────────────────────────────────────────────────────────┘
۴. درخت باینری شبکه (Network Tree)
┌─────────┐
│ Root │
│ (Admin) │
└────┬────┘
┌─────────┴─────────┐
┌────▼────┐ ┌────▼────┐
│ User A │ │ User B │
│ L=120 │ │ L=0 │
│ R=80 │ │ R=150 │
└────┬────┘ └────┬────┘
┌───────┴───────┐ ┌──────┴──────┐
┌────▼──┐ ┌────▼──┐ ┌──▼───┐ ┌───▼──┐
│User C │ │User D │ │User E│ │User F│
│Active │ │Active │ │Pend. │ │Active│
└───────┘ └───────┘ └──────┘ └──────┘
Legend:
L = Left leg sales this week
R = Right leg sales this week
Active = فعال (contract signed)
Pend. = در انتظار فعالسازی
شبکه روی entity User مدل شده (NetworkParentId, LegPosition)
محاسبه کمیسیون تا عمق 15 سطح — درخت بدون محدودیت عمق
۵. فلوی خرید — Regular vs Discount Store
┌────────────────────────────────┬──────────────────────────────────┐
│ Regular Store │ Discount Store │
├────────────────────────────────┼──────────────────────────────────┤
│ │ │
│ [مشاهده محصولات] │ [مشاهده محصولات] ← فقط باشگاه │
│ │ │ │ │
│ ▼ │ ▼ │
│ [Lazy Load — 12 per page] │ [Lazy Load — 12 per page] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [افزودن به سبد] │ [افزودن به سبد] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [بررسی موجودی] │ [بررسی موجودی] │
│ │ │ [بررسی DiscountBalance] │
│ ▼ │ │ │
│ [Checkout] │ ▼ │
│ │ │ [محاسبه سهم تخفیف (MaxDiscount%)]│
│ ▼ │ [محاسبه سهم نقدی (باقیمانده)] │
│ [ZarinPal IPG] │ │ │
│ [100% نقدی] │ ▼ │
│ │ │ [کسر از DiscountBalance] │
│ ▼ │ [ZarinPal IPG برای باقیمانده] │
│ [ثبت سفارش] │ │ │
│ │ │ ▼ │
│ ▼ │ [ثبت سفارش ترکیبی] │
│ [کسر موجودی] │ [کسر موجودی] │
│ │ │ │ │
│ ▼ │ ▼ │
│ [SMS تأیید] │ [SMS تأیید] │
│ │ │
└────────────────────────────────┴──────────────────────────────────┘
۶. معماری Deployment
┌──────────────────────────────────────────────────────────────┐
│ Production Server │
│ 45.149.79.127 │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌────────────────────────────────────┐ │
│ │ nginx │────→│ Kubernetes Cluster │ │
│ │ :80/:443│ │ │ │
│ └─────────┘ │ ┌───────────┐ ┌───────────────┐ │ │
│ │ │CMS ×2 │ │FrontOffice ×2 │ │ │
│ │ │:5001 gRPC │ │:5003 Blazor │ │ │
│ │ └─────┬─────┘ └───────────────┘ │ │
│ │ │ │ │
│ │ ┌─────▼─────┐ ┌───────────────┐ │ │
│ │ │SQL Server │ │BackOffice ×1 │ │ │
│ │ │:1433 │ │:5002 Static │ │ │
│ │ └───────────┘ └───────────────┘ │ │
│ │ │ │
│ │ ┌───────────┐ ┌───────────────┐ │ │
│ │ │Nexus │ │Hangfire │ │ │
│ │ │:8081 │ │(inside CMS) │ │ │
│ │ └───────────┘ └───────────────┘ │ │
│ └────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
۷. Entity Relationship (سادهشده)
┌──────────┐ ┌──────────────┐
│ User │────→│ ClubMembership│
│ +Network │ │ │
│ ParentId│ └──────────────┘
│ +LegPos │
└────┬─────┘
│
├────→ ┌──────────┐ ┌──────────┐
│ │ Order │────→│ OrderItem│────→ [Product]
│ └──────────┘ └──────────┘
│
├────→ ┌──────────────┐
│ │ Transaction │
│ └──────────────┘
│
├────→ ┌──────────────┐
│ │ UserWallet │────→ Balance + NetworkBalance + DiscountBalance
│ └──────────────┘
│
├────→ ┌──────────────┐
│ │ UserContract │
│ └──────────────┘
│
└────→ ┌──────────────┐
│ ChatMessage │
└──────────────┘
┌──────────┐ ┌───────────┐
│ Product │────→│ Inventory │
│ │────→│ Category │
│ │────→│ Images │
└──────────┘
┌──────────┐ ┌──────────────────────┐
│ SitePage │ │ SystemConfiguration │
│ (typed) │ │ (key-value) │
└──────────┘ └──────────────────────┘
┌──────────┐
│ BlogPost │────→ [Tags, Category, Author]
└──────────┘