feat: add admin panel

This commit is contained in:
2026-06-15 20:54:05 +03:30
parent 7dadb23fbe
commit 02060a4dc0
16 changed files with 698 additions and 108 deletions
+9 -5
View File
@@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"strings"
"sync"
"time"
)
@@ -34,6 +35,9 @@ type Service struct {
db *sql.DB
ad AdVerifier
iap IAPVerifier
mu sync.RWMutex // محافظ کشِ کاتالوگ
cat Catalog // کشِ کاتالوگ خوانده‌شده از DB
}
func New(db *sql.DB, ad AdVerifier, iap IAPVerifier) *Service {
@@ -154,7 +158,7 @@ func (s *Service) ClaimAdReward(ctx context.Context, userID int64, token string)
// BuyCard اسکین کارت را با سکه باز می‌کند.
func (s *Service) BuyCard(ctx context.Context, userID int64, cardID string) error {
skin := findCardSkin(cardID)
skin := s.findCardSkin(cardID)
if skin == nil {
return ErrNotFound
}
@@ -185,7 +189,7 @@ func (s *Service) BuyCard(ctx context.Context, userID int64, cardID string) erro
// SelectCard کارت انتخابی کاربر را تنظیم می‌کند (باید مالکش باشد یا کارت پیش‌فرض).
func (s *Service) SelectCard(ctx context.Context, userID int64, cardID string) error {
if findCardSkin(cardID) == nil {
if s.findCardSkin(cardID) == nil {
return ErrNotFound
}
if cardID != "simple" {
@@ -255,7 +259,7 @@ func (s *Service) VerifyPurchase(ctx context.Context, userID int64, req Purchase
var booster *Booster
switch req.Kind {
case "coin":
p := findCoinPackage(req.ProductID)
p := s.findCoinPackage(req.ProductID)
if p == nil {
return ErrNotFound
}
@@ -264,13 +268,13 @@ func (s *Service) VerifyPurchase(ctx context.Context, userID int64, req Purchase
coins += coins / 10 // پاداش ۱۰٪ VIP
}
case "ticket":
p := findTicketPackage(req.ProductID)
p := s.findTicketPackage(req.ProductID)
if p == nil {
return ErrNotFound
}
tickets = p.Tickets
case "booster":
booster = findBooster(req.ProductID)
booster = s.findBooster(req.ProductID)
if booster == nil {
return ErrNotFound
}