Browse Source

update 一个圈圈

master
DengBiao 10 months ago
parent
commit
14a60bbdc7
2 changed files with 5 additions and 9 deletions
  1. +3
    -3
      rule/one_circles/one_circles_available_green_energy_settlement.go
  2. +2
    -6
      rule/one_circles/one_circles_deal_available_green_energy_points.go

+ 3
- 3
rule/one_circles/one_circles_available_green_energy_settlement.go View File

@@ -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) //绿色能量个数


+ 2
- 6
rule/one_circles/one_circles_deal_available_green_energy_points.go View File

@@ -254,12 +254,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun
chain.StarLevelDividends = oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues //星级分红
chain.DestructionQuantityNums = oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues //销毁数量

originalQuantityNums, _ := decimal.NewFromString(chain.OriginalQuantityNums)
originalFunds := originalQuantityNums.Mul(nowPrice).RoundFloor(8).String()
chain.OriginalFunds = originalFunds //原始资金
marketplaceMerchantNums, _ := decimal.NewFromString(chain.MarketplaceMerchantNums)
marketplaceMerchantFunds := marketplaceMerchantNums.Mul(nowPrice).RoundFloor(8).String()
chain.MarketplaceMerchantFunds = marketplaceMerchantFunds //市商资金
chain.OriginalFunds = oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues //原始资金
chain.MarketplaceMerchantFunds = oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues //市商资金
//更新 `one_circles_green_energy_basic_setting` 表
if chain.NowPrice != nowPriceValue {
chain.NowPrice = nowPriceValue


Loading…
Cancel
Save