From 23f417c9183a6affc61ab9b297bcf5941d77dce6 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 8 Sep 2022 15:42:12 +0800 Subject: [PATCH] =?UTF-8?q?update=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 | 29 +++++++++++++++++++------- svc/svc_block_star_chain_settlement.go | 4 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/rule/block_star_chain_settlement.go b/rule/block_star_chain_settlement.go index ea990be..a7c46cd 100644 --- a/rule/block_star_chain_settlement.go +++ b/rule/block_star_chain_settlement.go @@ -227,17 +227,23 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, userIds []int, getCoin := amount.Div(sumStaticValue).Mul(publishCoinValue) //得到的区块币 needDestroyContribution := getCoin.Mul(platformGuidePriceForCoinValue) //需销毁贡献值 + coinAmount, err := svc.GetUserCoinAmount(session, mid, chain.Coin2, item.Uid) //获取此时用户的"静态贡献值" + if err != nil { + return err, unassignedTotalCoinValue + } + coinAmountValue, _ := decimal.NewFromString(coinAmount) + //3.1判断静态贡献值是否足够 - if needDestroyContribution.GreaterThan(amount) { + if needDestroyContribution.GreaterThan(coinAmountValue) { //TODO::公式【得到的区块币 = ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】 - tempCoin := (needDestroyContribution.Sub(amount)).Div(platformGuidePriceForCoinValue) + tempCoin := (needDestroyContribution.Sub(coinAmountValue)).Div(platformGuidePriceForCoinValue) getCoin = getCoin.Sub(tempCoin) unassignedTotalCoin.Add(tempCoin) - needDestroyContribution = amount + needDestroyContribution = coinAmountValue } //3.2给相应用户加上分配到的虚拟币 - err := DealUserCoin(session, md.DealUserCoinReq{ + err = DealUserCoin(session, md.DealUserCoinReq{ Kind: "add", Mid: mid, Title: md.StaticAreaDistributionTitleForUserVirtualCoinFlow, @@ -306,17 +312,24 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, userIds []int, amount := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(item.Amount)) //用户贡献值余额 getCoin := amount.Div(sumStaticValue).Mul(publishCoinValue) //得到的区块币 needDestroyContribution := getCoin.Mul(platformGuidePriceForCoinValue) //需销毁贡献值 + + coinAmount, err := svc.GetUserCoinAmount(session, mid, chain.Coin2, item.Uid) //获取此时用户的"静态贡献值" + if err != nil { + return err, unassignedTotalCoinValue + } + coinAmountValue, _ := decimal.NewFromString(coinAmount) + //3.1判断静态贡献值是否足够 - if needDestroyContribution.GreaterThan(amount) { + if needDestroyContribution.GreaterThan(coinAmountValue) { //TODO::公式【得到的区块币 - ((需销毁贡献值 - 用户贡献值余额) / 今日平台区块币指导价)】 - tempCoin := (needDestroyContribution.Sub(amount)).Div(platformGuidePriceForCoinValue) + tempCoin := (needDestroyContribution.Sub(coinAmountValue)).Div(platformGuidePriceForCoinValue) getCoin = getCoin.Sub(tempCoin) unassignedTotalCoin.Add(getCoin) - needDestroyContribution = amount + needDestroyContribution = coinAmountValue } //3.2给相应用户加上分配到的虚拟币 - err := DealUserCoin(session, md.DealUserCoinReq{ + err = DealUserCoin(session, md.DealUserCoinReq{ Kind: "add", Mid: mid, Title: md.DynamicAreaDistributionTitleForUserVirtualCoinFlow, diff --git a/svc/svc_block_star_chain_settlement.go b/svc/svc_block_star_chain_settlement.go index d00fca0..f52a23c 100644 --- a/svc/svc_block_star_chain_settlement.go +++ b/svc/svc_block_star_chain_settlement.go @@ -48,8 +48,8 @@ func SetCacheUserVirtualAmount(session *xorm.Session, masterId, amount string, c } } //_, err := cache.Set(redisKey, int64(utils.StrToFloat64(amount))) - //TODO::默认缓存1小时 (先调整为 1 min) - _, err := cache.SetEx(redisKey, int64(zhios_order_relate_utils.StrToFloat64(amount)), 60) + //TODO::默认缓存1小时 (先调整为 5 min) + _, err := cache.SetEx(redisKey, int64(zhios_order_relate_utils.StrToFloat64(amount)), 60*5) if err != nil { return err }