1
This commit is contained in:
@@ -6551,7 +6551,7 @@ func GetVendorStoreSkus(ctx *jxcontext.Context, storeID, vendorID int) (err erro
|
|||||||
|
|
||||||
// CopyMtToJd 复制美团到京东
|
// CopyMtToJd 复制美团到京东
|
||||||
func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCode string) (err error) {
|
func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCode string) (err error) {
|
||||||
type funcType func(mtID, parentID string, catInfo []*mtwmapi.RetailCategoryInfo)
|
//type funcType func(mtID, parentID string, catInfo []*mtwmapi.RetailCategoryInfo)
|
||||||
var (
|
var (
|
||||||
//mtAccessToken = ""
|
//mtAccessToken = ""
|
||||||
//db = dao.GetDB()
|
//db = dao.GetDB()
|
||||||
@@ -6594,46 +6594,53 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
|||||||
step := batchItemList[0].(int)
|
step := batchItemList[0].(int)
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
//jdCatList, _ := jd.QueryCategoriesByOrgCode()
|
jdCatList, _ := jd.QueryCategoriesByOrgCode()
|
||||||
catList, _ := mtapi.RetailCatList(mtStoreID)
|
catList, _ := mtapi.RetailCatList(mtStoreID)
|
||||||
//for _, jdc := range jdCatList {
|
for _, jdc := range jdCatList {
|
||||||
// for _, mtc := range catList {
|
for _, mtc := range catList {
|
||||||
// if jdc.Name == mtc.Name {
|
if jdc.Name == mtc.Name {
|
||||||
// catMap[mtc.Name] = utils.Int64ToStr(jdc.Id)
|
catMap[mtc.Name] = utils.Int64ToStr(jdc.Id)
|
||||||
// break
|
break
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//建分类 ,账号存在分类,不在创建分类
|
|
||||||
//jdCatList, _ := jd.QueryCategoriesByOrgCode()
|
|
||||||
//if len(jdCatList) == 0 {
|
|
||||||
//catList, _ = mtapi.RetailCatList(mtStoreID)
|
|
||||||
|
|
||||||
for i := len(catList) - 1; i > -1; i-- {
|
|
||||||
catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "")
|
|
||||||
if catID != "" {
|
|
||||||
if catList[i].Code != "" {
|
|
||||||
catMap[catList[i].Code] = catID
|
|
||||||
} else {
|
|
||||||
catMap[catList[i].Name] = catID
|
|
||||||
}
|
}
|
||||||
|
if len(mtc.Children) != 0 {
|
||||||
|
for _, mtcl := range mtc.Children {
|
||||||
|
if mtcl.Name == jdc.Name {
|
||||||
|
catMap[mtcl.Name] = utils.Int64ToStr(jdc.Id)
|
||||||
}
|
}
|
||||||
//LoopCatChild(catList[i].Code, catID, catList[i].Children)
|
|
||||||
//美团好像只能建两级分类?
|
|
||||||
for j := len(catList[i].Children) - 1; j > -1; j-- {
|
|
||||||
catID2, _ := jd.AddShopCategory(utils.Str2Int64(catID), catList[i].Children[j].Name, catList[i].Children[j].Level, catList[i].Children[j].Sequence, "")
|
|
||||||
if catID2 != "" {
|
|
||||||
if catList[i].Children[j].Code != "" {
|
|
||||||
catMap[catList[i].Children[j].Code] = catID2
|
|
||||||
} else {
|
|
||||||
catMap[catList[i].Children[j].Name] = catID2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("--------catMapcatMap := %s", utils.Format4Output(catList, false))
|
////建分类 ,账号存在分类,不在创建分类
|
||||||
|
////jdCatList, _ := jd.QueryCategoriesByOrgCode()
|
||||||
|
////if len(jdCatList) == 0 {
|
||||||
|
////catList, _ = mtapi.RetailCatList(mtStoreID)
|
||||||
|
//
|
||||||
|
//for i := len(catList) - 1; i > -1; i-- {
|
||||||
|
// catID, _ := jd.AddShopCategory(0, catList[i].Name, catList[i].Level, catList[i].Sequence, "")
|
||||||
|
// if catID != "" {
|
||||||
|
// if catList[i].Code != "" {
|
||||||
|
// catMap[catList[i].Code] = catID
|
||||||
|
// } else {
|
||||||
|
// catMap[catList[i].Name] = catID
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //LoopCatChild(catList[i].Code, catID, catList[i].Children)
|
||||||
|
// //美团好像只能建两级分类?
|
||||||
|
// for j := len(catList[i].Children) - 1; j > -1; j-- {
|
||||||
|
// catID2, _ := jd.AddShopCategory(utils.Str2Int64(catID), catList[i].Children[j].Name, catList[i].Children[j].Level, catList[i].Children[j].Sequence, "")
|
||||||
|
// if catID2 != "" {
|
||||||
|
// if catList[i].Children[j].Code != "" {
|
||||||
|
// catMap[catList[i].Children[j].Code] = catID2
|
||||||
|
// } else {
|
||||||
|
// catMap[catList[i].Children[j].Name] = catID2
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
globals.SugarLogger.Debugf("--------catMapcatMap := %s", utils.Format4Output(catMap, false))
|
||||||
//}
|
//}
|
||||||
case 1:
|
case 1:
|
||||||
//建商品
|
//建商品
|
||||||
@@ -6652,10 +6659,30 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var searchAfterSkuId string = ""
|
||||||
|
var jdSkus = make(map[string]int, 0)
|
||||||
|
for i2 := 0; i2 < 85; i2++ {
|
||||||
|
idList, afterSkuId, err := jd.AuerySkuInfoList(int64(i), 20, searchAfterSkuId)
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("--------err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second * 1)
|
||||||
|
searchAfterSkuId = utils.Int64ToStr(afterSkuId)
|
||||||
|
for _, ifd := range idList {
|
||||||
|
jdSkus[ifd] = 1
|
||||||
|
}
|
||||||
|
if len(idList) < 20 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("--------jdSkus := %d", len(jdSkus))
|
||||||
|
|
||||||
task2 := tasksch.NewParallelTask("美团到京东, 建商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx,
|
task2 := tasksch.NewParallelTask("美团到京东, 建商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
mtSku := batchItemList[0].(*mtwmapi.AppFood)
|
mtSku := batchItemList[0].(*mtwmapi.AppFood)
|
||||||
|
if _, ok := jdSkus[mtSku.AppFoodCode]; !ok {
|
||||||
//catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "")
|
//catMaps, _ := dao.GetMtJdCategoryMap(db, utils.Int2Str(mtSku.TagID), "")
|
||||||
//if len(catMaps) == 0 {
|
//if len(catMaps) == 0 {
|
||||||
//results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID)
|
//results, _ := dao.GetVendorCategoriesWithMap(db, model.VendorIDMTWM, mtSku.TagID)
|
||||||
@@ -6721,8 +6748,8 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
skuID, err := jd.NewAddSku(param)
|
skuID, err := jd.NewAddSku(param)
|
||||||
if err != nil {
|
if skuID == "0" || err != nil {
|
||||||
globals.SugarLogger.Debugf("---------AddSku2 := %s,%v", utils.Format4Output(param, false), err)
|
globals.SugarLogger.Debugf("Add sku : %s", utils.Format4Output(param, false))
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
if skuID != "" {
|
if skuID != "" {
|
||||||
@@ -6741,6 +6768,7 @@ func CopyMtToJd(ctx *jxcontext.Context, mtStoreID, mtOrgCode, jdStoreID, jdOrgCo
|
|||||||
globals.SugarLogger.Debugf("--------err r1 := %v", err2)
|
globals.SugarLogger.Debugf("--------err r1 := %v", err2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}, skuList)
|
}, skuList)
|
||||||
tasksch.HandleTask(task2, task, true).Run()
|
tasksch.HandleTask(task2, task, true).Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user