package svc import ( "applet/app/utils" "github.com/gin-gonic/gin" "strings" ) func GetCommissionPrec(c *gin.Context, sum, commPrec, isShowPoint string) string { if sum == "" { sum = "0" } sum = utils.StrToFormat(c, sum, utils.StrToInt(commPrec)) ex := strings.Split(sum, ".") if len(ex) == 2 && isShowPoint != "1" { if utils.StrToFloat64(ex[1]) == 0 { sum = ex[0] } else { val := utils.Float64ToStrByPrec(utils.StrToFloat64(ex[1]), 0) valNew := strings.ReplaceAll(val, "0", "") sum = ex[0] + "." + strings.ReplaceAll(ex[1], val, valNew) } } return sum }