33 lines
1014 B
Go
33 lines
1014 B
Go
package front
|
|
|
|
import (
|
|
"PaymentCenter/app/constants/errorcode"
|
|
"PaymentCenter/app/http/controllers"
|
|
"PaymentCenter/app/http/entities/front"
|
|
"PaymentCenter/app/services"
|
|
"PaymentCenter/app/services/thirdpay"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Pay(c *gin.Context) {
|
|
req := controllers.GetRequest(c).(*front.PayReqs)
|
|
appCheckInfo := controllers.GetAppCheckInfo(c).(*services.AppCheck)
|
|
check := thirdpay.ThirdPayCheck(c.Request.Context(), req, appCheckInfo, c.ClientIP())
|
|
if check.CheckCode != errorcode.Success {
|
|
if check.CheckCode == errorcode.OrdersExist {
|
|
//订单已存在,直接返回订单信息
|
|
controllers.ApiRes(c, thirdpay.PayCallBack(check.OldOrder, false), errorcode.Success)
|
|
return
|
|
}
|
|
controllers.ApiRes(c, nil, check.CheckCode)
|
|
return
|
|
}
|
|
payInfo := thirdpay.ThirdPayWeb(check)
|
|
if payInfo.PayCode != errorcode.Success {
|
|
controllers.ApiRes(c, nil, payInfo.PayCode)
|
|
return
|
|
}
|
|
controllers.ApiRes(c, thirdpay.PayCallBack(payInfo.Order, true), errorcode.Success)
|
|
return
|
|
}
|