|
@@ -1004,11 +1004,12 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
|
|
|
|
|
|
|
|
|
- invoiceItem,err := fms.GetLatestIncome()
|
|
|
+ invoiceItem, err := fms.GetLatestIncome()
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("获取最新的开票或到款日期, Err: %s", err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ invoiceItem.InvoiceDate = invoiceItem.InvoiceDate.AddDate(0,0,-invoiceItem.InvoiceDate.Day()+1)
|
|
|
|
|
|
var dateSlice []string
|
|
|
var totalMoneySlice, prevTotalMoneySlice []float64
|
|
@@ -1020,7 +1021,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
if req.StartDate != "" && req.EndDate != "" {
|
|
|
st := fmt.Sprint(req.StartDate, "-01 00:00:00")
|
|
|
ed := fmt.Sprint(req.EndDate, "-01 23:59:59")
|
|
|
- reqStartDate, _ = time.Parse(utils.FormatDateTime,st)
|
|
|
+ reqStartDate, _ = time.Parse(utils.FormatDateTime, st)
|
|
|
reqEndDate, _ = time.Parse(utils.FormatDateTime, ed)
|
|
|
if reqEndDate.After(invoiceItem.InvoiceDate) {
|
|
|
yearNum = invoiceItem.InvoiceDate.Year() - reqStartDate.Year()
|
|
@@ -1045,9 +1046,12 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
|
|
|
var accumulate float64
|
|
|
var historyAccumulate float64
|
|
|
- fmt.Println("numMonth:",numMonth)
|
|
|
- fmt.Println("InvoiceDate:",invoiceItem.InvoiceDate)
|
|
|
+
|
|
|
+
|
|
|
+ fmt.Println("numMonth:", numMonth)
|
|
|
+ fmt.Println("InvoiceDate:", invoiceItem.InvoiceDate)
|
|
|
|
|
|
+ var j int
|
|
|
for i := 0; i <= numMonth; i++ {
|
|
|
|
|
|
|
|
@@ -1083,9 +1087,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
endDate = endDateTime.Format(utils.FormatDate)
|
|
|
prevEndDate = prevEndDateTime.Format(utils.FormatDate)
|
|
|
|
|
|
-
|
|
|
- dateSlice = append(dateSlice, startDateTime.Format("06/01"))
|
|
|
-
|
|
|
cond := `1 = 1`
|
|
|
histrtyCond := `1 = 1`
|
|
|
pars := make([]interface{}, 0)
|
|
@@ -1149,6 +1150,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
var amountSum float64
|
|
|
for _, result := range results {
|
|
|
incomeChart.DataList = append(incomeChart.DataList, result)
|
|
@@ -1157,13 +1159,14 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
|
}
|
|
|
- if req.ListParam == "4" {
|
|
|
- totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
- } else {
|
|
|
- totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
+ if i == j {
|
|
|
+ if req.ListParam == "4" {
|
|
|
+ totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
+ } else {
|
|
|
+ totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
+ }
|
|
|
}
|
|
|
} else if endDateTime.Before(historyTime) || endDateTime.Equal(historyTime) {
|
|
|
-
|
|
|
|
|
|
|
|
|
histrtyCond += ` AND (invoice_time BETWEEN ? AND ? )`
|
|
@@ -1176,6 +1179,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
return
|
|
|
}
|
|
|
var amountSum float64
|
|
|
+
|
|
|
for _, result := range results {
|
|
|
incomeChart.DataList = append(incomeChart.DataList, result)
|
|
|
amountSum += result.Amount
|
|
@@ -1183,64 +1187,67 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
|
|
|
|
- if req.ListParam == "4" {
|
|
|
- totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
- } else {
|
|
|
- totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
-
|
|
|
- var historyAmountTotal float64
|
|
|
- histrtyCond += ` AND (invoice_time BETWEEN ? AND '2023-03-01 23:59:59' ) `
|
|
|
- historyPars = append(historyPars, st)
|
|
|
-
|
|
|
- var amountTotal float64
|
|
|
- results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- var amountSum float64
|
|
|
- for _, result := range results {
|
|
|
- incomeChart.DataList = append(incomeChart.DataList, result)
|
|
|
- amountSum += result.Amount
|
|
|
- }
|
|
|
- amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
- accumulate += amountTotal
|
|
|
- historyAmountTotal = amountTotal
|
|
|
-
|
|
|
- cond += ` AND ((c.invoice_time BETWEEN '2023-03-02 00:00:00' AND ?) or (d.invoice_time BETWEEN '2023-03-02 00:00:00' AND ?))`
|
|
|
- pars = append(pars, ed, ed)
|
|
|
- summaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(cond, pars)
|
|
|
- if e != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if len(summaryIds) > 0 {
|
|
|
- amountCond := `a.id IN ? AND (a.invoice_id <> 0 OR (a.payment_id <> 0 AND a.invoice_id =0))`
|
|
|
- amountPars := make([]interface{}, 0)
|
|
|
- amountPars = append(amountPars, summaryIds)
|
|
|
- results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- var amountSum float64
|
|
|
- for _, result := range results {
|
|
|
- incomeChart.DataList = append(incomeChart.DataList, result)
|
|
|
- amountSum += result.Amount
|
|
|
+ if i == j {
|
|
|
+ if req.ListParam == "4" {
|
|
|
+ totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
+ } else {
|
|
|
+ totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
}
|
|
|
- amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
- accumulate += amountTotal
|
|
|
}
|
|
|
- if req.ListParam == "4" {
|
|
|
- totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
- } else {
|
|
|
- totalMoneySlice = append(totalMoneySlice, amountTotal+historyAmountTotal)
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1273,13 +1280,21 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
return
|
|
|
}
|
|
|
var amountSum float64
|
|
|
+
|
|
|
for _, result := range results {
|
|
|
+
|
|
|
amountSum += result.Amount
|
|
|
}
|
|
|
prevAmountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
historyAccumulate += prevAmountTotal
|
|
|
}
|
|
|
- prevTotalMoneySlice = append(prevTotalMoneySlice, prevAmountTotal)
|
|
|
+ if i == j {
|
|
|
+ if req.ListParam == "4" {
|
|
|
+ prevTotalMoneySlice = append(prevTotalMoneySlice, historyAccumulate)
|
|
|
+ } else {
|
|
|
+ prevTotalMoneySlice = append(prevTotalMoneySlice, prevAmountTotal)
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if prevEndDateTime.Before(historyTime) || prevEndDateTime.Equal(historyTime) {
|
|
|
|
|
|
prevHistoryCond += ` AND (invoice_time BETWEEN ? AND ?)`
|
|
@@ -1291,6 +1306,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
var amountSum float64
|
|
|
for _, result := range results {
|
|
|
amountSum += result.Amount
|
|
@@ -1298,73 +1314,117 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
historyAccumulate += amountTotal
|
|
|
|
|
|
- if req.ListParam == "4" {
|
|
|
- prevTotalMoneySlice = append(prevTotalMoneySlice, historyAccumulate)
|
|
|
- } else {
|
|
|
- prevTotalMoneySlice = append(prevTotalMoneySlice, amountTotal)
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- var historyAmountTotal float64
|
|
|
- prevHistoryCond += ` AND (invoice_time BETWEEN ? AND '2023-03-01 23:59:59' ) `
|
|
|
- prevHistoryPars = append(prevHistoryPars, prevSt)
|
|
|
-
|
|
|
- var amountTotal float64
|
|
|
- results, e := fms.GetIncomeHistory(prevHistoryCond, prevHistoryPars)
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- var amountSum float64
|
|
|
- for _, result := range results {
|
|
|
- amountSum += result.Amount
|
|
|
- }
|
|
|
- amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
- historyAccumulate += amountTotal
|
|
|
-
|
|
|
-
|
|
|
- prevCond += ` AND ((c.invoice_time BETWEEN '2023-03-02 00:00:00' AND ?) or (d.invoice_time BETWEEN '2023-03-02 00:00:00' AND ?))`
|
|
|
- prevPars = append(prevPars, prevEd, prevEd)
|
|
|
- prevSummaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(prevCond, prevPars)
|
|
|
- if e != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- var prevAmountTotal float64
|
|
|
-
|
|
|
- if len(prevSummaryIds) > 0 {
|
|
|
- amountCond := `a.id IN ? AND (a.invoice_id <> 0 OR (a.payment_id <> 0 AND a.invoice_id =0))`
|
|
|
- amountPars := make([]interface{}, 0)
|
|
|
- amountPars = append(amountPars, prevSummaryIds)
|
|
|
- results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
+ if i == j {
|
|
|
+ if req.ListParam == "4" {
|
|
|
+ prevTotalMoneySlice = append(prevTotalMoneySlice, historyAccumulate)
|
|
|
+ } else {
|
|
|
+ prevTotalMoneySlice = append(prevTotalMoneySlice, amountTotal)
|
|
|
}
|
|
|
- var amountSum float64
|
|
|
- for _, result := range results {
|
|
|
- amountSum += result.Amount
|
|
|
- }
|
|
|
- prevAmountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
- historyAccumulate += prevAmountTotal
|
|
|
- }
|
|
|
- if req.ListParam == "4" {
|
|
|
- prevTotalMoneySlice = append(prevTotalMoneySlice, historyAccumulate)
|
|
|
- } else {
|
|
|
- prevTotalMoneySlice = append(prevTotalMoneySlice, prevAmountTotal+historyAmountTotal)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- if req.ListParam == "1" {
|
|
|
- i = i + 2
|
|
|
- } else if req.ListParam == "2" {
|
|
|
- i = i + 5
|
|
|
- } else if req.ListParam == "3" {
|
|
|
- i = i + 11
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if req.ListParam == "1" && i == j {
|
|
|
+ dateSlice = append(dateSlice, startDateTime.AddDate(0, 2, 0).Format("06/01"))
|
|
|
+ j = j + 2
|
|
|
+ } else if req.ListParam == "2" && i == j {
|
|
|
+ j = j + 5
|
|
|
+ dateSlice = append(dateSlice, startDateTime.AddDate(0, 5, 0).Format("06/01"))
|
|
|
+ } else if req.ListParam == "3" && i == j {
|
|
|
+ j = j + 11
|
|
|
+ dateSlice = append(dateSlice, startDateTime.AddDate(0, 11, 0).Format("06/01"))
|
|
|
+ } else if i == j {
|
|
|
+ dateSlice = append(dateSlice, startDateTime.Format("06/01"))
|
|
|
+ j++
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
fmt.Println("prevTotalMoneySlice:", len(prevTotalMoneySlice))
|
|
|
fmt.Println("totalMoneySlice:", len(totalMoneySlice))
|
|
|
|
|
@@ -1375,7 +1435,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
|
|
|
|
|
|
|
|
|
- if prevTotalMoneySlice[i] != 0 && totalMoneySlice[i] != 0{
|
|
|
+ if prevTotalMoneySlice[i] != 0 && totalMoneySlice[i] != 0 {
|
|
|
yoy = (totalMoneySlice[i] - prevTotalMoneySlice[i]) / prevTotalMoneySlice[i]
|
|
|
yoyStr = fmt.Sprintf("%.4f", yoy)
|
|
|
}
|
|
@@ -1454,4 +1514,3 @@ func ExportIncomeList(c *gin.Context, list []*fms.IncomeSummaryItem) {
|
|
|
c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
|
}
|
|
|
-
|