@@ -78,9 +78,13 @@ func BlockStarChainUpdate(session *xorm.Session, id interface{}, BlockStarChain | |||||
func BlockStarChainGetOneByParams(session *xorm.Session, params map[string]interface{}) (*model.BlockStarChain, error) { | func BlockStarChainGetOneByParams(session *xorm.Session, params map[string]interface{}) (*model.BlockStarChain, error) { | ||||
var m model.BlockStarChain | var m model.BlockStarChain | ||||
var query = fmt.Sprintf("%s =?", params["key"]) | 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) | return nil, zhios_order_relate_logx.Error(err) | ||||
} | } | ||||
if has == false { | |||||
return nil, errors.New("未查询到相应的 block_star_chain 记录") | |||||
} | |||||
return &m, nil | return &m, nil | ||||
} | } | ||||
@@ -31,6 +31,7 @@ type BlockStarChain struct { | |||||
OtherForUserLevel string `json:"other_for_user_level" xorm:"comment('其他分红对应会员等级') TEXT"` | 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)"` | 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"` | 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"` | 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"` | UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"` | ||||
SellLimit string `json:"sell_limit" xorm:"comment('挂卖条件') TEXT"` | SellLimit string `json:"sell_limit" xorm:"comment('挂卖条件') TEXT"` | ||||
@@ -37,6 +37,7 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) | |||||
}() | }() | ||||
session.Begin() | session.Begin() | ||||
now := time.Now() | now := time.Now() | ||||
today := now.Format("2006-01-02") | |||||
//1、查找 `block_star_chain` 基础设置 | //1、查找 `block_star_chain` 基础设置 | ||||
blockStarChain, err := db.BlockStarChainGetOneByParams(session, map[string]interface{}{ | blockStarChain, err := db.BlockStarChainGetOneByParams(session, map[string]interface{}{ | ||||
@@ -47,6 +48,10 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) | |||||
_ = session.Rollback() | _ = session.Rollback() | ||||
return err | return err | ||||
} | } | ||||
if blockStarChain.SettlementDate == today { | |||||
_ = session.Rollback() | |||||
return errors.New("今日“区块星链”已结算") | |||||
} | |||||
//initialCoinTotal := zhios_order_relate_utils.StrToFloat64(blockStarChain.InitialCoinTotal) //初始区块币总量 | //initialCoinTotal := zhios_order_relate_utils.StrToFloat64(blockStarChain.InitialCoinTotal) //初始区块币总量 | ||||
todayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.TodayPublishCoin) //今日区块币发行数量(若为0,则按当前每日区块币发行数量) | todayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.TodayPublishCoin) //今日区块币发行数量(若为0,则按当前每日区块币发行数量) | ||||
nowEverydayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.NowEverydayPublishCoin) //当前每日区块币发行数量 | nowEverydayPublishCoin := zhios_order_relate_utils.StrToFloat64(blockStarChain.NowEverydayPublishCoin) //当前每日区块币发行数量 | ||||
@@ -145,6 +150,18 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string) (err error) | |||||
return err | 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() | err = session.Commit() | ||||
if err != nil { | if err != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||