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