From adc00449c286a2847486d946d1b0a6339d0f1c9f Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 18 Aug 2021 11:00:56 +0800 Subject: [PATCH] x --- models/asset.go | 20 ++++---------------- models/db.go | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/models/asset.go b/models/asset.go index cc29a12..c194408 100644 --- a/models/asset.go +++ b/models/asset.go @@ -19,8 +19,6 @@ type Asset struct { TodayOut int YestodayIn int YestodayOut int - MonthIn int - MonthOut int ToExpire []int } RedPacket struct { @@ -68,7 +66,6 @@ func (ck *JdCookie) Query() string { if CookieOK(ck) { today := time.Now().Local().Format("2006-01-02") yestoday := time.Now().Local().Add(-time.Hour * 24).Format("2006-01-02") - month := time.Now().Local().Format("2006-01") page := 1 end := false for { @@ -82,35 +79,26 @@ func (ck *JdCookie) Query() string { } for _, bd := range bds { amount := Int(bd.Amount) - if !strings.Contains(bd.Date, month) { - end = true - break - } - if amount > 0 { - asset.Bean.MonthIn += amount - } else { - asset.Bean.MonthOut += -amount - } if strings.Contains(bd.Date, today) { if amount > 0 { asset.Bean.TodayIn += amount } else { asset.Bean.TodayOut += -amount } - } - if strings.Contains(bd.Date, yestoday) { + } else if strings.Contains(bd.Date, yestoday) { if amount > 0 { asset.Bean.YestodayIn += amount } else { asset.Bean.YestodayOut += -amount } + } else { + end = true + break } } page++ } msgs = append(msgs, []string{ - fmt.Sprintf("当月收入:%d京豆", asset.Bean.MonthIn), - fmt.Sprintf("当月支出:%d京豆", asset.Bean.MonthOut), fmt.Sprintf("昨日收入:%d京豆", asset.Bean.YestodayIn), fmt.Sprintf("昨日支出:%d京豆", asset.Bean.YestodayOut), fmt.Sprintf("今日收入:%d京豆", asset.Bean.TodayIn), diff --git a/models/db.go b/models/db.go index f73b3b6..9be8638 100644 --- a/models/db.go +++ b/models/db.go @@ -47,6 +47,7 @@ func initDB() { keys[jp.PtKey] = true pins[jp.PtPin] = true } + db.Model(JdCookie{}).Where(fmt.Sprintf("%s != ? || %s != ?", Hack, Hack), False, True).Update(Hack, False) } func HasPin(pin string) bool {