diff --git a/app/hdl/hdl_points_center.go b/app/hdl/hdl_points_center.go index 37e0e5b..c1fb554 100644 --- a/app/hdl/hdl_points_center.go +++ b/app/hdl/hdl_points_center.go @@ -455,17 +455,6 @@ func ExchangeEnergy(c *gin.Context) { if cb != nil { defer cb() // 释放锁 } - energyAmount, err := decimal.NewFromString(req.EnergyAmount) - if err != nil { - e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) - return - } - nowPrice, err := decimal.NewFromString(eggEnergyCoreData.NowPrice) - if err != nil { - e.OutErr(c, e.ERR_UNMARSHAL, err.Error()) - return - } - amount, _ := energyAmount.Mul(nowPrice).Float64() // 3. 获取用户蛋蛋能量余额 eggEnergyAmount, err := rule.GetUserCoinAmount(session, coinID, user.Id) @@ -481,7 +470,7 @@ func ExchangeEnergy(c *gin.Context) { } // 5. 调用降价公式 - err, calcPriceReductionFormula := egg_energy.CalcPriceReductionFormula(req.EnergyAmount, eggEnergyCoreData) + err, calcPriceReductionFormula := egg_energy.CalcPriceReductionFormula(req.EnergyAmount, eggEnergyCoreData, utils.IntToStr(user.Level), *setting) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return @@ -489,8 +478,8 @@ func ExchangeEnergy(c *gin.Context) { // 6. 更改动态数据 err = egg_energy.DealAvailableEggEnergyCoin(session, int(enum.EggEnergyExchangeAccountBalance), eggEnergyCoreData, md3.DealAvailableEggEnergyCoinReq{ - Amount: calcPriceReductionFormula.GetEggEnergyAmount, - AmountFee: "", + Amount: req.EnergyAmount, + AmountFee: calcPriceReductionFormula.AmountFee, BeforePrice: calcPriceReductionFormula.BeforePrice, AfterPrice: calcPriceReductionFormula.AfterPrice, BeforePlanetTotalValue: calcPriceReductionFormula.BeforePlanetTotalValue, @@ -526,7 +515,7 @@ func ExchangeEnergy(c *gin.Context) { Kind: int(enum.EggEnergyExchangeAccountBalance), Title: enum.EggEnergyExchangeAccountBalance.String(), Uid: user.Id, - Amount: amount, + Amount: utils.StrToFloat64(calcPriceReductionFormula.GetEggEnergyAmount), } err = rule.DealUserWallet(session, dealUserWalletReq) if err != nil { diff --git a/go.mod b/go.mod index 38829c3..3eac54f 100644 --- a/go.mod +++ b/go.mod @@ -32,8 +32,8 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241214095356-fdac2df9537f - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241214095427-b3f9e6ed2446 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241214062221-cde2ce240fa8 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241214075617-9e3855ecf0c0 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible