Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
5d46c57a
提交
5d46c57a
authored
12月 07, 2022
作者:
zhanglibo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
itao
上级
0c433221
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
617 行增加
和
213 行删除
+617
-213
itao.go
upstream/itao/itao.go
+115
-22
itao_address.go
upstream/itao/itao_address.go
+2
-2
itao_auth.go
upstream/itao/itao_auth.go
+92
-0
itao_goods.go
upstream/itao/itao_goods.go
+259
-86
itao_logistics.go
upstream/itao/itao_logistics.go
+1
-1
itao_order.go
upstream/itao/itao_order.go
+148
-102
没有找到文件。
upstream/itao/itao.go
浏览文件 @
5d46c57a
...
...
@@ -6,24 +6,28 @@ import (
"crypto/sha1"
"encoding/hex"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gutil"
"net/url"
"sort"
"strings"
"time"
)
type
Config
struct
{
ApiUrl
string
AppKey
string
AppSecret
string
AccessToken
string
ApiUrl
string
AppKey
string
AppSecret
string
}
var
server
*
Config
const
PkgName
=
"itao"
const
CacheKey
=
"itao:token"
const
Host
=
"https://open.huoju6.com/openapi/param2/1/com.huoju6.open/"
func
New
(
req
*
Config
)
{
server
=
req
...
...
@@ -36,22 +40,20 @@ type CommonRes struct {
ErrorMessage
string
`json:"errorMessage"`
}
func
(
s
*
Config
)
CreateSign
(
signStr
string
)
(
sign
string
)
{
func
generate
(
req
string
)
(
res
string
)
{
//拼接参数
appSecret
:=
[]
byte
(
s
.
AppSecret
)
mac
:=
hmac
.
New
(
sha1
.
New
,
appSecret
)
mac
.
Write
([]
byte
(
signStr
))
mac
:=
hmac
.
New
(
sha1
.
New
,
[]
byte
(
server
.
AppSecret
))
mac
.
Write
([]
byte
(
req
))
mdStr
:=
hex
.
EncodeToString
(
mac
.
Sum
(
nil
))
sign
=
strings
.
ToUpper
(
mdStr
)
res
=
strings
.
ToUpper
(
mdStr
)
return
}
func
(
s
*
Config
)
sign
(
method
string
,
param
g
.
Map
)
g
.
Map
{
func
sign
(
method
string
,
req
g
.
Map
)
(
err
error
)
{
var
keys
[]
string
param
[
"_aop_timestamp"
]
=
gtime
.
Now
()
.
TimestampMilliStr
()
req
[
"_aop_timestamp"
]
=
gtime
.
Now
()
.
TimestampMilliStr
()
mewparam
:=
param
for
k
:=
range
mewparam
{
for
k
:=
range
req
{
keys
=
append
(
keys
,
k
)
}
...
...
@@ -61,28 +63,82 @@ func (s *Config) sign(method string, param g.Map) g.Map {
for
_
,
v
:=
range
keys
{
if
v
!=
"_aop_signature"
{
signStr
+=
v
signStr
+=
gconv
.
String
(
mewparam
[
v
])
signStr
+=
gconv
.
String
(
req
[
v
])
}
}
//拼接参数
signStr
=
"param2/1/"
+
method
+
"/"
+
s
.
AppKey
+
signStr
param
[
"_aop_signature"
]
=
s
.
CreateSign
(
signStr
)
return
param
signStr
=
"param2/1/com.huoju6.open/"
+
method
+
"/"
+
server
.
AppKey
+
signStr
req
[
"_aop_signature"
]
=
generate
(
signStr
)
return
}
func
(
s
*
Config
)
Post
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
params
[
"access_token"
],
err
=
s
.
AccessToken
(
ctx
)
if
err
!=
nil
{
return
}
str
,
err
=
Post
(
ctx
,
method
,
params
)
return
}
func
Post
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
Start
:=
gtime
.
TimestampMilli
()
err
=
sign
(
method
,
params
)
if
err
!=
nil
{
return
}
Url
:=
Host
+
method
+
"/"
+
server
.
AppKey
Request
:=
g
.
Client
()
Request
.
SetHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
resp
,
err
:=
Request
.
Timeout
(
time
.
Second
*
5
)
.
Get
(
Url
,
params
)
defer
func
()
{
_
=
resp
.
Close
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"GET"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
Url
)
if
err
!=
nil
{
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%vms】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
}
else
{
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】响应【%v】响应时间【%vms】"
,
paramStr
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
}
}()
str
=
resp
.
ReadAllString
()
return
}
func
(
s
*
Config
)
Get
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
params
[
"access_token"
],
err
=
s
.
AccessToken
(
ctx
)
if
err
!=
nil
{
return
}
str
,
err
=
Get
(
ctx
,
method
,
params
)
return
}
func
Get
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
Start
:=
gtime
.
TimestampMilli
()
allparams
:=
s
.
sign
(
method
,
params
)
Url
:=
s
.
ApiUrl
+
method
+
"/"
+
s
.
AppKey
err
=
sign
(
method
,
params
)
if
err
!=
nil
{
return
}
Url
:=
Host
+
method
+
"/"
+
server
.
AppKey
Request
:=
g
.
Client
()
Values
:=
url
.
Values
{}
for
k
,
v
:=
range
params
{
Values
.
Add
(
k
,
gconv
.
String
(
v
))
}
Request
.
SetHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
resp
,
err
:=
Request
.
Timeout
(
time
.
Second
*
5
)
.
Post
(
Url
,
allparams
)
resp
,
err
:=
Request
.
Timeout
(
time
.
Second
*
5
)
.
Get
(
Url
+
"?"
+
Values
.
Encode
()
)
defer
func
()
{
_
=
resp
.
Close
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"
POS
T"
)
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"
GE
T"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
Url
)
if
err
!=
nil
{
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%vms】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
...
...
@@ -95,3 +151,40 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str
return
}
func
(
s
*
Config
)
AccessToken
(
ctx
context
.
Context
)
(
res
string
,
err
error
)
{
var
conn
=
g
.
Redis
()
.
Conn
()
defer
func
()
{
_
=
conn
.
Close
()
}()
_
,
_
=
conn
.
DoVar
(
"SELECT"
,
10
)
cache
,
_
:=
conn
.
DoVar
(
"HGETALL"
,
CacheKey
)
if
cache
.
IsEmpty
()
{
err
=
gerror
.
New
(
"获取token 失败"
)
return
}
var
token
*
AuthTokenRes
_
=
gjson
.
New
(
cache
)
.
Scan
(
&
token
)
if
token
==
nil
{
err
=
gerror
.
New
(
"获取token 失败"
)
return
}
if
token
.
AccessTokenExpireTime
<
gtime
.
Now
()
.
TimestampMilli
()
{
if
token
.
RefreshTokenExpireTime
<
gtime
.
Now
()
.
TimestampMilli
()
{
err
=
gerror
.
New
(
"获取token 失败"
)
return
}
token
,
err
=
Auth
.
Token
(
ctx
,
token
.
RefreshToken
,
2
)
if
err
!=
nil
{
return
}
if
token
.
Code
!=
"success"
{
err
=
gerror
.
New
(
"获取token 失败"
)
return
}
_
,
_
=
conn
.
Do
(
"HMSET"
,
append
(
g
.
Slice
{
CacheKey
},
gutil
.
StructToSlice
(
token
)
...
)
...
)
}
res
=
token
.
AccessToken
return
}
upstream/itao/itao_address.go
浏览文件 @
5d46c57a
...
...
@@ -47,7 +47,7 @@ type AddressDivisionRes struct {
//Division 行政区划
func
(
s
addressItao
)
Division
(
ctx
context
.
Context
,
req
AddressDivisionReq
)
(
res
*
AddressDivisionRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.delivery
.queryDivision"
method
:=
"
tt.order
.queryDivision"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"param"
:
req
,
...
...
@@ -81,7 +81,7 @@ type AddressParseRes struct {
//Parse 地址解析
// 省、市必传
func
(
s
addressItao
)
Parse
(
ctx
context
.
Context
,
req
AddressParseReq
)
(
res
*
AddressParseRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.delivery
.validate"
method
:=
"
tt.address
.validate"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"param"
:
req
,
...
...
upstream/itao/itao_auth.go
0 → 100644
浏览文件 @
5d46c57a
package
itao
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type
auth
struct
{
}
var
Auth
=
auth
{}
type
AuthStatusRes
struct
{
Code
string
`json:"code"`
Message
string
`json:"message"`
}
//Status 授权状态
func
(
s
auth
)
Status
(
ctx
context
.
Context
)
(
res
*
AuthStatusRes
,
err
error
)
{
method
:=
"tt.authority.checkAuthStatus"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"bId"
:
server
.
AppKey
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
AuthQrCodeRes
struct
{
Code
string
`json:"code"`
Message
string
`json:"message"`
TempCode
string
`json:"tempCode"`
TempCodeExpireTime
string
`json:"tempCodeExpireTime"`
QrCodeUrl
string
`json:"qrCodeUrl"`
}
//QrCode 二维码
func
(
s
auth
)
QrCode
(
ctx
context
.
Context
)
(
res
*
AuthQrCodeRes
,
err
error
)
{
method
:=
"tt.authority.generateQrCode"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"bId"
:
server
.
AppKey
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
AuthTokenRes
struct
{
Code
string
`json:"code"`
Message
string
`json:"message"`
RefreshToken
string
`json:"refreshToken"`
AccessToken
string
`json:"accessToken"`
AccessTokenExpireTime
int64
`json:"accessTokenExpireTime"`
RefreshTokenExpireTime
int64
`json:"refreshTokenExpireTime"`
TaoteId
string
`json:"taoteId"`
TaoteNickName
string
`json:"taoteNickName"`
Feature
string
`json:"feature"`
GwTraceId
string
`json:"gw_trace_id"`
}
//Token 授权
func
(
s
auth
)
Token
(
ctx
context
.
Context
,
code
string
,
Type
int
)
(
res
*
AuthTokenRes
,
err
error
)
{
method
:=
"tt.auth.getAccessToken"
var
request
=
g
.
Map
{
"bId"
:
server
.
AppKey
,
}
if
Type
==
1
{
request
[
"code"
]
=
code
//临时令牌
request
[
"grantType"
]
=
"code"
}
else
{
request
[
"refreshToken"
]
=
code
//刷新令牌
request
[
"grantType"
]
=
"refreshToken"
}
result
,
err
:=
server
.
Get
(
ctx
,
method
,
request
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
//Unbind 注销授权
func
(
s
auth
)
Unbind
(
ctx
context
.
Context
)
(
res
*
AuthTokenRes
,
err
error
)
{
method
:=
"tt.authority.unbind"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"bId"
:
server
.
AppKey
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
upstream/itao/itao_goods.go
浏览文件 @
5d46c57a
...
...
@@ -4,6 +4,7 @@ import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type
goodsItao
struct
{
...
...
@@ -11,8 +12,52 @@ type goodsItao struct {
var
Goods
=
goodsItao
{}
type
GoodsListReq
struct
{
Q
string
`json:"q,omitempty"`
//关键词
Sort
string
`json:"sort,omitempty"`
//排序参数 价格降序:sort=price:des 价格升序:sort=price:asc 综合排序:sort=popular:des 销量降序:sort=sales:des
Price
string
`json:"price,omitempty"`
Cate
string
`json:"cate,omitempty"`
S
int
`json:"s,omitempty"`
N
int
`json:"n,omitempty"`
Feature
string
`json:"feature,omitempty"`
}
type
GoodsListRes
struct
{
ErrorMessage
string
`json:"error_message"`
ErrorCode
string
`json:"error_code"`
TotalCount
int
`json:"totalCount"`
PageIndex
int
`json:"pageIndex"`
PageSize
int
`json:"pageSize"`
Auctions
[]
struct
{
Nid
string
`json:"nid"`
Title
string
`json:"title"`
ReservePrice
string
`json:"reservePrice"`
ZkFinalPrice
string
`json:"zkFinalPrice"`
TejiaTotalSoldQuantity
string
`json:"tejiaTotalSoldQuantity"`
PictUrl
string
`json:"pictUrl"`
LevelOneCat
string
`json:"levelOneCat"`
Category
string
`json:"category"`
}
`json:"auctions"`
}
func
(
goodsItao
)
List
(
ctx
context
.
Context
,
req
GoodsListReq
)
(
res
*
GoodsListRes
,
err
error
)
{
method
:=
"tt.item.list"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
gconv
.
Map
(
req
))
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
GoodsDetailReq
struct
{
AppKey
int
`json:"appKey"`
ItemId
string
`json:"itemId"`
SkuId
string
`json:"skuId,omitempty"`
}
type
GoodsDetailRes
struct
{
Result
struct
{
ErrorMessage
string
`json:"error_message"`
ErrorCode
string
`json:"error_code"`
Result
struct
{
DebugInfoMap
struct
{
TraceId
string
`json:"traceId"`
}
`json:"debugInfoMap"`
...
...
@@ -75,111 +120,239 @@ type GoodsItem struct {
PriceMoney
string
`json:"priceMoney"`
}
//Detail 详情
[实时]
//Detail 详情
func
(
goodsItao
)
Detail
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDetailRes
,
err
error
)
{
method
:=
"com.alibaba.c2m/ltao.detail.jnpiter.getDetail"
method
:=
"tt.item.detail.v2"
var
request
=
GoodsDetailReq
{
AppKey
:
gconv
.
Int
(
server
.
AppKey
),
ItemId
:
GoodsID
,
SkuId
:
""
,
}
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"parameters"
:
g
.
Map
{
"itemId"
:
GoodsID
,
"itemId"
:
request
,
},
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
GoodsDynamicRes
struct
{
Result
struct
{
Data
[]
struct
{
DebugInfoMap
struct
{
TraceId
string
`json:"traceId"`
}
`json:"debugInfoMap"`
EnterNewLink
string
`json:"enterNewLink"`
Sku2Info
map
[
string
]
GoodsItem
`json:"sku2info"`
}
`json:"data"`
ItemIds
string
`json:"itemIds"`
Time
int
`json:"time"`
}
`json:"result"`
type
GoodsDescRes
struct
{
ErrorMessage
string
`json:"error_message"`
ErrorCode
string
`json:"error_code"`
Components
*
GoodsDescItem
`json:"components"`
}
//Dynamic 详情[动态]
func
(
goodsItao
)
Dynamic
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDynamicRes
,
err
error
)
{
method
:=
"com.alibaba.c2m/ltao.detail.csp.getDetailDynamic"
type
GoodsDescJson
struct
{
ErrorMessage
string
`json:"error_message"`
ErrorCode
string
`json:"error_code"`
Components
string
`json:"components"`
}
type
GoodsDescItem
struct
{
ComponentData
struct
{
DetailPic1
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_1"`
DetailPic10
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_10"`
DetailPic11
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_11"`
DetailPic12
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_12"`
DetailPic2
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_2"`
DetailPic3
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_3"`
DetailPic4
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_4"`
DetailPic5
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_5"`
DetailPic6
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_6"`
DetailPic7
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_7"`
DetailPic8
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_8"`
DetailPic9
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_9"`
DetailPicTmallPriceDesc
struct
{
Actions
[]
string
`json:"actions"`
Children
[]
interface
{}
`json:"children"`
Model
struct
{
LocateId
string
`json:"locateId"`
PicUrl
string
`json:"picUrl"`
}
`json:"model"`
Styles
struct
{
Size
struct
{
Height
string
`json:"height"`
Width
string
`json:"width"`
}
`json:"size"`
}
`json:"styles"`
}
`json:"detail_pic_tmallPriceDesc"`
}
`json:"componentData"`
Layout
[]
struct
{
ID
string
`json:"ID"`
Key
string
`json:"key"`
}
`json:"layout"`
}
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"parameters"
:
g
.
Map
{
"itemIds"
:
GoodsID
,
},
//Desc 详情描述
func
(
goodsItao
)
Desc
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDescRes
,
err
error
)
{
method
:=
"tt.item.desc"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"itemId"
:
GoodsID
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
var
data
*
GoodsDescJson
err
=
gjson
.
New
(
result
)
.
Scan
(
&
data
)
if
err
!=
nil
{
return
}
if
data
.
ErrorCode
!=
""
{
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
res
=
new
(
GoodsDescRes
)
_
=
gjson
.
New
(
data
.
Components
)
.
Scan
(
&
res
.
Components
)
return
}
type
GoodBatchRes
struct
{
Result
struct
{
Data
[]
struct
{
DebugInfoMap
struct
{
TraceId
string
`json:"traceId"`
}
`json:"debugInfoMap"`
EnterNewLink
string
`json:"enterNewLink"`
Item
struct
{
CategoryId
[]
string
`json:"categoryId"`
CategoryName
[]
string
`json:"categoryName"`
City
string
`json:"city"`
FastPostFee
int
`json:"fastPostFee"`
Images
[]
string
`json:"images"`
ItemId
string
`json:"itemId"`
ItemServices
[]
struct
{
ActionTitle
string
`json:"actionTitle,omitempty"`
ActionUrl
string
`json:"actionUrl,omitempty"`
Desc
string
`json:"desc"`
Title
string
`json:"title"`
}
`json:"itemServices"`
MainPic
string
`json:"mainPic"`
OrdinaryPostFee
int
`json:"ordinaryPostFee"`
Props
[]
struct
{
Content
string
`json:"content"`
Word
string
`json:"word"`
}
`json:"props"`
Prov
string
`json:"prov"`
Receipt
bool
`json:"receipt"`
SoldQuantity
int
`json:"soldQuantity"`
Status
int
`json:"status"`
Title
string
`json:"title"`
}
`json:"item"`
Seller
struct
{
ShopName
string
`json:"shopName"`
}
`json:"seller"`
Sku2Info
map
[
string
]
GoodsItem
`json:"sku2info"`
SkuBase
struct
{
Props
[]
struct
{
Name
string
`json:"name"`
Pid
string
`json:"pid"`
Values
[]
struct
{
Image
string
`json:"image"`
Name
string
`json:"name"`
Vid
string
`json:"vid"`
}
`json:"values"`
}
`json:"props"`
Skus
[]
struct
{
PropPath
string
`json:"propPath"`
SkuId
string
`json:"skuId"`
}
`json:"skus"`
}
`json:"skuBase"`
}
`json:"data"`
ItemIds
string
`json:"itemIds"`
Time
int
`json:"time"`
}
`json:"result"`
type
GoodsCategoryRes
struct
{
ErrorMessage
string
`json:"error_message"`
ErrorCode
string
`json:"error_code"`
CateNameLists
[]
string
`json:"cateNameLists"`
Code
string
`json:"code"`
ItemId
string
`json:"itemId"`
ItemName
string
`json:"itemName"`
Message
string
`json:"message"`
}
//
Batch 详情[批量]
func
(
goodsItao
)
Batch
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodBatch
Res
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.detail.csp.getDetail
"
//
Category 商品类目
func
(
goodsItao
)
Category
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsCategory
Res
,
err
error
)
{
method
:=
"
tt.item.cateInfo
"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"parameters"
:
g
.
Map
{
"itemIds"
:
GoodsID
,
},
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"itemId"
:
GoodsID
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
...
...
upstream/itao/itao_logistics.go
浏览文件 @
5d46c57a
...
...
@@ -46,7 +46,7 @@ type LogisticsTraceRes struct {
//Trace 物流轨迹
func
(
logisticsItao
)
Trace
(
ctx
context
.
Context
,
req
string
)
(
res
*
LogisticsTraceRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.logistics.queryD
etail"
method
:=
"
tt.logistics.d
etail"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
...
...
upstream/itao/itao_order.go
浏览文件 @
5d46c57a
...
...
@@ -2,8 +2,10 @@ package itao
import
(
"context"
"fmt"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
)
...
...
@@ -139,7 +141,7 @@ type OrderPromotion struct {
//Before 前置校验
func
(
s
orderItao
)
Before
(
ctx
context
.
Context
,
req
OrderBeforeReq
)
(
res
*
OrderBeforeRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.trade.renderOr
der"
method
:=
"
tt.order.ren
der"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
...
...
@@ -193,8 +195,11 @@ type OrderCreateRes struct {
//Create 下单
func
(
s
orderItao
)
Create
(
ctx
context
.
Context
,
req
OrderCreateReq
)
(
res
*
OrderCreateRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.trade.createAndEnableOrder
"
method
:=
"
tt.order.create
"
for
k
,
item
:=
range
req
.
List
{
req
.
List
[
k
]
.
OrderSn
=
s
.
outId
(
item
.
OrderSn
)
}
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
})
...
...
@@ -204,51 +209,31 @@ func (s orderItao) Create(ctx context.Context, req OrderCreateReq) (res *OrderCr
return
}
func
(
s
orderItao
)
outId
(
req
string
)
(
res
string
)
{
res
=
gstr
.
SubStr
(
req
,
2
,
-
1
)
res
=
gstr
.
Replace
(
res
,
"_15_"
,
"_"
)
return
fmt
.
Sprintf
(
"%s_%s"
,
server
.
AppKey
,
res
)
}
type
OrderDetailRes
struct
{
Result
struct
{
Result
struct
{
BizOrderId
int64
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
DetailOrderList
[]
struct
{
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
EndTime
string
`json:"endTime"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
Main
int
`json:"main"`
ParentId
int64
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayOrderId
int64
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
PayTime
string
`json:"payTime"`
PostFee
uint
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"detailOrderList"`
EndTime
string
`json:"endTime"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
Result
struct
{
BizOrderId
int64
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
DetailOrderList
[]
struct
{
BizOrderId
int64
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
int64
`json:"itemId"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
Price
string
`json:"price"`
SkuId
int64
`json:"skuId"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
...
...
@@ -266,7 +251,7 @@ type OrderDetailRes struct {
//8 - 还未创建物流订单
Main
int
`json:"main"`
ParentId
int64
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayFee
int
`json:"payFee"`
PayOrderId
int64
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
//1 - 未冻结/未付款 -> 等待买家付款
...
...
@@ -277,20 +262,55 @@ type OrderDetailRes struct {
//8 - 交易被关闭
//9 - 不可付款
PayTime
string
`json:"payTime"`
PostFee
uint
`json:"postFee"`
PostFee
int
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
}
`json:"detailOrderList"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
int64
`json:"itemId"`
Pic
string
`json:"pic"`
Price
string
`json:"price"`
SkuId
int64
`json:"skuId"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
//1 - 未发货 -> 等待卖家发货
//2 - 已发货 -> 等待买家确认收货
//3 - 已收货 -> 交易成功
//4 - 已经退货 -> 交易失败
//5 - 部分收货 -> 交易成功
//6 - 部分发货中
//8 - 还未创建物流订单
Main
int
`json:"main"`
ParentId
int64
`json:"parentId"`
PayFee
int
`json:"payFee"`
PayOrderId
int64
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
//1 - 未冻结/未付款 -> 等待买家付款
//2 - 已冻结/已付款 -> 等待卖家发货
//4 - 已退款 -> 交易关闭
//6 - 已转交易 -> 交易成功
//7 - 没有创建外部交易
//8 - 交易被关闭
//9 - 不可付款
PayTime
string
`json:"payTime"`
PostFee
int
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"result"`
}
//Detail 详情
func
(
s
orderItao
)
Detail
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
OrderDetailRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.trade.queryOrder
"
method
:=
"
tt.order.detail
"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
...
...
@@ -305,39 +325,17 @@ func (s orderItao) Detail(ctx context.Context, req interface{}) (res *OrderDetai
type
OrderReflectRes
struct
{
Result
struct
{
Result
struct
{
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
uint
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
DetailOrderList
[]
struct
{
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
uint
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
interface
{}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
Main
int
`json:"main"`
ParentId
int64
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayOrderId
int64
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
PostFee
uint
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"detailOrderList"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
uint
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
DetailOrderList
[]
struct
{
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
uint
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
...
...
@@ -345,31 +343,79 @@ type OrderReflectRes struct {
SkuInfoList
[]
interface
{}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
Main
int
`json:"main"`
ParentId
string
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayOrderId
string
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
PostFee
uint
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
//1 - 未发货 -> 等待卖家发货
//2 - 已发货 -> 等待买家确认收货
//3 - 已收货 -> 交易成功
//4 - 已经退货 -> 交易失败
//5 - 部分收货 -> 交易成功
//6 - 部分发货中
//8 - 还未创建物流订单
Main
int
`json:"main"`
ParentId
int64
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayOrderId
int64
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
//1 - 未冻结/未付款 -> 等待买家付款
//2 - 已冻结/已付款 -> 等待卖家发货
//4 - 已退款 -> 交易关闭
//6 - 已转交易 -> 交易成功
//7 - 没有创建外部交易
//8 - 交易被关闭
//9 - 不可付款
PostFee
uint
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"detailOrderList"`
GmtCreate
string
`json:"gmtCreate"`
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
interface
{}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsStatus
int
`json:"logisticsStatus"`
//1 - 未发货 -> 等待卖家发货
//2 - 已发货 -> 等待买家确认收货
//3 - 已收货 -> 交易成功
//4 - 已经退货 -> 交易失败
//5 - 部分收货 -> 交易成功
//6 - 部分发货中
//8 - 还未创建物流订单
Main
int
`json:"main"`
ParentId
string
`json:"parentId"`
PayFee
uint
`json:"payFee"`
PayOrderId
string
`json:"payOrderId"`
PayStatus
int
`json:"payStatus"`
//1 - 未冻结/未付款 -> 等待买家付款
//2 - 已冻结/已付款 -> 等待卖家发货
//4 - 已退款 -> 交易关闭
//6 - 已转交易 -> 交易成功
//7 - 没有创建外部交易
//8 - 交易被关闭
//9 - 不可付款
PostFee
uint
`json:"postFee"`
RefundStatus
int
`json:"refundStatus"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
}
//Reflect 详情[反查]
func
(
s
orderItao
)
Reflect
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderReflectRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.trade.queryOrderByOutI
d"
method
:=
"
tt.order.detail.outi
d"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"outOrderId"
:
req
,
"outOrderId"
:
s
.
outId
(
req
)
,
},
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论