This commit is contained in:
邹宗楠
2023-07-13 11:06:45 +08:00
parent 15ec7f70ac
commit 71cda18bdb

View File

@@ -242,7 +242,7 @@ func UpdateTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
OuCode: utils.String2Pointer(vendorStoreID),
SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)),
SkuName: utils.String2Pointer(v.SkuName),
SkuName: utils.String2Pointer(checkNameLength(v.SkuName)),
MemberPrice: price,
SkuPrice: price, // 优先使用skuPrice 靠后SalePrice
SuggestedPrice: price, // 优先使用skuPrice 靠后SalePrice
@@ -291,7 +291,6 @@ func createTaoVegetable(ctx *jxcontext.Context, api *tao_vegetable.API, storeSku
InventoryUnit: utils.String2Pointer("份"),
ProducerPlace: utils.String2Pointer(tao_vegetable.CreateSkuProducerPlace),
SkuCode: utils.String2Pointer(utils.Int2Str(storeSku.SkuID)),
SkuName: utils.String2Pointer(storeSku.SkuName),
StorageType: utils.Int64ToPointer(tao_vegetable.CreateSkuStorageType),
SuggestedPrice: price,
Weight: utils.String2Pointer(utils.Int2Str(storeSku.Weight)),
@@ -333,6 +332,7 @@ func createTaoVegetable(ctx *jxcontext.Context, api *tao_vegetable.API, storeSku
if sku.SkuPicUrls == nil {
continue
}
sku.SkuName = utils.String2Pointer(checkNameLength(storeSku.Name))
if storeSku.MinOrderCount <= model.YES {
sku.PurchaseQuantity = utils.Int64ToPointer(model.YES) // 起购单位
@@ -396,6 +396,48 @@ func createTaoVegetable(ctx *jxcontext.Context, api *tao_vegetable.API, storeSku
return failedList, nil
}
func checkNameLength(name string) string {
if len(name) <= tao_vegetable.NameMaxLength {
return name
}
lastName := ""
if strings.Contains(name, "(") {
startIndex := strings.Index(name, "(")
endIndex := strings.Index(name, ")")
lastName = name[0:startIndex] + name[endIndex+1:]
if len(lastName) <= tao_vegetable.NameMaxLength {
return lastName
}
}
if strings.Contains(lastName, "") {
startIndex := strings.Index(lastName, "")
endIndex := strings.Index(lastName, "")
lastName = lastName[0:startIndex] + " " + lastName[endIndex+3:]
if len(lastName) <= tao_vegetable.NameMaxLength {
return lastName
}
}
if strings.Contains(lastName, "[") {
startIndex := strings.Index(lastName, "[")
endIndex := strings.Index(lastName, "]")
lastName = lastName[0:startIndex] + lastName[endIndex+1:]
if len(lastName) <= tao_vegetable.NameMaxLength {
return lastName
}
}
if strings.Contains(lastName, "【") {
startIndex := strings.Index(lastName, "【")
endIndex := strings.Index(lastName, "】")
lastName = lastName[0:startIndex] + " " + lastName[endIndex+3:]
if len(lastName) <= tao_vegetable.NameMaxLength {
return lastName
}
}
return name[0:60]
}
func uploadImg(api *tao_vegetable.API, imgs []string) *string {
result := make([]string, 0, 0)
for _, v := range imgs {