|
|
@@ -13,7 +13,7 @@ import ( |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float64, title string, chain *model.OneCirclesGreenEnergyBasicSetting, nowPriceValue string) error { |
|
|
|
func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amountFee float64, title string, chain *model.OneCirclesGreenEnergyBasicSetting, nowPriceValue string) error { |
|
|
|
amountValue := decimal.NewFromFloat(amount) |
|
|
|
now := time.Now() |
|
|
|
var oneCirclesAvailableGreenEnergyPointsFlow model.OneCirclesAvailableGreenEnergyPointsFlow |
|
|
@@ -22,6 +22,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.Title = title |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.Amount = amountValue.RoundFloor(8).String() |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.CreateTime = now |
|
|
|
|
|
|
|
nowPrice, _ := decimal.NewFromString(nowPriceValue) |
|
|
|
switch kind { |
|
|
|
case int(enum.PersonalActivePointRedemption): //个人活跃积分兑换 |
|
|
|
beforeOriginalQuantity, _ := decimal.NewFromString(chain.OriginalQuantityNums) |
|
|
@@ -46,6 +48,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = chain.OriginalFunds |
|
|
|
break |
|
|
|
case int(enum.TeamActivePointRedemption): //团队活跃积分兑换 |
|
|
|
beforeOriginalQuantity, _ := decimal.NewFromString(chain.OriginalQuantityNums) |
|
|
@@ -70,6 +74,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = chain.OriginalFunds |
|
|
|
break |
|
|
|
case int(enum.SettlementOfGreenEnergyRelease): //结算绿色能量释放 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.Direction = 1 |
|
|
@@ -93,6 +99,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = chain.OriginalFunds |
|
|
|
break |
|
|
|
case int(enum.SignInReward): //签到奖励 |
|
|
|
beforeTotalActiveGiveaways, _ := decimal.NewFromString(chain.TotalActiveGiveaways) |
|
|
@@ -117,6 +125,10 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = chain.OriginalFunds |
|
|
|
break |
|
|
|
case int(enum.AccountBalanceExchange): //账户余额兑换 |
|
|
|
beforeOriginalQuantity, _ := decimal.NewFromString(chain.OriginalQuantityNums) |
|
|
@@ -141,6 +153,13 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = chain.StarLevelDividends |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = chain.DestructionQuantityNums |
|
|
|
originalFunds, _ := decimal.NewFromString(chain.OriginalFunds) //原始资金 |
|
|
|
afterOriginalFundValues := originalFunds.Add(nowPrice.Mul(amountValue)).RoundFloor(8).String() |
|
|
|
|
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = afterOriginalFundValues |
|
|
|
break |
|
|
|
case int(enum.GreenEnergyExchangeBalance): //绿色能量兑换余额 |
|
|
|
var destructionSetting *md2.DestructionSettingStruct |
|
|
@@ -148,27 +167,34 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
decimalRate := decimal.NewFromInt(100) //百分比 |
|
|
|
decimalRate := decimal.NewFromInt(100) //百分比 |
|
|
|
amountFeeValue := decimal.NewFromFloat(amountFee) //手续费 |
|
|
|
|
|
|
|
marketplaceMerchantNums, _ := decimal.NewFromString(chain.MarketplaceMerchantNums) |
|
|
|
marketplaceMerchant, _ := decimal.NewFromString(destructionSetting.MarketplaceMerchant) //市商数量百分比 |
|
|
|
afterMarketplaceMerchantValues := marketplaceMerchantNums.Add(amountValue.Mul(marketplaceMerchant.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
afterMarketplaceMerchantValues := marketplaceMerchantNums.Add(amountFeeValue.Mul(marketplaceMerchant.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
|
|
|
|
developmentCommitteeNums, _ := decimal.NewFromString(chain.DevelopmentCommittee) |
|
|
|
developmentCommittee, _ := decimal.NewFromString(destructionSetting.DevelopmentCommittee) //发展委员会百分比 |
|
|
|
afterDevelopmentCommitteeValues := developmentCommitteeNums.Add(amountValue.Mul(developmentCommittee.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
afterDevelopmentCommitteeValues := developmentCommitteeNums.Add(amountFeeValue.Mul(developmentCommittee.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
|
|
|
|
publicWelfareAndCharityNums, _ := decimal.NewFromString(chain.PublicWelfareAndCharity) |
|
|
|
publicWelfareAndCharity, _ := decimal.NewFromString(destructionSetting.PublicWelfareAndCharity) //公益慈善百分比 |
|
|
|
afterPublicWelfareAndCharityValues := publicWelfareAndCharityNums.Add(amountValue.Mul(publicWelfareAndCharity.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
afterPublicWelfareAndCharityValues := publicWelfareAndCharityNums.Add(amountFeeValue.Mul(publicWelfareAndCharity.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
|
|
|
|
starLevelDividendsNums, _ := decimal.NewFromString(chain.StarLevelDividends) |
|
|
|
starLevelDividends, _ := decimal.NewFromString(destructionSetting.StarLevelDividends) //星级分红百分比 |
|
|
|
afterStarLevelDividendsValues := starLevelDividendsNums.Add(amountValue.Mul(starLevelDividends.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
afterStarLevelDividendsValues := starLevelDividendsNums.Add(amountFeeValue.Mul(starLevelDividends.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
|
|
|
|
destructionQuantityNums, _ := decimal.NewFromString(chain.DestructionQuantityNums) |
|
|
|
destructionQuantity, _ := decimal.NewFromString(destructionSetting.DestructionQuantity) //销毁百分比 |
|
|
|
afterDestructionQuantityValues := destructionQuantityNums.Add(amountValue.Mul(destructionQuantity.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
afterDestructionQuantityValues := destructionQuantityNums.Add(amountFeeValue.Mul(destructionQuantity.Div(decimalRate))).RoundFloor(8).String() |
|
|
|
|
|
|
|
originalQuantityNums, _ := decimal.NewFromString(chain.OriginalQuantityNums) //原始数量 |
|
|
|
afterOriginalQuantityValues := originalQuantityNums.Add(amountValue.Sub(amountFeeValue)).RoundFloor(8).String() |
|
|
|
|
|
|
|
originalFunds, _ := decimal.NewFromString(chain.OriginalFunds) //原始资金 |
|
|
|
afterOriginalFundValues := originalFunds.Sub(nowPrice.Mul(amountValue.Sub(amountFeeValue))).RoundFloor(8).String() |
|
|
|
|
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.Direction = 1 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeEcologicalApplicationValues = chain.EcologicalApplication //生态应用 |
|
|
@@ -180,9 +206,10 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeActiveGiveawaysValues = chain.TotalActiveGiveaways //活跃赠送 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterActiveGiveawaysValues = chain.TotalActiveGiveaways |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityValues = chain.OriginalQuantityNums //原始数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityValues = chain.OriginalQuantityNums |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityValues = afterOriginalQuantityValues |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantValues = chain.MarketplaceMerchantNums //市商数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantValues = afterMarketplaceMerchantValues |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantValues = afterMarketplaceMerchantValues |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDevelopmentCommitteeValues = chain.DevelopmentCommittee //发展委员会 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues = afterDevelopmentCommitteeValues |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforePublicWelfareAndCharityValues = chain.PublicWelfareAndCharity //公益慈善 |
|
|
@@ -191,6 +218,11 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues = afterStarLevelDividendsValues |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeDestructionQuantityValues = chain.DestructionQuantityNums //销毁数量 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues = afterDestructionQuantityValues |
|
|
|
|
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds //市商资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterMarketplaceMerchantFundValues = chain.MarketplaceMerchantFunds |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.BeforeOriginalQuantityFundValues = chain.OriginalFunds //原始资金 |
|
|
|
oneCirclesAvailableGreenEnergyPointsFlow.AfterOriginalQuantityFundValues = afterOriginalFundValues |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
@@ -203,10 +235,8 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount float6 |
|
|
|
chain.DevelopmentCommittee = oneCirclesAvailableGreenEnergyPointsFlow.AfterDevelopmentCommitteeValues //发展委员会 |
|
|
|
chain.PublicWelfareAndCharity = oneCirclesAvailableGreenEnergyPointsFlow.AfterPublicWelfareAndCharityValues //公益慈善 |
|
|
|
chain.StarLevelDividends = oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues //星级分红 |
|
|
|
chain.StarLevelDividends = oneCirclesAvailableGreenEnergyPointsFlow.AfterStarLevelDividendsValues //星级分红 |
|
|
|
chain.DestructionQuantityNums = oneCirclesAvailableGreenEnergyPointsFlow.AfterDestructionQuantityValues //销毁数量 |
|
|
|
|
|
|
|
nowPrice, _ := decimal.NewFromString(nowPriceValue) |
|
|
|
originalQuantityNums, _ := decimal.NewFromString(chain.OriginalQuantityNums) |
|
|
|
originalFunds := originalQuantityNums.Mul(nowPrice).RoundFloor(8).String() |
|
|
|
chain.OriginalFunds = originalFunds //原始资金 |
|
|
|