|
@@ -1490,24 +1490,31 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
// 当筛选条件是”季度“、”半年度“、”年度“、”月度统计“时,并且客户是”未续约“时,仅展示柱形图,无曲线图
|
|
|
// 未续约客户收入:去年同期老客户收入金额 减 当期老客户收入金额
|
|
|
// 移动平均值:若是10月份,计算8月,9月,10月,这三个月的收入金额平均值
|
|
|
- for i := range prevTotalMoneySlice {
|
|
|
- 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)
|
|
|
-
|
|
|
- if i == len(prevTotalMoneySlice)-1 && i > 0 && req.ListParam == "3" {
|
|
|
- fmt.Println("totalMoneySlice[i-1]:", totalMoneySlice[i-1])
|
|
|
- yoy = (totalMoneySlice[i] - totalMoneySlice[i-1]) / totalMoneySlice[i-1]
|
|
|
+ if req.ListParam == "0" {
|
|
|
+ for i := range prevTotalMoneySlice {
|
|
|
+ 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)
|
|
|
+ //
|
|
|
+ // if i == len(prevTotalMoneySlice)-1 && i > 0 && req.ListParam == "3" {
|
|
|
+ // fmt.Println("totalMoneySlice[i-1]:", totalMoneySlice[i-1])
|
|
|
+ // yoy = (totalMoneySlice[i] - totalMoneySlice[i-1]) / totalMoneySlice[i-1]
|
|
|
+ // yoyStr = fmt.Sprintf("%.4f", yoy)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ yoy = (totalMoneySlice[i] + totalMoneySlice[i-1] + totalMoneySlice[i-2]) / 3
|
|
|
yoyStr = fmt.Sprintf("%.4f", yoy)
|
|
|
+ yoySlice = append(yoySlice, yoyStr)
|
|
|
}
|
|
|
}
|
|
|
- yoySlice = append(yoySlice, yoyStr)
|
|
|
}
|
|
|
}
|
|
|
|