提交 16157917 authored 作者: zhanglibo's avatar zhanglibo

天猫sdk

上级 7b94255e
...@@ -11,13 +11,12 @@ import ( ...@@ -11,13 +11,12 @@ import (
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/grand" "github.com/gogf/gf/util/grand"
"net/url" "net/url"
"reflect"
"sort" "sort"
"strings" "strings"
"time" "time"
) )
const Source = 7
type Config struct { type Config struct {
AppKey string AppKey string
AppSecret string AppSecret string
...@@ -26,7 +25,7 @@ type Config struct { ...@@ -26,7 +25,7 @@ type Config struct {
var server *Config var server *Config
const Name = "tm" const PkgName = "tm"
const ( const (
apiUrl string = "http://linkedmall.aliyuncs.com/" apiUrl string = "http://linkedmall.aliyuncs.com/"
...@@ -113,7 +112,7 @@ func post(ctx context.Context, method string, params map[string]string) (str str ...@@ -113,7 +112,7 @@ func post(ctx context.Context, method string, params map[string]string) (str str
if err != nil { if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Ctx(ctx).Cat(Name).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
...@@ -125,7 +124,13 @@ func convert(pre string, req []map[string]interface{}) (res map[string]string) { ...@@ -125,7 +124,13 @@ func convert(pre string, req []map[string]interface{}) (res map[string]string) {
res = make(map[string]string) res = make(map[string]string)
for k, v := range req { for k, v := range req {
for key, val := range v { for key, val := range v {
res[pre+"."+gconv.String(k+1)+"."+key] = gconv.String(val) if reflect.TypeOf(val).String() == "[]string" {
for key2, val2 := range gconv.Strings(val) {
res[pre+"."+gconv.String(k+1)+"."+key+"."+gconv.String(key2+1)] = gconv.String(val2)
}
} else {
res[pre+"."+gconv.String(k+1)+"."+key] = gconv.String(val)
}
} }
} }
return return
......
...@@ -12,8 +12,8 @@ type goodsTm struct { ...@@ -12,8 +12,8 @@ type goodsTm struct {
var Goods = goodsTm{} var Goods = goodsTm{}
type GoodsInventoryReq struct { type GoodsInventoryReq struct {
ItemId string `json:"itemId"` ItemId string `json:"ItemId"`
SkuIdList []string `json:"skuIdList"` SkuIdList []string `json:"SkuIdList"`
} }
type GoodsInventoryRes struct { type GoodsInventoryRes struct {
......
...@@ -15,15 +15,15 @@ var Order = orderTm{} ...@@ -15,15 +15,15 @@ var Order = orderTm{}
type OrderGoodsItem struct { type OrderGoodsItem struct {
ItemId string `json:"ItemId"` ItemId string `json:"ItemId"`
SkuId string `json:"SkuId"`
Quantity string `json:"Quantity"` Quantity string `json:"Quantity"`
SkuId string `json:"SkuId"`
} }
type OrderAddress struct { type OrderAddress struct {
AddressDetail string `json:"AddressDetail"`
DivisionCode string `json:"DivisionCode"` DivisionCode string `json:"DivisionCode"`
FullName string `json:"FullName"` FullName string `json:"FullName"`
Mobile string `json:"Mobile"` Mobile string `json:"Mobile"`
AddressDetail string `json:"AddressDetail"`
} }
type OrderBeforeRes struct { type OrderBeforeRes struct {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论