Bläddra i källkod

add 区块星链

tags/v2.1.8
DengBiao 2 år sedan
förälder
incheckning
7d7dd2a043
3 ändrade filer med 41 tillägg och 1 borttagningar
  1. +1
    -0
      db/model/block_star_chain.go
  2. +5
    -0
      md/block_star_chain.go
  3. +35
    -1
      rule/block_star_chain_settlement.go

+ 1
- 0
db/model/block_star_chain.go Visa fil

@@ -30,6 +30,7 @@ type BlockStarChain struct {
PublishCoinOtherRate 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)"`
LotteryDrawDestroyCoinRate string `json:"lottery_draw_destroy_coin_rate" xorm:"not null default 70.00 comment('拼团抽奖销毁区块币比例') DECIMAL(5,2)"`
RewardSettings string `json:"reward_settings" xorm:"comment('奖励设置') TEXT"`
SettlementDate string `json:"settlement_date" xorm:"not null default '0000-00' comment('结算日期') CHAR(50)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`


+ 5
- 0
md/block_star_chain.go Visa fil

@@ -64,3 +64,8 @@ type DealUserCoinReq struct {
Uid int `json:"uid"`
Amount float64 `json:"amount"`
}

type DealLotteryDrawReq struct {
Uid int `json:"uid"`
Amount string `json:"amount"`
}

+ 35
- 1
rule/block_star_chain_settlement.go Visa fil

@@ -38,7 +38,10 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error)
session.Begin()
now := time.Now()
today := now.Format("2006-01-02")

if now.Hour() > 8 || now.Hour() < 1 {
//TODO::只在凌晨一点 ~ 凌晨 8 点运行
return errors.New("非运行时间")
}
//1、查找 `block_star_chain` 基础设置
blockStarChain, err := db.BlockStarChainGetOneByParams(session, map[string]interface{}{
"key": "is_use",
@@ -677,3 +680,34 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) {

return nil
}

// DealLotteryDraw 处理抽奖
func DealLotteryDraw(session *xorm.Session, req md.DealLotteryDrawReq) (err error) {
defer func() {
session.Close()
if err := recover(); err != nil {
zhios_order_relate_logx.Error(err)
}
}()
session.Begin()
//1、查找 `block_star_chain` 基础设置
blockStarChain, err := db.BlockStarChainGetOneByParams(session, map[string]interface{}{
"key": "is_use",
"value": 1,
})
if err != nil {
_ = session.Rollback()
return err
}
rewardValue, _ := decimal.NewFromString(req.Amount)
rewardValue = rewardValue.Mul(decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(blockStarChain.LotteryDrawDestroyCoinRate) / 100))
platformGuidePriceForCoin, _ := decimal.NewFromString(blockStarChain.PlatformGuidePriceForCoin)
needDestroyCoin := rewardValue.Div(platformGuidePriceForCoin) //须销毁的米豆
systemDestroyCoinValue, _ := needDestroyCoin.Float64() //系统销毁 区块币值
err = DealDestroyCoin(session, int(enum.GroupLotteryAndDestroy), systemDestroyCoinValue, enum.GroupLotteryAndDestroy.String(), blockStarChain)
if err != nil {
_ = session.Rollback()
return err
}
return nil
}

Laddar…
Avbryt
Spara