新增ebai2API
This commit is contained in:
@@ -1482,92 +1482,92 @@ func SumExianDaDepot(ctx *jxcontext.Context, isAsync, isContinueWhenError bool)
|
||||
switch step {
|
||||
case 0:
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*ebaiapi.ExianDaSkus)
|
||||
skus, err := api.EbaiAPI.GetExianDaSku(utils.Str2Int64(v.ElemeGoodsID))
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
skuNameExt := &model.SkuName{}
|
||||
sql2 := `
|
||||
SELECT a.*
|
||||
FROM sku_name a
|
||||
JOIN sku b ON b.name_id = a.id
|
||||
WHERE a.upc = ?
|
||||
`
|
||||
sqlParams2 := []interface{}{
|
||||
skus.UpcIds,
|
||||
}
|
||||
dao.GetRow(db, skuNameExt, sql2, sqlParams2)
|
||||
prefix, _, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.GoodsName)
|
||||
//京西库中存在此商品
|
||||
if skuNameExt.ID != 0 {
|
||||
var flag = false
|
||||
if skuNameExt.Name != v.GoodsName {
|
||||
skuNameExt.Name = v.GoodsName
|
||||
skuNameExt.Prefix = prefix
|
||||
skuNameExt.SpecUnit = specUnit
|
||||
skuNameExt.Unit = unit
|
||||
skuNameExt.SpecQuality = specQuality
|
||||
flag = true
|
||||
}
|
||||
if skuNameExt.Img != v.ImageURL {
|
||||
skuNameExt.Img = v.ImageURL
|
||||
flag = true
|
||||
}
|
||||
if flag {
|
||||
_, err = dao.UpdateEntity(db, skuNameExt, "Name", "Prefix", "SpecUnit", "Unit", "SpecQuality", "Img")
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
skuCat := &model.SkuCategory{}
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM sku_category
|
||||
WHERE ebai_category_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
skus.CategoryIDThird,
|
||||
}
|
||||
dao.GetRow(db, skuCat, sql, sqlParams)
|
||||
skuName := &model.SkuName{
|
||||
Prefix: prefix,
|
||||
Name: v.GoodsName,
|
||||
IsGlobal: model.YES,
|
||||
Unit: unit,
|
||||
SpecQuality: specQuality,
|
||||
SpecUnit: specUnit,
|
||||
Price: 100,
|
||||
Img: v.ImageURL,
|
||||
Upc: &v.UpcID,
|
||||
Status: model.SkuStatusNormal,
|
||||
}
|
||||
if skuCat.ID != 0 {
|
||||
skuName.CategoryID = skuCat.ID
|
||||
} else {
|
||||
skuName.CategoryID = 35 //默认给了个分类
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(skuName, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, skuName)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
sku := &model.Sku{
|
||||
NameID: skuName.ID,
|
||||
SpecQuality: specQuality,
|
||||
SpecUnit: specUnit,
|
||||
Weight: int(utils.Str2Int64(skus.Weight)),
|
||||
Status: model.SkuStatusNormal,
|
||||
ExdSkuID: v.ElemeGoodsID,
|
||||
ExdCategoryThirdID: skus.CategoryIDThird,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(sku, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, sku)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
// v := batchItemList[0].(*ebaiapi.ExianDaSkus)
|
||||
// skus, err := api.EbaiAPI.GetExianDaSku(utils.Str2Int64(v.ElemeGoodsID))
|
||||
// if err != nil {
|
||||
// return result, err
|
||||
// }
|
||||
// skuNameExt := &model.SkuName{}
|
||||
// sql2 := `
|
||||
// SELECT a.*
|
||||
// FROM sku_name a
|
||||
// JOIN sku b ON b.name_id = a.id
|
||||
// WHERE a.upc = ?
|
||||
// `
|
||||
// sqlParams2 := []interface{}{
|
||||
// skus.UpcIds,
|
||||
// }
|
||||
// dao.GetRow(db, skuNameExt, sql2, sqlParams2)
|
||||
// prefix, _, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.GoodsName)
|
||||
// //京西库中存在此商品
|
||||
// if skuNameExt.ID != 0 {
|
||||
// var flag = false
|
||||
// if skuNameExt.Name != v.GoodsName {
|
||||
// skuNameExt.Name = v.GoodsName
|
||||
// skuNameExt.Prefix = prefix
|
||||
// skuNameExt.SpecUnit = specUnit
|
||||
// skuNameExt.Unit = unit
|
||||
// skuNameExt.SpecQuality = specQuality
|
||||
// flag = true
|
||||
// }
|
||||
// if skuNameExt.Img != v.ImageURL {
|
||||
// skuNameExt.Img = v.ImageURL
|
||||
// flag = true
|
||||
// }
|
||||
// if flag {
|
||||
// _, err = dao.UpdateEntity(db, skuNameExt, "Name", "Prefix", "SpecUnit", "Unit", "SpecQuality", "Img")
|
||||
// if err != nil {
|
||||
// return result, err
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// skuCat := &model.SkuCategory{}
|
||||
// sql := `
|
||||
// SELECT *
|
||||
// FROM sku_category
|
||||
// WHERE ebai_category_id = ?
|
||||
// `
|
||||
// sqlParams := []interface{}{
|
||||
// skus.CategoryIDThird,
|
||||
// }
|
||||
// dao.GetRow(db, skuCat, sql, sqlParams)
|
||||
// skuName := &model.SkuName{
|
||||
// Prefix: prefix,
|
||||
// Name: v.GoodsName,
|
||||
// IsGlobal: model.YES,
|
||||
// Unit: unit,
|
||||
// SpecQuality: specQuality,
|
||||
// SpecUnit: specUnit,
|
||||
// Price: 100,
|
||||
// Img: v.ImageURL,
|
||||
// Upc: &v.UpcID,
|
||||
// Status: model.SkuStatusNormal,
|
||||
// }
|
||||
// if skuCat.ID != 0 {
|
||||
// skuName.CategoryID = skuCat.ID
|
||||
// } else {
|
||||
// skuName.CategoryID = 35 //默认给了个分类
|
||||
// }
|
||||
// dao.WrapAddIDCULDEntity(skuName, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, skuName)
|
||||
// if err != nil {
|
||||
// return result, err
|
||||
// }
|
||||
// sku := &model.Sku{
|
||||
// NameID: skuName.ID,
|
||||
// SpecQuality: specQuality,
|
||||
// SpecUnit: specUnit,
|
||||
// Weight: int(utils.Str2Int64(skus.Weight)),
|
||||
// Status: model.SkuStatusNormal,
|
||||
// ExdSkuID: v.ElemeGoodsID,
|
||||
// ExdCategoryThirdID: skus.CategoryIDThird,
|
||||
// }
|
||||
// dao.WrapAddIDCULDEntity(sku, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, sku)
|
||||
// if err != nil {
|
||||
// return result, err
|
||||
// }
|
||||
// }
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("更新京西上饿鲜达商品库", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, results)
|
||||
@@ -1591,11 +1591,11 @@ func SumExianDaDepot(ctx *jxcontext.Context, isAsync, isContinueWhenError bool)
|
||||
err = dao.GetRows(db, &skus, sql, sqlParams...)
|
||||
taskFunc2 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*model.SkuName)
|
||||
skuList, err := api.EbaiAPI.GetEbaiDepotSku(ebaiapi.EbaiWholeCountryStore, *v.Upc)
|
||||
skuList, err := api.Ebai2API.GetEbaiDepotSku(ebaiapi.EbaiWholeCountryStore, *v.Upc)
|
||||
if err != nil || len(skuList) == 0 {
|
||||
return retVal, err
|
||||
}
|
||||
sku, err := api.EbaiAPI.GetEbaiSku(skuList[0].UpcID, ebaiapi.EbaiWholeCountryStore)
|
||||
sku, err := api.Ebai2API.GetEbaiSku(skuList[0].UpcID, ebaiapi.EbaiWholeCountryStore)
|
||||
if err != nil || sku == nil {
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user