From 333e4216d282188fe9a7fe08c8b503f8cf26dce7 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 3 Jun 2023 10:11:59 +0800 Subject: [PATCH 1/2] fix: fix balance query (close #138) --- controller/channel-billing.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/channel-billing.go b/controller/channel-billing.go index e135e5fc..6009c7dd 100644 --- a/controller/channel-billing.go +++ b/controller/channel-billing.go @@ -73,8 +73,8 @@ func updateChannelBalance(channel *model.Channel) (float64, error) { } now := time.Now() startDate := fmt.Sprintf("%s-01", now.Format("2006-01")) - //endDate := now.Format("2006-01-02") - url = fmt.Sprintf("%s/v1/dashboard/billing/usage?start_date=%s&end_date=%s", baseURL, startDate, "2023-06-01") + endDate := now.Format("2006-01-02") + url = fmt.Sprintf("%s/v1/dashboard/billing/usage?start_date=%s&end_date=%s", baseURL, startDate, endDate) req, err = http.NewRequest("GET", url, nil) if err != nil { return 0, err From 98f1a627f0709a38c779dfb10037ef77bbc998ad Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 3 Jun 2023 10:17:52 +0800 Subject: [PATCH 2/2] fix: fix balance query (close #138) --- controller/channel-billing.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/channel-billing.go b/controller/channel-billing.go index 6009c7dd..63ec8a84 100644 --- a/controller/channel-billing.go +++ b/controller/channel-billing.go @@ -74,6 +74,9 @@ func updateChannelBalance(channel *model.Channel) (float64, error) { now := time.Now() startDate := fmt.Sprintf("%s-01", now.Format("2006-01")) endDate := now.Format("2006-01-02") + if !subscription.HasPaymentMethod { + startDate = now.AddDate(0, 0, -100).Format("2006-01-02") + } url = fmt.Sprintf("%s/v1/dashboard/billing/usage?start_date=%s&end_date=%s", baseURL, startDate, endDate) req, err = http.NewRequest("GET", url, nil) if err != nil {