1'|
This commit is contained in:
@@ -1,31 +1,34 @@
|
||||
package kuaishou_mini
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
// PreCreateOrder 预下单生成支付信息
|
||||
//func (a *API) PreCreateOrder(param *PreCreateOrderRes) error {
|
||||
// if a.appId == "" || a.appSecret == "" {
|
||||
// return error
|
||||
// }
|
||||
//
|
||||
// result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param))
|
||||
// if err != nil {
|
||||
// return "", "", err
|
||||
// }
|
||||
//
|
||||
// auth := GetLoginAuth{}
|
||||
// if err := utils.Map2StructByJson(result, &auth, false); err != nil {
|
||||
// return "", "", err
|
||||
// }
|
||||
//
|
||||
// if auth.Error != "" {
|
||||
// return "", "", errors.New(auth.ErrorMsg)
|
||||
// }
|
||||
//
|
||||
// return auth.SessionKey, auth.OpenId, nil
|
||||
//}
|
||||
func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) {
|
||||
if a.appId == "" || a.appSecret == "" {
|
||||
return "", errors.New("appId/appSecret 不能为空")
|
||||
}
|
||||
|
||||
param.Sign = a.sign(utils.Struct2MapByJson(param))
|
||||
result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
order := PreCreateOrderResponse{}
|
||||
if err := utils.Map2StructByJson(result, &order, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if order.Result != 1 {
|
||||
return "", errors.New(order.ErrorMsg)
|
||||
}
|
||||
|
||||
return order.OrderInfo, nil
|
||||
}
|
||||
|
||||
func (a *API) FullUrl(bashUrl string) string {
|
||||
return fmt.Sprintf(bashUrl+"?app_id=%s&access_token=%s", a.appId, a.accessToken)
|
||||
|
||||
Reference in New Issue
Block a user