Browse Source

update 区块星链

tags/v3.0.9
DengBiao 2 years ago
parent
commit
23f417c918
2 changed files with 23 additions and 10 deletions
  1. +21
    -8
      rule/block_star_chain_settlement.go
  2. +2
    -2
      svc/svc_block_star_chain_settlement.go

+ 21
- 8
rule/block_star_chain_settlement.go View File

@@ -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,


+ 2
- 2
svc/svc_block_star_chain_settlement.go View File

@@ -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
}


Loading…
Cancel
Save