价格统计优化

This commit is contained in:
苏尹岚
2020-02-10 17:47:40 +08:00
parent a2ffd1610a
commit 4c9028330f

View File

@@ -258,17 +258,18 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
}
dao.Commit(db)
case 3:
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
priceReferSnapshotList, err = dao.GetPriceReferSnapshotNoPage(db, []int{0}, nil, nil, snapshotAt)
for _, v := range priceReferSnapshotList {
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
v := batchItemList[0].(*model.PriceReferSnapshot)
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
if directPrice == 0 {
@@ -278,8 +279,12 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
dao.UpdateEntity(db, v, "JdDirectPrice")
}
}
dao.Commit(db)
return retVal, err
}
dao.Commit(db)
taskParallel := tasksch.NewParallelTask("获取并更新京东指导价格", tasksch.NewParallelConfig(), ctx, taskFunc, priceReferSnapshotList)
tasksch.HandleTask(taskParallel, task, true).Run()
_, err = taskParallel.GetResult(0)
}
return result, err
}