- 修复之前将老平台同步逻辑注释掉引入的BUG
This commit is contained in:
@@ -380,14 +380,13 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
|
||||
if len(loopMapInfo.StoreMapList) > 1 {
|
||||
loopStoreTask := tasksch.NewSeqTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
storeID := loopMapInfo.StoreMapList[step].StoreID
|
||||
_, err = handler.SyncStoreCategory(ctx, task, storeID, false)
|
||||
_, err = v.proxySyncStoreCategory(ctx, task, loopMapInfo.StoreMapList[step], nil, nil, false, isContinueWhenError)
|
||||
return nil, err
|
||||
}, len(loopMapInfo.StoreMapList))
|
||||
t.AddChild(loopStoreTask).Run()
|
||||
_, err = loopStoreTask.GetResult(0)
|
||||
} else {
|
||||
_, err = handler.SyncStoreCategory(ctx, t, loopMapInfo.StoreMapList[0].StoreID, false)
|
||||
_, err = v.proxySyncStoreCategory(ctx, t, loopMapInfo.StoreMapList[0], nil, nil, false, isContinueWhenError)
|
||||
}
|
||||
}
|
||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||
@@ -455,6 +454,13 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo
|
||||
// return globals.IsProductEnv() && storeMap.StoreID != 102652 // 绿城四季鲜店
|
||||
// }
|
||||
|
||||
func (v *VendorSync) proxySyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
// if isUseOldSyncLogic(storeMap) {
|
||||
// return v.GetStoreHandler(storeMap.VendorID).(partner.ISingleStoreHandler).SyncStoreCategory(ctx, parentTask, storeMap.StoreID, isAsync)
|
||||
// }
|
||||
return SyncStorCategories(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func (v *VendorSync) proxySyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
// if isUseOldSyncLogic(storeMap) {
|
||||
// return v.GetStoreHandler(storeMap.VendorID).SyncStoreSkus(ctx, parentTask, storeMap.StoreID, skuIDs, isAsync, isContinueWhenError)
|
||||
@@ -602,25 +608,25 @@ func (v *VendorSync) LoopMultiStoresVendors(ctx *jxcontext.Context, db *dao.DaoD
|
||||
return hint, makeSyncError(err)
|
||||
}
|
||||
|
||||
func (v *VendorSync) RefreshAllSkusID(ctx *jxcontext.Context, isAsync bool, vendorIDs []int, storeIDs []int) (hint string, err error) {
|
||||
task := tasksch.NewParallelTask("RefreshAllSkusID", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorID := batchItemList[0].(int)
|
||||
if handler := v.GetStoreHandler(vendorID); handler != nil {
|
||||
if multiHandler, ok := handler.(partner.IMultipleStoresHandler); ok {
|
||||
_, err = multiHandler.RefreshAllSkusID(ctx, task, false)
|
||||
} else if singleHandler, ok := handler.(partner.ISingleStoreHandler); ok {
|
||||
_, err = singleHandler.RefreshStoresAllSkusID(ctx, task, false, storeIDs)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, vendorIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
}
|
||||
return task.ID, err
|
||||
}
|
||||
// func (v *VendorSync) RefreshAllSkusID(ctx *jxcontext.Context, isAsync bool, vendorIDs []int, storeIDs []int) (hint string, err error) {
|
||||
// task := tasksch.NewParallelTask("RefreshAllSkusID", nil, ctx,
|
||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// vendorID := batchItemList[0].(int)
|
||||
// if handler := v.GetStoreHandler(vendorID); handler != nil {
|
||||
// if multiHandler, ok := handler.(partner.IMultipleStoresHandler); ok {
|
||||
// _, err = multiHandler.RefreshAllSkusID(ctx, task, false)
|
||||
// } else if singleHandler, ok := handler.(partner.ISingleStoreHandler); ok {
|
||||
// _, err = singleHandler.RefreshStoresAllSkusID(ctx, task, false, storeIDs)
|
||||
// }
|
||||
// }
|
||||
// return nil, err
|
||||
// }, vendorIDs)
|
||||
// tasksch.HandleTask(task, nil, true).Run()
|
||||
// if !isAsync {
|
||||
// _, err = task.GetResult(0)
|
||||
// }
|
||||
// return task.ID, err
|
||||
// }
|
||||
|
||||
func (v *VendorSync) RefreshAllStoresID(ctx *jxcontext.Context, isAsync bool, vendorIDs []int) (hint string, err error) {
|
||||
task := tasksch.NewParallelTask("RefreshAllStoresID", nil, ctx,
|
||||
|
||||
@@ -169,16 +169,16 @@ type IMultipleStoresHandler interface {
|
||||
UpdateSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error)
|
||||
DeleteSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error)
|
||||
|
||||
RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error)
|
||||
// RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error)
|
||||
|
||||
GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*SkuNameInfo, err error)
|
||||
}
|
||||
|
||||
type ISingleStoreHandler interface {
|
||||
IPurchasePlatformHandler
|
||||
SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error)
|
||||
// SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error)
|
||||
|
||||
RefreshStoresAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool, storeIDs []int) (hint string, err error)
|
||||
// RefreshStoresAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool, storeIDs []int) (hint string, err error)
|
||||
}
|
||||
|
||||
type BasePurchasePlatform struct {
|
||||
|
||||
@@ -2,38 +2,36 @@ package ebai
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func TestSyncStoresSkus(t *testing.T) {
|
||||
skus := make([]int, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
skus[i] = i + 1
|
||||
}
|
||||
_, err := CurPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false, false)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
time.Sleep(4 * time.Second)
|
||||
}
|
||||
// func TestSyncStoresSkus(t *testing.T) {
|
||||
// skus := make([]int, 100)
|
||||
// for i := 0; i < 100; i++ {
|
||||
// skus[i] = i + 1
|
||||
// }
|
||||
// _, err := CurPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// time.Sleep(4 * time.Second)
|
||||
// }
|
||||
|
||||
func TestSyncOneStoreCategoriesFromRemote2Local(t *testing.T) {
|
||||
db := dao.GetDB()
|
||||
err := CurPurchaseHandler.SyncLocalStoreCategory(db, testShopID, "autotest")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
// func TestSyncOneStoreCategoriesFromRemote2Local(t *testing.T) {
|
||||
// db := dao.GetDB()
|
||||
// err := CurPurchaseHandler.SyncLocalStoreCategory(db, testShopID, "autotest")
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// }
|
||||
|
||||
func TestSyncOneStoreCategoriesFromLocal2Remote(t *testing.T) {
|
||||
_, err := CurPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
// func TestSyncOneStoreCategoriesFromLocal2Remote(t *testing.T) {
|
||||
// _, err := CurPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// }
|
||||
|
||||
func TestGetAllRemoteSkus(t *testing.T) {
|
||||
result, err := CurPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, nil)
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
package elm
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
||||
return "", nil
|
||||
}
|
||||
// func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
||||
// return "", nil
|
||||
// }
|
||||
|
||||
// func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
// return hint, err
|
||||
// }
|
||||
|
||||
func (p *PurchaseHandler) RefreshStoresAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool, storeIDs []int) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
// func (p *PurchaseHandler) RefreshStoresAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool, storeIDs []int) (hint string, err error) {
|
||||
// return hint, err
|
||||
// }
|
||||
|
||||
// func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
// return hint, err
|
||||
|
||||
@@ -7,29 +7,29 @@ import (
|
||||
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
)
|
||||
|
||||
func TestSyncStoreCategory(t *testing.T) {
|
||||
hint, err := curPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
// func TestSyncStoreCategory(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
func TestSyncLocalStoreCategory(t *testing.T) {
|
||||
hint, err := curPurchaseHandler.SyncLocalStoreCategory(jxcontext.AdminCtx, nil, testShopID, true, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
// func TestSyncLocalStoreCategory(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncLocalStoreCategory(jxcontext.AdminCtx, nil, testShopID, true, nil)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
func TestSyncStoreSkus(t *testing.T) {
|
||||
hint, err := curPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, nil, false, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
// func TestSyncStoreSkus(t *testing.T) {
|
||||
// hint, err := curPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, nil, false, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
func TestDeleteRemoteSkus(t *testing.T) {
|
||||
err := curPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
package wsc
|
||||
|
||||
import (
|
||||
"testing"
|
||||
// func TestSyncLocalStoreCategory(t *testing.T) {
|
||||
// hint, err := new(PurchaseHandler).SyncLocalStoreCategory(jxcontext.AdminCtx, nil, 100077, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
)
|
||||
// func TestSyncStoreCategory(t *testing.T) {
|
||||
// hint, err := new(PurchaseHandler).SyncStoreCategory(jxcontext.AdminCtx, nil, 100077, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
func TestSyncLocalStoreCategory(t *testing.T) {
|
||||
hint, err := new(PurchaseHandler).SyncLocalStoreCategory(jxcontext.AdminCtx, nil, 100077, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
|
||||
func TestSyncStoreCategory(t *testing.T) {
|
||||
hint, err := new(PurchaseHandler).SyncStoreCategory(jxcontext.AdminCtx, nil, 100077, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
|
||||
func TestSyncStoreSkus(t *testing.T) {
|
||||
hint, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, 100077, nil, false, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(hint)
|
||||
}
|
||||
// func TestSyncStoreSkus(t *testing.T) {
|
||||
// hint, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, 100077, nil, false, true)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(hint)
|
||||
// }
|
||||
|
||||
@@ -88,14 +88,14 @@ func (c *SyncController) RefreshAllStoresID() {
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /RefreshAllSkusID [put]
|
||||
func (c *SyncController) RefreshAllSkusID() {
|
||||
c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorIDs, storeIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs)
|
||||
return retVal, "", err
|
||||
})
|
||||
// c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) {
|
||||
// var vendorIDs, storeIDs []int
|
||||
// if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
// return retVal, "", err
|
||||
// }
|
||||
// retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs)
|
||||
// return retVal, "", err
|
||||
// })
|
||||
}
|
||||
|
||||
// @Title 全新初始化商家商品信息
|
||||
|
||||
Reference in New Issue
Block a user