From f5c58ca2eb32260658fbcda3cbcb98444a15973d Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 30 Aug 2022 22:22:35 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=8C=BA=E5=9D=97=E6=98=9F=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/block_star_chain_settlement.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rule/block_star_chain_settlement.go b/rule/block_star_chain_settlement.go index 4e73f0d..ca352e5 100644 --- a/rule/block_star_chain_settlement.go +++ b/rule/block_star_chain_settlement.go @@ -45,7 +45,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) }) if err != nil { _ = session.Rollback() - return + return err } //initialCoinTotal := zhios_order_relate_utils.StrToFloat64(blockStarChain.InitialCoinTotal) //初始区块币总量 todayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.TodayPublishCoin) //今日区块币发行数量(若为0,则按当前每日区块币发行数量) @@ -68,7 +68,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) err = dealIssueCoin(session, int(enum.SystemDestroy), publishCoin, enum.SystemTimingIssue.String(), blockStarChain) if err != nil { _ = session.Rollback() - return + return err } //4、进行静态区-区块币统计分配 @@ -79,7 +79,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) err, destroyCoinForStatic := statisticsAndDistributeCoinForStatic(session, mid, staticAreaCoinNums, *blockStarChain) if err != nil { _ = session.Rollback() - return + return err } //5、进行动态区-区块币统计分配 @@ -90,7 +90,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) err, destroyCoinForDynamic := statisticsAndDistributeCoinForDynamic(session, mid, dynamicAreaCoinNums, *blockStarChain) if err != nil { _ = session.Rollback() - return + return err } //6、进行运营中心-区块币统计 TODO::未完成分配 @@ -98,12 +98,22 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) publishCoinOperationCenterRate, _ := decimal.NewFromString(blockStarChain.PublishCoinOperationCenterRate) //区块币发行动态占比 publishCoinOperationCenterRate = publishCoinOperationCenterRate.Div(decimal.NewFromFloat(100)) operationCenterCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinOperationCenterRate).String()) + err, destroyCoinForOperationCenter := statisticsAndDistributeCoinForOperationCenter(session, mid, operationCenterCoinNums, *blockStarChain) + if err != nil { + _ = session.Rollback() + return err + } //7、进行其他-区块币统计 TODO::未完成分配 var otherCoinNums float64 //动态区分配区块币总数 publishCoinOperationOtherRate, _ := decimal.NewFromString(blockStarChain.PublishCoinOperationOtherRate) //区块币发行动态占比 publishCoinOperationOtherRate = publishCoinOperationOtherRate.Div(decimal.NewFromFloat(100)) otherCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinOperationOtherRate).String()) + err, destroyCoinForOther := statisticsAndDistributeCoinForOther(session, mid, otherCoinNums, *blockStarChain) + if err != nil { + _ = session.Rollback() + return err + } //8、插入 block_star_chain_settlement_records 记录 var blockStarChainSettlementRecords = model.BlockStarChainSettlementRecords{ @@ -115,9 +125,9 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) TodayPublishCoinForDynamic: zhios_order_relate_utils.Float64ToStr(dynamicAreaCoinNums), TodayDestroyCoinForDynamic: zhios_order_relate_utils.Float64ToStr(destroyCoinForDynamic), TodayPublishCoinForOperationCenter: zhios_order_relate_utils.Float64ToStr(operationCenterCoinNums), - TodayDestroyCoinForOperationCenter: "", + TodayDestroyCoinForOperationCenter: zhios_order_relate_utils.Float64ToStr(destroyCoinForOperationCenter), TodayPublishCoinForOther: zhios_order_relate_utils.Float64ToStr(otherCoinNums), - TodayDestroyCoinForOther: "", + TodayDestroyCoinForOther: zhios_order_relate_utils.Float64ToStr(destroyCoinForOther), Date: now.Format("2006-01"), CreateAt: now, UpdateAt: now, @@ -125,14 +135,14 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) _, err = db.BlockStarChainSettlementRecordsInsert(session, &blockStarChainSettlementRecords) if err != nil { _ = session.Rollback() - return + return err } //6、计算当前每日区块币应发行数量 err = calcNowEverydayPublishCoin(session, *blockStarChain) if err != nil { _ = session.Rollback() - return + return err } return nil }