瀏覽代碼

修复充值bug

CaIon 2 年之前
父節點
當前提交
16aabbc490
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      controller/topup.go

+ 9 - 0
controller/topup.go

@@ -51,6 +51,11 @@ func RequestEpay(c *gin.Context) {
 		c.JSON(200, gin.H{"message": err.Error(), "data": 10})
 		return
 	}
+	if req.Amount < 1 {
+		c.JSON(200, gin.H{"message": "充值金额不能小于1", "data": 10})
+		return
+	}
+
 	id := c.GetInt("id")
 	amount := GetAmount(float64(req.Amount))
 
@@ -157,6 +162,10 @@ func RequestAmount(c *gin.Context) {
 		c.JSON(200, gin.H{"message": "error", "data": "参数错误"})
 		return
 	}
+	if req.Amount < 1 {
+		c.JSON(200, gin.H{"message": "error", "data": "充值金额不能小于1"})
+		return
+	}
 
 	c.JSON(200, gin.H{"message": "success", "data": GetAmount(float64(req.Amount))})
 }