feat(currency): add currency configuration support and integrate into payment processing

This commit is contained in:
Tension
2025-12-31 11:47:24 +08:00
parent 780e71441d
commit 798fb9e245
5 changed files with 71 additions and 37 deletions
+34
View File
@@ -0,0 +1,34 @@
package initialize
import (
"context"
"fmt"
"github.com/perfect-panel/server/internal/config"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/pkg/logger"
"github.com/perfect-panel/server/pkg/tool"
)
func Currency(ctx *svc.ServiceContext) {
// Retrieve system currency configuration
currency, err := ctx.SystemModel.GetCurrencyConfig(context.Background())
if err != nil {
logger.Errorf("[INIT] Failed to get currency configuration: %v", err.Error())
panic(fmt.Sprintf("[INIT] Failed to get currency configuration: %v", err.Error()))
}
// Parse currency configuration
configs := struct {
CurrencyUnit string
CurrencySymbol string
AccessKey string
}{}
tool.SystemConfigSliceReflectToStruct(currency, &configs)
ctx.Config.Currency = config.Currency{
Unit: configs.CurrencyUnit,
Symbol: configs.CurrencySymbol,
AccessKey: configs.AccessKey,
}
logger.Infof("[INIT] Currency configuration: %v", ctx.Config.Currency)
}
+1
View File
@@ -15,6 +15,7 @@ func StartInitSystemConfig(svc *svc.ServiceContext) {
Subscribe(svc)
Register(svc)
Mobile(svc)
Currency(svc)
if !svc.Config.Debug {
Telegram(svc)
}