|
@@ -84,12 +84,18 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userIds, err := db.UserLevelDescByWeightLow(session) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//4、进行静态区-区块币统计分配 |
|
|
//4、进行静态区-区块币统计分配 |
|
|
var staticAreaCoinNums float64 //静态区分配区块币总数 |
|
|
var staticAreaCoinNums float64 //静态区分配区块币总数 |
|
|
publishCoinStaticRate, _ := decimal.NewFromString(blockStarChain.PublishCoinStaticRate) //区块币发行静态占比 |
|
|
publishCoinStaticRate, _ := decimal.NewFromString(blockStarChain.PublishCoinStaticRate) //区块币发行静态占比 |
|
|
publishCoinStaticRate = publishCoinStaticRate.Div(decimal.NewFromFloat(100)) |
|
|
publishCoinStaticRate = publishCoinStaticRate.Div(decimal.NewFromFloat(100)) |
|
|
staticAreaCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinStaticRate).String()) |
|
|
staticAreaCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinStaticRate).String()) |
|
|
err, destroyCoinForStatic := statisticsAndDistributeCoinForStatic(session, mid, staticAreaCoinNums, *blockStarChain) |
|
|
|
|
|
|
|
|
err, destroyCoinForStatic := statisticsAndDistributeCoinForStatic(session, userIds, mid, staticAreaCoinNums, *blockStarChain) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
_ = session.Rollback() |
|
|
return err |
|
|
return err |
|
@@ -100,7 +106,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) |
|
|
publishCoinDynamicRate, _ := decimal.NewFromString(blockStarChain.PublishCoinDynamicRate) //区块币发行动态占比 |
|
|
publishCoinDynamicRate, _ := decimal.NewFromString(blockStarChain.PublishCoinDynamicRate) //区块币发行动态占比 |
|
|
publishCoinDynamicRate = publishCoinDynamicRate.Div(decimal.NewFromFloat(100)) |
|
|
publishCoinDynamicRate = publishCoinDynamicRate.Div(decimal.NewFromFloat(100)) |
|
|
dynamicAreaCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinDynamicRate).String()) |
|
|
dynamicAreaCoinNums = zhios_order_relate_utils.StrToFloat64(decimal.NewFromFloat(publishCoin).Mul(publishCoinDynamicRate).String()) |
|
|
err, destroyCoinForDynamic := statisticsAndDistributeCoinForDynamic(session, mid, dynamicAreaCoinNums, *blockStarChain) |
|
|
|
|
|
|
|
|
err, destroyCoinForDynamic := statisticsAndDistributeCoinForDynamic(session, userIds, mid, dynamicAreaCoinNums, *blockStarChain) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
_ = session.Rollback() |
|
|
_ = session.Rollback() |
|
|
return err |
|
|
return err |
|
@@ -197,21 +203,21 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) |
|
|
统计分配区块币-静态区 |
|
|
统计分配区块币-静态区 |
|
|
TODO:: 公式【 个人贡献值/全网贡献值x2100枚=每天获取的惠积分 】 |
|
|
TODO:: 公式【 个人贡献值/全网贡献值x2100枚=每天获取的惠积分 】 |
|
|
*/ |
|
|
*/ |
|
|
func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) { |
|
|
|
|
|
|
|
|
func statisticsAndDistributeCoinForStatic(session *xorm.Session, userIds []int, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) { |
|
|
publishCoinValue := decimal.NewFromFloat(publishCoin) //静态区发行区块币数量 |
|
|
publishCoinValue := decimal.NewFromFloat(publishCoin) //静态区发行区块币数量 |
|
|
platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 |
|
|
platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 |
|
|
var unassignedTotalCoin = decimal.NewFromFloat(0) //未分配完的区块币 |
|
|
var unassignedTotalCoin = decimal.NewFromFloat(0) //未分配完的区块币 |
|
|
var userVirtualAmount model.UserVirtualAmount |
|
|
var userVirtualAmount model.UserVirtualAmount |
|
|
var userVirtualAmounts []model.UserVirtualAmount |
|
|
var userVirtualAmounts []model.UserVirtualAmount |
|
|
//1、统计出静态区总贡献值 |
|
|
//1、统计出静态区总贡献值 |
|
|
sumStatic, err := session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).Sum(&userVirtualAmount, "amount") |
|
|
|
|
|
|
|
|
sumStatic, err := session.Table("user_virtual_amount").In("uid", userIds).Where("coin_id =?", chain.Coin2).Sum(&userVirtualAmount, "amount") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err, unassignedTotalCoinValue |
|
|
return err, unassignedTotalCoinValue |
|
|
} |
|
|
} |
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
|
|
|
|
|
|
//2、查询出所有拥有静态贡献值的用户 |
|
|
//2、查询出所有拥有静态贡献值的用户 |
|
|
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts) |
|
|
|
|
|
|
|
|
err = session.Table("user_virtual_amount").In("uid", userIds).Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err, unassignedTotalCoinValue |
|
|
return err, unassignedTotalCoinValue |
|
|
} |
|
|
} |
|
@@ -275,21 +281,22 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub |
|
|
/* |
|
|
/* |
|
|
统计分配区块币-动态区 |
|
|
统计分配区块币-动态区 |
|
|
*/ |
|
|
*/ |
|
|
func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) { |
|
|
|
|
|
|
|
|
func statisticsAndDistributeCoinForDynamic(session *xorm.Session, userIds []int, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) { |
|
|
publishCoinValue := decimal.NewFromFloat(publishCoin) //动态区发行区块币数量 |
|
|
publishCoinValue := decimal.NewFromFloat(publishCoin) //动态区发行区块币数量 |
|
|
platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 |
|
|
platformGuidePriceForCoinValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(chain.PlatformGuidePriceForCoin)) //今日平台区块币指导价 |
|
|
var unassignedTotalCoin = decimal.NewFromFloat(0) //未分配完的区块币 |
|
|
var unassignedTotalCoin = decimal.NewFromFloat(0) //未分配完的区块币 |
|
|
var userVirtualAmount model.UserVirtualAmount |
|
|
var userVirtualAmount model.UserVirtualAmount |
|
|
var userVirtualAmounts []model.UserVirtualAmount |
|
|
var userVirtualAmounts []model.UserVirtualAmount |
|
|
|
|
|
|
|
|
//1、统计出动态区总贡献值 |
|
|
//1、统计出动态区总贡献值 |
|
|
sumStatic, err := session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin3).Sum(&userVirtualAmount, "amount") |
|
|
|
|
|
|
|
|
sumStatic, err := session.Table("user_virtual_amount").In("uid", userIds).Where("coin_id =?", chain.Coin3).Sum(&userVirtualAmount, "amount") |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err, unassignedTotalCoinValue |
|
|
return err, unassignedTotalCoinValue |
|
|
} |
|
|
} |
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
|
|
|
|
|
|
//2、查询出所有拥有静态贡献值的用户 |
|
|
//2、查询出所有拥有静态贡献值的用户 |
|
|
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts) |
|
|
|
|
|
|
|
|
err = session.Table("user_virtual_amount").In("uid", userIds).Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err, unassignedTotalCoinValue |
|
|
return err, unassignedTotalCoinValue |
|
|
} |
|
|
} |
|
|