Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2023-03-23 15:29:09 +08:00

View File

@@ -1149,19 +1149,24 @@ type aa struct {
// 根据名称获取商品分类[京东]
func getCategoryByName(name string) string {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDJD).(partner.IPurchasePlatformStoreSkuHandler)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(beego.AppConfig.DefaultString("jdOrgCode", "320406"), name)
vendorCategoryId, err := handler.GetSkuCategoryIdByName("320406", name)
globals.SugarLogger.Debugf("getCategoryByName vendorCategoryId :%s", vendorCategoryId)
globals.SugarLogger.Debugf("getCategoryByName err :%v", err)
return vendorCategoryId
}
// 获取抖音商品分类[抖音]
func getCategoryByImg(img string) string {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IPurchasePlatformStoreSkuHandler)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName("57939570", img)
vendorCategoryId, err := handler.GetSkuCategoryIdByName("57939570", img)
globals.SugarLogger.Debugf("getCategoryByImg vendorCategoryId :%s", vendorCategoryId)
globals.SugarLogger.Debugf("getCategoryByImg err :%v", err)
return vendorCategoryId
}
// 根据平台返回的分类id,获取本地绑定的映射分类id
func getJDCategoryLoadingLocalCategoryReflex(jdCategoryId, jdsCategoryID, ebaiCategoryID, mtwmCategoryID string) (string, string, string) {
globals.SugarLogger.Debugf("getJDCategoryLoadingLocalCategoryReflex 1111: %s,%s,%s,%s", jdCategoryId, jdsCategoryID, ebaiCategoryID, mtwmCategoryID)
cats, err := dao.GetCategoriesByName(dao.GetDB(), "", jdCategoryId)
if len(cats) == 0 || err != nil {
globals.SugarLogger.Errorf("%v", fmt.Errorf("根据京东分类id设置美团/饿了么分类错误:%d,%v", len(cats), err))
@@ -1177,6 +1182,7 @@ func getJDCategoryLoadingLocalCategoryReflex(jdCategoryId, jdsCategoryID, ebaiCa
mtwmCategoryID = utils.Int64ToStr(cats[0].MtwmCategoryID)
}
}
globals.SugarLogger.Debugf("getJDCategoryLoadingLocalCategoryReflex 2222: %s,%s,%s,%s", jdCategoryId, jdsCategoryID, ebaiCategoryID, mtwmCategoryID)
return jdsCategoryID, ebaiCategoryID, mtwmCategoryID
}
@@ -1215,6 +1221,7 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
mtwmCategoryID := ""
ddCategoryID := ""
if skuNameExt != nil {
globals.SugarLogger.Debugf("======skuNameExt :%s", utils.Format4Output(skuNameExt, false))
if skuNameExt.JdCategoryID != "" {
jdCategoryId = skuNameExt.JdCategoryID
} else {
@@ -1237,6 +1244,7 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
ddCategoryID = getCategoryByImg(imgs)
}
} else {
globals.SugarLogger.Debugf("======payload :%s", utils.Format4Output(payload, false))
if payload["jdCategoryID"] != nil {
jdCategoryId = payload["jdCategoryID"].(string)
} else {
@@ -1259,23 +1267,29 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
}
}
if jdsCategoryID != "" {
globals.SugarLogger.Debugf("jdsCategoryID:%s", jdsCategoryID)
globals.SugarLogger.Debugf("ebaiCategoryID:%s", ebaiCategoryID)
globals.SugarLogger.Debugf("mtwmCategoryID:%s", mtwmCategoryID)
globals.SugarLogger.Debugf("ddCategoryID:%s", ddCategoryID)
globals.SugarLogger.Debugf("jdCategoryId:%s", jdCategoryId)
if jdsCategoryID != "" && jdsCategoryID != "0" {
updateOrCreate(model.VendorIDJDShop, nameID, jdsCategoryID)
flag = true
}
if ebaiCategoryID != "" {
if ebaiCategoryID != "" && ebaiCategoryID != "0" {
updateOrCreate(model.VendorIDEBAI, nameID, ebaiCategoryID)
flag = true
}
if mtwmCategoryID != "" {
if mtwmCategoryID != "" && mtwmCategoryID != "0" {
updateOrCreate(model.VendorIDMTWM, nameID, mtwmCategoryID)
flag = true
}
if ddCategoryID != "" {
if ddCategoryID != "" && ddCategoryID != "0" {
updateOrCreate(model.VendorIDDD, nameID, ddCategoryID)
flag = true
}
if jdCategoryId != "" {
if jdCategoryId != "" && jdCategoryId != "0" {
updateOrCreate(model.VendorIDJD, nameID, jdCategoryId)
flag = true
}