ziwen 1 year ago
parent
commit
15c54754f5
2 changed files with 15 additions and 3 deletions
  1. 2 2
      controller/census/seller.go
  2. 13 1
      models/fms/contract_invoice.go

+ 2 - 2
controller/census/seller.go

@@ -113,7 +113,7 @@ func (ct *SellerController) GroupInvoiceList(c *gin.Context) {
 		resp.FailMsg("获取失败", "获取组别列表失败, Err: "+e.Error(), c)
 		return
 	}
-	total := len(groupList)
+	//total := len(groupList)
 	groupMap := make(map[int]*crm.SysGroup)
 	groupIdSlice := make([]string,0)
 	for i := range groupList {
@@ -122,7 +122,7 @@ func (ct *SellerController) GroupInvoiceList(c *gin.Context) {
 	}
 
 	groupStr := strings.Join(groupIdSlice, ",")
-	list, e := fms.GetCensusSellerGroupInvoicePageListV2(page, groupStr, cond, pars, invSum)
+	total, list, e := fms.GetCensusSellerGroupInvoicePageListV2(page, groupStr, cond, pars, invSum)
 	if e != nil {
 		resp.FailMsg("获取失败", "获取销售组开票统计列表失败, Err: "+e.Error(), c)
 		return

+ 13 - 1
models/fms/contract_invoice.go

@@ -721,7 +721,7 @@ type NotPaymentCensusInfo struct {
 }
 
 // GetCensusSellerGroupInvoicePageListV2 获取销售组开票统计列表-分页
-func GetCensusSellerGroupInvoicePageListV2(page base.IPage,groupStr, condition string, pars []interface{}, amountSum float64) (results []*CensusSellerGroupInvoiceItem, err error) {
+func GetCensusSellerGroupInvoicePageListV2(page base.IPage,groupStr, condition string, pars []interface{}, amountSum float64) (count int, results []*CensusSellerGroupInvoiceItem, err error) {
 	sql := ` 
 				SELECT
 					seller_group_id AS group_id,
@@ -736,6 +736,18 @@ func GetCensusSellerGroupInvoicePageListV2(page base.IPage,groupStr, condition s
 					seller_group_id  ORDER BY %s LIMIT %d,%d
 			`
 
+	sqlCount := ` select count(1) as count from (SELECT * 
+				FROM
+					contract_invoice
+				WHERE
+					%s
+				AND seller_group_id IN (`+groupStr+`)
+				GROUP BY
+					seller_group_id  )as a
+			`
+	sqlCount = fmt.Sprintf(sqlCount, condition)
+	err = global.DEFAULT_MYSQL.Raw(sqlCount, pars...).Find(&count).Error
+
 	sql = fmt.Sprintf(sql, amountSum, condition, page.GetOrderItemsString(), page.Offset(), page.GetPageSize())
 	err = global.DEFAULT_MYSQL.Raw(sql, pars...).Scan(&results).Error
 	return