|
@@ -9,6 +9,7 @@ import (
|
|
|
"hongze/fms_api/controller/resp"
|
|
|
"hongze/fms_api/global"
|
|
|
"hongze/fms_api/models"
|
|
|
+ "hongze/fms_api/models/base"
|
|
|
"hongze/fms_api/models/fms"
|
|
|
"hongze/fms_api/services/alarm_msg"
|
|
|
"hongze/fms_api/utils"
|
|
@@ -1142,8 +1143,8 @@ func (this *InvoicePaymentController) IncomeList(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
//收入统计
|
|
|
- incomeList := make([]*fms.IncomeSummaryRespItem, 0)
|
|
|
- ch := make(chan []*fms.IncomeSummaryRespItem, 1)
|
|
|
+ var incomeList base.BaseData
|
|
|
+ ch := make(chan base.BaseData, 1)
|
|
|
if req.IncomeType == 0 {
|
|
|
go getPaymentIncomeList(ch, req)
|
|
|
} else {
|
|
@@ -1151,7 +1152,7 @@ func (this *InvoicePaymentController) IncomeList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
for v := range ch {
|
|
|
- incomeList = append(incomeList, v...)
|
|
|
+ incomeList = v
|
|
|
close(ch)
|
|
|
}
|
|
|
// 是否导出
|
|
@@ -1475,7 +1476,7 @@ func (this *InvoicePaymentController) IncomeList(c *gin.Context) {
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
-func getPaymentIncomeList(ch chan []*fms.IncomeSummaryRespItem, req fms.IncomeListReq) (resp []*fms.IncomeSummaryRespItem, err error) {
|
|
|
+func getPaymentIncomeList(ch chan base.BaseData, req fms.IncomeListReq) (baseData base.BaseData, err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
global.LOG.Error(err)
|
|
@@ -1483,10 +1484,9 @@ func getPaymentIncomeList(ch chan []*fms.IncomeSummaryRespItem, req fms.IncomeLi
|
|
|
go alarm_msg.SendAlarmMsg("获取业务收入金额统计数据异常,Err:"+err.Error(), 3)
|
|
|
}
|
|
|
}
|
|
|
- ch <- resp
|
|
|
+ ch <- baseData
|
|
|
}()
|
|
|
|
|
|
-
|
|
|
var reqStartDate, reqEndDate time.Time
|
|
|
|
|
|
st := fmt.Sprint(req.StartDate, "-01 00:00:00")
|
|
@@ -1500,13 +1500,11 @@ func getPaymentIncomeList(ch chan []*fms.IncomeSummaryRespItem, req fms.IncomeLi
|
|
|
startDate = reqStartDate.Format(utils.FormatDate)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//结束日期
|
|
|
if req.StartDate != "" && req.EndDate != "" {
|
|
|
endDate = reqEndDate.Format(utils.FormatDate)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
cond := `1 = 1`
|
|
|
pars := make([]interface{}, 0)
|
|
|
|
|
@@ -1549,6 +1547,11 @@ func getPaymentIncomeList(ch chan []*fms.IncomeSummaryRespItem, req fms.IncomeLi
|
|
|
pars = append(pars, st, ed, st, ed)
|
|
|
}
|
|
|
|
|
|
+ if req.Keyword != "" {
|
|
|
+ cond += ` AND b.company_name LIKE ?`
|
|
|
+ pars = append(pars, "%"+req.Keyword+"%")
|
|
|
+ }
|
|
|
+
|
|
|
summaryIds, e := fms.GetPaymentCensusSummaryDataIds(cond, pars)
|
|
|
if e != nil {
|
|
|
return
|
|
@@ -1565,22 +1568,54 @@ func getPaymentIncomeList(ch chan []*fms.IncomeSummaryRespItem, req fms.IncomeLi
|
|
|
} else {
|
|
|
amountCond += `AND (a.payment_id <> 0)`
|
|
|
}
|
|
|
- results, e := fms.GetContractSummaryPaymentIncomeAmountPage(amountCond, amountPars)
|
|
|
+ page := new(base.Page)
|
|
|
+ page.SetPageSize(req.PageSize)
|
|
|
+ page.SetCurrent(req.Current)
|
|
|
+
|
|
|
+ if req.SortType == "asc" {
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "d.invoice_time", Asc: true})
|
|
|
+ } else {
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "d.invoice_time", Asc: false})
|
|
|
+ }
|
|
|
+
|
|
|
+ results, total, e := fms.GetContractSummaryPaymentIncomeAmountPage(amountCond, amountPars, page)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("获取汇总数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // 货币列表
|
|
|
+ currencyOB := new(fms.CurrencyUnit)
|
|
|
+ currencyCond := `enable = 1`
|
|
|
+ currencyPars := make([]interface{}, 0)
|
|
|
+ currencyList, e := currencyOB.List(currencyCond, currencyPars)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("获取货币列表失败, Err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ unitMap := make(map[string]string)
|
|
|
+ for i := range currencyList {
|
|
|
+ unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
+ }
|
|
|
+
|
|
|
+ respItems := make([]*fms.IncomeSummaryRespItem, 0)
|
|
|
for _, v := range results {
|
|
|
respItem := &fms.IncomeSummaryRespItem{
|
|
|
- CompanyName: v.CompanyName,
|
|
|
- ContractType: v.ContractType,
|
|
|
- InvoiceDate: v.InvoiceDate.Format(utils.FormatDate),
|
|
|
- Amount: v.Amount,
|
|
|
- SellerName: v.SellerName,
|
|
|
- FinalSellerId: v.FinalSellerId,
|
|
|
+ CompanyName: v.CompanyName,
|
|
|
+ ContractType: v.ContractType,
|
|
|
+ InvoiceDate: v.InvoiceDate.Format(utils.FormatDate),
|
|
|
+ Amount: v.Amount,
|
|
|
+ SellerName: v.SellerName,
|
|
|
+ FinalSellerId: v.FinalSellerId,
|
|
|
+ OriginAmount: v.OriginAmount,
|
|
|
+ UnitName: unitMap[v.CurrencyUnit],
|
|
|
+ ServicesName: v.ServicesName,
|
|
|
}
|
|
|
- resp = append(resp, respItem)
|
|
|
+ respItems = append(respItems, respItem)
|
|
|
}
|
|
|
+ page.SetTotal(total)
|
|
|
+ baseData.SetPage(page)
|
|
|
+ baseData.SetList(respItems)
|
|
|
}
|
|
|
}
|
|
|
|