|
|
@@ -39,41 +39,41 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e |
|
|
|
} |
|
|
|
|
|
|
|
session := engine.NewSession() |
|
|
|
|
|
|
|
//4、处理释放 |
|
|
|
settlementQuantityRadio := decimal.NewFromFloat(100) |
|
|
|
settlementQuantityValue := decimal.NewFromInt(int64(settlementQuantity)).Div(settlementQuantityRadio) |
|
|
|
for _, v := range list1 { |
|
|
|
userAmount, _ := decimal.NewFromString(v.Amount) |
|
|
|
settlementQuantityAmount, _ := userAmount.Mul(settlementQuantityValue).Float64() |
|
|
|
if settlementQuantityAmount > 0 { |
|
|
|
//4.2给相应的用户加上个人的绿色积分(可用数量) |
|
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
|
Kind: "add", |
|
|
|
Mid: masterId, |
|
|
|
Title: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergy, |
|
|
|
TransferType: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergyForUserVirtualCoinFlow, |
|
|
|
OrdId: "", |
|
|
|
CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId, |
|
|
|
Uid: v.Uid, |
|
|
|
Amount: settlementQuantityAmount, |
|
|
|
}) |
|
|
|
|
|
|
|
//4.2给相应的用户加上个人的绿色积分(可用数量) |
|
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
|
Kind: "add", |
|
|
|
Mid: masterId, |
|
|
|
Title: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergy, |
|
|
|
TransferType: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergyForUserVirtualCoinFlow, |
|
|
|
OrdId: "", |
|
|
|
CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId, |
|
|
|
Uid: v.Uid, |
|
|
|
Amount: settlementQuantityAmount, |
|
|
|
}) |
|
|
|
|
|
|
|
//4.2给相应的用户减少个人的绿色积分(结算数量) |
|
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
|
Kind: "sub", |
|
|
|
Mid: masterId, |
|
|
|
Title: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergy, |
|
|
|
TransferType: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergyForUserVirtualCoinFlow, |
|
|
|
OrdId: "", |
|
|
|
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, |
|
|
|
Uid: v.Uid, |
|
|
|
Amount: settlementQuantityAmount, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
fmt.Println("err:::::33333", err) |
|
|
|
return err |
|
|
|
//4.2给相应的用户减少个人的绿色积分(结算数量) |
|
|
|
err = DealUserCoin(session, md.DealUserCoinReq{ |
|
|
|
Kind: "sub", |
|
|
|
Mid: masterId, |
|
|
|
Title: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergy, |
|
|
|
TransferType: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergyForUserVirtualCoinFlow, |
|
|
|
OrdId: "", |
|
|
|
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, |
|
|
|
Uid: v.Uid, |
|
|
|
Amount: settlementQuantityAmount, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
fmt.Println("err:::::33333", err) |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|