Browse Source

Merge branch 'bugfix_4/28'

ziwen 1 year ago
parent
commit
c54a128157
2 changed files with 6 additions and 5 deletions
  1. 4 3
      controller/statistic.go
  2. 2 2
      models/statistic.go

+ 4 - 3
controller/statistic.go

@@ -78,7 +78,7 @@ func getIncomeList(ch chan models.IncomeChartResp) (incomeChart models.IncomeCha
 			//	endDate = fmt.Sprint(endDate, "-01")
 			//}
 			endDate = fmt.Sprint(endDate, "-01")
-			cond := ` AND create_time >= '` + startDate + `' AND create_time < '` + endDate + `' `
+			cond := ` AND invoice_time >= '` + startDate + `' AND invoice_time < '` + endDate + `' `
 
 			item, countErr := models.GetIncomeListCount(cond)
 			if countErr != nil && countErr != utils.ErrNoRow {
@@ -164,9 +164,10 @@ func getIncomeListV2(ch chan models.IncomeChartResp) (incomeChart models.IncomeC
 			var invoiceTotal, paymentTotal float64
 
 			if len(summaryIds) > 0 {
-				amountTotalCond := `a.id IN ?`
+				//amountTotalCond := `a.id IN ?`
+				amountTotalCond := `a.id IN ? AND (b.invoice_time BETWEEN ? AND ?)`
 				amountTotalPars := make([]interface{}, 0)
-				amountTotalPars = append(amountTotalPars, summaryIds)
+				amountTotalPars = append(amountTotalPars, summaryIds, st, ed)
 				invoiceSum, e := fms.GetContractSummaryInvoicePaymentAmountTotal(amountTotalCond, amountTotalPars, 1)
 				if e != nil {
 					return

+ 2 - 2
models/statistic.go

@@ -19,8 +19,8 @@ type IncomeItem struct {
 
 func GetIncomeListCount(cond string) (results *IncomeItem, err error) {
 	sql := `SELECT a.contract_money, b.arrival_money FROM (
-SELECT SUM(amount) contract_money  FROM contract_invoice  WHERE is_deleted = 0 AND invoice_type = 1 `+cond+` ) AS a,
-(SELECT SUM(amount) arrival_money FROM  contract_invoice  WHERE is_deleted = 0 AND invoice_type = 2 `+cond+` ) AS b WHERE 1=1 `
+SELECT SUM(amount) contract_money  FROM contract_invoice  WHERE is_deleted = 0 AND (invoice_type = 1 OR invoice_type = 3) `+cond+` ) AS a,
+(SELECT SUM(amount) arrival_money FROM  contract_invoice  WHERE is_deleted = 0 AND (invoice_type = 2 OR invoice_type = 4) `+cond+` ) AS b WHERE 1=1 `
 
 	err = global.DEFAULT_MYSQL.Raw(sql).First(&results).Error
 	return