价格统计优化
This commit is contained in:
@@ -84,16 +84,11 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
||||
}
|
||||
}
|
||||
}()
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*model.PriceReferSnapshot)
|
||||
for _, v := range priceReferSnapshot {
|
||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||
v.SnapshotAt = snapshotAt
|
||||
err = dao.CreateEntity(db, v)
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("生成价格统计", tasksch.NewParallelConfig(), ctx, taskFunc, priceReferSnapshot)
|
||||
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||
_, err = taskParallel.GetResult(0)
|
||||
dao.CreateMultiEntities(db, priceReferSnapshot)
|
||||
dao.Commit(db)
|
||||
}
|
||||
case 1:
|
||||
@@ -210,15 +205,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
||||
}
|
||||
resultMap[k1] = skuNameMap
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
if len(priceReferSnapshotList) > 0 {
|
||||
for _, v := range priceReferSnapshotList {
|
||||
if v.CityCode == 0 {
|
||||
@@ -240,17 +226,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
||||
}
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
case 2:
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
if len(priceReferSnapshotList) > 0 {
|
||||
for _, v := range priceReferSnapshotList {
|
||||
result, _ := dao.GetPriceReferPrice(db, v.CityCode, v.SkuID, snapshotAt)
|
||||
@@ -261,22 +237,12 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
||||
dao.UpdateEntity(db, v, "MidPrice", "MaxPrice", "MinPrice", "AvgPrice")
|
||||
}
|
||||
}
|
||||
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 {
|
||||
for _, appOrg := range apimanager.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD) {
|
||||
directPrice, err := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
||||
if err != nil || directPrice == 0 {
|
||||
directPrice, _ := jd.GetAPI(appOrg).GetJdSkuDirectPrice(v.SkuID)
|
||||
if directPrice == 0 {
|
||||
continue
|
||||
} else {
|
||||
v.JdDirectPrice = int(directPrice)
|
||||
@@ -284,7 +250,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
||||
}
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user