aa
This commit is contained in:
@@ -2896,6 +2896,6 @@ func ReorderVendorCategories(ctx *jxcontext.Context, parentID, vendorID int, ven
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
_, err = SyncCategories(ctx, nil, []int{model.VendorIDJD}, []string{vendorOrgCode}, categoryIDs, true)
|
SyncReorderCategories(ctx, parentID, true)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,20 +222,35 @@ func SyncReorderCategories(ctx *jxcontext.Context, parentCatID int, isAsync bool
|
|||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
vendorInfo := batchItemList[0].(*MultiStoreVendorInfo)
|
vendorInfo := batchItemList[0].(*MultiStoreVendorInfo)
|
||||||
multiStoresHandler := CurVendorSync.GetMultiStoreHandler(vendorInfo.VendorID)
|
multiStoresHandler := CurVendorSync.GetMultiStoreHandler(vendorInfo.VendorID)
|
||||||
|
vendorOrgCode, err := dao.GetVendorOrgCode(db, vendorInfo.VendorID, vendorInfo.OrgCode)
|
||||||
if multiStoresHandler != nil {
|
if multiStoresHandler != nil {
|
||||||
catList, err2 := dao.GetSkuCategoryWithVendor(db, []int{vendorInfo.VendorID}, []string{vendorInfo.OrgCode}, parentCatID, nil, false)
|
var vendorCatIDList []string
|
||||||
if err = err2; err == nil {
|
var parentVendorCatID string
|
||||||
var vendorCatIDList []string
|
//如果用平台分类就走else,用京西分类就还是原来的if
|
||||||
for _, v := range catList {
|
if vendorOrgCode[0].IsJxCat == model.NO {
|
||||||
if v.VendorCatID != "" {
|
catList, err2 := dao.GetSkuCategoryWithVendor(db, []int{vendorInfo.VendorID}, []string{vendorInfo.OrgCode}, parentCatID, nil, false)
|
||||||
vendorCatIDList = append(vendorCatIDList, v.VendorCatID)
|
if err = err2; err == nil {
|
||||||
|
for _, v := range catList {
|
||||||
|
if v.VendorCatID != "" {
|
||||||
|
vendorCatIDList = append(vendorCatIDList, v.VendorCatID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(vendorCatIDList) > 0 {
|
parentVendorCatID = catList[0].ParentVendorCatID
|
||||||
if err = multiStoresHandler.ReorderCategories2(ctx, vendorInfo.OrgCode, catList[0].ParentVendorCatID, vendorCatIDList); err == nil {
|
} else {
|
||||||
retVal = []int{len(vendorCatIDList)}
|
vendorCatList, _ := dao.GetVendorCategoryMapExt(db, parentCatID, 0, vendorInfo.VendorID, vendorInfo.OrgCode, 0)
|
||||||
|
for _, v := range vendorCatList {
|
||||||
|
if v.VendorThingID != "" {
|
||||||
|
vendorCatIDList = append(vendorCatIDList, v.VendorThingID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
thingMaps, _ := dao.GetThingMapList(db, model.ThingTypeCategory, []int{vendorInfo.VendorID}, []int{parentCatID}, []string{vendorInfo.OrgCode})
|
||||||
|
parentVendorCatID = thingMaps[0].VendorThingID
|
||||||
|
}
|
||||||
|
if len(vendorCatIDList) > 0 {
|
||||||
|
if err = multiStoresHandler.ReorderCategories2(ctx, vendorInfo.OrgCode, parentVendorCatID, vendorCatIDList); err == nil {
|
||||||
|
retVal = []int{len(vendorCatIDList)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("非法平台:%d", vendorInfo.VendorID)
|
err = fmt.Errorf("非法平台:%d", vendorInfo.VendorID)
|
||||||
|
|||||||
@@ -485,3 +485,46 @@ func GetVendorCategoryMap(db *DaoDB, parentID, level, vendorID int, vendorOrgCod
|
|||||||
}
|
}
|
||||||
return vendorMaps, err
|
return vendorMaps, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetVendorCategoryMapExtResult struct {
|
||||||
|
model.VendorCategoryMap
|
||||||
|
VendorThingID string `orm:"column(vendor_thing_id)" json:"vendorThingID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetVendorCategoryMapExt(db *DaoDB, parentID, level, vendorID int, vendorOrgCode string, categoryID int) (vendorMaps []*GetVendorCategoryMapExtResult, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT a.*, b.vendor_thing_id
|
||||||
|
FROM vendor_category_map a
|
||||||
|
JOIN thing_map b ON b.thing_id = a.category_id AND b.thing_type = ?
|
||||||
|
WHERE a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if parentID >= 0 {
|
||||||
|
sql += " AND a.parent_id = ?"
|
||||||
|
sqlParams = append(sqlParams, parentID)
|
||||||
|
}
|
||||||
|
if level > 0 {
|
||||||
|
sql += " AND a.level = ?"
|
||||||
|
sqlParams = append(sqlParams, level)
|
||||||
|
}
|
||||||
|
if vendorID != -1 {
|
||||||
|
sql += " AND a.vendor_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorID)
|
||||||
|
}
|
||||||
|
if vendorOrgCode != "" {
|
||||||
|
sql += " AND a.vendor_org_code = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorOrgCode)
|
||||||
|
}
|
||||||
|
if categoryID > 0 {
|
||||||
|
sql += " AND a.category_id = ?"
|
||||||
|
sqlParams = append(sqlParams, categoryID)
|
||||||
|
}
|
||||||
|
sql += " ORDER BY a.vendor_category_seq"
|
||||||
|
err = GetRows(db, &vendorMaps, sql, sqlParams)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return vendorMaps, err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user