Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
ec5fe1a2
提交
ec5fe1a2
authored
12月 09, 2022
作者:
zhanglibo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
淘特
上级
2fa89b3f
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
602 行增加
和
184 行删除
+602
-184
itao.go
upstream/itao/itao.go
+46
-23
itao_address.go
upstream/itao/itao_address.go
+9
-11
itao_auth.go
upstream/itao/itao_auth.go
+2
-2
itao_goods.go
upstream/itao/itao_goods.go
+63
-30
itao_logistics.go
upstream/itao/itao_logistics.go
+43
-3
itao_order.go
upstream/itao/itao_order.go
+125
-115
itao_pay.go
upstream/itao/itao_pay.go
+27
-0
itao_refund.go
upstream/itao/itao_refund.go
+215
-0
itao_upload.go
upstream/itao/itao_upload.go
+72
-0
没有找到文件。
upstream/itao/itao.go
浏览文件 @
ec5fe1a2
...
@@ -8,9 +8,10 @@ import (
...
@@ -8,9 +8,10 @@ import (
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gctx"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/os/gtimer"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gutil"
"net/url"
"net/url"
"sort"
"sort"
"strings"
"strings"
...
@@ -31,13 +32,17 @@ const Host = "https://open.huoju6.com/openapi/param2/1/com.huoju6.open/"
...
@@ -31,13 +32,17 @@ const Host = "https://open.huoju6.com/openapi/param2/1/com.huoju6.open/"
func
New
(
req
*
Config
)
{
func
New
(
req
*
Config
)
{
server
=
req
server
=
req
gtimer
.
Add
(
time
.
Hour
,
func
()
{
var
ctx
=
gctx
.
New
()
_
,
_
=
server
.
accessToken
(
ctx
)
})
return
return
}
}
type
CommonRes
struct
{
type
CommonRes
struct
{
Success
bool
`json:"success"`
Success
bool
`json:"success"`
Err
orCode
string
`json:"erro
rCode"`
Err
Code
string
`json:"er
rCode"`
Err
orMessage
string
`json:"errorMessage
"`
Err
Msg
string
`json:"errMsg
"`
}
}
func
generate
(
req
string
)
(
res
string
)
{
func
generate
(
req
string
)
(
res
string
)
{
...
@@ -73,7 +78,7 @@ func sign(method string, req g.Map) (err error) {
...
@@ -73,7 +78,7 @@ func sign(method string, req g.Map) (err error) {
}
}
func
(
s
*
Config
)
Post
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
func
(
s
*
Config
)
Post
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
params
[
"access_token"
],
err
=
s
.
AccessToken
(
ctx
)
params
[
"access_token"
],
err
=
s
.
Get
AccessToken
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -96,7 +101,7 @@ func Post(ctx context.Context, method string, params g.Map) (str string, err err
...
@@ -96,7 +101,7 @@ func Post(ctx context.Context, method string, params g.Map) (str string, err err
defer
func
()
{
defer
func
()
{
_
=
resp
.
Close
()
_
=
resp
.
Close
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"
GE
T"
)
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"
POS
T"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
Url
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
Url
)
if
err
!=
nil
{
if
err
!=
nil
{
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%vms】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%vms】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
...
@@ -111,7 +116,7 @@ func Post(ctx context.Context, method string, params g.Map) (str string, err err
...
@@ -111,7 +116,7 @@ func Post(ctx context.Context, method string, params g.Map) (str string, err err
}
}
func
(
s
*
Config
)
Get
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
func
(
s
*
Config
)
Get
(
ctx
context
.
Context
,
method
string
,
params
g
.
Map
)
(
str
string
,
err
error
)
{
params
[
"access_token"
],
err
=
s
.
AccessToken
(
ctx
)
params
[
"access_token"
],
err
=
s
.
Get
AccessToken
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -152,7 +157,7 @@ func Get(ctx context.Context, method string, params g.Map) (str string, err erro
...
@@ -152,7 +157,7 @@ func Get(ctx context.Context, method string, params g.Map) (str string, err erro
}
}
func
(
s
*
Config
)
AccessToken
(
ctx
context
.
Context
)
(
res
string
,
err
error
)
{
func
(
s
*
Config
)
Get
AccessToken
(
ctx
context
.
Context
)
(
res
string
,
err
error
)
{
var
conn
=
g
.
Redis
()
.
Conn
()
var
conn
=
g
.
Redis
()
.
Conn
()
defer
func
()
{
defer
func
()
{
_
=
conn
.
Close
()
_
=
conn
.
Close
()
...
@@ -163,28 +168,46 @@ func (s *Config) AccessToken(ctx context.Context) (res string, err error) {
...
@@ -163,28 +168,46 @@ func (s *Config) AccessToken(ctx context.Context) (res string, err error) {
err
=
gerror
.
New
(
"获取token 失败"
)
err
=
gerror
.
New
(
"获取token 失败"
)
return
return
}
}
var
token
*
AuthTokenRes
var
result
*
AuthTokenRes
_
=
gjson
.
New
(
cache
)
.
Scan
(
&
token
)
_
=
gjson
.
New
(
cache
)
.
Scan
(
&
result
)
if
token
==
nil
{
if
result
==
nil
||
result
.
AccessToken
==
""
{
err
=
gerror
.
New
(
"获取token 失败"
)
err
=
gerror
.
New
(
"获取token 失败"
)
return
return
}
}
if
token
.
AccessTokenExpireTime
<
gtime
.
Now
()
.
TimestampMilli
()
{
if
result
.
AccessTokenExpireTime
<
gtime
.
TimestampMilli
()
{
if
token
.
RefreshTokenExpireTime
<
gtime
.
Now
()
.
TimestampMilli
()
{
result
,
err
=
s
.
accessToken
(
ctx
)
if
err
!=
nil
{
return
}
}
res
=
result
.
AccessToken
return
}
//accessToken 刷新
func
(
s
*
Config
)
accessToken
(
ctx
context
.
Context
)
(
res
*
AuthTokenRes
,
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 失败"
)
err
=
gerror
.
New
(
"获取token 失败"
)
return
return
}
}
token
,
err
=
Auth
.
Token
(
ctx
,
token
.
RefreshToken
,
2
)
_
=
gjson
.
New
(
cache
)
.
Scan
(
&
res
)
if
res
.
AccessTokenExpireTime
>
gtime
.
Now
()
.
Add
(
time
.
Hour
)
.
TimestampMilli
()
{
return
}
res
,
err
=
Auth
.
Token
(
ctx
,
res
.
RefreshToken
,
2
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
if
token
.
Code
!=
"success"
{
if
res
.
Code
!=
"success"
{
err
=
gerror
.
New
(
"获取token 失败"
)
err
=
gerror
.
New
(
"获取token 失败"
)
return
return
}
}
_
,
_
=
conn
.
Do
(
"HMSET"
,
append
(
g
.
Slice
{
CacheKey
},
gutil
.
StructToSlice
(
token
)
...
)
...
)
_
,
_
=
conn
.
Do
(
"HMSET"
,
CacheKey
,
"accessToken"
,
res
.
AccessToken
,
"accessTokenExpireTime"
,
res
.
AccessTokenExpireTime
)
}
res
=
token
.
AccessToken
return
return
}
}
upstream/itao/itao_address.go
浏览文件 @
ec5fe1a2
...
@@ -63,7 +63,6 @@ type AddressParseReq struct {
...
@@ -63,7 +63,6 @@ type AddressParseReq struct {
}
}
type
AddressParseRes
struct
{
type
AddressParseRes
struct
{
Result
struct
{
Result
struct
{
Result
struct
{
City
string
`json:"city"`
City
string
`json:"city"`
CityId
int
`json:"cityId"`
CityId
int
`json:"cityId"`
...
@@ -75,7 +74,6 @@ type AddressParseRes struct {
...
@@ -75,7 +74,6 @@ type AddressParseRes struct {
TownId
int
`json:"townId"`
TownId
int
`json:"townId"`
}
`json:"result"`
}
`json:"result"`
Success
bool
`json:"success"`
Success
bool
`json:"success"`
}
`json:"result"`
}
}
//Parse 地址解析
//Parse 地址解析
...
...
upstream/itao/itao_auth.go
浏览文件 @
ec5fe1a2
...
@@ -40,7 +40,7 @@ type AuthQrCodeRes struct {
...
@@ -40,7 +40,7 @@ type AuthQrCodeRes struct {
func
(
s
auth
)
QrCode
(
ctx
context
.
Context
)
(
res
*
AuthQrCodeRes
,
err
error
)
{
func
(
s
auth
)
QrCode
(
ctx
context
.
Context
)
(
res
*
AuthQrCodeRes
,
err
error
)
{
method
:=
"tt.authority.generateQrCode"
method
:=
"tt.authority.generateQrCode"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
Get
(
ctx
,
method
,
g
.
Map
{
"bId"
:
server
.
AppKey
,
"bId"
:
server
.
AppKey
,
})
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
...
@@ -75,7 +75,7 @@ func (s auth) Token(ctx context.Context, code string, Type int) (res *AuthTokenR
...
@@ -75,7 +75,7 @@ func (s auth) Token(ctx context.Context, code string, Type int) (res *AuthTokenR
request
[
"grantType"
]
=
"refreshToken"
request
[
"grantType"
]
=
"refreshToken"
}
}
result
,
err
:=
server
.
Get
(
ctx
,
method
,
request
)
result
,
err
:=
Get
(
ctx
,
method
,
request
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
return
}
}
...
...
upstream/itao/itao_goods.go
浏览文件 @
ec5fe1a2
...
@@ -7,43 +7,76 @@ import (
...
@@ -7,43 +7,76 @@ import (
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gconv"
)
)
type
goods
Itao
struct
{
type
goods
struct
{
}
}
var
Goods
=
goods
Itao
{}
var
Goods
=
goods
{}
type
GoodsListReq
struct
{
type
GoodsListReq
struct
{
Q
string
`json:"q,omitempty"`
//关键词
Q
string
`json:"q,omitempty"`
//关键词
Sort
string
`json:"sort,omitempty"`
//排序参数 价格降序:sort=price:des 价格升序:sort=price:asc 综合排序:sort=popular:des 销量降序:sort=sales:des
SessionId
string
`json:"sessionId,omitempty"`
//长度不要超过32位,用来分页去重,当前请求只是翻页,则这个值不要改变
Price
string
`json:"price,omitempty"`
Sort
string
`json:"sort,omitempty"`
//排序参数
Cate
string
`json:"cate,omitempty"`
// 价格降序:sort=price:des
S
int
`json:"s,omitempty"`
//价格升序:sort=price:asc
N
int
`json:"n,omitempty"`
//综合排序:sort=popular:des
Feature
string
`json:"feature,omitempty"`
//销量降序:sort=sales:des
//客户响应率倒序 sort=cst_reply_rate:des
//客户响应率正序 sort=cst_reply_rate:acs
//好评率倒序 sort=pos_review_all_rate_30d:des
//好评率正序 sort=pos_review_all_rate:acs
//退货率倒序 sort=tj_pinzhi_rfd_rate:des
//退货率正序 sort=tj_pinzhi_rfd_rate:acs
//发货时效倒序 sort=ship_ord_rate_7d_104:des
//发货时效正序 sort=ship_ord_rate_7d_104:acs
Price
string
`json:"price,omitempty"`
//价格筛选
//89~248 从89元到248元
//89~ 大于89元
//~248 小于248元
Cate
string
`json:"cate,omitempty"`
//一级类目筛选
S
int
`json:"s"`
//默认0,不是页码,是每次查询的起始位置,相当于 页码x每页数量
N
int
`json:"n"`
//默认20, 每页数量,建议值10,不宜过大
Feature
string
`json:"feature,omitempty"`
//字符串,不是json 请求示例 :{\"poolId\":\"1001\"}
//目前支持的key
//精选商品池映射 poolId
//退货率 refundRateBegin
//退货率 refundRateEnd
//好评率 posReviewRateBegin
//好评率 posReviewRateEnd
//客服响应率 cstRateBegin
//客服响应率 cstRateEnd
//发货时效 shipRateBegin
//发货时效 shipRateEnd
}
}
type
GoodsListRes
struct
{
type
GoodsListRes
struct
{
ErrorMessage
string
`json:"error_message"`
Result
struct
{
ErrorCode
string
`json:"error_code"`
TotalCount
int
`json:"totalCount"`
PageIndex
int
`json:"pageIndex"`
PageSize
int
`json:"pageSize"`
Auctions
[]
struct
{
Auctions
[]
struct
{
Category
string
`json:"category"`
CstRate
string
`json:"cstRate"`
LevelOneCat
string
`json:"levelOneCat"`
Nid
string
`json:"nid"`
Nid
string
`json:"nid"`
Title
string
`json:"title"`
PictUrl
string
`json:"pictUrl"`
PosReviewRate
string
`json:"posReviewRate"`
RefundRate
string
`json:"refundRate"`
ReservePrice
string
`json:"reservePrice"`
ReservePrice
string
`json:"reservePrice"`
ZkFinalPrice
string
`json:"zkFinalPrice"`
ShipIn24
string
`json:"shipIn24"`
ShipRate
string
`json:"shipRate"`
TejiaTotalSoldQuantity
string
`json:"tejiaTotalSoldQuantity"`
TejiaTotalSoldQuantity
string
`json:"tejiaTotalSoldQuantity"`
PictUrl
string
`json:"pictUrl"`
Title
string
`json:"title"`
LevelOneCat
string
`json:"levelOneCat"`
ZkFinalPrice
string
`json:"zkFinalPrice"`
Category
string
`json:"category"`
}
`json:"auctions"`
}
`json:"auctions"`
PageIndex
int
`json:"pageIndex"`
PageSize
int
`json:"pageSize"`
TotalCount
int
`json:"totalCount"`
}
`json:"result"`
}
}
func
(
goods
Itao
)
List
(
ctx
context
.
Context
,
req
GoodsListReq
)
(
res
*
GoodsListRes
,
err
error
)
{
func
(
goods
)
List
(
ctx
context
.
Context
,
req
GoodsListReq
)
(
res
*
GoodsListRes
,
err
error
)
{
method
:=
"tt.item.list"
method
:=
"tt.item.list
.v2
"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
gconv
.
Map
(
req
))
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
})
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
return
}
}
...
@@ -121,7 +154,7 @@ type GoodsItem struct {
...
@@ -121,7 +154,7 @@ type GoodsItem struct {
}
}
//Detail 详情
//Detail 详情
func
(
goods
Itao
)
Detail
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDetailRes
,
err
error
)
{
func
(
goods
)
Detail
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDetailRes
,
err
error
)
{
method
:=
"tt.item.detail.v2"
method
:=
"tt.item.detail.v2"
var
request
=
GoodsDetailReq
{
var
request
=
GoodsDetailReq
{
AppKey
:
gconv
.
Int
(
server
.
AppKey
),
AppKey
:
gconv
.
Int
(
server
.
AppKey
),
...
@@ -317,7 +350,7 @@ type GoodsDescItem struct {
...
@@ -317,7 +350,7 @@ type GoodsDescItem struct {
}
}
//Desc 详情描述
//Desc 详情描述
func
(
goods
Itao
)
Desc
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDescRes
,
err
error
)
{
func
(
goods
)
Desc
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsDescRes
,
err
error
)
{
method
:=
"tt.item.desc"
method
:=
"tt.item.desc"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
...
@@ -348,7 +381,7 @@ type GoodsCategoryRes struct {
...
@@ -348,7 +381,7 @@ type GoodsCategoryRes struct {
}
}
//Category 商品类目
//Category 商品类目
func
(
goods
Itao
)
Category
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsCategoryRes
,
err
error
)
{
func
(
goods
)
Category
(
ctx
context
.
Context
,
GoodsID
string
)
(
res
*
GoodsCategoryRes
,
err
error
)
{
method
:=
"tt.item.cateInfo"
method
:=
"tt.item.cateInfo"
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Get
(
ctx
,
method
,
g
.
Map
{
...
...
upstream/itao/itao_logistics.go
浏览文件 @
ec5fe1a2
...
@@ -6,10 +6,10 @@ import (
...
@@ -6,10 +6,10 @@ import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/frame/g"
)
)
type
logistics
Itao
struct
{
type
logistics
struct
{
}
}
var
Logistics
=
logistics
Itao
{}
var
Logistics
=
logistics
{}
type
LogisticsTraceRes
struct
{
type
LogisticsTraceRes
struct
{
Result
struct
{
Result
struct
{
...
@@ -45,7 +45,7 @@ type LogisticsTraceRes struct {
...
@@ -45,7 +45,7 @@ type LogisticsTraceRes struct {
}
}
//Trace 物流轨迹
//Trace 物流轨迹
func
(
logistics
Itao
)
Trace
(
ctx
context
.
Context
,
req
string
)
(
res
*
LogisticsTraceRes
,
err
error
)
{
func
(
logistics
)
Trace
(
ctx
context
.
Context
,
req
string
)
(
res
*
LogisticsTraceRes
,
err
error
)
{
method
:=
"tt.logistics.detail"
method
:=
"tt.logistics.detail"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
...
@@ -56,3 +56,43 @@ func (logisticsItao) Trace(ctx context.Context, req string) (res *LogisticsTrace
...
@@ -56,3 +56,43 @@ func (logisticsItao) Trace(ctx context.Context, req string) (res *LogisticsTrace
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
return
}
}
type
LogisticsCompanyRes
struct
{
Result
[]
LogisticsCompanyItem
`json:"result"`
Success
bool
`json:"success"`
}
type
LogisticsCompanyItem
struct
{
Code
string
`json:"code"`
Name
string
`json:"name"`
Id
int64
`json:"id"`
Type
int
`json:"type"`
}
type
LogisticsCompany
struct
{
Result
map
[
string
][]
interface
{}
`json:"result"`
Success
bool
`json:"success"`
}
//Company 物流公司
func
(
logistics
)
Company
(
ctx
context
.
Context
,
req
string
)
(
res
*
LogisticsCompanyRes
,
err
error
)
{
method
:=
"tt.refund.queryLogisticList"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"bizOrderId"
:
req
,
},
})
var
data
*
LogisticsCompany
_
=
gjson
.
New
(
result
)
.
Scan
(
&
data
)
res
=
new
(
LogisticsCompanyRes
)
res
.
Success
=
data
.
Success
for
_
,
item
:=
range
data
.
Result
{
for
_
,
val
:=
range
item
{
var
value
[]
LogisticsCompanyItem
_
=
gjson
.
New
(
val
)
.
Scan
(
&
value
)
res
.
Result
=
append
(
res
.
Result
,
value
...
)
}
}
return
}
upstream/itao/itao_order.go
浏览文件 @
ec5fe1a2
...
@@ -9,10 +9,10 @@ import (
...
@@ -9,10 +9,10 @@ import (
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gconv"
)
)
type
order
Itao
struct
{
type
order
struct
{
}
}
var
Order
=
order
Itao
{}
var
Order
=
order
{}
type
OrderBeforeReq
struct
{
type
OrderBeforeReq
struct
{
Address
OrderAddress
`json:"deliveryAddressInfo"`
Address
OrderAddress
`json:"deliveryAddressInfo"`
...
@@ -42,7 +42,10 @@ type OrderItem struct {
...
@@ -42,7 +42,10 @@ type OrderItem struct {
}
}
type
OrderBeforeRes
struct
{
type
OrderBeforeRes
struct
{
Result
struct
{
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
Success
bool
`json:"success"`
GwTraceId
string
`json:"gw_trace_id"`
Result
struct
{
Result
struct
{
ExtensionResp
struct
{
ExtensionResp
struct
{
TradeId
string
`json:"tradeId"`
TradeId
string
`json:"tradeId"`
...
@@ -92,23 +95,27 @@ type OrderBeforeRes struct {
...
@@ -92,23 +95,27 @@ type OrderBeforeRes struct {
ErrorMsg
string
`json:"errorMsg"`
ErrorMsg
string
`json:"errorMsg"`
}
}
ItemInfo
struct
{
ItemInfo
struct
{
ItemId
string
`json:"itemId"`
ItemId
int64
`json:"itemId"`
Pic
string
`json:"pic"`
Price
string
`json:"price"`
SkuId
string
`json:"skuId"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"skuInfoList"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
}
`json:"itemInfo"`
ItemPayPrice
uint
`json:"itemPayPrice"`
ItemPayPrice
uint
`json:"itemPayPrice"`
OrderLineId
int64
`json:"orderLineId"`
OrderLineId
int64
`json:"orderLineId"`
Quantity
uint
`json:"quantity"`
Quantity
uint
`json:"quantity"`
}
`json:"orderLineRenders"`
}
`json:"orderLineRenders"`
OrderPayPrice
uint
`json:"orderPayPrice"`
OrderPayPrice
int
`json:"orderPayPrice"`
Quantity
uint
`json:"quantity"`
PostFee
int
`json:"postFee"`
Quantity
int
`json:"quantity"`
SellerToken
string
`json:"sellerToken"`
SellerToken
string
`json:"sellerToken"`
Title
string
`json:"title"`
Title
string
`json:"title"`
}
`json:"validOrderGroups"`
}
`json:"validOrderGroups"`
}
`json:"result"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
}
`json:"result"`
}
}
type
OrderPromotion
struct
{
type
OrderPromotion
struct
{
...
@@ -140,7 +147,7 @@ type OrderPromotion struct {
...
@@ -140,7 +147,7 @@ type OrderPromotion struct {
}
}
//Before 前置校验
//Before 前置校验
func
(
s
order
Itao
)
Before
(
ctx
context
.
Context
,
req
OrderBeforeReq
)
(
res
*
OrderBeforeRes
,
err
error
)
{
func
(
s
order
)
Before
(
ctx
context
.
Context
,
req
OrderBeforeReq
)
(
res
*
OrderBeforeRes
,
err
error
)
{
method
:=
"tt.order.render"
method
:=
"tt.order.render"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
...
@@ -171,30 +178,24 @@ type OrderCreateDto struct {
...
@@ -171,30 +178,24 @@ type OrderCreateDto struct {
}
}
type
OrderCreateRes
struct
{
type
OrderCreateRes
struct
{
Result
struct
{
CommonRes
Result
struct
{
Result
struct
{
AlipaySuccess
bool
`json:"alipaySuccess"`
AlipaySuccess
bool
`json:"alipaySuccess"`
EnablingOrdersResult
struct
{
EnablingOrdersResult
struct
{
Model
struct
{
Model
struct
{
AlipayTradeIds
[]
string
`json:"alipayTradeIds"`
AlipayTradeIds
[]
string
`json:"alipayTradeIds"`
OrderIds
[]
string
`json:"orderIds"`
OrderIds
[]
string
`json:"orderIds"`
RedirectUrl
string
`json:"redirectUrl"`
}
`json:"model"`
}
`json:"model"`
}
`json:"enablingOrdersResult"`
}
`json:"enablingOrdersResult"`
ExtensionResult
struct
{
ExtensionResult
struct
{
TraceId
string
`json:"traceId"`
TraceId
string
`json:"traceId"`
}
`json:"extensionResult"`
}
`json:"extensionResult"`
PartSuccess
bool
`json:"partSuccess"`
PartSuccess
bool
`json:"partSuccess"`
Success
bool
`json:"success"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
}
`json:"result"`
}
`json:"result"`
}
}
//Create 下单
//Create 下单
func
(
s
order
Itao
)
Create
(
ctx
context
.
Context
,
req
OrderCreateReq
)
(
res
*
OrderCreateRes
,
err
error
)
{
func
(
s
order
)
Create
(
ctx
context
.
Context
,
req
OrderCreateReq
)
(
res
*
OrderCreateRes
,
err
error
)
{
method
:=
"tt.order.create"
method
:=
"tt.order.create"
for
k
,
item
:=
range
req
.
List
{
for
k
,
item
:=
range
req
.
List
{
...
@@ -209,7 +210,7 @@ func (s orderItao) Create(ctx context.Context, req OrderCreateReq) (res *OrderCr
...
@@ -209,7 +210,7 @@ func (s orderItao) Create(ctx context.Context, req OrderCreateReq) (res *OrderCr
return
return
}
}
func
(
s
order
Itao
)
outId
(
req
string
)
(
res
string
)
{
func
(
s
order
)
outId
(
req
string
)
(
res
string
)
{
res
=
gstr
.
SubStr
(
req
,
2
,
-
1
)
res
=
gstr
.
SubStr
(
req
,
2
,
-
1
)
res
=
gstr
.
Replace
(
res
,
"_15_"
,
"_"
)
res
=
gstr
.
Replace
(
res
,
"_15_"
,
"_"
)
return
fmt
.
Sprintf
(
"%s_%s"
,
server
.
AppKey
,
res
)
return
fmt
.
Sprintf
(
"%s_%s"
,
server
.
AppKey
,
res
)
...
@@ -219,12 +220,12 @@ type OrderDetailRes struct {
...
@@ -219,12 +220,12 @@ type OrderDetailRes struct {
Success
bool
`json:"success"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrMsg
string
`json:"errMsg"`
Result
struct
{
Result
struct
{
BizOrderId
int64
`json:"bizOrderId"`
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
Detail
int
`json:"detail"`
DetailOrderList
[]
struct
{
DetailOrderList
[]
struct
{
BizOrderId
int64
`json:"bizOrderId"`
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
int
`json:"buyAmount"`
BuyAmount
int
`json:"buyAmount"`
BuyerToken
string
`json:"buyerToken"`
BuyerToken
string
`json:"buyerToken"`
Detail
int
`json:"detail"`
Detail
int
`json:"detail"`
...
@@ -309,7 +310,7 @@ type OrderDetailRes struct {
...
@@ -309,7 +310,7 @@ type OrderDetailRes struct {
}
}
//Detail 详情
//Detail 详情
func
(
s
order
Itao
)
Detail
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
OrderDetailRes
,
err
error
)
{
func
(
s
order
)
Detail
(
ctx
context
.
Context
,
req
interface
{})
(
res
*
OrderDetailRes
,
err
error
)
{
method
:=
"tt.order.detail"
method
:=
"tt.order.detail"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
...
@@ -324,6 +325,9 @@ func (s orderItao) Detail(ctx context.Context, req interface{}) (res *OrderDetai
...
@@ -324,6 +325,9 @@ func (s orderItao) Detail(ctx context.Context, req interface{}) (res *OrderDetai
}
}
type
OrderReflectRes
struct
{
type
OrderReflectRes
struct
{
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
Result
struct
{
Result
struct
{
BizOrderId
string
`json:"bizOrderId"`
BizOrderId
string
`json:"bizOrderId"`
BuyAmount
uint
`json:"buyAmount"`
BuyAmount
uint
`json:"buyAmount"`
...
@@ -340,7 +344,10 @@ type OrderReflectRes struct {
...
@@ -340,7 +344,10 @@ type OrderReflectRes struct {
Pic
string
`json:"pic"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
interface
{}
`json:"skuInfoList"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"skuInfoList"`
Title
string
`json:"title"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
...
@@ -375,7 +382,10 @@ type OrderReflectRes struct {
...
@@ -375,7 +382,10 @@ type OrderReflectRes struct {
Pic
string
`json:"pic"`
Pic
string
`json:"pic"`
Price
uint
`json:"price"`
Price
uint
`json:"price"`
SkuId
string
`json:"skuId"`
SkuId
string
`json:"skuId"`
SkuInfoList
[]
interface
{}
`json:"skuInfoList"`
SkuInfoList
[]
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
`json:"skuInfoList"`
Title
string
`json:"title"`
Title
string
`json:"title"`
}
`json:"itemInfo"`
}
`json:"itemInfo"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
LogisticsOrderId
int64
`json:"logisticsOrderId"`
...
@@ -404,13 +414,10 @@ type OrderReflectRes struct {
...
@@ -404,13 +414,10 @@ type OrderReflectRes struct {
SellerToken
string
`json:"sellerToken"`
SellerToken
string
`json:"sellerToken"`
Status
int
`json:"status"`
Status
int
`json:"status"`
}
`json:"result"`
}
`json:"result"`
Success
bool
`json:"success"`
ErrMsg
string
`json:"errMsg"`
ErrCode
string
`json:"errCode"`
}
}
//Reflect 详情[反查]
//Reflect 详情[反查]
func
(
s
order
Itao
)
Reflect
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderReflectRes
,
err
error
)
{
func
(
s
order
)
Reflect
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderReflectRes
,
err
error
)
{
method
:=
"tt.order.detail.outid"
method
:=
"tt.order.detail.outid"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
...
@@ -426,18 +433,21 @@ func (s orderItao) Reflect(ctx context.Context, req string) (res *OrderReflectRe
...
@@ -426,18 +433,21 @@ func (s orderItao) Reflect(ctx context.Context, req string) (res *OrderReflectRe
type
OrderPayRes
struct
{
type
OrderPayRes
struct
{
Result
struct
{
Result
struct
{
Result
struct
{
Result
string
`json:"result"`
Success
bool
`json:"success"`
ErrCode
string
`json:"errCode"`
ErrCode
string
`json:"errCode"`
ErrMsg
string
`json:"errMsg"`
ErrMsg
string
`json:"errMsg"`
Success
bool
`json:"success
"`
}
`json:"result
"`
}
`json:"result"`
}
`json:"result"`
}
}
func
(
s
order
Itao
)
Pay
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderPayRes
,
err
error
)
{
func
(
s
order
)
Pay
(
ctx
context
.
Context
,
req
string
)
(
res
*
OrderPayRes
,
err
error
)
{
method
:=
"
com.alibaba.c2m/ltao.pay.agreementP
ay"
method
:=
"
tt.agreementpay.dop
ay"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"request"
:
g
.
Map
{
"bizOrderId"
:
req
,
"bizOrderId"
:
gconv
.
Int64
(
req
)
,
},
},
})
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
...
...
upstream/itao/itao_pay.go
0 → 100644
浏览文件 @
ec5fe1a2
package
itao
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type
pay
struct
{
}
var
Pay
=
pay
{}
type
PayAuthRes
struct
{
}
func
(
s
pay
)
Auth
(
ctx
context
.
Context
)
(
res
*
PayAuthRes
,
err
error
)
{
method
:=
"tt.agreementpay.genersignurl"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{},
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
upstream/itao/itao_refund.go
浏览文件 @
ec5fe1a2
package
itao
package
itao
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type
refund
struct
{
type
refund
struct
{
}
}
var
Refund
=
refund
{}
var
Refund
=
refund
{}
type
RefundPic
struct
{
MessagePic
string
`json:"messagePic"`
}
type
RefundBeforeRes
struct
{
CommonRes
Result
struct
{
BizClaimTypeVOList
[]
struct
{
BizClaimType
string
`json:"bizClaimType"`
//refund 仅退款 return_and_refund 退货退款
RefundTypeTitle
string
`json:"refundTypeTitle"`
}
`json:"bizClaimTypeVOList"`
}
`json:"result"`
}
//Before 退款类型
func
(
s
refund
)
Before
(
ctx
context
.
Context
,
req
string
)
(
res
*
RefundBeforeRes
,
err
error
)
{
method
:=
"tt.refund.refundApplyType"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"bizOrderId"
:
req
,
},
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
type
RefundReasonReq
struct
{
BizOrderId
string
`json:"bizOrderId"`
BizClaimType
string
`json:"bizClaimType"`
GoodsStatus
string
`json:"goodsStatus,omitempty"`
}
type
RefundReasonRes
struct
{
CommonRes
Result
struct
{
MaxRefundFee
int
`json:"maxRefundFee"`
MinRefundFee
int
`json:"minRefundFee"`
MustProof
bool
`json:"mustProof"`
RefundTextWrapperVOList
[]
struct
{
Name
string
`json:"name"`
ReasonGroup
int
`json:"reasonGroup"`
TextId
int
`json:"textId"`
}
`json:"refundTextWrapperVOList"`
}
`json:"result"`
}
//Reason 原因
func
(
s
refund
)
Reason
(
ctx
context
.
Context
,
req
RefundReasonReq
)
(
res
*
RefundReasonRes
,
err
error
)
{
method
:=
"tt.refund.refundApplyInit"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
type
RefundCreateReq
struct
{
BizOrderId
string
`json:"bizOrderId"`
//子订单号
BizClaimType
string
`json:"bizClaimType"`
//refund 仅退款 return_and_refund 退货退款
GoodsStatus
string
`json:"goodsStatus,omitempty"`
//"1":未收到货 "2":未已收到货 未发货情况下,千万不要传
RefundFee
string
`json:"refundFee"`
//退款金额,单位是分
ApplyRefundTextId
string
`json:"applyRefundTextId"`
//原因ID
LeaveMessagePics
[]
RefundPic
`json:"leaveMessagePics,omitempty"`
}
type
RefundCreateRess
struct
{
CommonRes
Result
struct
{
DisputeId
string
`json:"disputeId"`
}
`json:"result"`
}
//Create 申请
func
(
s
refund
)
Create
(
ctx
context
.
Context
,
req
RefundCreateReq
,
image
...
string
)
(
res
*
RefundCreateRess
,
err
error
)
{
method
:=
"tt.refund.refundSubmit"
if
len
(
image
)
>
0
{
for
_
,
item
:=
range
image
{
req
.
LeaveMessagePics
=
append
(
req
.
LeaveMessagePics
,
RefundPic
{
MessagePic
:
item
})
}
}
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
//Cancle 取消售后
//`bizOrderId` 子订单号
//`disputeId` 售后单号
func
(
s
refund
)
Cancle
(
ctx
context
.
Context
,
bizOrderId
,
disputeId
string
)
(
res
*
CommonRes
,
err
error
)
{
method
:=
"tt.refund.refundRevoke"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"bizOrderId"
:
bizOrderId
,
"disputeId"
:
disputeId
,
},
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
type
RefundSubmitReq
struct
{
DisputeId
string
`json:"disputeId"`
BizOrderId
string
`json:"bizOrderId"`
CompanyCode
string
`json:"logisticsCompanyCode"`
CompanyId
string
`json:"logisticsCompanyId"`
CompanyName
string
`json:"logisticsCompanyName"`
LogisticsNo
string
`json:"logisticsNo"`
MobileNum
string
`json:"mobileNum"`
LeaveMessagePics
[]
RefundPic
`json:"leaveMessagePics"`
}
type
RefundSubmitRes
struct
{
CommonRes
Result
struct
{
DisputeStatus
string
`json:"disputeStatus"`
//REFUND_WAIT_SELLER_AGREE:"买家已经申请退款,等待卖家同意";
//REFUND_WAIT_BUYER_RETURN_GOODS:"卖家已经同意退款,等待买家退货";
//REFUND_WAIT_SELLER_CONFIRM_GOODS:"买家已经退货,等待卖家确认收货";
//REFUND_CLOSED:"退款关闭";
//REFUND_SUCCESS:"退款成功";
//REFUND_SELLER_REFUSE_BUYER:"卖家拒绝退款";
//REFUND_WAIT_BUYER_CONFIRM_REDO_SEND_GOODS:"等待买家确认重新邮寄的货物";
//REFUND_WAIT_SELLER_CONFIRM_RETURN_ADDRESS:"等待卖家确认退货地址"
}
`json:"result"`
}
//Submit 提交物流信息
func
(
s
refund
)
Submit
(
ctx
context
.
Context
,
req
RefundSubmitReq
,
image
...
string
)
(
res
*
CommonRes
,
err
error
)
{
method
:=
"tt.refund.refundSubmit"
if
len
(
image
)
>
0
{
for
_
,
item
:=
range
image
{
req
.
LeaveMessagePics
=
append
(
req
.
LeaveMessagePics
,
RefundPic
{
MessagePic
:
item
})
}
}
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
req
,
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
type
RefundDetailRes
struct
{
CommonRes
Result
struct
{
DisputeId
int64
`json:"disputeId"`
//退款编号
DisputeStatus
string
`json:"disputeStatus"`
//退款状态
//REFUND_WAIT_SELLER_AGREE:"买家已经申请退款,等待卖家同意";
//REFUND_WAIT_BUYER_RETURN_GOODS:"卖家已经同意退款,等待买家退货";
//REFUND_WAIT_SELLER_CONFIRM_GOODS:"买家已经退货,等待卖家确认收货";
//REFUND_CLOSED:"退款关闭";
//REFUND_SUCCESS:"退款成功";
//REFUND_SELLER_REFUSE_BUYER:"卖家拒绝退款";
//REFUND_WAIT_BUYER_CONFIRM_REDO_SEND_GOODS:"等待买家确认重新邮寄的货物";
//REFUND_WAIT_SELLER_CONFIRM_RETURN_ADDRESS:"等待卖家确认退货地址"
DisputeTimeOut
struct
{
Duration
int
`json:"duration"`
GmtCreate
int64
`json:"gmtCreate"`
Running
bool
`json:"running"`
TimeoutActionType
string
`json:"timeoutActionType"`
}
`json:"disputeTimeOut"`
ReasonName
string
`json:"reasonName"`
//退款原因名称
RefundFee
int
`json:"refundFee"`
//退款金额,单位分
ShippingAddressWrapperDTO
struct
{
AddressDetail
string
`json:"addressDetail"`
AreaName
string
`json:"areaName"`
CityName
string
`json:"cityName"`
ConsigneeFullName
string
`json:"consigneeFullName"`
DivisionCode
string
`json:"divisionCode"`
Mobile
string
`json:"mobile"`
PostCode
string
`json:"postCode"`
ProvinceName
string
`json:"provinceName"`
TownName
string
`json:"townName"`
}
`json:"shippingAddressWrapperDTO"`
}
`json:"result"`
}
//Detail 详情
func
(
s
refund
)
Detail
(
ctx
context
.
Context
,
bizOrderId
,
disputeId
string
)
(
res
*
RefundDetailRes
,
err
error
)
{
method
:=
"tt.refund.queryRefundDetail"
result
,
err
:=
server
.
Post
(
ctx
,
method
,
g
.
Map
{
"request"
:
g
.
Map
{
"bizOrderId"
:
bizOrderId
,
"disputeId"
:
disputeId
,
},
})
_
=
gjson
.
NewWithOptions
(
result
,
gjson
.
Options
{
StrNumber
:
true
,
})
.
Scan
(
&
res
)
return
}
upstream/itao/itao_upload.go
0 → 100644
浏览文件 @
ec5fe1a2
package
itao
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
"net/url"
"time"
)
type
upload
struct
{
}
var
Upload
=
upload
{}
type
UploadImageReq
struct
{
FileName
string
`json:"fileName"`
FileContent
string
`json:"fileContent"`
ImageData
string
`json:"imageData"`
}
type
UploadImageRes
struct
{
Code
string
`json:"code"`
Message
string
`json:"message"`
FileUrl
string
`json:"fileUrl"`
}
func
(
s
upload
)
Image
(
ctx
context
.
Context
,
req
UploadImageReq
)
(
res
*
UploadImageRes
,
err
error
)
{
method
:=
"tt.upload.image"
req
.
FileContent
=
"base64"
var
request
=
g
.
Map
{}
request
[
"access_token"
],
err
=
server
.
GetAccessToken
(
ctx
)
if
err
!=
nil
{
return
}
result
,
err
:=
s
.
post
(
ctx
,
method
,
request
,
gconv
.
Map
(
req
))
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
func
(
upload
)
post
(
ctx
context
.
Context
,
method
string
,
params
,
req
g
.
Map
)
(
str
string
,
err
error
)
{
Start
:=
gtime
.
TimestampMilli
()
err
=
sign
(
method
,
params
)
if
err
!=
nil
{
return
}
Url
:=
Host
+
method
+
"/"
+
server
.
AppKey
Values
:=
url
.
Values
{}
for
k
,
v
:=
range
params
{
Values
.
Add
(
k
,
gconv
.
String
(
v
))
}
resp
,
err
:=
g
.
Client
()
.
ContentJson
()
.
Timeout
(
time
.
Second
*
5
)
.
Post
(
Url
+
"?"
+
Values
.
Encode
(),
req
)
defer
func
()
{
_
=
resp
.
Close
()
paramStr
:=
gjson
.
New
(
params
)
.
MustToJsonString
()
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"POST"
)
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
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论