This commit is contained in:
苏尹岚
2021-01-29 14:38:11 +08:00
parent b345f1a245
commit 0e5c9e80bb
3 changed files with 27 additions and 1 deletions

View File

@@ -2905,7 +2905,7 @@ func ReorderVendorCategories(ctx *jxcontext.Context, parentID, vendorID int, ven
} }
} }
dao.Commit(db) dao.Commit(db)
SyncReorderCategories(ctx, parentID, true) err = SyncReorderCategories2(ctx, parentID, vendorID, vendorOrgCode)
return err return err
} }

View File

@@ -260,6 +260,31 @@ func SyncReorderCategories(ctx *jxcontext.Context, parentCatID int, isAsync bool
return hint, err return hint, err
} }
func SyncReorderCategories2(ctx *jxcontext.Context, parentCatID, vendorID int, vendorOrgCode string) (err error) {
globals.SugarLogger.Debugf("SyncReorderCategories parentCatID:%d", parentCatID)
db := dao.GetDB()
multiStoresHandler := CurVendorSync.GetMultiStoreHandler(vendorID)
if multiStoresHandler != nil {
var vendorCatIDList []string
var parentVendorCatID string
vendorCatList, _ := dao.GetVendorCategoryMapExt(db, parentCatID, 0, vendorID, vendorOrgCode, 0)
for _, v := range vendorCatList {
if v.VendorThingID != "" {
vendorCatIDList = append(vendorCatIDList, v.VendorThingID)
}
}
thingMaps, _ := dao.GetThingMapList(db, model.ThingTypeCategory, []int{vendorID}, []int{parentCatID}, []string{vendorOrgCode})
parentVendorCatID = thingMaps[0].VendorThingID
if len(vendorCatIDList) > 0 {
err = multiStoresHandler.ReorderCategories2(ctx, vendorOrgCode, parentVendorCatID, vendorCatIDList)
}
} else {
err = fmt.Errorf("非法平台:%d", vendorID)
}
return err
}
func getThingMap(db *dao.DaoDB, thingMap *model.ThingMap) (err error) { func getThingMap(db *dao.DaoDB, thingMap *model.ThingMap) (err error) {
return dao.GetEntity(db, thingMap, "ThingID", "ThingType", "VendorID", "VendorOrgCode", model.FieldDeletedAt) return dao.GetEntity(db, thingMap, "ThingID", "ThingType", "VendorID", "VendorOrgCode", model.FieldDeletedAt)
} }

View File

@@ -501,6 +501,7 @@ func GetVendorCategoryMapExt(db *DaoDB, parentID, level, vendorID int, vendorOrg
WHERE a.deleted_at = ? WHERE a.deleted_at = ?
` `
sqlParams := []interface{}{ sqlParams := []interface{}{
model.ThingTypeCategory,
utils.DefaultTimeValue, utils.DefaultTimeValue,
} }
if parentID >= 0 { if parentID >= 0 {