- refactor jd RefreshAllSkusID

This commit is contained in:
gazebo
2018-10-31 12:54:37 +08:00
parent 0e09f42468
commit bbccf09d02
3 changed files with 13 additions and 12 deletions

View File

@@ -195,7 +195,7 @@ func (p *PurchaseHandler) GetAllStoresFromRemote() ([]*model.Store, error) {
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
globals.SugarLogger.Debugf("jd RefreshAllStoresID")
const stepCount = 3
var stores []*tJdStoreInfo
db := dao.GetDB()
rootTask := tasksch.NewSeqTask("jd RefreshAllStoresID", ctx.GetUserName(), func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
@@ -209,7 +209,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
`, utils.DefaultTimeValue, model.VendorIDJD, utils.DefaultTimeValue)
default:
taskName := "jd RefreshAllStoresID update outSystemId"
if step == 1 {
if step != stepCount-1 {
taskName = "jd RefreshAllStoresID update to uuid"
}
task1 := tasksch.NewParallelTask(taskName, nil, ctx.GetUserName(), func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
@@ -217,7 +217,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
storeParams := map[string]interface{}{
"outSystemId": utils.Int2Str(int(store.ID)),
}
if step == 1 {
if step != stepCount-1 {
storeParams["outSystemId"] = utils.GetUUID()
}
if true { //globals.EnableStoreWrite {
@@ -229,7 +229,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
_, err = task1.GetResult(0)
}
return nil, err
}, 3)
}, stepCount)
ctx.SetTaskOrAddChild(rootTask, parentTask)
rootTask.Run()