Browse Source

积分消耗改Int

boweniac 4 days ago
parent
commit
50e08c12d1
3 changed files with 35 additions and 3 deletions
  1. 9 1
      desc/wechat/dashboard.api
  2. 16 1
      internal/logic/dashboard/get_charts_logic.go
  3. 10 1
      internal/types/types.go

+ 9 - 1
desc/wechat/dashboard.api

@@ -31,7 +31,7 @@ type (
         ActiveUser *ChartsUint `json:"active_user"`
         NewUser *ChartsInt `json:"new_user"`
         LabelDist []LabelsData `json:"label_dist"`
-		ConsumeCoin *ChartsFloat `json:"consume_coin"`
+		ConsumeCoin *ChartsInt `json:"consume_coin"`
     }
 
     ChartsUint {
@@ -51,6 +51,14 @@ type (
 		LabelText string `json:"labelText"`
 		Tip *string `json:"tip"`
 	}
+	ChartsStr {
+        Count string `json:"count"`
+        Rate *float32 `json:"rate"`
+        Label []string `json:"label"`
+        Val []float64 `json:"val"`
+        LabelText string `json:"labelText"`
+        Tip *string `json:"tip"`
+    }
 
     ChartsInt {
         Count int64 `json:"count"`

+ 16 - 1
internal/logic/dashboard/get_charts_logic.go

@@ -500,6 +500,21 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
 		}
 	}
 
+	consumeCoinInt := types.ChartsInt{}
+	consumeCoinInt.Val = consumeCoin.Val
+	consumeCoinInt.Label = consumeCoin.Label
+	consumeCoinInt.LabelText = consumeCoin.LabelText
+
+	if consumeCoin.Count == 0 {
+		consumeCoinInt.Count = 0
+	} else {
+		if consumeCoin.Count >= 0 {
+			consumeCoinInt.Count = int64(math.Ceil(consumeCoin.Count))
+		} else {
+			consumeCoinInt.Count = int64(-math.Ceil(-consumeCoin.Count))
+		}
+	}
+
 	chartsData := types.ChartsData{
 		AiResponse:     &aiResponse,
 		SopRun:         &sopRun,
@@ -507,7 +522,7 @@ func (l *GetChartsLogic) GetCharts(req *types.ChartsReq) (resp *types.ChartsResp
 		TotalGroup:     &totalGroup,
 		AccountBalance: &accountBalance,
 		ConsumeToken:   &consumeToken,
-		ConsumeCoin:    &consumeCoin,
+		ConsumeCoin:    &consumeCoinInt,
 		ActiveUser:     &activeUser,
 		NewUser:        &newUser,
 		LabelDist:      labelsData,

+ 10 - 1
internal/types/types.go

@@ -3592,7 +3592,7 @@ type ChartsData struct {
 	ActiveUser     *ChartsUint  `json:"active_user"`
 	NewUser        *ChartsInt   `json:"new_user"`
 	LabelDist      []LabelsData `json:"label_dist"`
-	ConsumeCoin    *ChartsFloat `json:"consume_coin"`
+	ConsumeCoin    *ChartsInt   `json:"consume_coin"`
 }
 
 type ChartsUint struct {
@@ -3613,6 +3613,15 @@ type ChartsFloat struct {
 	Tip       *string   `json:"tip"`
 }
 
+type ChartsStr struct {
+	Count     string    `json:"count"`
+	Rate      *float32  `json:"rate"`
+	Label     []string  `json:"label"`
+	Val       []float64 `json:"val"`
+	LabelText string    `json:"labelText"`
+	Tip       *string   `json:"tip"`
+}
+
 type ChartsInt struct {
 	Count     int64    `json:"count"`
 	Rate      *float32 `json:"rate"`