zwxi 1 ano atrás
pai
commit
e08131a03b
3 arquivos alterados com 119 adições e 40 exclusões
  1. 42 11
      controller/census/seller.go
  2. 0 29
      models/fms/contract_invoice.go
  3. 77 0
      services/fms/seller.go

+ 42 - 11
controller/census/seller.go

@@ -13,6 +13,7 @@ import (
 	"hongze/fms_api/models/crm"
 	"hongze/fms_api/models/fms"
 	crmService "hongze/fms_api/services/crm"
+	fmsService "hongze/fms_api/services/fms"
 	"hongze/fms_api/utils"
 	"net/http"
 	"sort"
@@ -883,23 +884,38 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 		}
 	}
 
-	var respList fms.CensusSellerList
-	respList = list
+	sort.Slice(list, func(i, j int) bool {
+		if req.SortField == 2 {
+			if req.SortType == 2 {
+				return list[i].GroupRate < list[j].GroupRate
+			} else {
+				return list[i].GroupRate > list[j].GroupRate
+			}
+		} else {
+			if req.SortType == 2 {
+				return list[i].InvoiceAmount < list[j].InvoiceAmount
+			} else {
+				return list[i].InvoiceAmount > list[j].InvoiceAmount
+			}
+		}
+	})
 
-	sort.Sort(respList)
+	//var respList fmsService.CensusSellerListByAmountAsc
+	//respList = list
+	//sort.Sort(list)
 
 	// 是否导出
 	if req.IsExport == 1 {
-		ExportInvoiceList(c, respList, req)
+		ExportInvoiceList(c, list, req)
 		return
 	}
 	page.SetTotal(int64(len(list)))
 	baseData := new(base.BaseData)
 	baseData.SetPage(page)
 	if req.Current*req.PageSize > int64(len(list)) {
-		baseData.SetList(respList[(req.Current-1)*req.PageSize : len(list)])
+		baseData.SetList(list[(req.Current-1)*req.PageSize : len(list)])
 	} else {
-		baseData.SetList(respList[(req.Current-1)*req.PageSize : req.Current*req.PageSize])
+		baseData.SetList(list[(req.Current-1)*req.PageSize : req.Current*req.PageSize])
 	}
 	resp.OkData("获取成功", baseData, c)
 }
@@ -1315,15 +1331,30 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 		}
 	}
 
-	var respList fms.CensusSellerGroupList
-	respList = list
+	sort.Slice(list, func(i, j int) bool {
+		if req.SortField == 2 {
+			if req.SortType == 2 {
+				return list[i].GroupRate < list[j].GroupRate
+			} else {
+				return list[i].GroupRate > list[j].GroupRate
+			}
+		} else {
+			if req.SortType == 2 {
+				return list[i].InvoiceAmount < list[j].InvoiceAmount
+			} else {
+				return list[i].InvoiceAmount > list[j].InvoiceAmount
+			}
+		}
+	})
 
-	sort.Sort(respList)
+	//var respList fms.CensusSellerGroupList
+	//respList = list
+	//sort.Sort(respList)
 
 	// 是否导出
 	if req.IsExport == 1 {
-		ExportGroupInvoiceList(c, respList, req)
+		ExportGroupInvoiceList(c, list, req)
 		return
 	}
-	resp.OkData("获取成功", respList, c)
+	resp.OkData("获取成功", list, c)
 }

+ 0 - 29
models/fms/contract_invoice.go

@@ -818,33 +818,4 @@ func GetInvoiceCountByRegisterId(registerId int) (total int64, err error) {
 	err = global.DEFAULT_MYSQL.Table("contract_invoice as a ").
 		Where("is_deleted = 0 AND contract_register_id = ?", registerId).Count(&total).Error
 	return
-}
-
-type CensusSellerGroupList []*CensusSellerGroupInvoiceItem
-
-func (c CensusSellerGroupList) Len() int {
-	return len(c)
-}
-
-func (c CensusSellerGroupList) Less(i, j int) bool {
-	return c[i].InvoiceAmount > c[j].InvoiceAmount
-}
-
-func (c CensusSellerGroupList) Swap(i, j int) {
-	c[i], c[j] = c[j], c[i]
-}
-
-
-type CensusSellerList []*CensusSellerInvoiceItem
-
-func (c CensusSellerList) Len() int {
-	return len(c)
-}
-
-func (c CensusSellerList) Less(i, j int) bool {
-	return c[i].InvoiceAmount > c[j].InvoiceAmount
-}
-
-func (c CensusSellerList) Swap(i, j int) {
-	c[i], c[j] = c[j], c[i]
 }

+ 77 - 0
services/fms/seller.go

@@ -0,0 +1,77 @@
+package fms
+
+import (
+	"hongze/fms_api/models/fms"
+)
+
+type CensusSellerGroupList []*fms.CensusSellerGroupInvoiceItem
+
+func (c CensusSellerGroupList) Len() int {
+	return len(c)
+}
+
+func (c CensusSellerGroupList) Less(i, j int) bool {
+	return c[i].InvoiceAmount > c[j].InvoiceAmount
+}
+
+func (c CensusSellerGroupList) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+
+
+type CensusSellerListByAmountAsc []*fms.CensusSellerInvoiceItem
+
+func (c CensusSellerListByAmountAsc) Len() int {
+	return len(c)
+}
+
+func (c CensusSellerListByAmountAsc) Less(i, j int) bool {
+	return c[i].InvoiceAmount > c[j].InvoiceAmount
+}
+
+func (c CensusSellerListByAmountAsc) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+
+type CensusSellerListByAmountDesc []*fms.CensusSellerInvoiceItem
+
+func (c CensusSellerListByAmountDesc) Len() int {
+	return len(c)
+}
+
+func (c CensusSellerListByAmountDesc) Less(i, j int) bool {
+	return c[i].InvoiceAmount < c[j].InvoiceAmount
+}
+
+func (c CensusSellerListByAmountDesc) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+
+type CensusSellerListByGroupRateAsc []*fms.CensusSellerInvoiceItem
+
+func (c CensusSellerListByGroupRateAsc) Len() int {
+	return len(c)
+}
+
+func (c CensusSellerListByGroupRateAsc) Less(i, j int) bool {
+	return c[i].GroupRate > c[j].GroupRate
+}
+
+func (c CensusSellerListByGroupRateAsc) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+
+type CensusSellerListByGroupRateDesc []*fms.CensusSellerInvoiceItem
+
+func (c CensusSellerListByGroupRateDesc) Len() int {
+	return len(c)
+}
+
+func (c CensusSellerListByGroupRateDesc) Less(i, j int) bool {
+	return c[i].GroupRate < c[j].GroupRate
+}
+
+func (c CensusSellerListByGroupRateDesc) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+