From 46ac561698085fa62defca3e983411e36362da2c Mon Sep 17 00:00:00 2001 From: dengbiao Date: Sat, 14 Dec 2024 18:22:33 +0800 Subject: [PATCH] update --- ...gg_energy_platform_revenue_data_consume.go | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/consume/egg_energy_platform_revenue_data_consume.go b/consume/egg_energy_platform_revenue_data_consume.go index 35a3bf3..6b382ea 100644 --- a/consume/egg_energy_platform_revenue_data_consume.go +++ b/consume/egg_energy_platform_revenue_data_consume.go @@ -98,24 +98,32 @@ func handleEggEnergyDealPlatformRevenueDataConsume(msgData []byte) error { if cb != nil { defer cb() // 释放锁 } + + // 4. 计算涨价 + amountValue, _ := decimal.NewFromString(msg.Amount) + planetTotalValue, _ := decimal.NewFromString(eggEnergyCoreData.PlanetTotalValue) + energyTotalNumsValue, _ := decimal.NewFromString(eggEnergyCoreData.NowEnergyTotalNums) + afterPlanetTotalValue := planetTotalValue.Add(amountValue).Truncate(8).String() + afterPrice := (planetTotalValue.Add(amountValue)).Div(energyTotalNumsValue).Truncate(16).String() //涨价后的价格 + // 4. 计算涨价公式 - err3, calcPriceIncreaseFormulaResp := egg_energy.CalcPriceIncreaseFormula(utils2.AnyToString(msg.Amount), eggEnergyCoreData) - if err3 != nil { - _ = session.Rollback() - session.Close() - return err3 - } + //err3, calcPriceIncreaseFormulaResp := egg_energy.CalcPriceIncreaseFormula(utils2.AnyToString(msg.Amount), eggEnergyCoreData) + //if err3 != nil { + // _ = session.Rollback() + // session.Close() + // return err3 + //} // 5. 处理可用能量 dealAvailableEggEnergyCoinReq := md2.DealAvailableEggEnergyCoinReq{ - Amount: calcPriceIncreaseFormulaResp.GetEggEnergyNums, + Amount: msg.Amount, AmountFee: "", - BeforePrice: calcPriceIncreaseFormulaResp.BeforePrice, - AfterPrice: calcPriceIncreaseFormulaResp.AfterPrice, - BeforePlanetTotalValue: calcPriceIncreaseFormulaResp.BeforePlanetTotalValue, - AfterPlanetTotalValue: calcPriceIncreaseFormulaResp.AfterPlanetTotalValue, - BeforeEnergyTotalNums: calcPriceIncreaseFormulaResp.BeforeEnergyTotalNums, - AfterEnergyTotalNums: calcPriceIncreaseFormulaResp.AfterEnergyTotalNums, + BeforePrice: eggEnergyCoreData.NowPrice, + AfterPrice: afterPrice, + BeforePlanetTotalValue: eggEnergyCoreData.PlanetTotalValue, + AfterPlanetTotalValue: afterPlanetTotalValue, + BeforeEnergyTotalNums: eggEnergyCoreData.NowEnergyTotalNums, + AfterEnergyTotalNums: eggEnergyCoreData.NowEnergyTotalNums, } err4 := egg_energy.DealAvailableEggEnergyCoin(session, int(enum.PlatformProfitability), eggEnergyCoreData, dealAvailableEggEnergyCoinReq) if err4 != nil { @@ -136,10 +144,10 @@ func handleEggEnergyDealPlatformRevenueDataConsume(msgData []byte) error { TotalAmount: data.TotalAmount, BalanceAmount: balanceAmount, BalanceTimes: data.BalanceTimes - 1, - BeforePrice: calcPriceIncreaseFormulaResp.BeforePrice, - AfterPrice: calcPriceIncreaseFormulaResp.AfterPrice, - BeforePlanetTotalValue: calcPriceIncreaseFormulaResp.BeforePlanetTotalValue, - AfterPlanetTotalValue: calcPriceIncreaseFormulaResp.AfterPlanetTotalValue, + BeforePrice: eggEnergyCoreData.NowPrice, + AfterPrice: afterPrice, + BeforePlanetTotalValue: eggEnergyCoreData.PlanetTotalValue, + AfterPlanetTotalValue: afterPlanetTotalValue, CreateAt: now.Format("2006-01-02 15:04:05"), UpdateAt: now.Format("2006-01-02 15:04:05"), }