MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / RequestAmount

Function RequestAmount

controller/topup.go:241–265  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

239}
240
241func RequestAmount(c *gin.Context) {
242 var req AmountRequest
243 err := c.ShouldBindJSON(&req)
244 if err != nil {
245 c.JSON(200, gin.H{"message": "error", "data": "参数错误"})
246 return
247 }
248
249 if req.Amount < getMinTopup() {
250 c.JSON(200, gin.H{"message": "error", "data": fmt.Sprintf("充值数量不能小于 %d", getMinTopup())})
251 return
252 }
253 id := c.GetInt("id")
254 group, err := model.GetUserGroup(id, true)
255 if err != nil {
256 c.JSON(200, gin.H{"message": "error", "data": "获取用户分组失败"})
257 return
258 }
259 payMoney := getPayMoney(req.Amount, group)
260 if payMoney <= 0.01 {
261 c.JSON(200, gin.H{"message": "error", "data": "充值金额过低"})
262 return
263 }
264 c.JSON(200, gin.H{"message": "success", "data": strconv.FormatFloat(payMoney, 'f', 2, 64)})
265}

Callers

nothing calls this directly

Calls 3

GetUserGroupFunction · 0.92
getMinTopupFunction · 0.85
getPayMoneyFunction · 0.85

Tested by

no test coverage detected