ソースを参照

add 区块星链

tags/v1.9.6
DengBiao 2年前
コミット
ec0b95240c
3個のファイルの変更106行の追加0行の削除
  1. +3
    -0
      db/model/block_star_chain.go
  2. +5
    -0
      md/block_star_chain.go
  3. +98
    -0
      rule/block_star_chain_settlement.go

+ 3
- 0
db/model/block_star_chain.go ファイルの表示

@@ -26,7 +26,10 @@ type BlockStarChain struct {
PublishCoinDynamicRate string `json:"publish_coin_dynamic_rate" xorm:"not null default 45.00 comment('区块币发行动态占比') DECIMAL(5,2)"`
PublishCoinStaticRate string `json:"publish_coin_static_rate" xorm:"not null default 45.00 comment('区块币发行静态占比') DECIMAL(5,2)"`
PublishCoinOperationCenterRate string `json:"publish_coin_operation_center_rate" xorm:"not null default 3.00 comment('区块币发行运营中心占比') DECIMAL(5,2)"`
OperationCenterForUserLevel int `json:"operation_center_for_user_level" xorm:"not null default 0 comment('运营中心分红对应会员等级') INT(11)"`
PublishCoinOperationOtherRate string `json:"publish_coin_other_rate" xorm:"not null default 7.00 comment('区块币发行其他占比') DECIMAL(5,2)"`
OtherForUserLevel string `json:"other_for_user_level" xorm:"comment('其他分红对应会员等级') TEXT"`
RewardDestroyCoinRate string `json:"reward_destroy_coin_rate" xorm:"not null default 70.00 comment('商家打赏销毁区块币比例') DECIMAL(5,2)"`
RewardSettings string `json:"reward_settings" xorm:"comment('奖励设置') TEXT"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`


+ 5
- 0
md/block_star_chain.go ファイルの表示

@@ -13,14 +13,19 @@ const (
const (
StaticAreaDistributionTitleForUserVirtualCoinFlow = "区块星链-静态区发放"
DynamicAreaDistributionTitleForUserVirtualCoinFlow = "区块星链-动态区发放"
OperationCenterTitleForUserVirtualCoinFlow = "区块星链-运营中心发放"
OtherTitleForUserVirtualCoinFlow = "区块星链-其他发放"
StaticIssueAndDestroyStaticContributionTitleForUserVirtualCoinFlow = "区块星链-静态发放(销毁静态贡献值)"
DynamicIssueAndDestroyStaticContributionTitleForUserVirtualCoinFlow = "区块星链-动态发放(销毁静态贡献值)"
)

const (
StaticAreaDistributionTransferTypeForUserVirtualCoinFlow = 100
DynamicAreaDistributionTransferTypeForUserVirtualCoinFlow = 101
StaticIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 102
DynamicIssueAndDestroyStaticContributionTransferTypeForUserVirtualCoinFlow = 103
OperationCenterTransferTypeForUserVirtualCoinFlow = 104
OtherTransferTypeForUserVirtualCoinFlow = 105
)

const DealUserCoinRequestIdPrefix = "%s:block_star_chain_deal_user_coin:%d:uid:%d"


+ 98
- 0
rule/block_star_chain_settlement.go ファイルの表示

@@ -9,6 +9,7 @@ import (
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"encoding/json"
"errors"
"fmt"
"github.com/shopspring/decimal"
@@ -292,6 +293,103 @@ func statisticsAndDistributeCoinForDynamic(session *xorm.Session, mid string, pu
return
}

/*
统计分配区块币-运营中心
*/
func statisticsAndDistributeCoinForOperationCenter(session *xorm.Session, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) {
publishCoinValue := decimal.NewFromFloat(publishCoin) //运营中心-发行区块币数量
var totalCoin = decimal.NewFromFloat(0)

//1、查询出运营中心等级的所有用户
var userList []*model.User
totalUser, err := session.Table("user").Where("level =?", chain.OperationCenterForUserLevel).FindAndCount(&userList)
if err != nil {
return
}
if totalUser > 0 {
singleValue := publishCoinValue.Div(decimal.NewFromInt(totalUser))
//2、循环处理每个用户的数据(增加虚拟币)
for _, item := range userList {
totalCoin = totalCoin.Add(singleValue)
err := DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: mid,
Title: md.OperationCenterTitleForUserVirtualCoinFlow,
TransferType: md.OperationCenterTransferTypeForUserVirtualCoinFlow,
OrdId: "",
CoinId: chain.Coin1,
Uid: item.Uid,
Amount: zhios_order_relate_utils.StrToFloat64(singleValue.String()),
})
if err != nil {
return
}
}
}

//3、处理未分配完的区块币-运营中心
unassignedTotalCoinValue, _ = publishCoinValue.Sub(totalCoin).Float64()
if unassignedTotalCoinValue > 0 {
err := DealDestroyCoin(session, int(enum.OperationCenterUnallocatedAndDestroy), unassignedTotalCoinValue, enum.OperationCenterUnallocatedAndDestroy.String(), &chain)
if err != nil {
return
}
}
return
}

/*
统计分配区块币-其他
*/
func statisticsAndDistributeCoinForOther(session *xorm.Session, mid string, publishCoin float64, chain model.BlockStarChain) (err error, unassignedTotalCoinValue float64) {
publishCoinValue := decimal.NewFromFloat(publishCoin) //运营中心-发行区块币数量
var totalCoin = decimal.NewFromFloat(0)

var userLevel = make([]string, 0)
err = json.Unmarshal([]byte(chain.OtherForUserLevel), &userLevel)
if err != nil {
return
}
if len(userLevel) > 0 {
//1、查询出运营中心等级的所有用户
var userList []*model.User
totalUser, err := session.Table("user").In("level", userLevel).FindAndCount(&userList)
if err != nil {
return
}
if totalUser > 0 {
singleValue := publishCoinValue.Div(decimal.NewFromInt(totalUser))
//2、循环处理每个用户的数据(增加虚拟币)
for _, item := range userList {
totalCoin = totalCoin.Add(singleValue)
err := DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: mid,
Title: md.OtherTitleForUserVirtualCoinFlow,
TransferType: md.OtherTransferTypeForUserVirtualCoinFlow,
OrdId: "",
CoinId: chain.Coin1,
Uid: item.Uid,
Amount: zhios_order_relate_utils.StrToFloat64(singleValue.String()),
})
if err != nil {
return
}
}
}
}

//3、处理未分配完的区块币-其他
unassignedTotalCoinValue, _ = publishCoinValue.Sub(totalCoin).Float64()
if unassignedTotalCoinValue > 0 {
err := DealDestroyCoin(session, int(enum.OtherUnallocatedAndDestroy), unassignedTotalCoinValue, enum.OtherUnallocatedAndDestroy.String(), &chain)
if err != nil {
return
}
}
return
}

//计算当前每日区块币应发行数量
func calcNowEverydayPublishCoin(session *xorm.Session, chain model.BlockStarChain) error {
now := time.Now()


読み込み中…
キャンセル
保存