|
@@ -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
|
|
|
}
|
|
|
|