diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index f2cfac981..297d76b20 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -1081,6 +1081,8 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } userName := ctx.GetUserName() needSyncIDMap := make(map[int]int) + isSyncSkus := false + var appCodeList []string dao.Begin(db) defer func() { if r := recover(); r != nil { @@ -1248,26 +1250,26 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs if thingMaps[0].VendorThingID == "" { //并且同步标志还没有带待创建(因为addskuname现在建到thingmap上不会带待创建标志了) if !model.IsSyncStatusNew(thingMaps[0].SyncStatus) { - if err = OnCreateThing(ctx, db, []*MultiStoreVendorInfo{ + isSyncSkus = true + appCodeList = append(appCodeList, list1[0].VendorOrgCode) + OnCreateThing(ctx, db, []*MultiStoreVendorInfo{ &MultiStoreVendorInfo{ VendorID: model.VendorIDJD, OrgCode: list1[0].VendorOrgCode, }, - }, int64(v.RealSkuID), model.ThingTypeSku, model.SyncFlagNewMask); err == nil { - _, err = SyncSkus(ctx, nil, []int{model.VendorIDJD}, []string{list1[0].VendorOrgCode}, nil, []int{v.RealSkuID}, true) - } + }, int64(v.RealSkuID), model.ThingTypeSku, model.SyncFlagNewMask) } } } else { //万一不存在 - if err = OnCreateThing(ctx, db, []*MultiStoreVendorInfo{ + isSyncSkus = true + appCodeList = append(appCodeList, list1[0].VendorOrgCode) + OnCreateThing(ctx, db, []*MultiStoreVendorInfo{ &MultiStoreVendorInfo{ VendorID: model.VendorIDJD, OrgCode: list1[0].VendorOrgCode, }, - }, int64(v.RealSkuID), model.ThingTypeSku, model.SyncFlagNewMask); err == nil { - _, err = SyncSkus(ctx, nil, []int{model.VendorIDJD}, []string{list1[0].VendorOrgCode}, nil, []int{v.RealSkuID}, true) - } + }, int64(v.RealSkuID), model.ThingTypeSku, model.SyncFlagNewMask) } } } @@ -1418,6 +1420,9 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } dao.Commit(db) skuIDs := jxutils.IntMap2List(needSyncIDMap) + if isSyncSkus { + _, err = SyncSkus(ctx, nil, []int{model.VendorIDJD}, appCodeList, nil, skuIDs, true) + } return skuIDs, err }