From 6bad4cacdb44125d28a548c2b4d0eaaa21c022cb Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 16 Nov 2022 20:52:05 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=BB=BF=E8=89=B2=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/block_green_chain_settlement.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rule/block_green_chain_settlement.go b/rule/block_green_chain_settlement.go index 0f60e8b..1d21b8b 100644 --- a/rule/block_green_chain_settlement.go +++ b/rule/block_green_chain_settlement.go @@ -144,12 +144,11 @@ func DailySettlementBlockGreenChain(engine *xorm.Engine, mid string, isTask bool } //5、进行空投区-区块币统计分配 - destroyCoinForAirdrop := 3522.00 - //err, destroyCoinForAirdrop := statisticsAndDistributeCoinForAirdrop(session, mid, airdropAreaCoinNums, blockGreenChain) - //if err != nil { - // _ = session.Rollback() - // return err - //} + err, destroyCoinForAirdrop := statisticsAndDistributeCoinForAirdrop(session, mid, airdropAreaCoinNums, blockGreenChain) + if err != nil { + _ = session.Rollback() + return err + } //6、插入 block_star_chain_settlement_records 记录 var blockGreenChainSettlementRecords = model.BlockGreenChainSettlementRecords{ @@ -226,9 +225,9 @@ func DailySettlementBlockGreenChain(engine *xorm.Engine, mid string, isTask bool TODO:: 公式【 个人贡献值/全网贡献值x2100枚=每天获取的绿色积分 】 */ func statisticsAndDistributeCoinForConsume(session *xorm.Session, userIds []int, mid string, publishCoin float64, chain *model.BlockGreenChain) (err error, unassignedTotalCoinValue float64) { - publishCoinValue := decimal.NewFromFloat(publishCoin) //消费区发行区块币数量 - platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 - var unassignedTotalCoin = decimal.NewFromFloat(0) //分配的区块币 + publishCoinValue := decimal.NewFromFloat(publishCoin) //消费区发行区块币数量 + //platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 + var unassignedTotalCoin = decimal.NewFromFloat(0) //分配的区块币 var userVirtualAmount model.UserVirtualAmount var userVirtualAmounts []model.UserVirtualAmount //1、统计出消费区的总贡献值 @@ -247,7 +246,8 @@ func statisticsAndDistributeCoinForConsume(session *xorm.Session, userIds []int, for _, item := range userVirtualAmounts { amount := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(item.Amount)) //用户贡献值余额 getCoin := amount.Div(sumStaticValue).Mul(publishCoinValue) //得到的区块币 - needDestroyContribution := getCoin.Mul(platformGuidePriceForCoinValue) //需销毁贡献值 + //needDestroyContribution := getCoin.Mul(platformGuidePriceForCoinValue) //需销毁贡献值 + needDestroyContribution := amount //需销毁贡献值 coinAmount, err := svc.GetUserCoinAmount(session, mid, chain.Coin2, item.Uid) //获取此时用户的"贡献值" if err != nil { @@ -257,9 +257,9 @@ func statisticsAndDistributeCoinForConsume(session *xorm.Session, userIds []int, //3.1判断静态贡献值是否足够 if needDestroyContribution.GreaterThan(coinAmountValue) { - //TODO::公式【得到的区块币 = ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】 - tempCoin := (needDestroyContribution.Sub(coinAmountValue)).Div(platformGuidePriceForCoinValue) - getCoin = getCoin.Sub(tempCoin) + ////TODO::公式【得到的区块币 = ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】 + //tempCoin := (needDestroyContribution.Sub(coinAmountValue)).Div(platformGuidePriceForCoinValue) + //getCoin = getCoin.Sub(tempCoin) needDestroyContribution = coinAmountValue } unassignedTotalCoin = unassignedTotalCoin.Add(getCoin) @@ -325,7 +325,7 @@ func statisticsAndDistributeCoinForAirdrop(session *xorm.Session, mid string, pu for _, item := range userList { var singleValue = decimal.NewFromFloat(0) - if item.AirdropDate != "0000-00" { + if item.AirdropDate != "0000-00-00" { startAt, err := time.ParseInLocation("2006-01-02", chain.StartAt, time.Local) //起始时间 if err != nil { return err, unassignedTotalCoinValue