zwxi 1 年之前
父节点
当前提交
f54850fa60
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      controller/census/invoice_payment.go

+ 5 - 3
controller/census/invoice_payment.go

@@ -1492,14 +1492,14 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 		// 移动平均值:若是10月份,计算8月,9月,10月,这三个月的收入金额平均值
 		if req.ListParam == "0" {
 			for i := range prevTotalMoneySlice {
+				totalMoneySlice[i], _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalMoneySlice[i] - prevTotalMoneySlice[i]), 64)
+				var yoy float64
+				var yoyStr string
 				if i > 2 {
 					// 前俩月没有
-					var yoy float64
-					var yoyStr string
 					//fmt.Println("1:", prevTotalMoneySlice[i])
 					//fmt.Println("2:", totalMoneySlice[i])
 					//fmt.Println("3:", totalMoneySlice[i]-prevTotalMoneySlice[i])
-					totalMoneySlice[i], _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalMoneySlice[i] - prevTotalMoneySlice[i]), 64)
 					//if prevTotalMoneySlice[i] != 0 && totalMoneySlice[i] != 0 {
 					//	yoy = (totalMoneySlice[i] - prevTotalMoneySlice[i]) / prevTotalMoneySlice[i]
 					//	yoyStr = fmt.Sprintf("%.4f", yoy)
@@ -1514,6 +1514,8 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 					yoyStr = fmt.Sprintf("%.4f", yoy)
 					yoySlice = append(yoySlice, yoyStr)
 				}
+				yoyStr = fmt.Sprintf("%.4f", yoy)
+				yoySlice = append(yoySlice, yoyStr)
 			}
 		}
 	}