You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.9 KiB

package api
import (
"epur-pay/model"
"epur-pay/pkg/dapi"
"epur-pay/pkg/logger"
"github.com/shopspring/decimal"
)
type TestParams struct {
model.Http
}
type TestResponse struct {
*dapi.ResponseCommon
Data struct {
RequestQuery interface{} `json:"requestQuery"`
RequestBody interface{} `json:"requestBody"`
Response interface{} `json:"response"`
} `json:"data"` //数据列表
}
func Test(a *dapi.ApiBase, data *TestParams) error {
Response := TestResponse{
ResponseCommon: a.NewSuccessResponseCommon(),
}
//fmt.Println(utils.ToJson(data))
if req, err := data.Do(); err != nil {
return a.ReturnPublicErrorResponse(err.Error())
} else {
Response.Data.RequestQuery = req.QueryParams
Response.Data.RequestBody = req.Body
Response.Data.Response = string(req.Result)
}
return a.ReturnSuccessCustomResponse(Response)
}
type Test1Params struct {
Amount decimal.Decimal `json:"amount"`
OrderId string `json:"orderId"`
}
type Test1Response struct {
*dapi.ResponseCommon
Data struct {
Url string `json:"url"` // 支付连接
Status string `json:"status"` // 支付状态 0-成功 1-失败
} `json:"data"` //数据列表
}
func Test1(a *dapi.ApiBase, data *Test1Params) error {
logger.AccessLogger.Infoln(a.C.Query("11"))
logger.AccessLogger.Infof("支付金额[%s] 订单号[%s]", data.Amount, data.OrderId)
Response := Test1Response{}
Response.ResponseCommon = a.NewSuccessResponseCommon()
Response.Data.Url = "https://www.baidu.com"
Response.Data.Status = "0"
return a.ReturnSuccessCustomResponse(Response)
}
//
//type Test2Params struct {
// model.Http
//}
//
//func Test2(a *dapi.ApiBase, data *Test2Params) error {
//
// Response := TestResponse{}
//
// if req, err := data.Do(); err != nil {
// return a.ReturnPublicErrorResponse(err.Error())
// } else {
// Response.ResponseCommon = a.NewSuccessResponseCommon()
// Response.Data = string(req.Result)
// }
//
// return a.ReturnSuccessCustomResponse(Response)
//}