支付宝 支付
This commit is contained in:
@@ -4,13 +4,11 @@ import (
|
||||
"common/remark"
|
||||
"common/resultStatus"
|
||||
"common/webServer"
|
||||
"goutil/intUtil"
|
||||
"goutil/logUtilPlus"
|
||||
"goutil/webUtil"
|
||||
"net/http"
|
||||
"paycenter/internal"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -72,12 +70,6 @@ func (a *PayApi) PlaceAnOrder(orderId int64, modelID int32, currency int64, stor
|
||||
|
||||
//获取对应充值配置
|
||||
|
||||
orderId, err := intUtil.ShuffleIntDigits(time.Now().UnixNano())
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.DataError)
|
||||
return
|
||||
}
|
||||
|
||||
//客户端请求ip
|
||||
clientIp := webUtil.GetRequestIP(r)
|
||||
|
||||
@@ -167,3 +159,54 @@ func (a *PayApi) CallBack(orderIDStr string) (responseObj *webServer.ResponseObj
|
||||
|
||||
return responseObj
|
||||
}
|
||||
|
||||
func init() {
|
||||
moduleName := "PayApi"
|
||||
methodName := "AliPayPlaceAnOrder"
|
||||
skipVerifyTokenPage := true
|
||||
methodDesc := "下单"
|
||||
methodAuthor := "tangping"
|
||||
methodMendor := ""
|
||||
methodDate := "2025年1月8日15:51:34"
|
||||
methodInParam := []string{"int64:订单id(由服务器生成),int32:充值模版id,int64:充值金额,string:商品id, string:客户端IP地址,string:玩家id,int32:区服id"}
|
||||
methodOutParam := `
|
||||
{
|
||||
"Code '类型:int'": "响应结果的状态值",
|
||||
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||
"Data '类型:interface{}'": "响应结果的数据"
|
||||
{
|
||||
"OrderID '类型:int64'": "订单id",
|
||||
"prepayId '类型:int64'": "预支付会话id",
|
||||
}
|
||||
}`
|
||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||
}
|
||||
|
||||
func (a *PayApi) AliPayPlaceAnOrder(orderId int64, modelID int32, currency int64, storeId string, playerID string, serverID int64, r *http.Request) (responseObj *webServer.ResponseObject) {
|
||||
responseObj = webServer.GetInitResponseObj()
|
||||
if orderId == 0 || modelID == 0 || playerID == "" || serverID == 0 {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//客户端请求ip
|
||||
clientIp := webUtil.GetRequestIP(r)
|
||||
|
||||
//下微信订单
|
||||
prepayId, err := internal.AliPayPlace(orderId, currency, storeId, clientIp, "描述!!!!!!!!!!")
|
||||
if err != nil {
|
||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||
return
|
||||
}
|
||||
|
||||
//处理数据
|
||||
order := NewOrder(orderId, prepayId, playerID, serverID, 1)
|
||||
|
||||
//添加到数据库
|
||||
AddOrder(order)
|
||||
|
||||
resultMap := make(map[string]any)
|
||||
resultMap["orderID"] = order.OrderID
|
||||
resultMap["prepayId"] = order.PrepayId
|
||||
responseObj.SetData(resultMap)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user