Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

tags/v2.1.7
huangjiajun vor 2 Jahren
Ursprung
Commit
a3a3e11183
3 geänderte Dateien mit 23 neuen und 1 gelöschten Zeilen
  1. +5
    -1
      db/db_block_star_chain.go
  2. +1
    -0
      db/model/block_star_chain.go
  3. +17
    -0
      rule/block_star_chain_settlement.go

+ 5
- 1
db/db_block_star_chain.go Datei anzeigen

@@ -78,9 +78,13 @@ func BlockStarChainUpdate(session *xorm.Session, id interface{}, BlockStarChain
func BlockStarChainGetOneByParams(session *xorm.Session, params map[string]interface{}) (*model.BlockStarChain, error) {
var m model.BlockStarChain
var query = fmt.Sprintf("%s =?", params["key"])
if has, err := session.Where(query, params["value"]).Get(&m); err != nil || has == false {
has, err := session.Where(query, params["value"]).Get(&m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, errors.New("未查询到相应的 block_star_chain 记录")
}
return &m, nil
}



+ 1
- 0
db/model/block_star_chain.go Datei anzeigen

@@ -31,6 +31,7 @@ type BlockStarChain struct {
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"`
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"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
SellLimit string `json:"sell_limit" xorm:"comment('挂卖条件') TEXT"`


+ 17
- 0
rule/block_star_chain_settlement.go Datei anzeigen

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

//1、查找 `block_star_chain` 基础设置
blockStarChain, err := db.BlockStarChainGetOneByParams(session, map[string]interface{}{
@@ -47,6 +48,10 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error)
_ = session.Rollback()
return err
}
if blockStarChain.SettlementDate == today {
_ = session.Rollback()
return errors.New("今日“区块星链”已结算")
}
//initialCoinTotal := zhios_order_relate_utils.StrToFloat64(blockStarChain.InitialCoinTotal) //初始区块币总量
todayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.TodayPublishCoin) //今日区块币发行数量(若为0,则按当前每日区块币发行数量)
nowEverydayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.NowEverydayPublishCoin) //当前每日区块币发行数量
@@ -145,6 +150,18 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error)
return err
}

//7、更新 block_star_chain 中的 settlement_date 字段
blockStarChain.SettlementDate = today
updateAffected, err := db.BlockStarChainUpdate(session, blockStarChain.Id, blockStarChain, "settlement_date")
if err != nil {
_ = session.Rollback()
return err
}
if updateAffected == 0 {
_ = session.Rollback()
return errors.New("更新 block_star_chain 的 settlement_date 记录失败")
}

err = session.Commit()
if err != nil {
_ = session.Rollback()


Laden…
Abbrechen
Speichern