pay.go 1.15 KB
Newer Older
wangp's avatar
wangp committed
1 2 3
package pay

import (
wangp's avatar
wangp committed
4
	"fmt"
wangp's avatar
wangp committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
	"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
wangp's avatar
wangp committed
22
// @Param   body    body  models.PlaceAnOrderParamInput   true	 "参数"
wangp's avatar
wangp committed
23 24
// @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文"
// @Success 200
wangp's avatar
wangp committed
25
// @router /api/v1/pay/unified_order [post]
wangp's avatar
wangp committed
26 27 28
func (l *PayController) UnifiedOrder(c *gin.Context) {

	ph := new(models.PlaceAnOrderParamInput)
wangp's avatar
wangp committed
29 30
	fmt.Println("ContentType="+c.ContentType())
	err := c.ShouldBindJSON(ph)
wangp's avatar
wangp committed
31 32 33 34 35 36
	if err != nil {
		zap.L().Error(err.Error())
		base.ResponseErrorWithMsg(c, base.ServerError)
		return
	}

wangp's avatar
wangp committed
37
	// 拉卡拉统一支付
wangp's avatar
wangp committed
38 39 40 41 42 43 44 45 46 47
	rtn, err := pay.UnifiedOrder(ph)
	if err != nil {
		zap.L().Error(err.Error())
		//base.ResponseErrorWithMsg(c, base.ServerError)
		base.ResponseErrorMsg(c, err.Error())
		return
	}

	base.ResponseSuccess(c, rtn)
}