- 去掉partner.PruneMissingStoreSkus
This commit is contained in:
@@ -529,14 +529,13 @@ func (v *VendorSync) PruneMissingStoreSkus(ctx *jxcontext.Context, vendorIDs []i
|
|||||||
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), 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) {
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
storeID := storeMap.StoreID
|
_, err = PruneMissingStoreSkus(ctx, task, loopMapInfo.VendorID, storeMap.StoreID, storeMap.VendorStoreID, false, isContinueWhenError)
|
||||||
_, err = handler.PruneMissingStoreSkus(ctx, task, storeID, false, isContinueWhenError)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}, loopMapInfo.StoreMapList)
|
}, loopMapInfo.StoreMapList)
|
||||||
t.AddChild(loopStoreTask).Run()
|
t.AddChild(loopStoreTask).Run()
|
||||||
_, err = loopStoreTask.GetResult(0)
|
_, err = loopStoreTask.GetResult(0)
|
||||||
} else {
|
} else {
|
||||||
_, err = handler.PruneMissingStoreSkus(ctx, t, loopMapInfo.StoreMapList[0].StoreID, false, isContinueWhenError)
|
_, err = PruneMissingStoreSkus(ctx, t, loopMapInfo.VendorID, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, false, isContinueWhenError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||||
|
|||||||
@@ -263,8 +263,6 @@ type ISingleStoreHandler interface {
|
|||||||
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)
|
||||||
|
|
||||||
PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateWaybillPolicy func(refDeliveryFee, refAddFee, deliveryFee int64) (errStr string)
|
type CreateWaybillPolicy func(refDeliveryFee, refAddFee, deliveryFee int64) (errStr string)
|
||||||
|
|||||||
@@ -184,45 +184,45 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
|||||||
return rootTask.ID, err
|
return rootTask.ID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo 往上提
|
// // todo 往上提
|
||||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
// func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
// localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return "", err
|
// return "", err
|
||||||
}
|
// }
|
||||||
localSkuMap := make(map[int]*dao.StoreSkuSyncInfo)
|
// localSkuMap := make(map[int]*dao.StoreSkuSyncInfo)
|
||||||
for _, v := range localSkuList {
|
// for _, v := range localSkuList {
|
||||||
localSkuMap[v.SkuID] = v
|
// localSkuMap[v.SkuID] = v
|
||||||
}
|
// }
|
||||||
var vendorSkuID2Delete []string
|
// var vendorSkuID2Delete []string
|
||||||
task := tasksch.NewSeqTask("ebai PruneMissingStoreSkus", ctx,
|
// task := tasksch.NewSeqTask("ebai PruneMissingStoreSkus", 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) {
|
||||||
switch step {
|
// switch step {
|
||||||
case 0:
|
// case 0:
|
||||||
remoteSkuList, err2 := p.GetAllRemoteSkus(ctx, storeID, parentTask)
|
// remoteSkuList, err2 := p.GetAllRemoteSkus(ctx, storeID, parentTask)
|
||||||
if err = err2; err == nil {
|
// if err = err2; err == nil {
|
||||||
for _, v := range remoteSkuList {
|
// for _, v := range remoteSkuList {
|
||||||
if localSkuMap[int(utils.Str2Int64WithDefault(v.CustomSkuID, 0))] == nil {
|
// if localSkuMap[int(utils.Str2Int64WithDefault(v.CustomSkuID, 0))] == nil {
|
||||||
vendorSkuID2Delete = append(vendorSkuID2Delete, utils.Int64ToStr(v.SkuID))
|
// vendorSkuID2Delete = append(vendorSkuID2Delete, utils.Int64ToStr(v.SkuID))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
case 1:
|
// case 1:
|
||||||
if len(vendorSkuID2Delete) > 0 {
|
// if len(vendorSkuID2Delete) > 0 {
|
||||||
err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
// err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, 2)
|
// }, 2)
|
||||||
tasksch.HandleTask(task, parentTask, true).Run()
|
// tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
if isAsync {
|
// if isAsync {
|
||||||
hint = task.GetID()
|
// hint = task.GetID()
|
||||||
} else {
|
// } else {
|
||||||
_, err = task.GetResult(0)
|
// _, err = task.GetResult(0)
|
||||||
}
|
// }
|
||||||
return hint, err
|
// return hint, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
|
|||||||
@@ -29,7 +29,3 @@ func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTa
|
|||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
||||||
return storeSkuList, err
|
return storeSkuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
|
||||||
return hint, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -526,45 +526,45 @@ func (p *PurchaseHandler) DeleteRemoteCategories(ctx *jxcontext.Context, parentT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo 往上提
|
// todo 往上提
|
||||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
// func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
// localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return "", err
|
// return "", err
|
||||||
}
|
// }
|
||||||
localSkuMap := make(map[string]*dao.StoreSkuSyncInfo)
|
// localSkuMap := make(map[string]*dao.StoreSkuSyncInfo)
|
||||||
for _, v := range localSkuList {
|
// for _, v := range localSkuList {
|
||||||
localSkuMap[utils.Int2Str(v.SkuID)] = v
|
// localSkuMap[utils.Int2Str(v.SkuID)] = v
|
||||||
}
|
// }
|
||||||
var vendorSkuID2Delete []string
|
// var vendorSkuID2Delete []string
|
||||||
task := tasksch.NewSeqTask("mtwm PruneMissingStoreSkus", ctx,
|
// task := tasksch.NewSeqTask("mtwm PruneMissingStoreSkus", 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) {
|
||||||
switch step {
|
// switch step {
|
||||||
case 0:
|
// case 0:
|
||||||
remoteSkuList, err2 := p.GetAllRemoteSkus(storeID)
|
// remoteSkuList, err2 := p.GetAllRemoteSkus(storeID)
|
||||||
if err = err2; err == nil {
|
// if err = err2; err == nil {
|
||||||
for _, v := range remoteSkuList {
|
// for _, v := range remoteSkuList {
|
||||||
skuIDStr := v.AppFoodCode
|
// skuIDStr := v.AppFoodCode
|
||||||
if localSkuMap[skuIDStr] == nil {
|
// if localSkuMap[skuIDStr] == nil {
|
||||||
vendorSkuID2Delete = append(vendorSkuID2Delete, skuIDStr)
|
// vendorSkuID2Delete = append(vendorSkuID2Delete, skuIDStr)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
case 1:
|
// case 1:
|
||||||
if len(vendorSkuID2Delete) > 0 {
|
// if len(vendorSkuID2Delete) > 0 {
|
||||||
err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
// err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, 2)
|
// }, 2)
|
||||||
tasksch.HandleTask(task, parentTask, true).Run()
|
// tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
if isAsync {
|
// if isAsync {
|
||||||
hint = task.GetID()
|
// hint = task.GetID()
|
||||||
} else {
|
// } else {
|
||||||
_, err = task.GetResult(0)
|
// _, err = task.GetResult(0)
|
||||||
}
|
// }
|
||||||
return hint, err
|
// return hint, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
|
|||||||
@@ -341,7 +341,3 @@ func composeFakeDelName(name string) string {
|
|||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
||||||
return storeSkuList, err
|
return storeSkuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
|
||||||
return hint, err
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user