1
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -15,7 +14,7 @@ import (
|
||||
|
||||
const (
|
||||
// KuaiShouBashUrl 基础域名
|
||||
KuaiShouBashUrl = "https://open.kuaishou.com" // 域名
|
||||
KuaiShouBashUrl = "http://open.kuaishou.com" // 域名
|
||||
|
||||
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
|
||||
KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token
|
||||
@@ -87,10 +86,8 @@ func (a *API) GetToken() error {
|
||||
func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
globals.SugarLogger.Debugf("====param := %s", utils.Format4Output(params, false))
|
||||
globals.SugarLogger.Debugf("====url := %s", utils.Format4Output(url, false))
|
||||
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Format4Output(params, false)))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
|
||||
@@ -44,9 +44,14 @@ type PreCreateOrderReq struct {
|
||||
|
||||
// PreCreateOrderResponse 预下单返回参数
|
||||
type PreCreateOrderResponse struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
OrderInfo string `json:"order_info"` //拉起收银台的 orderInfo
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
OrderInfo CreateOrderResponseInfo `json:"order_info"` //拉起收银台的 orderInfo
|
||||
}
|
||||
|
||||
type CreateOrderResponseInfo struct {
|
||||
OrderInfoToken string `json:"order_info_token"`
|
||||
OrderNo string `json:"order_no"`
|
||||
}
|
||||
|
||||
// GetOrderDetailRes 获取支付订单详情
|
||||
|
||||
@@ -9,27 +9,26 @@ import (
|
||||
)
|
||||
|
||||
// PreCreateOrder 预下单生成支付信息
|
||||
func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) {
|
||||
func (a *API) PreCreateOrder(param *PreCreateOrderReq) (*CreateOrderResponseInfo, error) {
|
||||
if a.appId == "" || a.appSecret == "" {
|
||||
return "", errors.New("appId/appSecret 不能为空")
|
||||
return nil, errors.New("appId/appSecret 不能为空")
|
||||
}
|
||||
|
||||
param.Sign = a.sign(utils.Struct2MapByJson(param))
|
||||
result, err := a.AccessAPI1(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
order := PreCreateOrderResponse{}
|
||||
if err := utils.Map2StructByJson(result, &order, false); err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if order.Result != 1 {
|
||||
return "", errors.New(order.ErrorMsg)
|
||||
return nil, errors.New(order.ErrorMsg)
|
||||
}
|
||||
|
||||
return order.OrderInfo, nil
|
||||
return &order.OrderInfo, nil
|
||||
}
|
||||
|
||||
// GetOrderDetail 订单详情查询接口
|
||||
|
||||
Reference in New Issue
Block a user