From 5864cf027645222b048364a702b001a1bc5d20d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 9 Oct 2022 15:47:46 +0800 Subject: [PATCH] 1 --- .../purchase/tiktok_store/store_sku2.go | 66 ++++++++++--------- business/partner/putils/store_sku.go | 10 +++ 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2.go b/business/partner/purchase/tiktok_store/store_sku2.go index 4be7a082e..750a74668 100644 --- a/business/partner/purchase/tiktok_store/store_sku2.go +++ b/business/partner/purchase/tiktok_store/store_sku2.go @@ -1,19 +1,15 @@ package tiktok_store import ( - "encoding/json" "fmt" + "git.rosy.net.cn/baseapi/platformapi/mtwmapi" freightTemplate_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/freightTemplate_create/request" product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request" product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response" product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request" shop_bindStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreFreight/request" + sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request" tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" - "math/rand" - "regexp" - "strings" - - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -23,6 +19,8 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" + "math/rand" + "regexp" ) const ( @@ -500,32 +498,40 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { api := getAPI(vendorOrgCode, storeID, vendorStoreID) for _, v := range storeSkuList { - param := &product_editV2_request.ProductEditV2Param{} - param.ProductId = utils.Str2Int64(v.VendorSkuID) - param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit - - skuSize := make([]*tiktokShop.SpecDetailList, 0, 0) - detail1 := strings.Split(param.Specs, "^") - name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",") - for i := 0; i < len(name1); i++ { - sku := &tiktokShop.SpecDetailList{ - SpecDetailName1: name1[i], - StockNum: v.Stock, - Price: int(v.VendorPrice), - Code: utils.Int2Str(v.SkuID), - StepStockNum: 0, - SupplierID: "", - OuterSkuID: utils.Int2Str(v.NameID), - DeliveryInfos: []*tiktokShop.DeliveryInfos{ - {InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)}, - }, - } - skuSize = append(skuSize, sku) + //param := &product_editV2_request.ProductEditV2Param{} + //param.ProductId = utils.Str2Int64(v.VendorSkuID) + //param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit + // + //skuSize := make([]*tiktokShop.SpecDetailList, 0, 0) + //detail1 := strings.Split(param.Specs, "^") + //name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",") + //for i := 0; i < len(name1); i++ { + // sku := &tiktokShop.SpecDetailList{ + // SpecDetailName1: name1[i], + // StockNum: v.Stock, + // Price: int(v.VendorPrice), + // Code: utils.Int2Str(v.SkuID), + // StepStockNum: 0, + // SupplierID: "", + // OuterSkuID: utils.Int2Str(v.NameID), + // DeliveryInfos: []*tiktokShop.DeliveryInfos{ + // {InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)}, + // }, + // } + // skuSize = append(skuSize, sku) + //} + //data, _ := json.Marshal(skuSize) + //param.SpecPrices = string(data) + param := &sku_editPrice_request.SkuEditPriceParam{ + Price: v.VendorPrice, + Code: "", + SkuId: 0, + OutSkuId: int64(v.SkuID), + ProductId: utils.Str2Int64(v.VendorSkuID), + OutProductId: int64(v.SkuID), } - data, _ := json.Marshal(skuSize) - param.SpecPrices = string(data) - err := api.EditStoreCommodity(param) + err := api.EditPrice(param) if err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "上架商品异常")...) } else { diff --git a/business/partner/putils/store_sku.go b/business/partner/putils/store_sku.go index bd1d199ff..4862088ed 100644 --- a/business/partner/putils/store_sku.go +++ b/business/partner/putils/store_sku.go @@ -260,6 +260,16 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID int SyncType: syncType, } failedList = append(failedList, storeSkuInfoWithErr) + } else if storeSku, ok := storeSkuList.(*partner.StoreSkuInfo); ok { + globals.SugarLogger.Debugf("=======storeSku== %s", utils.Format4Output(storeSkuLists, false)) + storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{ + StoreSkuInfo: storeSku, + ErrMsg: errMsg, + StoreID: storeID, + VendoreName: vendorName, + SyncType: syncType, + } + failedList = append(failedList, storeSkuInfoWithErr) } else if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok { globals.SugarLogger.Debugf("=======storeSkuLists StoreSkuSyncInfo== %s", utils.Format4Output(storeSkuLists, false)) storeSkuInfo := &partner.StoreSkuInfo{