This commit is contained in:
邹宗楠
2023-04-06 18:25:24 +08:00
parent 18572ce050
commit 88e7b96fec
10 changed files with 457 additions and 18 deletions

View File

@@ -17,9 +17,14 @@ const (
// KuaiShouBashUrl 基础域名
KuaiShouBashUrl = "https://open.kuaishou.com" // 域名
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token
KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token
KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口
KuaiShouGetOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_order" // 获取订单详情接口
KuaiShouRefundOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/apply_refund" // 订单退款
KuaiShouRefundOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_refund" // 订单退款详情
KuaiShouGetSettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/settle" // 刷新订单结算信息
KuaiShouQuerySettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_settle" // 查询订单的结算信息
)
type API struct {
@@ -82,8 +87,9 @@ 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))
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode()))
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
return request
},
a.config,
@@ -137,8 +143,6 @@ func (a *API) sign(param map[string]interface{}) string {
sort.Strings(paramsArr)
globals.SugarLogger.Debugf("param := %s", utils.Format4Output(param, false))
globals.SugarLogger.Debugf("paramsArr := %s", utils.Format4Output(paramsArr, false))
signParma := make([]string, len(paramsArr))
for k, v := range paramsArr {
if !utils.IsNil(param[v]) {