package finance import ( "context" "bindbox-game/internal/pkg/logger" "bindbox-game/internal/repository/mysql" "gorm.io/gorm" ) // Service defines the finance P&L query interface. type Service interface { QueryUserProfitLoss(ctx context.Context, params UserProfitLossParams) (*ProfitLossResult, error) QueryActivityProfitLoss(ctx context.Context, params ActivityProfitLossParams) (*ProfitLossResult, error) } type service struct { logger logger.CustomLogger dbR *gorm.DB // read replica only — QUA-02: no writes in this package } // New creates a new finance Service backed by the read-only DB replica. // CRITICAL: only db.GetDbR() is called — never GetDbW() (QUA-02). func New(l logger.CustomLogger, db mysql.Repo) Service { return &service{ logger: l, dbR: db.GetDbR(), } } // QueryUserProfitLoss dispatches to the user-dimension implementation (Plan 02). func (s *service) QueryUserProfitLoss(ctx context.Context, params UserProfitLossParams) (*ProfitLossResult, error) { return s.queryUser(ctx, params) } // QueryActivityProfitLoss dispatches to the activity-dimension implementation (Plan 03). func (s *service) QueryActivityProfitLoss(ctx context.Context, params ActivityProfitLossParams) (*ProfitLossResult, error) { return s.queryActivity(ctx, params) }