123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package v1
- import (
- "encoding/json"
- "sfbase/global"
- "sfis/model/response"
- "sfis/service"
- "strconv"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- )
- //充值相关接口服务
- func RechargeApiRegister(router *gin.Engine) {
- routerGroup := router.Group("/sfis/api/v1/user/")
- routerGroup.Use()
- {
- routerGroup.POST("/moneyRecharge", moneyRecharge)
- routerGroup.POST("/productRecharge", productRecharge)
- }
- }
- //余额充值接口
- 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,
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- global.Logger.Info("api moneyRecharge:", zap.Any("param:", param))
- service.MoneyRecharge(appid, money, 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,
- }
- bs, _ := json.Marshal(p)
- param := string(bs)
- global.Logger.Info("api productRecharge:", zap.Any("param:", param))
- service.ProductRecharge(appid, productId, rechargeNum, endTime, c)
- }
|