|
|
@@ -59,7 +59,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) |
|
|
|
err := DealDestroyCoin(session, int(enum.SystemDestroy), zhios_order_relate_utils.StrToFloat64(destroyCoinForSystem), enum.SystemDestroy.String(), blockStarChain) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return |
|
|
|
return err |
|
|
|
} |
|
|
|
publishCoin = nowEverydayPublishCoin |
|
|
|
} |
|
|
@@ -160,14 +160,14 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub |
|
|
|
//1、统计出静态区总贡献值 |
|
|
|
sumStatic, err := session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).Sum(&userVirtualAmount, "amount") |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
|
|
|
|
|
//2、查询出所有拥有静态贡献值的用户 |
|
|
|
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin2).And("amount > 0").Find(&userVirtualAmounts) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
for _, item := range userVirtualAmounts { |
|
|
@@ -195,7 +195,7 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
//3.3给相应用户扣除 "静态发放(销毁静态贡献值)" |
|
|
@@ -210,7 +210,7 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -219,10 +219,10 @@ func statisticsAndDistributeCoinForStatic(session *xorm.Session, mid string, pub |
|
|
|
if unassignedTotalCoinValue > 0 { |
|
|
|
err := DealDestroyCoin(session, int(enum.StaticUnallocatedAndDestroy), unassignedTotalCoinValue, enum.StaticUnallocatedAndDestroy.String(), &chain) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return nil, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@@ -237,14 +237,14 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu |
|
|
|
//1、统计出动态区总贡献值 |
|
|
|
sumStatic, err := session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin3).Sum(&userVirtualAmount, "amount") |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
sumStaticValue := decimal.NewFromFloat(sumStatic) |
|
|
|
|
|
|
|
//2、查询出所有拥有动态贡献值的用户 |
|
|
|
err = session.Table("user_virtual_amount").Where("coin_id =?", chain.Coin3).And("amount > 0").Find(&userVirtualAmounts) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
//3、循环处理每个用户的数据(增加虚拟币,扣除静态贡献值) |
|
|
@@ -273,7 +273,7 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
//3.3给相应用户扣除 "动态发放(销毁静态贡献值)" |
|
|
@@ -288,7 +288,7 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(getCoin.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -297,10 +297,10 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu |
|
|
|
if unassignedTotalCoinValue > 0 { |
|
|
|
err := DealDestroyCoin(session, int(enum.DynamicallyUnallocatedAndDestroy), unassignedTotalCoinValue, enum.DynamicallyUnallocatedAndDestroy.String(), &chain) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return nil, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@@ -314,7 +314,7 @@ func statisticsAndDistributeCoinForOperationCenter(session *xorm.Session, mid st |
|
|
|
var userList []*model.User |
|
|
|
totalUser, err := session.Table("user").Where("level =?", chain.OperationCenterForUserLevel).FindAndCount(&userList) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
if totalUser > 0 { |
|
|
|
singleValue := publishCoinValue.Div(decimal.NewFromInt(totalUser)) |
|
|
@@ -332,7 +332,7 @@ func statisticsAndDistributeCoinForOperationCenter(session *xorm.Session, mid st |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(singleValue.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -342,10 +342,10 @@ func statisticsAndDistributeCoinForOperationCenter(session *xorm.Session, mid st |
|
|
|
if unassignedTotalCoinValue > 0 { |
|
|
|
err := DealDestroyCoin(session, int(enum.OperationCenterUnallocatedAndDestroy), unassignedTotalCoinValue, enum.OperationCenterUnallocatedAndDestroy.String(), &chain) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return nil, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
@@ -358,14 +358,14 @@ func statisticsAndDistributeCoinForOther(session *xorm.Session, mid string, publ |
|
|
|
var userLevel = make([]string, 0) |
|
|
|
err = json.Unmarshal([]byte(chain.OtherForUserLevel), &userLevel) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
if len(userLevel) > 0 { |
|
|
|
//1、查询出运营中心等级的所有用户 |
|
|
|
var userList []*model.User |
|
|
|
totalUser, err := session.Table("user").In("level", userLevel).FindAndCount(&userList) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
if totalUser > 0 { |
|
|
|
singleValue := publishCoinValue.Div(decimal.NewFromInt(totalUser)) |
|
|
@@ -383,7 +383,7 @@ func statisticsAndDistributeCoinForOther(session *xorm.Session, mid string, publ |
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(singleValue.String()), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -394,10 +394,10 @@ func statisticsAndDistributeCoinForOther(session *xorm.Session, mid string, publ |
|
|
|
if unassignedTotalCoinValue > 0 { |
|
|
|
err := DealDestroyCoin(session, int(enum.OtherUnallocatedAndDestroy), unassignedTotalCoinValue, enum.OtherUnallocatedAndDestroy.String(), &chain) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return nil, unassignedTotalCoinValue |
|
|
|
} |
|
|
|
|
|
|
|
//计算当前每日区块币应发行数量 |
|
|
@@ -615,7 +615,7 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) { |
|
|
|
now := time.Now() |
|
|
|
coinAmount, err := svc.GetUserCoinAmount(session, req.Mid, req.CoinId, req.Uid) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return err |
|
|
|
} |
|
|
|
coinAmountValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(coinAmount)) |
|
|
|
amountValue := decimal.NewFromFloat(req.Amount) |
|
|
@@ -636,7 +636,7 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) { |
|
|
|
userVirtualCoinFlow.AfterAmout = coinAmountValue.Sub(amountValue).String() |
|
|
|
} else { |
|
|
|
err = errors.New("错误的kind类型") |
|
|
|
return |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
//3、插入 `user_virtual_coin_flow` 记录 |
|
|
|