fix: 修复微信通知字段截断导致的编码错误 feat: 添加有效邀请相关字段和任务中心常量 refactor: 重构一番赏奖品格位逻辑 perf: 优化道具卡列表聚合显示 docs: 更新项目说明文档和API文档 test: 添加字符串截断工具测试
23 lines
449 B
Go
23 lines
449 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, nil
|
|
}
|