zwxi 1 year ago
parent
commit
67dbfcb15d
2 changed files with 10 additions and 6 deletions
  1. 9 5
      controller/census/seller.go
  2. 1 1
      models/fms/contract_invoice.go

+ 9 - 5
controller/census/seller.go

@@ -771,9 +771,13 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 	for k, v := range groupInvoiceMap {
 		rate := v / accumulate
 		mulNum := decimal.NewFromFloat(100)
-		d := decimal.NewFromFloat(rate)
-		d = d.Mul(mulNum).Round(2)
-		a, _ := d.Float64()
+		newRate := decimal.NewFromFloat(rate)
+		newRate = newRate.Mul(mulNum).Round(2)
+		finalRate, _ := newRate.Float64()
+
+		newAmount := decimal.NewFromFloat(v)
+		newAmount = newAmount.Mul(mulNum).Round(2)
+		finalAmount, _ := newAmount.Float64()
 
 		groupName := ""
 		if groupItem ,ok := groupMap[k]; ok {
@@ -782,8 +786,8 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 		list = append(list, &fms.CensusSellerGroupInvoiceItem{
 			GroupId:       k,
 			GroupName:     groupName,
-			InvoiceAmount: v,
-			GroupRate:     a,
+			InvoiceAmount: finalAmount,
+			GroupRate:     finalRate,
 		})
 	}
 

+ 1 - 1
models/fms/contract_invoice.go

@@ -827,7 +827,7 @@ func (c CensusSellerGroupList) Len() int {
 }
 
 func (c CensusSellerGroupList) Less(i, j int) bool {
-	return c[i].InvoiceAmount < c[j].InvoiceAmount
+	return c[i].InvoiceAmount > c[j].InvoiceAmount
 }
 
 func (c CensusSellerGroupList) Swap(i, j int) {