1
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainSku struct {
|
type MainSku struct {
|
||||||
@@ -156,7 +157,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
if len(param.Name) < 23 { // 中文字符一个汉字三个长度符号/数字/字母两个长度,商品名称不能大于
|
if len(param.Name) < 23 { // 中文字符一个汉字三个长度符号/数字/字母两个长度,商品名称不能大于
|
||||||
param.Name += "【同城配送】"
|
param.Name += "【同城配送】"
|
||||||
} else if len(param.Name) > 90 { // 抖音最大60个字符,三十个汉字
|
} else if len(param.Name) > 90 { // 抖音最大60个字符,三十个汉字
|
||||||
param.Name = param.Name[0:90]
|
param.Name = checkNameLenght(param.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传图,商品轮播图
|
// 获取上传图,商品轮播图
|
||||||
@@ -367,7 +368,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
if len(param.Name) < 23 { // 中文字符一个汉字三个长度符号/数字/字母两个长度,商品名称不能大于
|
if len(param.Name) < 23 { // 中文字符一个汉字三个长度符号/数字/字母两个长度,商品名称不能大于
|
||||||
param.Name += "【同城配送】"
|
param.Name += "【同城配送】"
|
||||||
} else if len(param.Name) > 90 { // 抖音最大60个字符,三十个汉字
|
} else if len(param.Name) > 90 { // 抖音最大60个字符,三十个汉字
|
||||||
param.Name = param.Name[0:90]
|
param.Name = checkNameLenght(param.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传图,商品轮播图
|
// 获取上传图,商品轮播图
|
||||||
@@ -410,6 +411,52 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkNameLenght(name string) string {
|
||||||
|
var chinesLen int // 中文
|
||||||
|
var punctZh int // 中文标点
|
||||||
|
var punctEn int // 英文标点
|
||||||
|
var punctAZ int // 字母
|
||||||
|
var punctNum int // 字母
|
||||||
|
var spance int // 空格
|
||||||
|
for _, v := range name {
|
||||||
|
if unicode.Is(unicode.Han, v) { // 中文
|
||||||
|
chinesLen++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if unicode.IsPunct(v) {
|
||||||
|
if v >= 1000 { // 中文字符
|
||||||
|
fmt.Println(v)
|
||||||
|
punctZh++
|
||||||
|
} else {
|
||||||
|
punctEn++ // 英文字符
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if unicode.IsLetter(v) { // 字母
|
||||||
|
punctAZ++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if unicode.IsNumber(v) { // 数字
|
||||||
|
punctNum++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if unicode.IsSpace(v) { // 空格
|
||||||
|
spance++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maxLen := (chinesLen * 2) + (punctZh * 2) + punctEn + punctAZ + punctNum + spance
|
||||||
|
if maxLen > 60 { // 美团最多支持30个汉字长度
|
||||||
|
index := strings.LastIndex(name, " ")
|
||||||
|
if index != 0 {
|
||||||
|
return name[0:index]
|
||||||
|
} else {
|
||||||
|
return name[0 : len(name)-(maxLen-60)*3]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, childrenProductId int64, vendorStoreID, syncType string) (failedList []*partner.StoreSkuInfoWithErr) {
|
func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, childrenProductId int64, vendorStoreID, syncType string) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||||
skuId, failed := getProductSkuID(api, storeSku, syncType, childrenProductId)
|
skuId, failed := getProductSkuID(api, storeSku, syncType, childrenProductId)
|
||||||
if skuId == 0 || len(failed) > 0 {
|
if skuId == 0 || len(failed) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user