package user import ( "sfbase/global" "sfis/model/response" "sfis/service" "strconv" "github.com/gin-gonic/gin" "go.uber.org/zap" ) //余额充值接口 func moneyRecharge(c *gin.Context) { appid := c.PostForm("appid") money, err := strconv.Atoi(c.PostForm("money")) if err != nil { response.FailWithDetailed(response.ParamError, nil, "参数错误", c) } p := gin.H{ "appid": appid, "money": money, } global.Logger.Info("api moneyRecharge:", zap.Any("param:", p)) errs := service.MoneyRecharge(appid, money, c) if errs == nil { response.Ok(c) } else { global.Logger.Error("数据库操作失败", zap.Any("error:", errs)) response.FailWithMessage("充值失败", c) } } //产品剩余量充值接口 func productRecharge(c *gin.Context) { appid := c.PostForm("appid") productId, err := strconv.Atoi(c.PostForm("productId")) rechargeNum, errs := strconv.Atoi(c.PostForm("rechargeNum")) endTime := c.PostForm("endTime") if err != nil || errs != nil { response.FailWithDetailed(response.ParamError, nil, "参数错误", c) } p := gin.H{ "appid": appid, "productId": productId, "rechargeNum": rechargeNum, "endTime": endTime, } global.Logger.Info("api productRecharge:", zap.Any("param:", p)) errss := service.ProductRecharge(appid, productId, rechargeNum, endTime, c) if errs == nil { response.Ok(c) } else { global.Logger.Error("数据库操作失败", zap.Any("error:", errss)) response.FailWithMessage("充值失败", c) } }