价格统计优化

This commit is contained in:
苏尹岚
2020-02-10 10:04:50 +08:00
parent 7338ca0999
commit a2ffd1610a

View File

@@ -205,6 +205,15 @@ 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 {
@@ -226,7 +235,17 @@ 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)
@@ -237,7 +256,17 @@ 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) {
@@ -250,6 +279,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
} }
} }
} }
dao.Commit(db)
} }
return result, err return result, err
} }