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