package pay import ( "fmt" "github.com/gin-gonic/gin" "go.uber.org/zap" "system_pay/controller/base" "system_pay/models" "system_pay/repository/pay" ) // 卡拉卡统一支付 type PayController struct { } // UnifiedOrder 拉卡拉统一支付 // @Summary 拉卡拉统一支付 // @Description 拉卡拉统一支付 // @Tags 拉卡拉统一支付 // @Accept application/json // @Produce application/json // @Param body body models.PlaceAnOrderParamInput true "参数" // @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文" // @Success 200 // @router /api/v1/pay/unified_order [post] func (l *PayController) UnifiedOrder(c *gin.Context) { ph := new(models.PlaceAnOrderParamInput) //fmt.Println("ContentType="+c.ContentType()) err := c.ShouldBindJSON(ph) if err != nil { zap.L().Error(err.Error()) base.ResponseErrorWithMsg(c, base.ServerError) return } // clientIp ip //ip = c.Ctx.Input.IP() ip := c.ClientIP() fmt.Println("ip="+ip) // 拉卡拉统一支付 rtn, err := pay.UnifiedOrder(ph, ip) if err != nil { zap.L().Error(err.Error()) //base.ResponseErrorWithMsg(c, base.ServerError) base.ResponseErrorMsg(c, err.Error()) return } base.ResponseSuccess(c, rtn) } // UnifiedRefund 拉卡拉退款 // @Summary 拉卡拉退款 // @Description 拉卡拉退款 // @Tags 拉卡拉退款 // @Accept application/json // @Produce application/json // @Param body body models.RefundParamInput true "参数" // @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文" // @Success 200 // @router /api/v1/pay/unified_refund [post] func (l *PayController) UnifiedRefund(c *gin.Context) { ph := new(models.RefundParamInput) err := c.ShouldBindJSON(ph) if err != nil { zap.L().Error(err.Error()) base.ResponseErrorWithMsg(c, base.ServerError) return } ip := c.ClientIP() fmt.Println("ip="+ip) // 拉卡拉退款 rtn, err := pay.UnifiedRefund(ph, ip) if err != nil { zap.L().Error(err.Error()) base.ResponseErrorMsg(c, err.Error()) return } base.ResponseSuccess(c, rtn) }