|
@@ -431,7 +431,11 @@ func ExportInvoicePaymentCensusList(c *gin.Context, results *fms.InvoicePaymentC
|
|
|
// 是否新客户
|
|
|
colC := dataRow.AddCell()
|
|
|
colC.VMerge = mergeRowNum
|
|
|
- colC.SetString(newCompanyMap[v.NewCompany])
|
|
|
+ newCompany := 0
|
|
|
+ if v.ContractType == 1 {
|
|
|
+ newCompany = 1
|
|
|
+ }
|
|
|
+ colC.SetString(newCompanyMap[newCompany])
|
|
|
// 合同有效期
|
|
|
colD := dataRow.AddCell()
|
|
|
colD.VMerge = mergeRowNum
|
|
@@ -1166,8 +1170,8 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
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)
|
|
|
- amountCond += ` AND (b.invoice_time BETWEEN ? AND ?)`
|
|
|
- amountPars = append(amountPars, st, ed)
|
|
|
+ amountCond += ` AND (b.invoice_time BETWEEN ? AND ?) OR (d.invoice_time BETWEEN ? AND ?)`
|
|
|
+ amountPars = append(amountPars, st, ed, st, ed)
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
@@ -1233,59 +1237,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
|
|
|
//fmt.Println("partAccumulate:",partAccumulate)
|
|
|
}
|
|
|
- //else {
|
|
|
- // //刚好跨过20230301的,各查一部分
|
|
|
- // //fmt.Println("查询3")
|
|
|
- // 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
|
|
|
- // }
|
|
|
- // amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
- // accumulate += amountTotal
|
|
|
- // }
|
|
|
- // if req.ListParam == "4" {
|
|
|
- // totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
- // } else {
|
|
|
- // totalMoneySlice = append(totalMoneySlice, amountTotal+historyAmountTotal)
|
|
|
- // }
|
|
|
- //
|
|
|
- //}
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1310,7 +1261,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
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)
|
|
|
- amountCond += ` AND (b.invoice_time BETWEEN ? AND ?)`
|
|
|
+ amountCond += ` AND (b.invoice_time BETWEEN ? AND ?) OR (d.invoice_time BETWEEN ? AND ?)`
|
|
|
amountPars = append(amountPars, prevSt, prevEd)
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
if e != nil {
|
|
@@ -1372,58 +1323,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
}
|
|
|
//fmt.Println("partHistoryAccumulate:",partHistoryAccumulate)
|
|
|
}
|
|
|
- //else {
|
|
|
- // //刚好跨过20230301的,各查一部分
|
|
|
- // 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
|
|
|
- // }
|
|
|
- // 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 == j {
|
|
|
if i == 0{
|
|
|
dateSlice = append(dateSlice, startDateTime.AddDate(0, 2, 0).Format("06/01"))
|
|
@@ -1454,41 +1353,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //for i, v := range dataList {
|
|
|
- // amountTotal, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.Amount), 64)
|
|
|
- // accumulate += amountTotal
|
|
|
- //
|
|
|
- // if req.ListParam == "4" {
|
|
|
- // totalMoneySlice = append(totalMoneySlice, accumulate)
|
|
|
- // } else {
|
|
|
- // totalMoneySlice = append(totalMoneySlice, amountTotal)
|
|
|
- // }
|
|
|
- // if req.ListParam == "1" {
|
|
|
- // i = i + 2
|
|
|
- // } else if req.ListParam == "2" {
|
|
|
- // i = i + 5
|
|
|
- // } else if req.ListParam == "3" {
|
|
|
- // i = i + 11
|
|
|
- // }
|
|
|
- //}
|
|
|
- //
|
|
|
- //for i, v := range historydataList {
|
|
|
- // historyAmountTotal, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.Amount), 64)
|
|
|
- // historyAccumulate += historyAmountTotal
|
|
|
- //
|
|
|
- // if req.ListParam == "4" {
|
|
|
- // prevTotalMoneySlice = append(prevTotalMoneySlice, historyAccumulate)
|
|
|
- // } else {
|
|
|
- // prevTotalMoneySlice = append(prevTotalMoneySlice, historyAmountTotal)
|
|
|
- // }
|
|
|
- // if req.ListParam == "1" {
|
|
|
- // i = i + 2
|
|
|
- // } else if req.ListParam == "2" {
|
|
|
- // i = i + 5
|
|
|
- // } else if req.ListParam == "3" {
|
|
|
- // i = i + 11
|
|
|
- // }
|
|
|
- //}
|
|
|
|
|
|
fmt.Println("prevTotalMoneySlice:", len(prevTotalMoneySlice))
|
|
|
fmt.Println("totalMoneySlice:", len(totalMoneySlice))
|
|
@@ -1568,7 +1432,11 @@ func ExportIncomeList(c *gin.Context, list []*fms.IncomeSummaryItem) {
|
|
|
for _, v := range incomeSummaryItemList {
|
|
|
dataRow := sheet.AddRow()
|
|
|
dataRow.AddCell().SetString(v.InvoiceDate.Format(utils.FormatDate)) // 开票日期
|
|
|
- dataRow.AddCell().SetString(strconv.Itoa(v.NewCompany)) // 新客户
|
|
|
+ newCompany := 0
|
|
|
+ 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) // 销售员
|