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 }