Explorar o código

fix: fix balance query (close #138)

JustSong %!s(int64=2) %!d(string=hai) anos
pai
achega
98f1a627f0
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      controller/channel-billing.go

+ 3 - 0
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 {