zwxi 11 月之前
父节点
当前提交
c52c49b58b
共有 1 个文件被更改,包括 12 次插入14 次删除
  1. 12 14
      controller/census/invoice_payment.go

+ 12 - 14
controller/census/invoice_payment.go

@@ -834,6 +834,17 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 	}
 
 	latestTime = latestTime.AddDate(0, 0, -latestTime.Day()+1)
+	addMonth := 0
+	if req.ListParam == "1" {
+		addMonth = int(3 - latestTime.Month() % 3)
+	}
+	if req.ListParam == "2" {
+		addMonth = int(6 - latestTime.Month() % 6)
+	}
+	if req.ListParam == "3" {
+		addMonth = int(12 - latestTime.Month() % 12)
+	}
+	latestTime = latestTime.AddDate(0,addMonth,0)
 
 	var dateSlice []string
 	var totalMoneySlice, prevTotalMoneySlice []float64
@@ -883,19 +894,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 	} else {
 		yearNum = latestTime.Year() - 2020
 		monthNum = int(latestTime.Month() - 1)
-
-		addMonth := 0
-		if req.ListParam == "1" {
-			addMonth = int(3 - latestTime.Month() % 3)
-		}
-		if req.ListParam == "2" {
-			addMonth = int(6 - latestTime.Month() % 6)
-		}
-		if req.ListParam == "3" {
-			addMonth = int(12 - latestTime.Month() % 12)
-		}
-		latestTime = latestTime.AddDate(0,addMonth,0)
-		monthNum += addMonth
 	}
 
 	//if yearNum < 0 {
@@ -1329,7 +1327,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 	}
 
 	incomeChart.Title = "开票到款统计图"
-	incomeChart.Date = dateSlice
+	incomeChart.Date = dateSlice[:len(totalMoneySlice)]
 	incomeChart.TotalMoney = totalMoneySlice
 	incomeChart.PrevTotalMoney = prevTotalMoneySlice
 	incomeChart.Yoy = yoySlice