From 5bf025de2b37192a0ba7117154465562aa933b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 30 Dec 2022 13:42:56 +0800 Subject: [PATCH 01/45] 1 --- business/jxstore/cms/sync_store_sku.go | 6 ------ business/jxstore/misc/misc.go | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 4cd67dcf5..8d0f67778 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -676,12 +676,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag // api.JdShop2API.SetCookieWithStr(configs[0].Value) // } } - //createList, updateList []*dao.StoreSkuSyncInfo - //deleteList, stockList, onlineList, offlineList, priceList []*partner.StoreSkuInfo - //updateItems []*dao.KVUpdateItem - //reorderSkuMap map[string][]*dao.StoreSkuSyncInfo - globals.SugarLogger.Debugf("createList len = %d ", len(createList)) - globals.SugarLogger.Debugf("====skuList %s", utils.Format4Output(skus, false)) task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { step := batchItemList[0].(int) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index a52d0bc87..c118e5202 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -253,9 +253,9 @@ func Init() { // 抖音更新门店商品 if beego.BConfig.RunMode != "jxgy" { - ScheduleTimerFuncByInterval(func() { + ScheduleTimerFunc("RefreshSyncSkuList", func() { syncStoreSkuTiktok() - }, 60*time.Second, 30*time.Minute) + }, []string{}) } // 定时任务刷新当前订单的物流信息 @@ -590,7 +590,7 @@ func syncStoreSkuTiktok() { if beego.BConfig.RunMode != "jxgy" { errList.AddErr(cms.DeleteSkuNameExPrefixOverdue(db)) errList.AddErr(cms.SetMultiStoreSkuSyncModifyStatus(db, partner.GetMultiStoreVendorIDs())) - _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, []int{668619}, false, nil, nil, syncFlag, true, true) + _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, []int{}, false, nil, nil, syncFlag, true, true) errList.AddErr(err) } case 1: From 659e87e73abf2f09000c0227b42c482af064239f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 30 Dec 2022 15:00:25 +0800 Subject: [PATCH 02/45] 1 --- business/jxstore/cms/store.go | 1 - business/jxstore/cms/sync.go | 1 - business/model/dao/thing_map.go | 11 +++++++++++ controllers/cms_sku.go | 8 ++++---- controllers/tiktok_delivery.go | 1 - controllers/tiktok_order.go | 1 - 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index c2001727b..df49da4ce 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -784,7 +784,6 @@ func GetVendorStore(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorS return nil, err } if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil { - globals.SugarLogger.Debugf("step1 handler==============%s", handler) result, err2 := handler.ReadStore(ctx, vendorOrgCode, vendorStoreID, "") if err = err2; err == nil { retVal = &StoreExt{ diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 1c1948e6e..7c2a82b48 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -288,7 +288,6 @@ func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs var vendorStoreID string storeMap := loopMapInfo.StoreMapList[0] if model.IsSyncStatusNew(storeMap.SyncStatus) { - globals.SugarLogger.Debug("进入handler.CreateStore2") storeDetail, _ := dao.GetStoreDetail(db, storeMap.StoreID, storeMap.VendorID, storeMap.VendorOrgCode) if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, storeDetail); err == nil { resultList = append(resultList, 1) diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 921e0789b..907014b85 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -1,6 +1,7 @@ package dao import ( + "fmt" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" ) @@ -50,8 +51,15 @@ func UpdateThingMap(thingMap *model.ThingMap) error { return err } +var thingMapList = make(map[string][]*model.ThingMap, 1024) + // GetThingToTiktokMapList 抖店获取同步类型 func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCode string) (cats []*model.ThingMap, err error) { + if _, ok := thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)]; ok { + if len(thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)]) != 0 { + return thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)], nil + } + } sql := ` SELECT t1.* FROM thing_map t1 @@ -65,6 +73,9 @@ func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCo } err = GetRows(db, &cats, sql, sqlParams...) + if len(cats) != 0 { + thingMapList[fmt.Sprintf("%d_%s_%d", cats[0].VendorID, cats[0].VendorOrgCode, cats[0].ThingID)] = cats + } return cats, err } diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go index 30d6359ea..79d0cbd8d 100644 --- a/controllers/cms_sku.go +++ b/controllers/cms_sku.go @@ -886,21 +886,21 @@ func (c *SkuController) UpdateTiktokCategory() { item.VendorCategoryID = data2[v.DdId] skuVendorCategoryMap := &model.SkuVendorCategoryMap{} if err := dao.GetRow(db, skuVendorCategoryMap, `SELECT * FROM sku_vendor_category_map WHERE name_id = ? AND vendor_id = ? AND deleted_at = ?`, []interface{}{v.NameId, model.VendorIDDD, utils.DefaultTimeValue}); err != nil { - globals.SugarLogger.Debugf("====================err3 %s", err) + globals.SugarLogger.Errorf("get row err : %v", err) } if skuVendorCategoryMap != nil && skuVendorCategoryMap.ID > 0 { if _, err := dao.UpdateEntity(db, skuVendorCategoryMap, "VendorCategoryID"); err != nil { - globals.SugarLogger.Debugf("====================err4 %s", err) + globals.SugarLogger.Errorf("update err : %v", err) } } else { if err := dao.CreateEntity(db, item); err != nil { - globals.SugarLogger.Debugf("====================err5 %s", err) + globals.SugarLogger.Errorf("create err : %v", err) } } go func() { time.Sleep(500 * time.Millisecond) hit, err := cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, 0, db, []int{14}, []int{v.StoreId}, []int{v.Id}, true, false, true) - globals.SugarLogger.Debugf("===============hit:%s err: %s", hit, err) + globals.SugarLogger.Debugf("hit:%s err: %v", hit, err) }() } if page*pageSize < total { diff --git a/controllers/tiktok_delivery.go b/controllers/tiktok_delivery.go index fcae5e8ed..0bd9daf92 100644 --- a/controllers/tiktok_delivery.go +++ b/controllers/tiktok_delivery.go @@ -157,7 +157,6 @@ func (c *LogisticsController) LogisticsQuery() { // 查询订单的运单是否存在 data, err := dao.GetWayBillsByWayBillId(dao.GetDB(), param.TrackNo) if err != nil || len(data) == 0 { - globals.SugarLogger.Debugf("根据单号查询运单数据错误:%s,运单号 :%s", err.Error(), param.TrackNo) c.Data["json"] = LogisticsQueryRest{ Result: false, ReturnCode: "1002", diff --git a/controllers/tiktok_order.go b/controllers/tiktok_order.go index 86d5f3589..9c5e2e345 100644 --- a/controllers/tiktok_order.go +++ b/controllers/tiktok_order.go @@ -40,7 +40,6 @@ func (t *TiktokController) CallbackTiktokOrderMsg() { for k, v := range orderStatus { for _, callback := range v { - globals.SugarLogger.Debugf("CallbackTiktokOrderMsg v======%s", utils.Format4Output(v, false)) resp2 := tiktok_store.OnOrderMsg(k, callback) if resp2.Code != 0 { t.Data["json"] = resp2 From f26443f3d9117936be67dfbb00839d0fcc2a3ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 30 Dec 2022 15:06:58 +0800 Subject: [PATCH 03/45] 1 --- business/jxstore/misc/misc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index c118e5202..2b9e95fa3 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -255,7 +255,7 @@ func Init() { if beego.BConfig.RunMode != "jxgy" { ScheduleTimerFunc("RefreshSyncSkuList", func() { syncStoreSkuTiktok() - }, []string{}) + }, []string{"01:25:00"}) } // 定时任务刷新当前订单的物流信息 From 36059bd1dc485273922e2416e0e5f43d77141389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 14:35:45 +0800 Subject: [PATCH 04/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 20cea0e55..75fb4d89c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -316,7 +316,18 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - if err != nil || childrenProductId == 0 { + if err != nil && strings.Contains(err.Error(), "2010001") { // 子品已经同步了但本地不存在 + mainOrderDetailSkuId, _ := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) + if mainOrderDetailSkuId.MainProductId != 0 { // 子品 + storeSku.VendorSonSkuID = mainOrderDetailSkuId.ProductIdStr // (属性id skuID方案一)(自商品的商品id方案二) + storeSku.SkuSyncStatus = 0 + storeSku.VendorSkuID = mainOrderDetailSkuId.ProductIdStr // 子商品主id + storeSku.VendorMainId = utils.Int64ToStr(mainOrderDetailSkuId.MainProductId) // 主品id + childrenProductId = mainOrderDetailSkuId.ProductId + } else { // 正常不会进入 + continue + } + } else if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) From 9902bf1ed483bcef62c0d3bf15d4f652407c1d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 16:17:16 +0800 Subject: [PATCH 05/45] 1' --- business/partner/purchase/mtwm/store_sku2.go | 1 - .../purchase/tiktok_store/{mtwm.go => dy.go} | 0 .../purchase/tiktok_store/store_sku2.go | 54 +++++++++---------- .../purchase/tiktok_store/store_sku2_utils.go | 10 ++-- 4 files changed, 28 insertions(+), 37 deletions(-) rename business/partner/purchase/tiktok_store/{mtwm.go => dy.go} (100%) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 8ac303798..f846cb18f 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -343,7 +343,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } - globals.SugarLogger.Debugf("foodDataList=======mtwm %s", utils.Format4Output(foodDataList, false)) if globals.EnableMtwmStoreWrite { if len(foodDataList) == 1 { foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"])) diff --git a/business/partner/purchase/tiktok_store/mtwm.go b/business/partner/purchase/tiktok_store/dy.go similarity index 100% rename from business/partner/purchase/tiktok_store/mtwm.go rename to business/partner/purchase/tiktok_store/dy.go diff --git a/business/partner/purchase/tiktok_store/store_sku2.go b/business/partner/purchase/tiktok_store/store_sku2.go index 0a602cdb7..72744e168 100644 --- a/business/partner/purchase/tiktok_store/store_sku2.go +++ b/business/partner/purchase/tiktok_store/store_sku2.go @@ -130,17 +130,15 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr if status == model.SkuStatusNormal { // 下架 for _, v := range storeSkuList { // 子品商品id获取skuId - childrenSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) - if len(failedList) > 0 { - continue - } + //childrenSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) + //if len(failedList) > 0 { + // continue + //} param := &sku_syncStock_request.SkuSyncStockParam{ - SkuId: childrenSkuId, - ProductId: utils.Str2Int64(v.VendorSkuID), - Incremental: false, - IdempotentId: "", - StockNum: 99999, - OutWarehouseId: vendorStoreID, + ProductId: utils.Str2Int64(v.VendorSkuID), + Incremental: false, + StockNum: 99999, + OutSkuId: int64(v.SkuID), } if err := api.UpdateSkuStock(param); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("上架商品,库存值最大化.%s", utils.Format4Output(param, false)))...) @@ -149,18 +147,16 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr } else { // 上架 for _, v := range storeSkuList { // 子品商品id获取skuId - childrenSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) - if len(failedList) > 0 { - continue - } + //childrenSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) + //if len(failedList) > 0 { + // continue + //} param := &sku_syncStock_request.SkuSyncStockParam{ - SkuId: childrenSkuId, - ProductId: utils.Str2Int64(v.VendorSkuID), - Incremental: false, - IdempotentId: "", - StockNum: 0, - OutWarehouseId: vendorStoreID, + ProductId: utils.Str2Int64(v.VendorSkuID), + Incremental: false, + StockNum: 0, + OutSkuId: int64(v.SkuID), } if err := api.UpdateSkuStock(param); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("下架商品,库存值为0失败.%s", utils.Format4Output(param, false)))...) @@ -203,18 +199,16 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg tiktokApi := getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID) for _, v := range storeSkuList { // 子品商品id获取skuId - childrenSkuId, failedList := getProductSkuId4UpdateStock(tiktokApi, v, storeID) - if len(failedList) > 0 { - continue - } + //childrenSkuId, failedList := getProductSkuId4UpdateStock(tiktokApi, v, storeID) + //if len(failedList) > 0 { + // continue + //} stockNum := &sku_syncStock_request.SkuSyncStockParam{ - SkuId: childrenSkuId, - ProductId: utils.Str2Int64(v.VendorSkuID), - Incremental: false, - IdempotentId: "", - StockNum: int64(v.Stock), - OutWarehouseId: vendorStoreID, + ProductId: utils.Str2Int64(v.VendorSkuID), + Incremental: false, + StockNum: int64(v.Stock), + OutSkuId: int64(v.SkuID), } if stockNum.StockNum == 0 { stockNum.StockNum = 99999 diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 75fb4d89c..1cd2614a3 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -529,12 +529,10 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS } // 同步库存 paramStock := &sku_syncStock_request.SkuSyncStockParam{ - SkuId: skuId, - ProductId: childrenProductId, - Incremental: false, - IdempotentId: "", - StockNum: int64(storeSku.Stock), - OutWarehouseId: vendorStoreID, + ProductId: childrenProductId, + Incremental: false, + StockNum: int64(storeSku.Stock), + OutSkuId: int64(storeSku.SkuID), } if paramStock.StockNum == 0 { paramStock.StockNum = 99999 From 45d0f0ea0fe9604c75d7068105c68b87cab0d3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 16:39:02 +0800 Subject: [PATCH 06/45] 1' --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 1cd2614a3..97e3a14cb 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -337,7 +337,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } // 同步价格,库存,上架 - failedList = upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) + upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id storeSku.VendorMainId = localThing[0].VendorThingID // 商品主id @@ -549,6 +549,7 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS } else { storeSku.SkuSyncStatus = 0 } + globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch===,%s", utils.Format4Output(failedList, false)) return failedList } From 3a430e51ebad1ad13442fb158c4cbce8b4e8853f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 16:49:35 +0800 Subject: [PATCH 07/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 97e3a14cb..00df43ff5 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -318,6 +318,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) if err != nil && strings.Contains(err.Error(), "2010001") { // 子品已经同步了但本地不存在 mainOrderDetailSkuId, _ := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) + globals.SugarLogger.Debugf("==GetSkuDetailLocalID === %s", utils.Format4Output(mainOrderDetailSkuId, false)) if mainOrderDetailSkuId.MainProductId != 0 { // 子品 storeSku.VendorSonSkuID = mainOrderDetailSkuId.ProductIdStr // (属性id skuID方案一)(自商品的商品id方案二) storeSku.SkuSyncStatus = 0 From fd5c7a56d3e892a2b510cda1dc58818e2085bbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 17:22:15 +0800 Subject: [PATCH 08/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 00df43ff5..a21d6a10f 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -316,19 +316,20 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - if err != nil && strings.Contains(err.Error(), "2010001") { // 子品已经同步了但本地不存在 - mainOrderDetailSkuId, _ := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) - globals.SugarLogger.Debugf("==GetSkuDetailLocalID === %s", utils.Format4Output(mainOrderDetailSkuId, false)) - if mainOrderDetailSkuId.MainProductId != 0 { // 子品 - storeSku.VendorSonSkuID = mainOrderDetailSkuId.ProductIdStr // (属性id skuID方案一)(自商品的商品id方案二) - storeSku.SkuSyncStatus = 0 - storeSku.VendorSkuID = mainOrderDetailSkuId.ProductIdStr // 子商品主id - storeSku.VendorMainId = utils.Int64ToStr(mainOrderDetailSkuId.MainProductId) // 主品id - childrenProductId = mainOrderDetailSkuId.ProductId - } else { // 正常不会进入 - continue - } - } else if err != nil || childrenProductId == 0 { + //if err != nil && strings.Contains(err.Error(), "2010001") { // 子品已经同步了但本地不存在 + // mainOrderDetailSkuId, _ := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) + // globals.SugarLogger.Debugf("==GetSkuDetailLocalID === %s", utils.Format4Output(mainOrderDetailSkuId, false)) + // if mainOrderDetailSkuId.MainProductId != 0 { // 子品 + // storeSku.VendorSonSkuID = mainOrderDetailSkuId.ProductIdStr // (属性id skuID方案一)(自商品的商品id方案二) + // storeSku.SkuSyncStatus = 0 + // storeSku.VendorSkuID = mainOrderDetailSkuId.ProductIdStr // 子商品主id + // storeSku.VendorMainId = utils.Int64ToStr(mainOrderDetailSkuId.MainProductId) // 主品id + // childrenProductId = mainOrderDetailSkuId.ProductId + // } else { // 主品 + // continue + // } + //} else + if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) From 61206b6490b1855a96474d8020549b24163433fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 17:54:01 +0800 Subject: [PATCH 09/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index a21d6a10f..7a3e2f28a 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -264,7 +264,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) storeSku.SkuSyncStatus = 0 storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id - failedList = upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) + upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) } else { storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // (属性id skuID方案一)(自商品的商品id方案二) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) // 子商品主id From b49f41acbb49c660a18966df9e2cfa8dc6888cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 3 Jan 2023 18:08:13 +0800 Subject: [PATCH 10/45] 1 --- business/model/dao/thing_map.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 907014b85..5eba0483d 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -1,7 +1,6 @@ package dao import ( - "fmt" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" ) @@ -51,15 +50,9 @@ func UpdateThingMap(thingMap *model.ThingMap) error { return err } -var thingMapList = make(map[string][]*model.ThingMap, 1024) - // GetThingToTiktokMapList 抖店获取同步类型 func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCode string) (cats []*model.ThingMap, err error) { - if _, ok := thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)]; ok { - if len(thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)]) != 0 { - return thingMapList[fmt.Sprintf("%d_%s_%d", vendorId, vendorOrgCode, thingId)], nil - } - } + sql := ` SELECT t1.* FROM thing_map t1 @@ -73,9 +66,7 @@ func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCo } err = GetRows(db, &cats, sql, sqlParams...) - if len(cats) != 0 { - thingMapList[fmt.Sprintf("%d_%s_%d", cats[0].VendorID, cats[0].VendorOrgCode, cats[0].ThingID)] = cats - } + return cats, err } From cc53eedafc594c7a0d6fbc706abdaee802b94026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 19:38:30 +0800 Subject: [PATCH 11/45] 1 --- business/jxstore/misc/misc.go | 38 ++++++++++++++++--- business/model/dao/thing_map.go | 1 - .../purchase/tiktok_store/store_sku2_utils.go | 22 +++-------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 2b9e95fa3..1ae1bf341 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -252,11 +252,11 @@ func Init() { }, 60*time.Second, 30*time.Minute) // 抖音更新门店商品 - if beego.BConfig.RunMode != "jxgy" { - ScheduleTimerFunc("RefreshSyncSkuList", func() { - syncStoreSkuTiktok() - }, []string{"01:25:00"}) - } + //if beego.BConfig.RunMode != "jxgy" { + // ScheduleTimerFunc("RefreshSyncSkuList", func() { + // syncStoreSkuTiktok() + // }, []string{"01:25:00"}) + //} // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { @@ -590,7 +590,33 @@ func syncStoreSkuTiktok() { if beego.BConfig.RunMode != "jxgy" { errList.AddErr(cms.DeleteSkuNameExPrefixOverdue(db)) errList.AddErr(cms.SetMultiStoreSkuSyncModifyStatus(db, partner.GetMultiStoreVendorIDs())) - _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, []int{}, false, nil, nil, syncFlag, true, true) + var storeList2GD = []int{ + 102533, + 668619, + 100336, + 102014, + 103089, + 667212, + 667510, + 100328, + 100524, + 102046, + 103190, + 667149, + 100334, + 101995, + 102563, + 102039, + 100329, + 102465, + 102417, + 100517, + 102377, + 666761, + 102592, + 102057, + } + _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, storeList2GD, false, nil, nil, syncFlag, true, true) errList.AddErr(err) } case 1: diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 5eba0483d..3c9ec2ca5 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -52,7 +52,6 @@ func UpdateThingMap(thingMap *model.ThingMap) error { // GetThingToTiktokMapList 抖店获取同步类型 func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCode string) (cats []*model.ThingMap, err error) { - sql := ` SELECT t1.* FROM thing_map t1 diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 7a3e2f28a..4f0ff92f4 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -442,28 +442,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) *product_detail_response.ProductDetailData { // 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态 var mainOrderDetail = &product_detail_response.ProductDetailData{} - mainOrderDetailSkuId, err := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) - if err != nil || mainOrderDetailSkuId == nil { + if storeSku.VendorMainId == "" { mainOrderDetail.MainProductId = 0 return mainOrderDetail } - if mainOrderDetailSkuId.MainProductId != 0 { // 查询出来是子商品 - mainOrderDetail.MainProductId = mainOrderDetailSkuId.MainProductId - } else { // 查询出来是主商品 - mainOrderDetail.MainProductId = mainOrderDetailSkuId.ProductId + mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "") + if err != nil || mainOrderDetailProductId == nil { + mainOrderDetail.MainProductId = 0 return mainOrderDetail } - - if mainOrderDetail.MainProductId != 0 { // 子商品时,获取主商品id和状态 - mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "") - if err != nil || mainOrderDetailProductId == nil { - mainOrderDetail.MainProductId = 0 - return mainOrderDetail - } - mainOrderDetail.MainProductId = mainOrderDetailProductId.ProductId - } else { - mainOrderDetail.MainProductId = mainOrderDetail.ProductId // 主商品 - } + mainOrderDetail.MainProductId = mainOrderDetailProductId.ProductId return mainOrderDetail } From 761885879b139cacc75f2504918bb549f0f28005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 19:56:26 +0800 Subject: [PATCH 12/45] 1 --- business/jxstore/misc/misc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 1ae1bf341..680a4c850 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -252,11 +252,11 @@ func Init() { }, 60*time.Second, 30*time.Minute) // 抖音更新门店商品 - //if beego.BConfig.RunMode != "jxgy" { - // ScheduleTimerFunc("RefreshSyncSkuList", func() { - // syncStoreSkuTiktok() - // }, []string{"01:25:00"}) - //} + if beego.BConfig.RunMode != "jxgy" { + ScheduleTimerFunc("RefreshSyncSkuList", func() { + syncStoreSkuTiktok() + }, []string{"20:30:00"}) + } // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From e3da652deb0c7428bf9966b8315f30b13961b8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 19:58:31 +0800 Subject: [PATCH 13/45] 1 --- business/jxstore/misc/misc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 680a4c850..d8eeb6b6a 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -255,7 +255,7 @@ func Init() { if beego.BConfig.RunMode != "jxgy" { ScheduleTimerFunc("RefreshSyncSkuList", func() { syncStoreSkuTiktok() - }, []string{"20:30:00"}) + }, []string{"11:30:00"}) } // 定时任务刷新当前订单的物流信息 From 910cf57b6407931ee27ad4227d0dceb6aa7f7310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 21:53:39 +0800 Subject: [PATCH 14/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 4f0ff92f4..801f04bca 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -28,6 +28,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" "math/rand" "strings" + "time" "unicode" ) @@ -165,8 +166,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.Description = detailImg // 部分商品没有所属的分类,直接跳过! - if storeSku.SkuVendorMapCatID != "" { - param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) + if storeSku.VendorVendorCatID != 0 { + param.CategoryLeafId = storeSku.VendorVendorCatID } else if len(param.Pic) != 0 { // 自动推导分类id param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) if param.CategoryLeafId == 0 || err != nil { @@ -274,45 +275,45 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } else { // 线上本地都存在,但是线上审核不成功,就去更新主商品 - //if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { - // // 更新主商品,在同步到子门店,考虑审核时间 - // updateParam := &product_editV2_request.ProductEditV2Param{ - // PayType: tiktokShop.TiktokPayType1, - // ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, - // Weight: utils.Int2Float64(storeSku.Weight), - // DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, - // PresellType: tiktokShop.SendGoodsTypeNow, - // Supply7dayReturn: 0, - // Mobile: storeDetail.Tel1, - // Commit: true, - // Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, - // NeedRechargeMode: false, - // SellChannel: []int64{0}, - // StartSaleType: 0, - // PickupMethod: "0", - // CategoryLeafId: param.CategoryLeafId, - // Name: param.Name, - // ProductFormatNew: param.ProductFormatNew, - // } - // updateParam.Pic = img - // updateParam.Description = detailImg - // updateParam.WeightUnit = tiktokShop.WeightUint_G - // updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 - // updateParam.ProductId = mainOrderDetail.ProductId - // updateParam.MainProductId = mainProductId - // updateParam.SpecPrices = param.SpecPrices - // //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - // if err := api.EditStoreCommodity(updateParam); err != nil { - // failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - // storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - // } else { - // localThing[0].UpdatedAt = time.Now() - // localThing[0].SyncStatus = 0 - // localThing[0].ThingType = model.ThingTypeSku - // dao.UpdateThingMap(localThing[0]) - // } - // continue - //} + if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { + // 更新主商品,在同步到子门店,考虑审核时间 + updateParam := &product_editV2_request.ProductEditV2Param{ + PayType: tiktokShop.TiktokPayType1, + ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, + Weight: utils.Int2Float64(storeSku.Weight), + DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, + PresellType: tiktokShop.SendGoodsTypeNow, + Supply7dayReturn: 0, + Mobile: storeDetail.Tel1, + Commit: true, + Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, + NeedRechargeMode: false, + SellChannel: []int64{0}, + StartSaleType: 0, + PickupMethod: "0", + CategoryLeafId: param.CategoryLeafId, + Name: param.Name, + ProductFormatNew: param.ProductFormatNew, + } + updateParam.Pic = img + updateParam.Description = detailImg + updateParam.WeightUnit = tiktokShop.WeightUint_G + updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 + updateParam.ProductId = mainOrderDetail.ProductId + updateParam.MainProductId = mainProductId + updateParam.SpecPrices = param.SpecPrices + //updateParam.StoreId = utils.Str2Int64(vendorStoreID) + if err := api.EditStoreCommodity(updateParam); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) + } else { + localThing[0].UpdatedAt = time.Now() + localThing[0].SyncStatus = 0 + localThing[0].ThingType = model.ThingTypeSku + dao.UpdateThingMap(localThing[0]) + } + continue + } // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) From e701bfbcc23bb64ecd7ba111f030f5632adaef0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:08:42 +0800 Subject: [PATCH 15/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 801f04bca..398eea43c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -275,6 +275,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } else { // 线上本地都存在,但是线上审核不成功,就去更新主商品 + mainOrderDetail = loadMainProductId(api, storeSku) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { // 更新主商品,在同步到子门店,考虑审核时间 updateParam := &product_editV2_request.ProductEditV2Param{ @@ -443,8 +444,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) *product_detail_response.ProductDetailData { // 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态 var mainOrderDetail = &product_detail_response.ProductDetailData{} - if storeSku.VendorMainId == "" { - mainOrderDetail.MainProductId = 0 + if storeSku.VendorMainId != "" { + mainOrderDetail.MainProductId = utils.Str2Int64(storeSku.VendorMainId) return mainOrderDetail } mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "") From 632f79a781d5a66e90b3d4de56e8ea63ebb13dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:08:50 +0800 Subject: [PATCH 16/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 95 ++++++++----------- 1 file changed, 41 insertions(+), 54 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 398eea43c..2d8e091e6 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -28,7 +28,6 @@ import ( "git.rosy.net.cn/jx-callback/globals" "math/rand" "strings" - "time" "unicode" ) @@ -274,63 +273,51 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } } else { - // 线上本地都存在,但是线上审核不成功,就去更新主商品 - mainOrderDetail = loadMainProductId(api, storeSku) - if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { - // 更新主商品,在同步到子门店,考虑审核时间 - updateParam := &product_editV2_request.ProductEditV2Param{ - PayType: tiktokShop.TiktokPayType1, - ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, - Weight: utils.Int2Float64(storeSku.Weight), - DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, - PresellType: tiktokShop.SendGoodsTypeNow, - Supply7dayReturn: 0, - Mobile: storeDetail.Tel1, - Commit: true, - Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, - NeedRechargeMode: false, - SellChannel: []int64{0}, - StartSaleType: 0, - PickupMethod: "0", - CategoryLeafId: param.CategoryLeafId, - Name: param.Name, - ProductFormatNew: param.ProductFormatNew, - } - updateParam.Pic = img - updateParam.Description = detailImg - updateParam.WeightUnit = tiktokShop.WeightUint_G - updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 - updateParam.ProductId = mainOrderDetail.ProductId - updateParam.MainProductId = mainProductId - updateParam.SpecPrices = param.SpecPrices - //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - if err := api.EditStoreCommodity(updateParam); err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - } else { - localThing[0].UpdatedAt = time.Now() - localThing[0].SyncStatus = 0 - localThing[0].ThingType = model.ThingTypeSku - dao.UpdateThingMap(localThing[0]) - } - continue - } - // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - //if err != nil && strings.Contains(err.Error(), "2010001") { // 子品已经同步了但本地不存在 - // mainOrderDetailSkuId, _ := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) - // globals.SugarLogger.Debugf("==GetSkuDetailLocalID === %s", utils.Format4Output(mainOrderDetailSkuId, false)) - // if mainOrderDetailSkuId.MainProductId != 0 { // 子品 - // storeSku.VendorSonSkuID = mainOrderDetailSkuId.ProductIdStr // (属性id skuID方案一)(自商品的商品id方案二) - // storeSku.SkuSyncStatus = 0 - // storeSku.VendorSkuID = mainOrderDetailSkuId.ProductIdStr // 子商品主id - // storeSku.VendorMainId = utils.Int64ToStr(mainOrderDetailSkuId.MainProductId) // 主品id - // childrenProductId = mainOrderDetailSkuId.ProductId - // } else { // 主品 + //if strings.Contains(err.Error(), "") { + // // 线上本地都存在,但是线上审核不成功,就去更新主商品 + // mainOrderDetail = loadMainProductId(api, storeSku) + // if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { + // // 更新主商品,在同步到子门店,考虑审核时间 + // updateParam := &product_editV2_request.ProductEditV2Param{ + // PayType: tiktokShop.TiktokPayType1, + // ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, + // Weight: utils.Int2Float64(storeSku.Weight), + // DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, + // PresellType: tiktokShop.SendGoodsTypeNow, + // Supply7dayReturn: 0, + // Mobile: storeDetail.Tel1, + // Commit: true, + // Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, + // NeedRechargeMode: false, + // SellChannel: []int64{0}, + // StartSaleType: 0, + // PickupMethod: "0", + // CategoryLeafId: param.CategoryLeafId, + // Name: param.Name, + // ProductFormatNew: param.ProductFormatNew, + // } + // updateParam.Pic = img + // updateParam.Description = detailImg + // updateParam.WeightUnit = tiktokShop.WeightUint_G + // updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 + // updateParam.ProductId = mainOrderDetail.ProductId + // updateParam.MainProductId = mainProductId + // updateParam.SpecPrices = param.SpecPrices + // //updateParam.StoreId = utils.Str2Int64(vendorStoreID) + // if err := api.EditStoreCommodity(updateParam); err != nil { + // failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + // storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) + // } else { + // localThing[0].UpdatedAt = time.Now() + // localThing[0].SyncStatus = 0 + // localThing[0].ThingType = model.ThingTypeSku + // dao.UpdateThingMap(localThing[0]) + // } // continue // } - //} else + //} if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask From 239965819ad94579c47878fc6beb850ddf52a705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:10:51 +0800 Subject: [PATCH 17/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 87 ++++++++++--------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 2d8e091e6..b11944b75 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -28,6 +28,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" "math/rand" "strings" + "time" "unicode" ) @@ -275,49 +276,49 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - //if strings.Contains(err.Error(), "") { - // // 线上本地都存在,但是线上审核不成功,就去更新主商品 - // mainOrderDetail = loadMainProductId(api, storeSku) - // if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { - // // 更新主商品,在同步到子门店,考虑审核时间 - // updateParam := &product_editV2_request.ProductEditV2Param{ - // PayType: tiktokShop.TiktokPayType1, - // ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, - // Weight: utils.Int2Float64(storeSku.Weight), - // DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, - // PresellType: tiktokShop.SendGoodsTypeNow, - // Supply7dayReturn: 0, - // Mobile: storeDetail.Tel1, - // Commit: true, - // Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, - // NeedRechargeMode: false, - // SellChannel: []int64{0}, - // StartSaleType: 0, - // PickupMethod: "0", - // CategoryLeafId: param.CategoryLeafId, - // Name: param.Name, - // ProductFormatNew: param.ProductFormatNew, - // } - // updateParam.Pic = img - // updateParam.Description = detailImg - // updateParam.WeightUnit = tiktokShop.WeightUint_G - // updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 - // updateParam.ProductId = mainOrderDetail.ProductId - // updateParam.MainProductId = mainProductId - // updateParam.SpecPrices = param.SpecPrices - // //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - // if err := api.EditStoreCommodity(updateParam); err != nil { - // failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - // storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - // } else { - // localThing[0].UpdatedAt = time.Now() - // localThing[0].SyncStatus = 0 - // localThing[0].ThingType = model.ThingTypeSku - // dao.UpdateThingMap(localThing[0]) - // } - // continue - // } - //} + if strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 + // 线上本地都存在,但是线上审核不成功,就去更新主商品 + mainOrderDetail = loadMainProductId(api, storeSku) + if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { + // 更新主商品,在同步到子门店,考虑审核时间 + updateParam := &product_editV2_request.ProductEditV2Param{ + PayType: tiktokShop.TiktokPayType1, + ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, + Weight: utils.Int2Float64(storeSku.Weight), + DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, + PresellType: tiktokShop.SendGoodsTypeNow, + Supply7dayReturn: 0, + Mobile: storeDetail.Tel1, + Commit: true, + Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, + NeedRechargeMode: false, + SellChannel: []int64{0}, + StartSaleType: 0, + PickupMethod: "0", + CategoryLeafId: param.CategoryLeafId, + Name: param.Name, + ProductFormatNew: param.ProductFormatNew, + } + updateParam.Pic = img + updateParam.Description = detailImg + updateParam.WeightUnit = tiktokShop.WeightUint_G + updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 + updateParam.ProductId = mainOrderDetail.ProductId + updateParam.MainProductId = mainProductId + updateParam.SpecPrices = param.SpecPrices + //updateParam.StoreId = utils.Str2Int64(vendorStoreID) + if err := api.EditStoreCommodity(updateParam); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) + } else { + localThing[0].UpdatedAt = time.Now() + localThing[0].SyncStatus = 0 + localThing[0].ThingType = model.ThingTypeSku + dao.UpdateThingMap(localThing[0]) + } + continue + } + } if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask From bb1eb616c21c24fa2a8c44fa93c8d59c4dfcc547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:14:31 +0800 Subject: [PATCH 18/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index b11944b75..db96a0ec9 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -28,7 +28,6 @@ import ( "git.rosy.net.cn/jx-callback/globals" "math/rand" "strings" - "time" "unicode" ) @@ -276,7 +275,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - if strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 + if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 mainOrderDetail = loadMainProductId(api, storeSku) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { @@ -310,12 +309,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if err := api.EditStoreCommodity(updateParam); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - } else { - localThing[0].UpdatedAt = time.Now() - localThing[0].SyncStatus = 0 - localThing[0].ThingType = model.ThingTypeSku - dao.UpdateThingMap(localThing[0]) - } + } //else { + // localThing[0].UpdatedAt = time.Now() + // localThing[0].SyncStatus = 0 + // localThing[0].ThingType = model.ThingTypeSku + // dao.UpdateThingMap(localThing[0]) + //} continue } } From 869ae67697d3f7fec63ff010dc65f0dcbd57102c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:19:29 +0800 Subject: [PATCH 19/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index db96a0ec9..4b73b697e 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -275,6 +275,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) + globals.SugarLogger.Debugf("===============err %s", err.Error()) + globals.SugarLogger.Debugf("===============err %s", utils.Format4Output(err != nil && strings.Contains(err.Error(), "2010004"), false)) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 mainOrderDetail = loadMainProductId(api, storeSku) From 82a843dc03c424d52262baeef2c8b49205d9e0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:26:03 +0800 Subject: [PATCH 20/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 4b73b697e..c0f3eebbc 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -308,7 +308,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.MainProductId = mainProductId updateParam.SpecPrices = param.SpecPrices //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - if err := api.EditStoreCommodity(updateParam); err != nil { + err := api.EditStoreCommodity(updateParam) + if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) } //else { @@ -317,6 +318,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // localThing[0].ThingType = model.ThingTypeSku // dao.UpdateThingMap(localThing[0]) //} + globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", err.Error()) + globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", updateParam) continue } } From 35f5b53920d405a59c810ed92c6206648603a9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:27:00 +0800 Subject: [PATCH 21/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index c0f3eebbc..0a303835c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -280,6 +280,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 mainOrderDetail = loadMainProductId(api, storeSku) + globals.SugarLogger.Debugf("====bool %s", utils.Format4Output(mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass, false)) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { // 更新主商品,在同步到子门店,考虑审核时间 updateParam := &product_editV2_request.ProductEditV2Param{ From ca74b1e1c72ed298ef93344ab96e1618ba128510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:33:29 +0800 Subject: [PATCH 22/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 0a303835c..f0ea38b9e 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -436,18 +436,18 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) *product_detail_response.ProductDetailData { // 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态 - var mainOrderDetail = &product_detail_response.ProductDetailData{} + var mainOrderDetailProductId = &product_detail_response.ProductDetailData{} if storeSku.VendorMainId != "" { - mainOrderDetail.MainProductId = utils.Str2Int64(storeSku.VendorMainId) - return mainOrderDetail + mainOrderDetailProductId.MainProductId = utils.Str2Int64(storeSku.VendorMainId) + return mainOrderDetailProductId } - mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "") + mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetailProductId.MainProductId), "") if err != nil || mainOrderDetailProductId == nil { - mainOrderDetail.MainProductId = 0 - return mainOrderDetail + mainOrderDetailProductId.MainProductId = 0 + mainOrderDetailProductId.CheckStatus = 4 + return mainOrderDetailProductId } - mainOrderDetail.MainProductId = mainOrderDetailProductId.ProductId - return mainOrderDetail + return mainOrderDetailProductId } func checkNameLenght(name string) string { From 76abfbf5a9e4397211aefb073beccd0ab8cf145e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:42:36 +0800 Subject: [PATCH 23/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 118 ++++++++---------- 1 file changed, 52 insertions(+), 66 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index f0ea38b9e..0b7a085bd 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -218,60 +218,57 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode) if len(localThing) != 0 { mainProductId = utils.Str2Int64(localThing[0].VendorThingID) - } else { - mainOrderDetail = loadMainProductId(api, storeSku) - mainProductId = mainOrderDetail.MainProductId } if len(localThing) == 0 { - if mainProductId == 0 { - tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(tiktokResult.ProductId), storeDetail.VendorOrgCode, "本地不存在,线上也不存在", model.ThingTypeSku, 0) - var attrId []string - for _, v := range tiktokResult.Sku { - attrId = append(attrId, utils.Int64ToStr(v.SkuId)) - } - - mainProductId = tiktokResult.ProductId - storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 - storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId) - storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID - storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // 还没同步子商品 - failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - } else { - // 本地不存在,线上存在.直接创建子商品保存本地同步记录 - var childrenProductId int64 = 0 - dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0) - - childrenProductId, err = api.CreateSubProduct(mainProductId, utils.Str2Int64(vendorStoreID)) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - - storeSku.VendorMainId = utils.Int64ToStr(mainProductId) - var attrId []string - for _, v := range mainOrderDetail.SpecPrices { - attrId = append(attrId, utils.Int64ToStr(v.SkuId)) - } - storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID - if childrenProductId > 0 { - storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) - storeSku.SkuSyncStatus = 0 - storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id - upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) - } else { - storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // (属性id skuID方案一)(自商品的商品id方案二) - storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) // 子商品主id - storeSku.SkuSyncStatus = model.SyncFlagNewMask - failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("主商品创建了,子商品为创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - } + //if mainProductId == 0 { + tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue } + dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(tiktokResult.ProductId), storeDetail.VendorOrgCode, "本地不存在,线上也不存在", model.ThingTypeSku, 0) + var attrId []string + for _, v := range tiktokResult.Sku { + attrId = append(attrId, utils.Int64ToStr(v.SkuId)) + } + + mainProductId = tiktokResult.ProductId + storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 + storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId) + storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID + storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // 还没同步子商品 + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + //} else { + // // 本地不存在,线上存在.直接创建子商品保存本地同步记录 + // var childrenProductId int64 = 0 + // dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0) + // + // childrenProductId, err = api.CreateSubProduct(mainProductId, utils.Str2Int64(vendorStoreID)) + // if err != nil { + // failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + // continue + // } + // + // storeSku.VendorMainId = utils.Int64ToStr(mainProductId) + // var attrId []string + // for _, v := range mainOrderDetail.SpecPrices { + // attrId = append(attrId, utils.Int64ToStr(v.SkuId)) + // } + // storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID + // if childrenProductId > 0 { + // storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) + // storeSku.SkuSyncStatus = 0 + // storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id + // upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) + // } else { + // storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // (属性id skuID方案一)(自商品的商品id方案二) + // storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) // 子商品主id + // storeSku.SkuSyncStatus = model.SyncFlagNewMask + // failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("主商品创建了,子商品为创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + // } + //} } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) @@ -279,7 +276,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI globals.SugarLogger.Debugf("===============err %s", utils.Format4Output(err != nil && strings.Contains(err.Error(), "2010004"), false)) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 - mainOrderDetail = loadMainProductId(api, storeSku) + mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID) globals.SugarLogger.Debugf("====bool %s", utils.Format4Output(mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass, false)) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { // 更新主商品,在同步到子门店,考虑审核时间 @@ -397,14 +394,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if storeSku.VendorMainId == "" { localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode) if len(localThing) == 0 || localThing == nil { - mainOrderDetail := loadMainProductId(api, storeSku) - if mainOrderDetail.MainProductId == 0 { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("主商品获取失败"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - mainIdInt = mainOrderDetail.MainProductId - storeSku.VendorMainId = utils.Int64ToStr(mainIdInt) - dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainIdInt), storeDetail.VendorOrgCode, "更新发现不存在", model.ThingTypeSku, 0) + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New(fmt.Sprintf("更新主品失败,请创建主品skuId[storeId:%d,skuId:%s]", storeID, storeSku.SkuID)), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue } else { storeSku.VendorMainId = localThing[0].VendorThingID mainIdInt = utils.Str2Int64(localThing[0].VendorThingID) @@ -434,14 +425,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI return failedList, err } -func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) *product_detail_response.ProductDetailData { +func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, mainProductId string) *product_detail_response.ProductDetailData { // 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态 - var mainOrderDetailProductId = &product_detail_response.ProductDetailData{} - if storeSku.VendorMainId != "" { - mainOrderDetailProductId.MainProductId = utils.Str2Int64(storeSku.VendorMainId) - return mainOrderDetailProductId - } - mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetailProductId.MainProductId), "") + mainOrderDetailProductId, err := api.GetSkuDetail(mainProductId, "") if err != nil || mainOrderDetailProductId == nil { mainOrderDetailProductId.MainProductId = 0 mainOrderDetailProductId.CheckStatus = 4 From b648e2c085246b964c4dd126d24e0830f5f7e314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:47:54 +0800 Subject: [PATCH 24/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 0b7a085bd..76a9b07e4 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -307,6 +307,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.SpecPrices = param.SpecPrices //updateParam.StoreId = utils.Str2Int64(vendorStoreID) err := api.EditStoreCommodity(updateParam) + globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", err.Error()) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) @@ -316,8 +317,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // localThing[0].ThingType = model.ThingTypeSku // dao.UpdateThingMap(localThing[0]) //} - globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", err.Error()) - globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", updateParam) + globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", utils.Format4Output(updateParam, false)) continue } } From 8a8b83d568b0554174ac4f78688706f815e1a271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 4 Jan 2023 22:55:19 +0800 Subject: [PATCH 25/45] 1 --- business/jxstore/misc/misc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index d8eeb6b6a..1773fee08 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -252,11 +252,11 @@ func Init() { }, 60*time.Second, 30*time.Minute) // 抖音更新门店商品 - if beego.BConfig.RunMode != "jxgy" { - ScheduleTimerFunc("RefreshSyncSkuList", func() { - syncStoreSkuTiktok() - }, []string{"11:30:00"}) - } + //if beego.BConfig.RunMode != "jxgy" { + // ScheduleTimerFunc("RefreshSyncSkuList", func() { + // syncStoreSkuTiktok() + // }, []string{"11:30:00"}) + //} // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From 1c390bc99b5dc7170cf169cfb0fa058222634bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 09:04:32 +0800 Subject: [PATCH 26/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 76a9b07e4..cfbc02eb8 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -273,7 +273,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) globals.SugarLogger.Debugf("===============err %s", err.Error()) - globals.SugarLogger.Debugf("===============err %s", utils.Format4Output(err != nil && strings.Contains(err.Error(), "2010004"), false)) + globals.SugarLogger.Debugf("===============childrenProductId %d", childrenProductId) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID) @@ -486,6 +486,7 @@ func checkNameLenght(name string) string { return name } func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, childrenProductId int64, vendorStoreID, syncType string) (failedList []*partner.StoreSkuInfoWithErr) { + globals.SugarLogger.Debugf("===========1") skuId, failed := getProductSkuID(api, storeSku, syncType, childrenProductId) if skuId == 0 || len(failed) > 0 { return failed @@ -497,7 +498,10 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS ProductId: childrenProductId, }); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType) + globals.SugarLogger.Debugf("===========2 failedList %s", utils.Format4Output(failedList, false)) } + globals.SugarLogger.Debugf("===========2") + // 同步库存 paramStock := &sku_syncStock_request.SkuSyncStockParam{ ProductId: childrenProductId, @@ -510,17 +514,21 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS } if err := api.UpdateSkuStock(paramStock); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("子商品添加固定库存.%s", err.Error()))...) + globals.SugarLogger.Debugf("===========3 failedList %s", utils.Format4Output(failedList, false)) } + globals.SugarLogger.Debugf("===========3") + // 上架 if err := api.LaunchProduct(childrenProductId); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("上架子商品异常.%s", err.Error()))...) + globals.SugarLogger.Debugf("===========4 failedList %s", utils.Format4Output(failedList, false)) } if len(failedList) > 0 { storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask } else { storeSku.SkuSyncStatus = 0 } - globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch===,%s", utils.Format4Output(failedList, false)) + globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch=== 444444,%s", utils.Format4Output(failedList, false)) return failedList } @@ -532,6 +540,7 @@ func getProductSkuID(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, syncTy childrenDetail, err := api.GetSkuDetail(utils.Int64ToStr(productId), "") if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType) + return 0, failedList } for _, v := range childrenDetail.SpecPrices { From ba444ea66793808064af318b9ddf5317973cca0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 09:19:20 +0800 Subject: [PATCH 27/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 1 - 1 file changed, 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index cfbc02eb8..b311a2cc1 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -272,7 +272,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - globals.SugarLogger.Debugf("===============err %s", err.Error()) globals.SugarLogger.Debugf("===============childrenProductId %d", childrenProductId) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 From 867690c646dae4b6321cf8cfaeb84b88903a6a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 09:32:25 +0800 Subject: [PATCH 28/45] 1 --- business/jxstore/cms/store.go | 2 -- business/jxstore/cms/sync_store_sku.go | 1 - business/model/dao/dao_bz.go | 1 - business/partner/delivery/tiktok_store/waybill.go | 7 +------ business/partner/purchase/jd/sku2.go | 1 - business/partner/purchase/tiktok_store/callback.go | 1 - .../partner/purchase/tiktok_store/store_sku2.go | 5 ----- .../purchase/tiktok_store/store_sku2_utils.go | 13 +------------ business/partner/purchase/tiktok_store/warehouse.go | 3 --- controllers/tiktok_order.go | 3 --- 10 files changed, 2 insertions(+), 35 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index df49da4ce..4eabfd73b 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -811,7 +811,6 @@ func GetVendorStore(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorS return nil, err } else { handler := partner.GetDeliveryPlatformFromVendorID(vendorID).Handler - globals.SugarLogger.Debugf("step2 handler==============%s", handler) if store, err := handler.GetStore(ctx, 0, vendorStoreID); err == nil { retVal = &StoreExt{ Store: store.Store, @@ -1705,7 +1704,6 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor if (valid["deliveryFeeDeductionSill"] != nil || valid["deliveryFeeDeductionFee"] != nil || valid["ybStorePrefix"] != nil) && vendorID == model.VendorIDDD { DDFlag = true } //特殊处理抖店运费模板、打包费 - globals.SugarLogger.Debugf("DeliveryFeeDeductionFee=====%d,YbStorePrefix====%s", storeMap.DeliveryFeeDeductionFee, storeMap.YbStorePrefix) if (storeMap.DeliveryFeeDeductionFee > 0 || utils.Str2Int(storeMap.YbStorePrefix) > 0) && vendorID == model.VendorIDDD { DDFlag = true } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 8d0f67778..91eee2be8 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -840,7 +840,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag for vendorCatID := range reorderSkuMap { vendorCatIDs = append(vendorCatIDs, vendorCatID) } - globals.SugarLogger.Debugf("门店商品排序=====") reorderTask := tasksch.NewParallelTask("门店商品排序", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError2), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { vendorCatID := batchItemList[0].(string) diff --git a/business/model/dao/dao_bz.go b/business/model/dao/dao_bz.go index b33750322..3c6fc8fd2 100644 --- a/business/model/dao/dao_bz.go +++ b/business/model/dao/dao_bz.go @@ -79,7 +79,6 @@ func BatchUpdateEntityByKV(db *DaoDB, items []*KVUpdateItem) (num int64, err err if r := recover(); r != nil { if item != nil { var bindID int64 - globals.SugarLogger.Debugf("========item.item %s", utils.Format4Output(item.Item, false)) value := refutil.CheckAndGetStructValue(item.Item).FieldByName(model.FieldID) if value.IsValid() { bindID = value.Int() diff --git a/business/partner/delivery/tiktok_store/waybill.go b/business/partner/delivery/tiktok_store/waybill.go index b9272888f..959d27c75 100644 --- a/business/partner/delivery/tiktok_store/waybill.go +++ b/business/partner/delivery/tiktok_store/waybill.go @@ -62,11 +62,9 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt VendorStoreID: utils.Int64ToStr(storeInfo.StoreDetail.Store.StoreId), CourierStatus: int(storeInfo.StoreDetail.Store.State), } - globals.SugarLogger.Debugf("storeDetail.Store.Lng====%d,storeDetail.Store.Lat==========%d", storeDetail.Store.Lng, storeDetail.Store.Lat) } else { - globals.SugarLogger.Debugf("GetStoreDetail err=========%s", err) + globals.SugarLogger.Debugf("GetStoreDetail err %s", err) } - globals.SugarLogger.Debugf("DYPS GetStore storeDetail====%s", utils.Format4Output(storeDetail, false)) return storeDetail, err } @@ -101,7 +99,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee return nil, err } delivery.OnWaybillCreated(bill) - globals.SugarLogger.Debugf("DYPS CreateWaybill bill======%s", utils.Format4Output(bill, false)) return bill, nil } @@ -119,7 +116,6 @@ func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, bill.Remark = cancelReason partner.CurOrderManager.OnWaybillStatusChanged(bill) } - globals.SugarLogger.Debugf("DYPS CancelWaybill bill.Status=%d err=%v", bill.Status, err) return err } @@ -133,7 +129,6 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf deliveryFeeInfo = &partner.WaybillFeeInfo{} deliveryFeeInfo.DeliveryFee = dispatcherFee } - globals.SugarLogger.Debugf("DYPS GetWaybillFee deliveryFeeInfo======%s", utils.Format4Output(deliveryFeeInfo, false)) return deliveryFeeInfo, err } func getDispatcherFee(storeID int64, vendorOrderID string, dispatcherType int32) int64 { diff --git a/business/partner/purchase/jd/sku2.go b/business/partner/purchase/jd/sku2.go index 57b59cbcd..b505c1cd8 100644 --- a/business/partner/purchase/jd/sku2.go +++ b/business/partner/purchase/jd/sku2.go @@ -218,7 +218,6 @@ func (p *PurchaseHandler) CreateSku2(ctx *jxcontext.Context, sku *dao.StoreSkuSy } func (p *PurchaseHandler) UpdateSku2(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (err error) { - globals.SugarLogger.Debugf("是不是正儿八经的京东商城%s", "UpdateSku2") param := skuInfo2Param(ctx, sku) if globals.EnableJdStoreWrite { _, err = getAPI(sku.VendorOrgCode).UpdateSku2(param) diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index 1212dface..9bf6d126a 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -40,7 +40,6 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes //} jxutils.CallMsgHandler(func() { response = CurPurchaseHandler.onOrderMsg(msgId, orderId, msg) - globals.SugarLogger.Debugf("OnOrderMsg response====%s", utils.Format4Output(response, false)) }, jxutils.ComposeUniversalOrderID(orderId, model.VendorIDDD)) } return response diff --git a/business/partner/purchase/tiktok_store/store_sku2.go b/business/partner/purchase/tiktok_store/store_sku2.go index 72744e168..a40bfe99a 100644 --- a/business/partner/purchase/tiktok_store/store_sku2.go +++ b/business/partner/purchase/tiktok_store/store_sku2.go @@ -170,11 +170,9 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr // UpdateStoreSkusPrice 更新商品价格 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) - globals.SugarLogger.Debugf("看看走这儿了没,是不是更新 storeSkuList %s", utils.Format4Output(storeSkuList, false)) for _, v := range storeSkuList { tiktokSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) if len(failedList) > 0 { - globals.SugarLogger.Debugf("看看走这儿了没,是不是更新 参数failedList1 %s", utils.Format4Output(failedList, false)) return failedList, err } globals.SugarLogger.Debugf("====SkuId:= %d,ProductId := %d ", tiktokSkuId, utils.Str2Int64(v.VendorMainId)) @@ -187,9 +185,6 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg if err = api.EditPrice(price); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格异常")...) } - globals.SugarLogger.Debugf("看看走这儿了没,是不是更新 参数 %s", utils.Format4Output(price, false)) - globals.SugarLogger.Debugf("看看走这儿了没,是不是更新 返回值 %s", utils.Format4Output(failedList, false)) - globals.SugarLogger.Debugf("看看走这儿了没,是不是更新 结构体 %s", utils.Format4Output(v, false)) } return failedList, err } diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index b311a2cc1..ddaab7126 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -272,11 +272,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) - globals.SugarLogger.Debugf("===============childrenProductId %d", childrenProductId) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 // 线上本地都存在,但是线上审核不成功,就去更新主商品 mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID) - globals.SugarLogger.Debugf("====bool %s", utils.Format4Output(mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass, false)) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { // 更新主商品,在同步到子门店,考虑审核时间 updateParam := &product_editV2_request.ProductEditV2Param{ @@ -306,7 +304,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.SpecPrices = param.SpecPrices //updateParam.StoreId = utils.Str2Int64(vendorStoreID) err := api.EditStoreCommodity(updateParam) - globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", err.Error()) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) @@ -316,10 +313,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // localThing[0].ThingType = model.ThingTypeSku // dao.UpdateThingMap(localThing[0]) //} - globals.SugarLogger.Debugf("=====EditStoreCommodity====== %s", utils.Format4Output(updateParam, false)) continue } } + if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask @@ -485,7 +482,6 @@ func checkNameLenght(name string) string { return name } func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, childrenProductId int64, vendorStoreID, syncType string) (failedList []*partner.StoreSkuInfoWithErr) { - globals.SugarLogger.Debugf("===========1") skuId, failed := getProductSkuID(api, storeSku, syncType, childrenProductId) if skuId == 0 || len(failed) > 0 { return failed @@ -497,9 +493,7 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS ProductId: childrenProductId, }); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType) - globals.SugarLogger.Debugf("===========2 failedList %s", utils.Format4Output(failedList, false)) } - globals.SugarLogger.Debugf("===========2") // 同步库存 paramStock := &sku_syncStock_request.SkuSyncStockParam{ @@ -513,21 +507,17 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS } if err := api.UpdateSkuStock(paramStock); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("子商品添加固定库存.%s", err.Error()))...) - globals.SugarLogger.Debugf("===========3 failedList %s", utils.Format4Output(failedList, false)) } - globals.SugarLogger.Debugf("===========3") // 上架 if err := api.LaunchProduct(childrenProductId); err != nil { failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("上架子商品异常.%s", err.Error()))...) - globals.SugarLogger.Debugf("===========4 failedList %s", utils.Format4Output(failedList, false)) } if len(failedList) > 0 { storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask } else { storeSku.SkuSyncStatus = 0 } - globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch=== 444444,%s", utils.Format4Output(failedList, false)) return failedList } @@ -739,7 +729,6 @@ func GetDeliveryTemp(api *tiktokShop.API, vendorStoreID string, storeDetail *dao StoreId: utils.Str2Int64(vendorStoreID), FreightId: temp.TemplateId, }); err != nil { - globals.SugarLogger.Debugf("BindFreightTemplate =err %s", err) return 0, err } freightId = temp.TemplateId diff --git a/business/partner/purchase/tiktok_store/warehouse.go b/business/partner/purchase/tiktok_store/warehouse.go index 6fd354be3..10a1fb407 100644 --- a/business/partner/purchase/tiktok_store/warehouse.go +++ b/business/partner/purchase/tiktok_store/warehouse.go @@ -270,11 +270,9 @@ func SpecialTreat(vendorOrgCode string, vendorStoreID, storeID, deliveryFeeDeduc } if bindFreightIDs == 0 { //(1)未查询到绑定信息,不算错误 if freightTemplateID, err := CreateFreightTemplate(int(storeID)); err != nil || freightTemplateID == 0 || utils.IsNil(freightTemplateID) { - globals.SugarLogger.Debug("创建运费模板失败:", err) errList.AddErr(fmt.Errorf("创建运费模板失败:%v", err)) } else { //绑定 if err = ShopBindStoreFreight(vendorOrgCode, vendorStoreID, freightTemplateID); err != nil { - globals.SugarLogger.Debugf("京西菜市门店:%d 平台门店:%d 绑定运费模板:%d 失败:%v", storeID, vendorStoreID, freightTemplateID, err) errList.AddErr(fmt.Errorf("京西菜市门店:%d 平台门店:%d 绑定运费模板:%d 失败:%v", storeID, vendorStoreID, freightTemplateID, err)) } else { FreightTemplate.TemplateID = freightTemplateID @@ -319,7 +317,6 @@ func SpecialTreat(vendorOrgCode string, vendorStoreID, storeID, deliveryFeeDeduc } } endErr := errList.GetErrListAsOne() - globals.SugarLogger.Debugf("SpecialTreat wrong information endErr: %s", endErr) return endErr } diff --git a/controllers/tiktok_order.go b/controllers/tiktok_order.go index 9c5e2e345..2a1eecdcb 100644 --- a/controllers/tiktok_order.go +++ b/controllers/tiktok_order.go @@ -2,9 +2,7 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" "strings" @@ -31,7 +29,6 @@ func (t *TiktokController) CallbackTiktokOrderMsg() { // 2.参数解析 orderStatus, resp := api.TiktokStore.CreateOrderCallback(byteList) - globals.SugarLogger.Debugf("CallbackTiktokOrderMsg orderStatus====%s resp====%s ", utils.Format4Output(orderStatus, false), utils.Format4Output(resp, false)) if resp.Code != 0 { t.Data["json"] = resp t.ServeJSON() From d2c22e6292455a1b02881f973b4760ccc6976bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 11:04:42 +0800 Subject: [PATCH 29/45] 1 --- business/jxstore/cms/store_sku.go | 42 +++++++++++++------------- business/jxstore/cms/sync_store_sku.go | 3 ++ business/jxstore/misc/misc.go | 27 ++++++++--------- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 2fe9902b6..43b26257f 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -6614,27 +6614,27 @@ func UpdateMtCatToJd(ctx *jxcontext.Context, mtCatID, jdCatID string) (err error } func SyncTiktokMainIdToLocal(ctx *jxcontext.Context, param *tiktok_store.MainSku) error { - codes, err := dao.GetVendorOrgCode(dao.GetDB(), model.VendorIDDD, "", "platform") - if err != nil { - return err - } - db := dao.GetDB() - for _, code := range codes { - result, err := tiktok_store.QueryAllMainSkuList(code.VendorOrgCode, param) - if err != nil { - continue - } - - // 删除当前时间段数据 - jxutils.CallMsgHandlerAsync(func() { - if err := DeleteThingByData(ctx, db, code.VendorOrgCode, utils.Timestamp2Time(param.StartTime), utils.Timestamp2Time(param.EndTime)); err != nil { - globals.SugarLogger.Error("删除需要同步的数据 := %s", err.Error()) - } - if err := OnCreateThing2Tiktok(ctx, db, code.VendorOrgCode, result, model.ThingTypeSku, model.SyncFlagNewMask, false); err != nil { - globals.SugarLogger.Error("初始他抖音平台主订单已经子订单id信息错误:= %s", err.Error()) - } - }, "") - } + //codes, err := dao.GetVendorOrgCode(dao.GetDB(), model.VendorIDDD, "", "platform") + //if err != nil { + // return err + //} + //db := dao.GetDB() + //for _, code := range codes { + // result, err := tiktok_store.QueryAllMainSkuList(code.VendorOrgCode, param) + // if err != nil { + // continue + // } + // + // // 删除当前时间段数据 + // jxutils.CallMsgHandlerAsync(func() { + // if err := DeleteThingByData(ctx, db, code.VendorOrgCode, utils.Timestamp2Time(param.StartTime), utils.Timestamp2Time(param.EndTime)); err != nil { + // globals.SugarLogger.Error("删除需要同步的数据 := %s", err.Error()) + // } + // if err := OnCreateThing2Tiktok(ctx, db, code.VendorOrgCode, result, model.ThingTypeSku, model.SyncFlagNewMask, false); err != nil { + // globals.SugarLogger.Error("初始他抖音平台主订单已经子订单id信息错误:= %s", err.Error()) + // } + // }, "") + //} return nil } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 91eee2be8..b413a28b8 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -312,6 +312,8 @@ func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyn //美团的商品名字都要有 ‘约’ if skuItem.VendorID == model.VendorIDMTWM { skuItem.SkuName = jxutils.ComposeSkuNameSync2(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) + } else if skuItem.VendorID == model.VendorIDDD { + skuItem.SkuName = jxutils.ComposeSkuNameSync("", skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) } else { skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) } @@ -380,6 +382,7 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item if sku.VendorSonSkuID != "" { kvs["VendorSonSkuID"] = sku.VendorSonSkuID } + storeSku := &model.StoreSkuBind{} storeSku.ID = sku.BindID item = &dao.KVUpdateItem{ diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 1773fee08..bacd716ce 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -6,7 +6,6 @@ import ( "git.rosy.net.cn/jx-callback/business/bidding" "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "git.rosy.net.cn/jx-callback/business/partner/delivery" - "git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store" "sync" "time" @@ -214,19 +213,19 @@ func Init() { }) // 定时任务更新昨天的都要商品和本地商品id的映射关系 - ScheduleTimerFunc("RefreshStoreOperator", func() { - t := time.Now() - cms.SyncTiktokMainIdToLocal(jxcontext.AdminCtx, &tiktok_store.MainSku{ - AppOrgCode: "", - CheckStatus: 3, - StartTime: time.Date(t.Year(), t.Month(), t.Day()-1, 0, 0, 1, 0, time.Local).Unix(), - EndTime: time.Date(t.Year(), t.Month(), t.Day()-1, 23, 59, 59, 0, time.Local).Unix(), - Page: 1, - PageSize: 100, - }) - }, []string{ - "04:30:00", - }) + //ScheduleTimerFunc("RefreshStoreOperator", func() { + // t := time.Now() + // cms.SyncTiktokMainIdToLocal(jxcontext.AdminCtx, &tiktok_store.MainSku{ + // AppOrgCode: "", + // CheckStatus: 3, + // StartTime: time.Date(t.Year(), t.Month(), t.Day()-1, 0, 0, 1, 0, time.Local).Unix(), + // EndTime: time.Date(t.Year(), t.Month(), t.Day()-1, 23, 59, 59, 0, time.Local).Unix(), + // Page: 1, + // PageSize: 100, + // }) + //}, []string{ + // "04:30:00", + //}) ScheduleTimerFuncByInterval(func() { defsch.FixedScheduler.ConfirmSelfTakeOrders(jxcontext.AdminCtx, []int{model.VendorIDJD}, time.Now().Add(-48*time.Hour), time.Now().Add(-30*time.Minute), true, true) From 6d737fddfc643921c91a5459985628c44cb6ee9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 11:57:42 +0800 Subject: [PATCH 30/45] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index ddaab7126..d182af693 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -165,8 +165,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.Description = detailImg // 部分商品没有所属的分类,直接跳过! - if storeSku.VendorVendorCatID != 0 { - param.CategoryLeafId = storeSku.VendorVendorCatID + if storeSku.SkuVendorMapCatID != "" { + param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) } else if len(param.Pic) != 0 { // 自动推导分类id param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) if param.CategoryLeafId == 0 || err != nil { @@ -302,17 +302,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.ProductId = mainOrderDetail.ProductId updateParam.MainProductId = mainProductId updateParam.SpecPrices = param.SpecPrices - //updateParam.StoreId = utils.Str2Int64(vendorStoreID) - err := api.EditStoreCommodity(updateParam) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + if err := api.EditStoreCommodity(updateParam); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - } //else { - // localThing[0].UpdatedAt = time.Now() - // localThing[0].SyncStatus = 0 - // localThing[0].ThingType = model.ThingTypeSku - // dao.UpdateThingMap(localThing[0]) - //} + } + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改子品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } } @@ -357,11 +351,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI StartSaleType: 0, PickupMethod: "0", } - if storeSku.SkuVendorMapCatID != "" { - param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) - } else { - param.CategoryLeafId = storeSku.VendorVendorCatID - } param.Name = checkNameLenght(param.Name) // 获取上传图,商品轮播图 @@ -374,6 +363,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.Description = detailImg param.WeightUnit = tiktokShop.WeightUint_G + // 部分商品没有所属的分类,直接跳过! + if storeSku.SkuVendorMapCatID != "" { + param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) + } else if len(param.Pic) != 0 { // 自动推导分类id + param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) + if param.CategoryLeafId == 0 || err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + } // 获取商品的属性 if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) From 83de903b77397478e269648f578d066333c0635a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 15:01:18 +0800 Subject: [PATCH 31/45] 1 --- business/jxstore/cms/sync_store_sku.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index b413a28b8..ca9ad87c6 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -313,7 +313,18 @@ func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyn if skuItem.VendorID == model.VendorIDMTWM { skuItem.SkuName = jxutils.ComposeSkuNameSync2(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) } else if skuItem.VendorID == model.VendorIDDD { - skuItem.SkuName = jxutils.ComposeSkuNameSync("", skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) + var endIndex int = 0 + var skuName string = "" + if strings.HasPrefix(skuItem.Name, "[") { + endIndex = strings.Index(skuItem.Name, "]") + skuName = skuItem.Name[endIndex+1:] + } else if strings.HasPrefix(skuItem.Name, "【") { + endIndex = strings.Index(skuItem.Name, "】") + skuName = skuItem.Name[endIndex+3:] + } else { + skuName = skuItem.Name + } + skuItem.SkuName = jxutils.ComposeSkuNameSync("", skuName, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) } else { skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd, (skuItem.BrandID == skuItem.ExBrandID && skuItem.ExBrandID != 0) || skuItem.ExBrandID == 0) } From 4c2435771924f4ff69999b8ac7fdae3c57fe7fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 16:42:41 +0800 Subject: [PATCH 32/45] 1 --- .../jxcallback/scheduler/defsch/defsch.go | 15 ++ .../purchase/tiktok_store/store_sku2_utils.go | 195 ++++++++---------- 2 files changed, 105 insertions(+), 105 deletions(-) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 8bea09133..c9c197a38 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -596,6 +596,21 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo // s.addWaybill2Map(savedOrderInfo, bill) // updateBillsInfo中会添加 globals.SugarLogger.Debugf("OnWaybillStatusChanged bill not exist! orderID:%s, bill:%v", bill.VendorOrderID, bill) } + // 美团订单会存在:用户直接申请退款,不推送取消消息!导致三方配送未取消! + if order.Status >= model.OrderStatusCanceled { + s.removeWaybillFromMap(savedOrderInfo, bill.WaybillVendorID) + if s.isBillCandidate(order, bill) { + s.resetTimer(savedOrderInfo, bill, isPending) + if !isPending { + s.updateOrderByBill(order, nil, true) + } + } else if model.IsOrderHaveWaybill(order) { + s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) + if !isPending { + globals.SugarLogger.Warnf("OnWaybillStatusChanged AcceptCanceled orderID:%s got multiple bill:%v, order details:%v", order.VendorOrderID, bill, order) + } + } + } switch bill.Status { case model.WaybillStatusAccepted, model.WaybillStatusCourierAssigned, model.WaybillStatusCourierArrived, model.WaybillStatusDelivering: s.resetTimer(savedOrderInfo, bill, isPending) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index d182af693..ca217194c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -136,80 +136,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if storeSku.StoreSkuStatus != 1 { // 未可售的商品不参与修改 continue } - param := &product_addV2_request.ProductAddV2Param{ - Name: utils.LimitUTF8StringLen(storeSku.SkuName, 90), - PayType: tiktokShop.TiktokPayType1, - ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, - Weight: utils.Int2Float64(storeSku.Weight), - DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, - PresellType: tiktokShop.SendGoodsTypeNow, - Supply7dayReturn: 0, // 是否支持7天无理由,0不支持,1支持,2支持(拆封后不支持) - Mobile: storeDetail.Tel1, - Commit: true, - Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, - NeedRechargeMode: false, - SellChannel: []int64{0}, - StartSaleType: 0, - PickupMethod: "0", - OuterProductId: utils.Int2Str(storeSku.SkuID), // 本地skuId为外部商品id - } - param.Name = checkNameLenght(param.Name) - - // 获取上传图,商品轮播图 - img, detailImg, err := GetTiktokImgList(api, utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg, storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - param.Pic = img - param.Description = detailImg - - // 部分商品没有所属的分类,直接跳过! - if storeSku.SkuVendorMapCatID != "" { - param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) - } else if len(param.Pic) != 0 { // 自动推导分类id - param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) - if param.CategoryLeafId == 0 || err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - } - // 这个情况是原有商品不存在和推荐查询不到类目id是,使用京西类目和抖音类目的绑定关系 - // 但是不太实用,导致商品类目错误被暂停营业等 - //if storeSku.VendorVendorCatID != 0 && param.CategoryLeafId == 0 { - // param.CategoryLeafId = storeSku.VendorVendorCatID - //} - - // 是否支持七天无理由 - if api.GetProductUpdateRule(param.CategoryLeafId) { - param.Supply7dayReturn = 1 - } else { - param.Supply7dayReturn = 0 - } - - // weight_unit 目前抖音只支持g和kg两种 - param.WeightUnit = tiktokShop.WeightUint_G - - // spec_prices - param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku) - // 获取商品的属性 - if storeSku.TiktokAttribute != "" && storeSku.TiktokAttribute != "{}" { - param.ProductFormatNew = storeSku.TiktokAttribute - } else if storeSku.VendorSkuAttrId != "" && storeSku.VendorSkuAttrId != "{}" { - param.ProductFormatNew = storeSku.TiktokAttribute - } else { - param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - } - param.StandardBrandId = 789194134 // 默认品牌京西菜市 596120136 - param.FreightId, param.SaleLimitId, err = getFreightIdAndSaleLimitId(api, db, storeDetail, vendorStoreID) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } // 根据本地商品id获取线上商品是否存在,存在则只创建子商品 // 获取本地存储映射关系,获取本地主商品id是否存在 @@ -222,6 +148,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if len(localThing) == 0 { //if mainProductId == 0 { + param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) + if len(failedList2) != 0 { + failedList = append(failedList, failedList2...) + continue + } tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) @@ -240,35 +171,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // 还没同步子商品 failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - //} else { - // // 本地不存在,线上存在.直接创建子商品保存本地同步记录 - // var childrenProductId int64 = 0 - // dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0) - // - // childrenProductId, err = api.CreateSubProduct(mainProductId, utils.Str2Int64(vendorStoreID)) - // if err != nil { - // failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - // continue - // } - // - // storeSku.VendorMainId = utils.Int64ToStr(mainProductId) - // var attrId []string - // for _, v := range mainOrderDetail.SpecPrices { - // attrId = append(attrId, utils.Int64ToStr(v.SkuId)) - // } - // storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID - // if childrenProductId > 0 { - // storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) - // storeSku.SkuSyncStatus = 0 - // storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id - // upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) - // } else { - // storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // (属性id skuID方案一)(自商品的商品id方案二) - // storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) // 子商品主id - // storeSku.SkuSyncStatus = model.SyncFlagNewMask - // failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("主商品创建了,子商品为创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - // } - //} } else { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) @@ -277,6 +179,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID) if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass { // 更新主商品,在同步到子门店,考虑审核时间 + param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) + if len(failedList2) != 0 { + failedList = append(failedList, failedList2...) + continue + } updateParam := &product_editV2_request.ProductEditV2Param{ PayType: tiktokShop.TiktokPayType1, ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, @@ -295,8 +202,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI Name: param.Name, ProductFormatNew: param.ProductFormatNew, } - updateParam.Pic = img - updateParam.Description = detailImg + updateParam.Pic = param.Pic + updateParam.Description = param.Description updateParam.WeightUnit = tiktokShop.WeightUint_G updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 updateParam.ProductId = mainOrderDetail.ProductId @@ -420,6 +327,84 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI return failedList, err } +func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, storeDetail *dao.StoreDetail, storeID int, vendorStoreID, syncType string) (param *product_addV2_request.ProductAddV2Param, failedList []*partner.StoreSkuInfoWithErr) { + param = &product_addV2_request.ProductAddV2Param{ + Name: utils.LimitUTF8StringLen(storeSku.SkuName, 90), + PayType: tiktokShop.TiktokPayType1, + ReduceType: tiktokShop.SkuReduceTypePayMakeOrder, + Weight: utils.Int2Float64(storeSku.Weight), + DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay, + PresellType: tiktokShop.SendGoodsTypeNow, + Supply7dayReturn: 0, // 是否支持7天无理由,0不支持,1支持,2支持(拆封后不支持) + Mobile: storeDetail.Tel1, + Commit: true, + Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit, + NeedRechargeMode: false, + SellChannel: []int64{0}, + StartSaleType: 0, + PickupMethod: "0", + OuterProductId: utils.Int2Str(storeSku.SkuID), // 本地skuId为外部商品id + } + param.Name = checkNameLenght(param.Name) + + // 获取上传图,商品轮播图 + img, detailImg, err := GetTiktokImgList(api, utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg, storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5) + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + return + } + param.Pic = img + param.Description = detailImg + + // 部分商品没有所属的分类,直接跳过! + if storeSku.SkuVendorMapCatID != "" { + param.CategoryLeafId = utils.Str2Int64(storeSku.SkuVendorMapCatID) + } else if len(param.Pic) != 0 { // 自动推导分类id + param.CategoryLeafId, err = api.GetRecommendCategory(strings.Split(img, "|")) + if param.CategoryLeafId == 0 || err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("当前商品本地未设置抖音分类/抖音推荐分类查询错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + return + } + } + // 这个情况是原有商品不存在和推荐查询不到类目id是,使用京西类目和抖音类目的绑定关系 + // 但是不太实用,导致商品类目错误被暂停营业等 + //if storeSku.VendorVendorCatID != 0 && param.CategoryLeafId == 0 { + // param.CategoryLeafId = storeSku.VendorVendorCatID + //} + + // 是否支持七天无理由 + if api.GetProductUpdateRule(param.CategoryLeafId) { + param.Supply7dayReturn = 1 + } else { + param.Supply7dayReturn = 0 + } + + // weight_unit 目前抖音只支持g和kg两种 + param.WeightUnit = tiktokShop.WeightUint_G + + // spec_prices + param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku) + // 获取商品的属性 + if storeSku.TiktokAttribute != "" && storeSku.TiktokAttribute != "{}" { + param.ProductFormatNew = storeSku.TiktokAttribute + } else if storeSku.VendorSkuAttrId != "" && storeSku.VendorSkuAttrId != "{}" { + param.ProductFormatNew = storeSku.TiktokAttribute + } else { + param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + return + } + } + param.StandardBrandId = 789194134 // 默认品牌京西菜市 596120136 + param.FreightId, param.SaleLimitId, err = getFreightIdAndSaleLimitId(api, db, storeDetail, vendorStoreID) + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + return + } + return +} + func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, mainProductId string) *product_detail_response.ProductDetailData { // 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态 mainOrderDetailProductId, err := api.GetSkuDetail(mainProductId, "") From ffabbd73259e7931333298494276ef3388846735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 16:45:15 +0800 Subject: [PATCH 33/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index ca217194c..598240a06 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -213,7 +213,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) } - failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改子品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } } From 26bbebf52f0e8a659cc8788d2711a9c3257e6848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 17:45:14 +0800 Subject: [PATCH 34/45] 1 --- business/jxstore/misc/misc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index bacd716ce..1ef8763d0 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -251,11 +251,11 @@ func Init() { }, 60*time.Second, 30*time.Minute) // 抖音更新门店商品 - //if beego.BConfig.RunMode != "jxgy" { - // ScheduleTimerFunc("RefreshSyncSkuList", func() { - // syncStoreSkuTiktok() - // }, []string{"11:30:00"}) - //} + if beego.BConfig.RunMode != "jxgy" { + ScheduleTimerFunc("RefreshSyncSkuList", func() { + syncStoreSkuTiktok() + }, []string{"11:30:00"}) + } // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From 21bf72af714173622859a56a5f22715816dc3878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 5 Jan 2023 19:03:00 +0800 Subject: [PATCH 35/45] 1 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 598240a06..e72fb869b 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -218,7 +218,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } - if err != nil || childrenProductId == 0 { + if (err != nil || childrenProductId == 0) && !strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品 failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) From a1584a6d727194a159efbc4bcd22d1bf3268032c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 13:37:41 +0800 Subject: [PATCH 36/45] 1 --- business/model/dao/dao_order.go | 1 - business/model/dao/thing_map.go | 18 ++++++-- business/model/sync_map.go | 6 +++ .../purchase/tiktok_store/store_sku2_utils.go | 45 +++++++++++++++++-- 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 9dc8b1f94..b31e44f3c 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1037,7 +1037,6 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat if len(vendorIDs) > 0 { sqlWhere += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" sqlParams = append(sqlParams, vendorIDs) - //globals.SugarLogger.Debugf("sqlParams vendorIDs================%d", vendorIDs) } } if userID != "" { diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 3c9ec2ca5..cf99464ea 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -45,8 +45,21 @@ func CreateThingMap(thingId int64, vendorThingID, appOrgCode, err string, thingT return CreateEntity(GetDB(), thingMap) } -func UpdateThingMap(thingMap *model.ThingMap) error { - _, err := UpdateEntity(GetDB(), thingMap, "ID") +func UpdateThingMap(db *DaoDB, syncStatus int8, vendorThingId string, thingId int, vendorId int, vendorOrgCode string) error { + sql := ` + UPDATE thing_map t1 + SET t1.sync_status = ?,t1.vendor_thing_id = ? + WHERE t1.deleted_at = ? AND t1.thing_id = ? AND t1.vendor_id = ? AND t1.vendor_org_code = ? +` + sqlParams := []interface{}{ + syncStatus, + vendorThingId, + utils.DefaultTimeValue, + thingId, + vendorId, + vendorOrgCode, + } + _, err := ExecuteSQL(db, sql, sqlParams...) return err } @@ -65,7 +78,6 @@ func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCo } err = GetRows(db, &cats, sql, sqlParams...) - return cats, err } diff --git a/business/model/sync_map.go b/business/model/sync_map.go index c8c5ef010..fe5539c86 100644 --- a/business/model/sync_map.go +++ b/business/model/sync_map.go @@ -9,6 +9,12 @@ const ( ThingTypeOrder = 6 // 同步订单 ) +const ( + ThingTypeSyncSuccess = 0 // 主商品创建成功 + ThingTypeSyncFail = 2 // 主商品创建失败 + ThingTypeSyncing = 3 // 主商品创建中 +) + type ThingMap struct { ModelIDCULD diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index e72fb869b..1569a28e7 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -28,6 +28,7 @@ import ( "git.rosy.net.cn/jx-callback/globals" "math/rand" "strings" + "time" "unicode" ) @@ -147,7 +148,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } if len(localThing) == 0 { - //if mainProductId == 0 { + if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(time.Now().Unix()), storeDetail.VendorOrgCode, "本地不存在,线上也不存在", model.ThingTypeSku, model.ThingTypeSyncing); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) if len(failedList2) != 0 { failedList = append(failedList, failedList2...) @@ -155,10 +159,15 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 if err != nil { + dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + + if err := dao.UpdateThingMap(db, model.ThingTypeSyncSuccess, utils.Int64ToStr(tiktokResult.ProductId), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } - dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(tiktokResult.ProductId), storeDetail.VendorOrgCode, "本地不存在,线上也不存在", model.ThingTypeSku, 0) var attrId []string for _, v := range tiktokResult.Sku { attrId = append(attrId, utils.Int64ToStr(v.SkuId)) @@ -171,7 +180,37 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // 还没同步子商品 failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - } else { + } else if localThing[0].SyncStatus == model.ThingTypeSyncFail { // 同步失败在重新创建 + param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) + if len(failedList2) != 0 { + failedList = append(failedList, failedList2...) + continue + } + tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 + if err != nil { + dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + + if err := dao.UpdateThingMap(db, model.ThingTypeSyncSuccess, utils.Int64ToStr(tiktokResult.ProductId), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + var attrId []string + for _, v := range tiktokResult.Sku { + attrId = append(attrId, utils.Int64ToStr(v.SkuId)) + } + mainProductId = tiktokResult.ProductId + storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 + storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId) + storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID + storeSku.VendorSonSkuID = utils.Int2Str(storeSku.SkuID) // 还没同步子商品 + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("只创建了主商品,没创建子商品"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + } else if localThing[0].SyncStatus == model.ThingTypeSyncing { + continue + } else if localThing[0].SyncStatus == model.ThingTypeSyncSuccess { // 主商品存在,直接同步子商品 childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品 From a9340b6333468b80a0935c858f3a4bf7dc503e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 15:53:09 +0800 Subject: [PATCH 37/45] 1 --- business/jxstore/cms/sku.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index 6c096eae1..e3ac670f9 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -3314,9 +3314,9 @@ func GetSkuNamesNew(ctx *jxcontext.Context, keyword string, skuIDs, skuNameIDs [ for _, v := range skus { var things []*model.ThingMap sql := ` - SELECT * FROM thing_map WHERE vendor_org_code = ? AND thing_type = ? AND thing_id = ? AND deleted_at = ? + SELECT * FROM thing_map WHERE thing_type = ? AND thing_id = ? AND deleted_at = ? ` - sqlParams := []interface{}{"320406", model.ThingTypeSku, v.ID, utils.DefaultTimeValue} + sqlParams := []interface{}{model.ThingTypeSku, v.ID, utils.DefaultTimeValue} dao.GetRows(db, &things, sql, sqlParams) skusVendor := &model.SkuWithVendor{ Sku: v, From 275a932b23e3ddbcf049360115254a4f6ee50a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 16:00:10 +0800 Subject: [PATCH 38/45] 1 --- business/jxstore/cms/sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index e3ac670f9..84fbce64a 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -3314,7 +3314,7 @@ func GetSkuNamesNew(ctx *jxcontext.Context, keyword string, skuIDs, skuNameIDs [ for _, v := range skus { var things []*model.ThingMap sql := ` - SELECT * FROM thing_map WHERE thing_type = ? AND thing_id = ? AND deleted_at = ? + SELECT * FROM thing_map WHERE thing_type = ? AND thing_id = ? AND vendor_thing_id <> "" AND deleted_at = ? ` sqlParams := []interface{}{model.ThingTypeSku, v.ID, utils.DefaultTimeValue} dao.GetRows(db, &things, sql, sqlParams) From 3788f78aa93c3ef3e6c65f75c2fe82a59cfe342b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 18:22:05 +0800 Subject: [PATCH 39/45] 1 --- business/jxstore/cms/sync_store_sku.go | 4 ++++ .../purchase/tiktok_store/store_sku2_utils.go | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index ca9ad87c6..1f33e1a49 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -370,6 +370,9 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagNewMask } else { sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagPriceMask + if sku.VendorID == model.VendorIDDD && sku.SkuSyncStatus == 57 { + sku.SkuSyncStatus = 57 + } } } else if syncStatus&model.SyncFlagStockMask != 0 { if isStoreSkuSyncNeedDelete(sku) { @@ -393,6 +396,7 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item if sku.VendorSonSkuID != "" { kvs["VendorSonSkuID"] = sku.VendorSonSkuID } + // 抖音在同步时,无法区分修改的是主商品还是子商品,所以先同步主商品,在定时任务同步子商品 storeSku := &model.StoreSkuBind{} storeSku.ID = sku.BindID diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 1569a28e7..5d423a099 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -16,6 +16,7 @@ import ( shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request" sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request" sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request" + superm_product_batchRedistributeStoreProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchRedistributeStoreProduct/request" trade_createTradeLimitTemplate_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/trade_createTradeLimitTemplate/request" tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" "git.rosy.net.cn/baseapi/utils" @@ -257,13 +258,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } - if (err != nil || childrenProductId == 0) && !strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品 - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask - storeSku.VendorSonSkuID = utils.Int64ToStr(childrenProductId) // (属性id skuID方案一)(自商品的商品id方案二) - storeSku.VendorSkuID = utils.Int64ToStr(childrenProductId) // 子商品主id - storeSku.VendorMainId = localThing[0].VendorThingID // 商品主id - continue + if (err != nil || childrenProductId == 0) && !strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品,就去更新 + param := &superm_product_batchRedistributeStoreProduct_request.TaskParams{ + MainProductId: utils.Str2Int64(localThing[0].VendorThingID), + AddStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, + DelStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, + } + if _, err := api.BatchRedistributeStoreProduct(param); err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } } // 同步价格,库存,上架 From 972b25370662b6db336f503a7f486ac6f6f9c514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 18:25:13 +0800 Subject: [PATCH 40/45] 1 --- business/jxstore/cms/sync_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 1f33e1a49..bbac751ae 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -370,7 +370,7 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagNewMask } else { sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagPriceMask - if sku.VendorID == model.VendorIDDD && sku.SkuSyncStatus == 57 { + if sku.VendorID == model.VendorIDDD && sku.StoreSkuStatus == 57 { sku.SkuSyncStatus = 57 } } From 3e1d48f11c935b9b4c54e39ecb91c650bf6d2191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 18:33:06 +0800 Subject: [PATCH 41/45] 1 --- business/jxstore/cms/sync_store_sku.go | 3 --- business/partner/purchase/tiktok_store/store_sku2_utils.go | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index bbac751ae..b1112921f 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -370,9 +370,6 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagNewMask } else { sku.SkuSyncStatus = sku.SkuSyncStatus & model.SyncFlagPriceMask - if sku.VendorID == model.VendorIDDD && sku.StoreSkuStatus == 57 { - sku.SkuSyncStatus = 57 - } } } else if syncStatus&model.SyncFlagStockMask != 0 { if isStoreSkuSyncNeedDelete(sku) { diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 5d423a099..b42ca5a80 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -363,7 +363,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI //if storeSku.VendorSkuID != "" && len(storeSku.VendorSkuID) > 19 { // failedList = upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) //} - storeSku.StoreSkuStatus = 57 // 品库修改 售卖状态待同步 价格待同步 + storeSku.SkuSyncStatus = 57 // 品库修改 售卖状态待同步 价格待同步 } return } From 2308c54e230f299ac57ab6fe3f3341bcc92e8bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 6 Jan 2023 18:35:40 +0800 Subject: [PATCH 42/45] 1 --- business/jxstore/cms/sync_store_sku.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index b1112921f..d3b9dba64 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -428,6 +428,7 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn for k, v := range storeSkuList { updateItemList[k] = sku2Update(vendorID, v, syncStatus) } + globals.SugarLogger.Debugf("========updateItemList=== %s", utils.Format4Output(updateItemList, false)) num, err = dao.BatchUpdateEntityByKV(db, updateItemList) if vendorID == model.VendorIDYB { err = updateYbOhterSku(db, storeSkuList) From 076d66c227a36197fd8e237f2b2414850ae29b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 9 Jan 2023 10:25:40 +0800 Subject: [PATCH 43/45] 1 --- business/jxstore/cms/sync_store_sku.go | 1 + .../purchase/tiktok_store/store_sku2_utils.go | 64 +++++++++++-------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index d3b9dba64..f425cc94e 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -435,6 +435,7 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn } } } + globals.SugarLogger.Debugf("=========updateItemList===num-- %d,%s", num, err.Error()) return num, err } diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index b42ca5a80..5902aa758 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -16,7 +16,6 @@ import ( shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request" sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request" sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request" - superm_product_batchRedistributeStoreProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchRedistributeStoreProduct/request" trade_createTradeLimitTemplate_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/trade_createTradeLimitTemplate/request" tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" "git.rosy.net.cn/baseapi/utils" @@ -259,15 +258,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } if (err != nil || childrenProductId == 0) && !strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品,就去更新 - param := &superm_product_batchRedistributeStoreProduct_request.TaskParams{ - MainProductId: utils.Str2Int64(localThing[0].VendorThingID), - AddStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, - DelStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, - } - if _, err := api.BatchRedistributeStoreProduct(param); err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } + continue + //param := &superm_product_batchRedistributeStoreProduct_request.TaskParams{ + // MainProductId: utils.Str2Int64(localThing[0].VendorThingID), + // AddStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, + // DelStoreIds: []int64{utils.Str2Int64(vendorStoreID)}, + //} + //if _, err := api.BatchRedistributeStoreProduct(param); err != nil { + // failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + // continue + //} } // 同步价格,库存,上架 @@ -323,18 +323,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI continue } } - // 获取商品的属性 - if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { - param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - continue - } - } else { - param.ProductFormatNew = storeSku.TiktokAttribute - } - // 获取品牌 - param.StandardBrandId = 789194134 // 默认品牌京西菜市 + + // 获取主商品id var mainIdInt int64 if storeSku.VendorMainId == "" { localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode) @@ -349,20 +339,40 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI mainIdInt = utils.Str2Int64(storeSku.VendorMainId) } + // 更新商品,主品如果名字和类目没变化,则更新子品价格! + mainProductDetail, err := api.GetSkuDetail(utils.Int64ToStr(mainIdInt), "") + if err != nil || mainProductDetail == nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + if mainProductDetail.Name == param.Name && (mainProductDetail.CategoryDetail.ThirdCid == param.CategoryLeafId || mainProductDetail.CategoryDetail.FourthCid == param.CategoryLeafId) { + upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) + continue + } + + // 获取商品的属性 + if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { + param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + continue + } + } else { + param.ProductFormatNew = storeSku.TiktokAttribute + } + // 获取品牌 + param.StandardBrandId = 789194134 // 默认品牌京西菜市 + // 修改商品 param.ProductId = mainIdInt param.MainProductId = mainIdInt - //param.StoreId = utils.Str2Int64(vendorStoreID) param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, param.MainProductId, storeSku) if err := api.EditStoreCommodity(param); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) continue } - // todo 更主品的同间考虑更新子品,子品的更新只能重新分配子品,在更新价格 - //if storeSku.VendorSkuID != "" && len(storeSku.VendorSkuID) > 19 { - // failedList = upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) - //} + storeSku.SkuSyncStatus = 57 // 品库修改 售卖状态待同步 价格待同步 } return From a479963d21219fa8600bff812b9fafe067ecc951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 9 Jan 2023 11:33:59 +0800 Subject: [PATCH 44/45] 1 --- business/jxstore/cms/sync_store_sku.go | 2 +- business/partner/purchase/tiktok_store/store_sku2.go | 1 - business/partner/purchase/tiktok_store/store_sku2_utils.go | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index f425cc94e..b1620c93d 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -426,6 +426,7 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn } else { updateItemList := make([]*dao.KVUpdateItem, len(storeSkuList)) for k, v := range storeSkuList { + globals.SugarLogger.Debugf("======skusyncStatus %s", utils.Format4Output(v, false)) updateItemList[k] = sku2Update(vendorID, v, syncStatus) } globals.SugarLogger.Debugf("========updateItemList=== %s", utils.Format4Output(updateItemList, false)) @@ -435,7 +436,6 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn } } } - globals.SugarLogger.Debugf("=========updateItemList===num-- %d,%s", num, err.Error()) return num, err } diff --git a/business/partner/purchase/tiktok_store/store_sku2.go b/business/partner/purchase/tiktok_store/store_sku2.go index a40bfe99a..5844c4144 100644 --- a/business/partner/purchase/tiktok_store/store_sku2.go +++ b/business/partner/purchase/tiktok_store/store_sku2.go @@ -175,7 +175,6 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg if len(failedList) > 0 { return failedList, err } - globals.SugarLogger.Debugf("====SkuId:= %d,ProductId := %d ", tiktokSkuId, utils.Str2Int64(v.VendorMainId)) price := &sku_editPrice_request.SkuEditPriceParam{ Price: v.VendorPrice, SkuId: tiktokSkuId, diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 5902aa758..874ef402c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -598,7 +598,6 @@ func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuI } } - globals.SugarLogger.Debugf("=GetSkuDetail By childrenSku %s", utils.Format4Output(childrenSku, false)) for _, v := range childrenSku.SpecPrices { tiktokSkuId = v.SkuId skuInfo.VendorSonSkuID = utils.Int64ToStr(v.SkuId) From 68b5033815cd812e1d9516b5f64acfab2665ee94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 9 Jan 2023 11:54:05 +0800 Subject: [PATCH 45/45] 1 --- .../partner/purchase/tiktok_store/store_sku2_utils.go | 10 +++++----- 1 file changed, 5 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 874ef402c..b7b5c07e1 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -345,10 +345,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } - if mainProductDetail.Name == param.Name && (mainProductDetail.CategoryDetail.ThirdCid == param.CategoryLeafId || mainProductDetail.CategoryDetail.FourthCid == param.CategoryLeafId) { - upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) - continue - } + //if mainProductDetail.Name == param.Name && (mainProductDetail.CategoryDetail.ThirdCid == param.CategoryLeafId || mainProductDetail.CategoryDetail.FourthCid == param.CategoryLeafId) { + // upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) + // continue + //} // 获取商品的属性 if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { @@ -368,9 +368,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.MainProductId = mainIdInt param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, param.MainProductId, storeSku) if err := api.EditStoreCommodity(param); err != nil { + globals.SugarLogger.Debugf("====EditStoreCommodity===== %s", err.Error()) failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) - continue } storeSku.SkuSyncStatus = 57 // 品库修改 售卖状态待同步 价格待同步