|
@@ -997,7 +997,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
global.LOG.Error(err)
|
|
|
- go alarm_msg.SendAlarmMsg("获取近两年的收入统计数据异常,Err:"+err.Error(), 3)
|
|
|
+ go alarm_msg.SendAlarmMsg("获取业务收入金额统计数据异常,Err:"+err.Error(), 3)
|
|
|
|
|
|
}
|
|
|
ch <- incomeChart
|
|
@@ -1032,23 +1032,22 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
var latestTime time.Time
|
|
|
|
|
|
invoiceItem, err := fms.GetLatestIncome(cond, pars)
|
|
|
- if err != nil && err != utils.ErrNoRow {
|
|
|
+ if err != nil && err != utils.ErrNoRow {
|
|
|
err = fmt.Errorf("获取最新的开票或到款日期, Err: %s", err.Error())
|
|
|
return
|
|
|
}
|
|
|
latestTime = invoiceItem.InvoiceDate
|
|
|
|
|
|
- if err == utils.ErrNoRow{
|
|
|
+ if err == utils.ErrNoRow {
|
|
|
historyItem, e := fms.GetLatestHistoryIncome(historyCond, historyPars)
|
|
|
- if e != nil {
|
|
|
+ if e != nil && err != utils.ErrNoRow {
|
|
|
err = fmt.Errorf("获取最新的历史开票或到款日期, Err: %s", err.Error())
|
|
|
return
|
|
|
}
|
|
|
latestTime = historyItem.InvoiceDate
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- latestTime = latestTime.AddDate(0,0,-latestTime.Day()+1)
|
|
|
+ latestTime = latestTime.AddDate(0, 0, -latestTime.Day()+1)
|
|
|
|
|
|
var dateSlice []string
|
|
|
var totalMoneySlice, prevTotalMoneySlice []float64
|
|
@@ -1167,8 +1166,8 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
historyPars = append(historyPars, sellerIds)
|
|
|
prevHistoryPars = append(prevHistoryPars, sellerIds)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
|
|
|
st := fmt.Sprint(startDate, " 00:00:00")
|
|
@@ -1204,7 +1203,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
for _, result := range results {
|
|
|
incomeChart.DataList = append(incomeChart.DataList, result)
|
|
|
amountSum += result.Amount
|
|
|
- fmt.Println("result.Amount:",result.Amount)
|
|
|
+ fmt.Println("result.Amount:", result.Amount)
|
|
|
}
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
@@ -1220,8 +1219,8 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
} else if i > 0 || i == numMonth {
|
|
|
totalMoneySlice = append(totalMoneySlice, partAccumulate)
|
|
|
- fmt.Println("partAccumulate:",partAccumulate)
|
|
|
- partAccumulate = 0.0
|
|
|
+ fmt.Println("partAccumulate:", partAccumulate)
|
|
|
+ partAccumulate = 0.0
|
|
|
}
|
|
|
}
|
|
|
} else if endDateTime.Before(historyTime) || endDateTime.Equal(historyTime) {
|
|
@@ -1260,7 +1259,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
} else if i > 0 || i == numMonth {
|
|
|
totalMoneySlice = append(totalMoneySlice, partAccumulate)
|
|
|
- partAccumulate = 0.0
|
|
|
+ partAccumulate = 0.0
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1317,14 +1316,14 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
prevTotalMoneySlice = append(prevTotalMoneySlice, prevAmountTotal)
|
|
|
} else if i > 0 || i == numMonth {
|
|
|
prevTotalMoneySlice = append(prevTotalMoneySlice, partHistoryAccumulate)
|
|
|
- fmt.Println("partHistoryAccumulate:",partHistoryAccumulate)
|
|
|
+ fmt.Println("partHistoryAccumulate:", partHistoryAccumulate)
|
|
|
partHistoryAccumulate = 0.0
|
|
|
}
|
|
|
}
|
|
|
} else if prevEndDateTime.Before(historyTime) || prevEndDateTime.Equal(historyTime) {
|
|
|
|
|
|
- fmt.Println("prevSt:",prevSt)
|
|
|
- fmt.Println("prevEd:",prevEd)
|
|
|
+ fmt.Println("prevSt:", prevSt)
|
|
|
+ fmt.Println("prevEd:", prevEd)
|
|
|
prevHistoryCond += ` AND (invoice_time BETWEEN ? AND ?)`
|
|
|
prevHistoryPars = append(prevHistoryPars, prevSt, prevEd)
|
|
|
|
|
@@ -1353,14 +1352,14 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
prevTotalMoneySlice = append(prevTotalMoneySlice, amountTotal)
|
|
|
} else if i > 0 || i == numMonth {
|
|
|
prevTotalMoneySlice = append(prevTotalMoneySlice, partHistoryAccumulate)
|
|
|
- fmt.Println("partHistoryAccumulate:",partHistoryAccumulate)
|
|
|
+ fmt.Println("partHistoryAccumulate:", partHistoryAccumulate)
|
|
|
partHistoryAccumulate = 0.0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if req.ListParam == "1" && i == j {
|
|
|
- if i == 0{
|
|
|
+ if i == 0 {
|
|
|
dateSlice = append(dateSlice, startDateTime.AddDate(0, 2, 0).Format("06/01"))
|
|
|
j = j + 2
|
|
|
} else {
|
|
@@ -1368,7 +1367,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
j = j + 3
|
|
|
}
|
|
|
} else if req.ListParam == "2" && i == j {
|
|
|
- if i == 0{
|
|
|
+ if i == 0 {
|
|
|
dateSlice = append(dateSlice, startDateTime.AddDate(0, 5, 0).Format("06/01"))
|
|
|
j = j + 5
|
|
|
} else {
|
|
@@ -1376,7 +1375,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
j = j + 6
|
|
|
}
|
|
|
} else if req.ListParam == "3" && i == j {
|
|
|
- if i == 0{
|
|
|
+ if i == 0 {
|
|
|
dateSlice = append(dateSlice, startDateTime.AddDate(0, 11, 0).Format("06/01"))
|
|
|
j = j + 11
|
|
|
} else {
|
|
@@ -1405,8 +1404,8 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
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])
|
|
|
+ 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)
|
|
|
}
|
|
@@ -1473,10 +1472,10 @@ func ExportIncomeList(c *gin.Context, list []*fms.IncomeSummaryItem) {
|
|
|
if v.ContractType == 1 {
|
|
|
newCompany = 1
|
|
|
}
|
|
|
- dataRow.AddCell().SetString(strconv.Itoa(newCompany))
|
|
|
- dataRow.AddCell().SetString(v.CompanyName)
|
|
|
- dataRow.AddCell().SetString(fmt.Sprint(v.Amount))
|
|
|
- dataRow.AddCell().SetString(v.SellerName)
|
|
|
+ dataRow.AddCell().SetString(strconv.Itoa(newCompany))
|
|
|
+ dataRow.AddCell().SetString(v.CompanyName)
|
|
|
+ dataRow.AddCell().SetString(fmt.Sprint(v.Amount))
|
|
|
+ dataRow.AddCell().SetString(v.SellerName)
|
|
|
}
|
|
|
|
|
|
|