|
|
@@ -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"), |
|
|
|
} |
|
|
|