Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 15s
23 lines
457 B
Go
23 lines
457 B
Go
package user
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
func (s *service) CentsToPoints(ctx context.Context, cents int64) (int64, error) {
|
|
if cents <= 0 {
|
|
return 0, nil
|
|
}
|
|
cfg, _ := s.readDB.SystemConfigs.WithContext(ctx).Where(s.readDB.SystemConfigs.ConfigKey.Eq("points_exchange_per_cent")).First()
|
|
rate := int64(1)
|
|
if cfg != nil {
|
|
var r int64
|
|
_, _ = fmt.Sscanf(cfg.ConfigValue, "%d", &r)
|
|
if r > 0 {
|
|
rate = r
|
|
}
|
|
}
|
|
return (cents * rate) / 100, nil
|
|
}
|