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