- jd spu support

This commit is contained in:
gazebo
2018-12-11 12:44:41 +08:00
parent 35f1d51e77
commit f7c5e089ff
4 changed files with 147 additions and 14 deletions

View File

@@ -235,6 +235,20 @@ func ComposeSkuName(prefix, name, comment, unit string, spec_quality float32, sp
return skuName
}
func ComposeSpuName(prefix, name string, maxLen int) (spuName string) {
if prefix != "" {
spuName = "[" + prefix + "]"
}
spuName += name
if maxLen > 0 {
runeList := []rune(spuName)
if len(runeList) > maxLen {
spuName = string(runeList[:maxLen])
}
}
return spuName
}
func ComposeSkuSpec(spec_quality float32, spec_unit string) (spec string) {
if math.Round(float64(spec_quality)) == float64(spec_quality) || (spec_unit != "L" && spec_unit != "kg") {
spec = fmt.Sprintf("%d", int(spec_quality))