|
@@ -48,21 +48,12 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e |
|
|
|
|
|
|
|
|
//2、当前 "可用"绿色能量可以兑换的用户数据 |
|
|
//2、当前 "可用"绿色能量可以兑换的用户数据 |
|
|
var list1 []model.UserVirtualAmount |
|
|
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 { |
|
|
if err != nil { |
|
|
fmt.Println("err:::::1111", err) |
|
|
fmt.Println("err:::::1111", err) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
session := engine.NewSession() |
|
|
|
|
|
defer func() { |
|
|
|
|
|
session.Close() |
|
|
|
|
|
if err := recover(); err != nil { |
|
|
|
|
|
_ = zhios_order_relate_logx.Error(err) |
|
|
|
|
|
} |
|
|
|
|
|
}() |
|
|
|
|
|
session.Begin() |
|
|
|
|
|
|
|
|
|
|
|
//4、处理释放 |
|
|
//4、处理释放 |
|
|
settlementQuantityRadio := decimal.NewFromFloat(100) |
|
|
settlementQuantityRadio := decimal.NewFromFloat(100) |
|
|
settlementQuantityValue := decimal.NewFromInt(int64(settlementQuantity)).Div(settlementQuantityRadio) |
|
|
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) |
|
|
userAmount, _ := decimal.NewFromString(v.Amount) |
|
|
settlementQuantityAmount, _ := userAmount.Mul(settlementQuantityValue).Float64() |
|
|
settlementQuantityAmount, _ := userAmount.Mul(settlementQuantityValue).Float64() |
|
|
if settlementQuantityAmount > 0 { |
|
|
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给相应的用户加上个人的绿色积分(可用数量) |
|
|
//4.2给相应的用户加上个人的绿色积分(可用数量) |
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
Kind: "add", |
|
|
Kind: "add", |
|
@@ -96,15 +96,16 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
_ = session.Rollback() |
|
|
fmt.Println("err:::::33333", err) |
|
|
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 |
|
|
return |
|
|
} |
|
|
} |