Explorar el Código

fix: resolve pricing calculation issue (#659)

CalciumIon hace 1 año
padre
commit
7c20e6d047
Se han modificado 1 ficheros con 6 adiciones y 8 borrados
  1. 6 8
      controller/pricing.go

+ 6 - 8
controller/pricing.go

@@ -10,18 +10,16 @@ func GetPricing(c *gin.Context) {
 	pricing := model.GetPricing()
 	userId, exists := c.Get("id")
 	usableGroup := map[string]string{}
-	groupRatio := common.GroupRatio
+	groupRatio := map[string]float64{}
+	for s, f := range common.GroupRatio {
+		groupRatio[s] = f
+	}
 	var group string
 	if exists {
 		user, err := model.GetChannelById(userId.(int), false)
-		if err != nil {
-			c.JSON(200, gin.H{
-				"success": false,
-				"message": err.Error(),
-			})
-			return
+		if err == nil {
+			group = user.Group
 		}
-		group = user.Group
 	}
 
 	usableGroup = common.GetUserUsableGroups(group)