refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
24 lines
516 B
Go
24 lines
516 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
|
|
}
|
|
|