From b3319703380174984a44ae4575411376eb01acc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 26 Dec 2022 18:37:13 +0800 Subject: [PATCH 1/9] 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 1046976d0..5e8bc4ab3 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -589,7 +589,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{668594, 668726}, false, nil, nil, syncFlag, true, true) + _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{model.VendorIDDD}, []int{668619}, false, nil, nil, syncFlag, true, true) errList.AddErr(err) } case 1: From 4591bdf5f51628131679eda8e2b1019c59abf70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 26 Dec 2022 18:56:08 +0800 Subject: [PATCH 2/9] 1 --- business/model/dao/thing_map.go | 3 +++ business/partner/purchase/tiktok_store/store_sku2_utils.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index b6316054c..921e0789b 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -37,6 +37,9 @@ func CreateThingMap(thingId int64, vendorThingID, appOrgCode, err string, thingT Remark: err, SyncStatus: syncStatus, } + if thingMap.VendorThingID == "" { + return nil + } WrapAddIDCULDEntity(thingMap, "jxadmin") return CreateEntity(GetDB(), thingMap) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 6c061529a..925a57512 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -246,7 +246,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI continue } - if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainOrderDetail.MainProductId), storeDetail.VendorOrgCode, storeSku.VendorSkuAttrId, model.ThingTypeSku, 0); err != nil { + if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainOrderDetail.MainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) } @@ -398,7 +398,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } mainIdInt = mainOrderDetail.MainProductId storeSku.VendorMainId = utils.Int64ToStr(mainIdInt) - if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainIdInt), storeDetail.VendorOrgCode, storeSku.VendorSkuAttrId, model.ThingTypeSku, 0); err != nil { + if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainIdInt), storeDetail.VendorOrgCode, "更新发现不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) } } else { From 5e4b7e7febee687cf47417c46d101726952aaf49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 26 Dec 2022 18:56:57 +0800 Subject: [PATCH 3/9] 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 5e8bc4ab3..308186f66 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -255,7 +255,7 @@ func Init() { if beego.BConfig.RunMode != "jxgy" { ScheduleTimerFuncByInterval(func() { syncStoreSkuTiktok() - }, 60*time.Second, 10*time.Minute) + }, 60*time.Second, 2*time.Minute) } // 定时任务刷新当前订单的物流信息 From fd8b94639398e5b754f1e7344e1285da686d1c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 26 Dec 2022 19:08:19 +0800 Subject: [PATCH 4/9] 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 308186f66..10f85c8b4 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" { - ScheduleTimerFuncByInterval(func() { - syncStoreSkuTiktok() - }, 60*time.Second, 2*time.Minute) - } + //if beego.BConfig.RunMode != "jxgy" { + // ScheduleTimerFuncByInterval(func() { + // syncStoreSkuTiktok() + // }, 60*time.Second, 2*time.Minute) + //} // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From ca7d039a47e0ebd4199f49f6ae7affe878f162fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 27 Dec 2022 09:34:45 +0800 Subject: [PATCH 5/9] 1 --- business/jxstore/misc/misc.go | 10 +++++----- .../partner/purchase/tiktok_store/store_sku2_utils.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 10f85c8b4..5e8bc4ab3 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" { - // ScheduleTimerFuncByInterval(func() { - // syncStoreSkuTiktok() - // }, 60*time.Second, 2*time.Minute) - //} + if beego.BConfig.RunMode != "jxgy" { + ScheduleTimerFuncByInterval(func() { + syncStoreSkuTiktok() + }, 60*time.Second, 10*time.Minute) + } // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 925a57512..1c26a24bb 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -246,11 +246,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI continue } - if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainOrderDetail.MainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0); err != nil { + if err := dao.CreateThingMap(int64(storeSku.SkuID), mainOrderDetail.ProductIdStr, storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) } - childrenProductId, err = api.CreateSubProduct(mainOrderDetail.MainProductId, utils.Str2Int64(vendorStoreID)) + childrenProductId, err = api.CreateSubProduct(mainOrderDetail.ProductId, utils.Str2Int64(vendorStoreID)) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue @@ -300,8 +300,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.Description = detailImg updateParam.WeightUnit = tiktokShop.WeightUint_G updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 - updateParam.ProductId = mainOrderDetail.MainProductId - updateParam.MainProductId = mainOrderDetail.MainProductId + updateParam.ProductId = mainOrderDetail.ProductId + updateParam.MainProductId = mainOrderDetail.ProductId updateParam.SpecPrices = param.SpecPrices //updateParam.StoreId = utils.Str2Int64(vendorStoreID) if err := api.EditStoreCommodity(updateParam); err != nil { @@ -396,7 +396,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } - mainIdInt = mainOrderDetail.MainProductId + mainIdInt = mainOrderDetail.ProductId storeSku.VendorMainId = utils.Int64ToStr(mainIdInt) if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainIdInt), storeDetail.VendorOrgCode, "更新发现不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) From 7a81cb50607b0779d8e169e33cf5c2b82fa5bd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 27 Dec 2022 09:35:09 +0800 Subject: [PATCH 6/9] 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 5e8bc4ab3..0ac2f64c3 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" { - ScheduleTimerFuncByInterval(func() { - syncStoreSkuTiktok() - }, 60*time.Second, 10*time.Minute) - } + //if beego.BConfig.RunMode != "jxgy" { + // ScheduleTimerFuncByInterval(func() { + // syncStoreSkuTiktok() + // }, 60*time.Second, 10*time.Minute) + //} // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From d8f2fee6542e55b21c379d27d34465779a242c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 27 Dec 2022 09:58:43 +0800 Subject: [PATCH 7/9] 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 1c26a24bb..9d184f87d 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -250,6 +250,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) } + globals.SugarLogger.Debugf("111111111") childrenProductId, err = api.CreateSubProduct(mainOrderDetail.ProductId, utils.Str2Int64(vendorStoreID)) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) @@ -317,6 +318,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } // 主商品存在,直接同步子商品 + globals.SugarLogger.Debugf("22222222") childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) From 9a2f326fa214a5d548bb59e039473434f67831a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 27 Dec 2022 11:28:55 +0800 Subject: [PATCH 8/9] 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 0ac2f64c3..33b53aa23 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" { - // ScheduleTimerFuncByInterval(func() { - // syncStoreSkuTiktok() - // }, 60*time.Second, 10*time.Minute) - //} + if beego.BConfig.RunMode != "jxgy" { + ScheduleTimerFuncByInterval(func() { + syncStoreSkuTiktok() + }, 60*time.Second, 30*time.Minute) + } // 定时任务刷新当前订单的物流信息 ScheduleTimerFunc("RefreshMaterialLogistics", func() { From 7d3865690923eac7fa9e9963c5e42f5a6d91e851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 27 Dec 2022 15:02:28 +0800 Subject: [PATCH 9/9] 1 --- .../purchase/tiktok_store/store_sku2_utils.go | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 9d184f87d..5c48aef3a 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -214,8 +214,15 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI // 根据本地商品id获取线上商品是否存在,存在则只创建子商品 // 获取本地存储映射关系,获取本地主商品id是否存在 + var mainProductId int64 = 0 localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode) mainOrderDetail, err := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID)) + if mainOrderDetail.MainProductId != 0 { + mainProductId = mainOrderDetail.MainProductId + } else { + mainProductId = mainOrderDetail.ProductId + } + if len(localThing) == 0 { if err != nil || mainOrderDetail == nil || mainOrderDetail.ProductIdStr == "" { tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 @@ -246,18 +253,17 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI continue } - if err := dao.CreateThingMap(int64(storeSku.SkuID), mainOrderDetail.ProductIdStr, storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0); err != nil { + if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainProductId), storeDetail.VendorOrgCode, "线上存在本地不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) } - globals.SugarLogger.Debugf("111111111") - childrenProductId, err = api.CreateSubProduct(mainOrderDetail.ProductId, utils.Str2Int64(vendorStoreID)) + 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 = mainOrderDetail.ProductIdStr + storeSku.VendorMainId = utils.Int64ToStr(mainProductId) var attrId []string for _, v := range mainOrderDetail.SpecPrices { attrId = append(attrId, utils.Int64ToStr(v.SkuId)) @@ -302,7 +308,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.WeightUnit = tiktokShop.WeightUint_G updateParam.StandardBrandId = param.StandardBrandId // 默认品牌京西菜市 updateParam.ProductId = mainOrderDetail.ProductId - updateParam.MainProductId = mainOrderDetail.ProductId + updateParam.MainProductId = mainProductId updateParam.SpecPrices = param.SpecPrices //updateParam.StoreId = utils.Str2Int64(vendorStoreID) if err := api.EditStoreCommodity(updateParam); err != nil { @@ -318,7 +324,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } // 主商品存在,直接同步子商品 - globals.SugarLogger.Debugf("22222222") childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID)) if err != nil || childrenProductId == 0 { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) @@ -398,7 +403,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } - mainIdInt = mainOrderDetail.ProductId + if mainOrderDetail.MainProductId != 0 { + mainIdInt = mainOrderDetail.MainProductId + } else { + mainIdInt = mainOrderDetail.ProductId + } + storeSku.VendorMainId = utils.Int64ToStr(mainIdInt) if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(mainIdInt), storeDetail.VendorOrgCode, "更新发现不存在", model.ThingTypeSku, 0); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) @@ -412,10 +422,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } // 修改商品 - param.ProductId = mainIdInt + param.ProductId = utils.Str2Int64(storeSku.VendorSkuID) param.MainProductId = mainIdInt param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, param.MainProductId, storeSku) - //param.StoreId = utils.Str2Int64(vendorStoreID) if err := api.EditStoreCommodity(param); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)