|
|
@@ -62,6 +62,20 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string, isTask bool) |
|
|
|
return errors.New("今日“区块星链”已结算") |
|
|
|
} |
|
|
|
|
|
|
|
isHasBlockStarChainSettlementRecords, err := db.BlockStarChainSettlementRecordsGetOneByParams(session, map[string]interface{}{ |
|
|
|
"key": "date", |
|
|
|
"value": today, |
|
|
|
}) |
|
|
|
if isHasBlockStarChainSettlementRecords != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return errors.New("今日区块星链已结算!!!") |
|
|
|
} |
|
|
|
|
|
|
|
if today == "2022-10-23" { |
|
|
|
_ = session.Rollback() |
|
|
|
return errors.New("今日区块星链已结算。。。") |
|
|
|
} |
|
|
|
|
|
|
|
//TODO::增加“悲观锁”防止串行 |
|
|
|
getString, _ := cache.GetString(PessimismLockKey) |
|
|
|
//if err != nil { |
|
|
@@ -189,7 +203,8 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string, isTask bool) |
|
|
|
|
|
|
|
//10、更新 block_star_chain 中的 settlement_date 字段 |
|
|
|
blockStarChain.SettlementDate = today |
|
|
|
updateAffected, err := db.BlockStarChainUpdate(session, blockStarChain.Id, blockStarChain, "settlement_date") |
|
|
|
//updateAffected, err := db.BlockStarChainUpdate(session, blockStarChain.Id, blockStarChain, "settlement_date") |
|
|
|
updateAffected, err := db.BlockStarChainUpdate(session, blockStarChain.Id, blockStarChain) |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return err |
|
|
@@ -218,12 +233,14 @@ func DailySettlementBlockStarChain(engine *xorm.Engine, mid string, isTask bool) |
|
|
|
_ = session.Rollback() |
|
|
|
return errors.New("事务提交失败") |
|
|
|
} |
|
|
|
cache.Del(PessimismLockKey) |
|
|
|
|
|
|
|
zhios_order_relate_utils.CurlPost("http://zhios-app:5000/api/v1/check_app_over_time", map[string]string{ |
|
|
|
"mid": mid, |
|
|
|
"is_close": "0", |
|
|
|
}, map[string]string{}) |
|
|
|
|
|
|
|
//cache.Del(PessimismLockKey) |
|
|
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>区块星链结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") |
|
|
|
return nil |
|
|
|
} |
|
|
@@ -592,14 +609,14 @@ func calcNowEverydayPublishCoin(session *xorm.Session, chain *model.BlockStarCha |
|
|
|
everyThirtyDaysReduceRate := zhios_order_relate_utils.StrToFloat64(chain.EveryThirtyDaysReduceRate) / 100 //每三十日递减发行百分比 |
|
|
|
nowEverydayPublishCoin := zhios_order_relate_utils.StrToFloat64(chain.NowEverydayPublishCoin) //当前每日区块币发行数量 |
|
|
|
chain.NowEverydayPublishCoin = zhios_order_relate_utils.Float64ToStrPrec10(nowEverydayPublishCoin * (1 - everyThirtyDaysReduceRate)) |
|
|
|
updateAffected, err := db.BlockStarChainUpdate(session, chain.Id, chain, "now_everyday_publish_coin") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if updateAffected == 0 { |
|
|
|
err = errors.New("更新 block_star_chain 的 now_everyday_publish_coin 记录失败") |
|
|
|
return err |
|
|
|
} |
|
|
|
//updateAffected, err := db.BlockStarChainUpdate(session, chain.Id, chain, "now_everyday_publish_coin") |
|
|
|
//if err != nil { |
|
|
|
// return err |
|
|
|
//} |
|
|
|
//if updateAffected == 0 { |
|
|
|
// err = errors.New("更新 block_star_chain 的 now_everyday_publish_coin 记录失败") |
|
|
|
// return err |
|
|
|
//} |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|