aa
This commit is contained in:
@@ -79,6 +79,13 @@ var (
|
||||
// return ebaiUploadRTFShopID
|
||||
// }
|
||||
|
||||
func GetVendorCategoriesWithMap(ctx *jxcontext.Context, vendorID int) (vendorCats []*dao.GetVendorCategoriesWithMapResult, err error) {
|
||||
if vendorID != model.VendorIDMTWM {
|
||||
return nil, fmt.Errorf("只支持美团!")
|
||||
}
|
||||
return dao.GetVendorCategoriesWithMap(dao.GetDB(), vendorID)
|
||||
}
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetVendorCategories(ctx *jxcontext.Context, vendorID int, parentID string) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
cond := map[string]interface{}{
|
||||
|
||||
@@ -5734,3 +5734,29 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
||||
task.GetResult(0)
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateMtCatToJd(ctx *jxcontext.Context, mtCatID, jdCatID string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
list, _ := dao.GetMtJdCategoryMap(db, mtCatID, jdCatID)
|
||||
if len(list) > 0 {
|
||||
return
|
||||
}
|
||||
list2, _ := dao.GetMtJdCategoryMap(db, mtCatID, "")
|
||||
if len(list2) > 0 {
|
||||
if list2[0].JdID == jdCatID {
|
||||
return
|
||||
} else {
|
||||
list2[0].JdID = jdCatID
|
||||
dao.UpdateEntity(db, list2[0], "JdID")
|
||||
}
|
||||
} else {
|
||||
catMap := &model.MtJdCategoryMap{
|
||||
MtID: mtCatID,
|
||||
JdID: jdCatID,
|
||||
}
|
||||
dao.CreateEntity(db, catMap)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -598,3 +598,21 @@ func GetMtJdCategoryMap(db *DaoDB, mtID, jdID string) (cats []*model.MtJdCategor
|
||||
}
|
||||
return cats, err
|
||||
}
|
||||
|
||||
type GetVendorCategoriesWithMapResult struct {
|
||||
model.SkuVendorCategory
|
||||
|
||||
CatMapID string `orm:"column(cat_map_id)" json:"catMapID"`
|
||||
}
|
||||
|
||||
func GetVendorCategoriesWithMap(db *DaoDB, vendorID int) (results []*GetVendorCategoriesWithMapResult, err error) {
|
||||
sql := `
|
||||
SELECT a.*, b.jd_id cat_map_id
|
||||
FROM sku_vendor_category a
|
||||
LEFT JOIN mt_jd_category_map b ON a.vendor_category_id = b.mt_id
|
||||
WHERE vendor_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{vendorID}
|
||||
GetRows(db, &results, sql, sqlParams)
|
||||
return results, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user