hsun 2 gadi atpakaļ
vecāks
revīzija
7532fe91a4
2 mainītis faili ar 6 papildinājumiem un 4 dzēšanām
  1. 1 1
      controller/census/seller.go
  2. 5 3
      models/fms/contract_invoice.go

+ 1 - 1
controller/census/seller.go

@@ -21,7 +21,7 @@ import (
 // SellerController 销售统计
 type SellerController struct{}
 
-// InvoiceGroupList
+// GroupInvoiceList
 // @Title 销售组开票统计列表
 // @Description 销售组开票统计列表
 // @Param   StartDate		query	string	false	"开始日期"

+ 5 - 3
models/fms/contract_invoice.go

@@ -70,11 +70,13 @@ func (c *ContractInvoice) Fetch(id int) (item *ContractInvoice, err error) {
 }
 
 func (c *ContractInvoice) Sum(field, condition string, pars []interface{}) (total float64, err error) {
-	selectField := fmt.Sprintf("SUM(%s)", field)
+	totalList := make([]float64, 0)
 	err = global.DEFAULT_MYSQL.Model(c).
-		Select(selectField).
 		Where(condition, pars...).
-		Find(&total).Error
+		Pluck(field, &totalList).Error
+	for i := range totalList {
+		total += totalList[i]
+	}
 	return
 }