|
|
@@ -23,7 +23,7 @@ func CalcPriceIncreaseFormula(engine *xorm.Engine, userAmountValue string) (err |
|
|
|
userAmount, _ := decimal.NewFromString(userAmountValue) //用户资金 |
|
|
|
nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格 |
|
|
|
originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量 |
|
|
|
originalQuantityFunds := originalQuantityNums.Mul(nowPrice) //原始资金 |
|
|
|
originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金 |
|
|
|
afterPrice := (userAmount.Add(originalQuantityFunds)).Div(originalQuantityNums).Truncate(8) //涨价后的价格 |
|
|
|
|
|
|
|
values = userAmount.Div(afterPrice).Truncate(8).String() //用户得到绿色能量个数 |
|
|
@@ -37,7 +37,7 @@ func NewCalcPriceIncreaseFormula(userAmountValue string, oneCirclesGreenEnergyBa |
|
|
|
userAmount, _ := decimal.NewFromString(userAmountValue) //用户资金 |
|
|
|
nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格 |
|
|
|
originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量 |
|
|
|
originalQuantityFunds := originalQuantityNums.Mul(nowPrice) //原始资金 |
|
|
|
originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金 |
|
|
|
afterPrice := (userAmount.Add(originalQuantityFunds)).Div(originalQuantityNums).Truncate(8) //涨价后的价格 |
|
|
|
|
|
|
|
values = userAmount.Div(afterPrice).Truncate(8).String() //用户得到绿色能量个数 |
|
|
@@ -76,7 +76,7 @@ func CalcPriceReductionFormula(engine *xorm.Engine, userExchangeNumsValue string |
|
|
|
userExchangeNums, _ := decimal.NewFromString(userExchangeNumsValue) //用户兑换绿色能量 |
|
|
|
originalQuantityNums, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalQuantityNums) //原始数量 |
|
|
|
nowPrice, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.NowPrice) //当前价格 |
|
|
|
originalQuantityFunds := originalQuantityNums.Mul(nowPrice) //原始资金 |
|
|
|
originalQuantityFunds, _ := decimal.NewFromString(oneCirclesGreenEnergyBasicSetting.OriginalFunds) //原始资金 |
|
|
|
afterPrice := originalQuantityFunds.Div(userExchangeNums.Add(originalQuantityNums)) //降价后的价格 |
|
|
|
|
|
|
|
greenEnergyValues := userExchangeNums.Mul(afterPrice) //绿色能量个数 |
|
|
|