From fb9f21dd342c2508ca1b205ebe5955227de77409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 10 Nov 2022 18:03:59 +0800 Subject: [PATCH] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index cfb3334f8..b40af3286 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -593,6 +593,16 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk if len(detail1) > 3 { detail1 = detail1[0:3] } + specsUnit := "g" + var infoValue float64 = 1 + switch localSku.SpecUnit { + case "g", "G", "ml", "ML": + specsUnit = "g" + infoValue = 1 + case "l", "L", "KG", "kg": + specsUnit = "g" + infoValue = 1000 + } switch len(detail1) { case 1: name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",") @@ -604,9 +614,10 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk StepStockNum: 0, SupplierID: "", OuterSkuID: utils.Int2Str(localSku.SkuID), - DeliveryInfos: []*tiktokShop.DeliveryInfos{ - {InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)}, - }, + } + + sku.DeliveryInfos = []*tiktokShop.DeliveryInfos{ + {InfoType: "weight", InfoUnit: specsUnit, InfoValue: utils.Float64ToStr(float64(localSku.SpecQuality) * infoValue)}, } stock := localSku.Stock if localSku.Stock == 0 { @@ -631,7 +642,7 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk SupplierID: "", OuterSkuID: utils.Int2Str(localSku.NameID), DeliveryInfos: []*tiktokShop.DeliveryInfos{ - {InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)}, + {InfoType: "weight", InfoUnit: specsUnit, InfoValue: utils.Float64ToStr(float64(localSku.SpecQuality) * infoValue)}, }, } stock := localSku.Stock @@ -661,7 +672,7 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk SupplierID: "", OuterSkuID: utils.Int2Str(localSku.NameID), DeliveryInfos: []*tiktokShop.DeliveryInfos{ - {InfoType: "weight", InfoUnit: localSku.SpecUnit, InfoValue: fmt.Sprintf("%f", localSku.SpecQuality)}, + {InfoType: "weight", InfoUnit: specsUnit, InfoValue: utils.Float64ToStr(float64(localSku.SpecQuality) * infoValue)}, }, } stock := localSku.Stock