From a2ffd1610a7e3438b58cdfe4756627700033cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 10 Feb 2020 10:04:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E7=BB=9F=E8=AE=A1=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 8ed465825..3df659e26 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -205,6 +205,15 @@ 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 { @@ -226,7 +235,17 @@ 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) @@ -237,7 +256,17 @@ 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) { @@ -250,6 +279,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn } } } + dao.Commit(db) } return result, err }