You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
2 months ago
|
package servicemanager
|
||
|
|
||
|
import (
|
||
|
"github.com/shopspring/decimal"
|
||
|
"os"
|
||
|
"wss-pool/cmd/selfContract"
|
||
|
"wss-pool/config"
|
||
|
"wss-pool/internal/data"
|
||
|
red "wss-pool/internal/redis"
|
||
|
"wss-pool/logging/applogger"
|
||
|
)
|
||
|
|
||
|
// Gather
|
||
|
func SelfContract(checkStr, ipServer, addrServer, contractCode string) {
|
||
|
red.RedisClient = red.RedisInit(config.Config.Redis.DbEleven)
|
||
|
data.Mgo_init(config.Config.Mongodb)
|
||
|
data.InitGorm(config.Config.Bourse)
|
||
|
if contractCode == "" {
|
||
|
applogger.Error("Lack of contract code")
|
||
|
os.Exit(400)
|
||
|
}
|
||
|
//初始价格优先数据库
|
||
|
res := selfContract.GetNewPrice(contractCode)
|
||
|
if len(res) > 0 {
|
||
|
selfContract.InitialPrice = decimal.RequireFromString(res[0].Close)
|
||
|
}
|
||
|
if selfContract.InitialPrice.IsZero() {
|
||
|
selfContract.InitialPrice, _ = decimal.NewFromString(checkStr)
|
||
|
}
|
||
|
if selfContract.InitialPrice.IsZero() {
|
||
|
applogger.Error("Lack of initial price")
|
||
|
os.Exit(400)
|
||
|
}
|
||
|
selfContract.SelfContractCode = contractCode
|
||
|
applogger.Info("合约", selfContract.SelfContractCode, "初始价格", selfContract.InitialPrice)
|
||
|
// Enable collaborative data collection
|
||
|
selfContract.NewSelfContract()
|
||
|
}
|