From 61206c54a3470862a122d8bd5a57854de6c285a4 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 29 Jan 2024 22:35:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cles_available_green_energy_points_flow.go | 6 ++- ...ctivity_coin_auto_exchange_green_energy.go | 4 +- ...cles_deal_available_green_energy_points.go | 50 +++++++++++++++---- ...circles_sign_in_green_energy_settlement.go | 2 +- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/db/model/one_circles_available_green_energy_points_flow.go b/db/model/one_circles_available_green_energy_points_flow.go index 08cd5f5..8de7c92 100644 --- a/db/model/one_circles_available_green_energy_points_flow.go +++ b/db/model/one_circles_available_green_energy_points_flow.go @@ -8,7 +8,7 @@ type OneCirclesAvailableGreenEnergyPointsFlow struct { Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` CoinId int `json:"coin_id" xorm:"not null comment('虚拟币id') INT(11)"` Direction int `json:"direction" xorm:"not null default 1 comment('方向:1收入 2支出') TINYINT(255)"` - Kind int `json:"kind" xorm:"not null default 1 comment('种类(1:个人活跃积分兑换 2:结算绿色能量释放 3:签到奖励 4:账户余额兑换 5:绿色能量兑换余额 6:活跃赠送)') TINYINT(1)"` + Kind int `json:"kind" xorm:"not null default 1 comment('种类(1:个人活跃积分兑换 2:结算绿色能量释放 3:签到奖励 4:账户余额兑换 5:绿色能量兑换余额)') TINYINT(1)"` Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(255)"` Amount string `json:"amount" xorm:"not null comment('变更数量') DECIMAL(28,10)"` BeforeEcologicalApplicationValues string `json:"before_ecological_application_values" xorm:"not null default 0.0000000000 comment('变更前-生态应用区块币数量') DECIMAL(28,10)"` @@ -21,8 +21,12 @@ type OneCirclesAvailableGreenEnergyPointsFlow struct { AfterActiveGiveawaysValues string `json:"after_active_giveaways_values" xorm:"not null default 0.0000000000 comment('变更后-活跃赠送区块币数量') DECIMAL(28,10)"` BeforeOriginalQuantityValues string `json:"before_original_quantity_values" xorm:"not null default 0.0000000000 comment('变更前-原始数量区块币数量') DECIMAL(28,10)"` AfterOriginalQuantityValues string `json:"after_original_quantity_values" xorm:"not null default 0.0000000000 comment('变更后-原始数量区块币数量') DECIMAL(28,10)"` + BeforeOriginalQuantityFundValues string `json:"before_original_quantity_fund_values" xorm:"not null default 0.0000000000 comment('变更前-原始资金值') DECIMAL(28,10)"` + AfterOriginalQuantityFundValues string `json:"after_original_quantity_fund_values" xorm:"not null default 0.0000000000 comment('变更后-原始资金值') DECIMAL(28,10)"` BeforeMarketplaceMerchantValues string `json:"before_marketplace_merchant_values" xorm:"not null default 0.0000000000 comment('变更前-市商区块币数量') DECIMAL(28,10)"` AfterMarketplaceMerchantValues string `json:"after_marketplace_merchant_values" xorm:"not null default 0.0000000000 comment('变更后-市商区块币数量') DECIMAL(28,10)"` + BeforeMarketplaceMerchantFundValues string `json:"before_marketplace_merchant_fund_values" xorm:"not null default 0.0000000000 comment('变更前-市商资金值') DECIMAL(28,10)"` + AfterMarketplaceMerchantFundValues string `json:"after_marketplace_merchant_fund_values" xorm:"not null default 0.0000000000 comment('变更后-市商资金值') DECIMAL(28,10)"` BeforeDevelopmentCommitteeValues string `json:"before_development_committee_values" xorm:"not null default 0.0000000000 comment('变更前-发展委员会区块币数量') DECIMAL(28,10)"` AfterDevelopmentCommitteeValues string `json:"after_development_committee_values" xorm:"not null default 0.0000000000 comment('变更后-发展委员会区块币数量') DECIMAL(28,10)"` BeforePublicWelfareAndCharityValues string `json:"before_public_welfare_and_charity_values" xorm:"not null default 0.0000000000 comment('变更前-公益慈善区块币数量') DECIMAL(28,10)"` diff --git a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go index c30c31e..0b65a71 100644 --- a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go +++ b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go @@ -115,7 +115,7 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( } //4.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) + err = DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), 0, enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) if err != nil { _ = session.Rollback() fmt.Println("err:::::44444", err) @@ -164,7 +164,7 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( } //5.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) + err = DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), 0, enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) if err != nil { _ = session.Rollback() fmt.Println("err:::::44444", err) diff --git a/rule/one_circles/one_circles_deal_available_green_energy_points.go b/rule/one_circles/one_circles_deal_available_green_energy_points.go index 8e11676..8afc8a9 100644 --- a/rule/one_circles/one_circles_deal_available_green_energy_points.go +++ b/rule/one_circles/one_circles_deal_available_green_energy_points.go @@ -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 //原始资金 diff --git a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go index 11dcb33..a26196c 100644 --- a/rule/one_circles/one_circles_sign_in_green_energy_settlement.go +++ b/rule/one_circles/one_circles_sign_in_green_energy_settlement.go @@ -112,7 +112,7 @@ func SettlementSignInGreenEnergy(engine *xorm.Engine, masterId string) (err erro //5、减少“活跃赠送” 中的绿色能量 if reduceTotalGreenEnergy > 0 { - err = DealAvailableGreenEnergyCoin(session, int(enum.SignInReward), reduceTotalGreenEnergy, enum.SignInReward.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) + err = DealAvailableGreenEnergyCoin(session, int(enum.SignInReward), reduceTotalGreenEnergy, 0, enum.SignInReward.String(), oneCirclesGreenEnergyBasicSetting, oneCirclesGreenEnergyBasicSetting.NowPrice) if err != nil { _ = session.Rollback() fmt.Println("err:::::55555", err)