hsun 2 years ago
parent
commit
82f4f2a9b3
2 changed files with 12 additions and 5 deletions
  1. 9 4
      controller/census/invoice_payment.go
  2. 3 1
      controller/contract/register.go

+ 9 - 4
controller/census/invoice_payment.go

@@ -13,6 +13,7 @@ import (
 	fmsService "hongze/fms_api/services/fms"
 	"hongze/fms_api/utils"
 	"net/http"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -210,6 +211,8 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
 		for i := range amountTotalList {
 			amountTotalMap[amountTotalList[i].InvoiceType] = amountTotalList[i].TotalAmount
 		}
+		invoiceTotal, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", amountTotalMap[fms.ContractInvoiceTypeMake]), 64)
+		paymentTotal, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", amountTotalMap[fms.ContractInvoiceTypePay]), 64)
 
 		// 分币种金额统计
 		currencyOB := new(fms.CurrencyUnit)
@@ -255,15 +258,17 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
 			}
 		}
 		for i := range invoiceCurrencyTotals {
-			invoiceCurrencyTotals[i].Amount = invoiceSumMap[invoiceCurrencyTotals[i].Code]
+			a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", invoiceSumMap[invoiceCurrencyTotals[i].Code]), 64)
+			invoiceCurrencyTotals[i].Amount = a
 		}
 		for i := range paymentCurrencyTotals {
-			paymentCurrencyTotals[i].Amount = paymentSumMap[paymentCurrencyTotals[i].Code]
+			a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", paymentSumMap[paymentCurrencyTotals[i].Code]), 64)
+			paymentCurrencyTotals[i].Amount = a
 		}
 
 		results.DataList = respList
-		results.InvoiceTotal = amountTotalMap[fms.ContractInvoiceTypeMake]
-		results.PaymentTotal = amountTotalMap[fms.ContractInvoiceTypePay]
+		results.InvoiceTotal = invoiceTotal
+		results.PaymentTotal = paymentTotal
 		results.InvoiceCurrencyTotal = invoiceCurrencyTotals
 		results.PaymentCurrencyTotal = paymentCurrencyTotals
 	}

+ 3 - 1
controller/contract/register.go

@@ -1411,8 +1411,10 @@ func (rg *RegisterController) InvoiceList(c *gin.Context) {
 		amountTotal += sumList[i].AmountTotal
 		sumMap[sumList[i].CurrencyUnit] = sumList[i].OriginAmountTotal
 	}
+	amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountTotal), 64)
 	for i := range currencyTotals {
-		currencyTotals[i].Amount = sumMap[currencyTotals[i].Code]
+		a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", sumMap[currencyTotals[i].Code]), 64)
+		currencyTotals[i].Amount = a
 	}
 
 	respData := &fms.InvoiceListRespData{