refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
20 lines
655 B
Go
20 lines
655 B
Go
package points
|
|
|
|
func CentsToPoints(cents int64, rate int64) int64 {
|
|
if cents <= 0 || rate <= 0 { return 0 }
|
|
return cents * rate
|
|
}
|
|
|
|
func PointsToCents(points int64, rate int64) int64 {
|
|
if points <= 0 || rate <= 0 { return 0 }
|
|
return points / rate
|
|
}
|
|
|
|
func RefundPointsAmount(pointsAmountCents int64, refundedCents int64, totalPaidCents int64, rate int64) int64 {
|
|
if pointsAmountCents <= 0 || refundedCents <= 0 || totalPaidCents <= 0 || rate <= 0 { return 0 }
|
|
if refundedCents > totalPaidCents { refundedCents = totalPaidCents }
|
|
targetCents := (pointsAmountCents * refundedCents) / totalPaidCents
|
|
return targetCents / 100
|
|
}
|
|
|