From 05c96e790902fd8b9671c2d68b32b4303a005a43 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 4 Mar 2024 17:55:33 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one_circles_auto_release_green_energy.go | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/rule/one_circles/one_circles_auto_release_green_energy.go b/rule/one_circles/one_circles_auto_release_green_energy.go index d881e92..c5fd018 100644 --- a/rule/one_circles/one_circles_auto_release_green_energy.go +++ b/rule/one_circles/one_circles_auto_release_green_energy.go @@ -48,21 +48,12 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e //2、当前 "可用"绿色能量可以兑换的用户数据 var list1 []model.UserVirtualAmount - err = engine.Where("coin_id = ?", oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId).And("amount >=?", 0).Find(&list1) + err = engine.Where("coin_id = ?", oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId).And("amount > ?", 0).Find(&list1) if err != nil { fmt.Println("err:::::1111", err) return } - session := engine.NewSession() - defer func() { - session.Close() - if err := recover(); err != nil { - _ = zhios_order_relate_logx.Error(err) - } - }() - session.Begin() - //4、处理释放 settlementQuantityRadio := decimal.NewFromFloat(100) settlementQuantityValue := decimal.NewFromInt(int64(settlementQuantity)).Div(settlementQuantityRadio) @@ -70,6 +61,15 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e userAmount, _ := decimal.NewFromString(v.Amount) settlementQuantityAmount, _ := userAmount.Mul(settlementQuantityValue).Float64() if settlementQuantityAmount > 0 { + session := engine.NewSession() + defer func() { + session.Close() + if err := recover(); err != nil { + _ = zhios_order_relate_logx.Error(err) + } + }() + session.Begin() + //4.2给相应的用户加上个人的绿色积分(可用数量) err = DealUserCoin(session, md.DealUserCoinReq{ Kind: "add", @@ -96,15 +96,16 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e if err != nil { _ = session.Rollback() fmt.Println("err:::::33333", err) - return err + continue + } + + err = session.Commit() + if err != nil { + _ = session.Rollback() + continue } } } - err = session.Commit() - if err != nil { - _ = session.Rollback() - return errors.New("事务提交失败") - } return }