optimize
This commit is contained in:
12
fund/fund.go
12
fund/fund.go
@@ -21,6 +21,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,6 +41,7 @@ type fund struct {
|
||||
EstimateVal string `json:"gsz"`
|
||||
RisePer string `json:"gszzl"`
|
||||
UpdateTime string `json:"gztime"`
|
||||
CheckTime time.Time
|
||||
}
|
||||
|
||||
func (f *fund) Name() string {
|
||||
@@ -64,11 +66,21 @@ func (f *fund) Update() error {
|
||||
f.EstimateVal = ff.EstimateVal
|
||||
f.RisePer = ff.RisePer
|
||||
f.UpdateTime = ff.UpdateTime
|
||||
f.CheckTime = time.Now()
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *fund) Msg() string {
|
||||
now := time.Now()
|
||||
h := now.Hour()
|
||||
if h > 9 && h < 15 && now.Sub(f.CheckTime) > time.Minute*5 {
|
||||
err := f.Update()
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
}
|
||||
}
|
||||
var rise string
|
||||
last, err1 := strconv.ParseFloat(f.UnitVal, 64)
|
||||
cur, err2 := strconv.ParseFloat(f.EstimateVal, 64)
|
||||
|
||||
Reference in New Issue
Block a user