Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
508f6397
提交
508f6397
authored
6月 09, 2022
作者:
zhanglibo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
京东订单
上级
5628fbca
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
133 行增加
和
79 行删除
+133
-79
jingdong_deliver.go
upstream/jingdong/jingdong_deliver.go
+46
-0
jingdong_order.go
upstream/jingdong/jingdong_order.go
+87
-79
没有找到文件。
upstream/jingdong/jingdong_deliver.go
0 → 100644
浏览文件 @
508f6397
package
jingdong
import
(
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type
deliveryJD
struct
{
}
var
Delivery
=
deliveryJD
{}
//DeliveryDetailRes 物流轨迹
type
DeliveryDetailRes
struct
{
*
CommonRes
Result
struct
{
OrderTrack
[]
struct
{
Content
string
`json:"content"`
//操作内容明细
MsgTime
string
`json:"msgTime"`
//操作时间。日期格式为“yyyy-MM-dd hh:mm:ss”
Operator
string
`json:"operator"`
//操作员名称
}
`json:"orderTrack"`
WaybillCode
[]
struct
{
OrderID
string
`json:"orderId"`
//订单号
ParentID
string
`json:"parentId"`
//父订单号。 此字段为0 未拆单
Carrier
string
`json:"carrier"`
//承运商
DeliveryOrderID
string
`json:"deliveryOrderId"`
//运单号
}
`json:"waybillCode"`
JdOrderID
int
`json:"jdOrderId"`
}
`json:"result"`
}
// Detail 物流信息
func
(
*
deliveryJD
)
Detail
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
DeliveryDetailRes
,
err
error
)
{
method
:=
"order/orderTrack"
param
:=
g
.
Map
{
"jdOrderId"
:
OrderID
,
"waybillCode"
:
"1"
,
}
result
,
err
:=
server
.
requestApi
(
ctx
,
method
,
param
)
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
upstream/jingdong/jingdong_order.go
浏览文件 @
508f6397
...
...
@@ -12,33 +12,14 @@ type orderJD struct {
//Order 订单
var
Order
=
orderJD
{}
//GetDeliveryRes 物流轨迹
type
GetDeliveryRes
struct
{
*
CommonRes
Result
struct
{
OrderTrack
[]
struct
{
Content
string
`json:"content"`
//操作内容明细
MsgTime
string
`json:"msgTime"`
//操作时间。日期格式为“yyyy-MM-dd hh:mm:ss”
Operator
string
`json:"operator"`
//操作员名称
}
`json:"orderTrack"`
WaybillCode
[]
struct
{
OrderID
string
`json:"orderId"`
//订单号
ParentID
string
`json:"parentId"`
//父订单号。 此字段为0 未拆单
Carrier
string
`json:"carrier"`
//承运商
DeliveryOrderID
string
`json:"deliveryOrderId"`
//运单号
}
`json:"waybillCode"`
JdOrderID
int
`json:"jdOrderId"`
}
`json:"result"`
}
//PriceSnap 商品价格
type
PriceSnap
struct
{
SkuID
int
`json:"skuId"`
//商品编号
Price
float64
`json:"price"`
//商品价格 格式:21.30
}
//
PlaceOrder
Req 下单
type
PlaceOrder
Req
struct
{
//
OrderCreate
Req 下单
type
OrderCreate
Req
struct
{
OrderSn
string
//订单单号
SkuNums
[]
*
SkuNums
Consignee
string
//收货人姓名,最多20个字符
...
...
@@ -57,8 +38,8 @@ type PlaceOrderAddress struct {
Desc
string
//收货人详细地址,最多100个字符
}
//
PlaceOrder
Res 下单
type
PlaceOrder
Res
struct
{
//
OrderCreate
Res 下单
type
OrderCreate
Res
struct
{
*
CommonRes
Result
struct
{
JdOrderID
int64
`json:"jdOrderId"`
//京东订单号
...
...
@@ -78,45 +59,62 @@ type OrderSkuItem struct {
NakedPrice
float64
`json:"nakedPrice"`
//商品未税价
}
//
ReflectOrder
Res 反查订单
type
ReflectOrder
Res
struct
{
//
OrderReflect
Res 反查订单
type
OrderReflect
Res
struct
{
*
CommonRes
Result
string
`json:"result"`
//第三方订单号(非京东订单号)
}
//GetOrderRes 订单详情
type
GetOrderRes
struct
{
type
OrderDetailBase
struct
{
*
CommonRes
Result
struct
{
JdOrderID
int64
`json:"jdOrderId"`
//京东订单编号
Type
int
`json:"type"`
//订单类型。1是父订单 2是子订单
Freight
float64
`json:"freight"`
//运费
OrderPrice
float64
`json:"orderPrice"`
//订单总金额
OrderNakedPrice
float64
`json:"orderNakedPrice"`
//订单未含税金额
OrderTaxPrice
float64
`json:"orderTaxPrice"`
//订单税额
Sku
[]
*
OrderSkuItem
`json:"sku"`
//商品列表
OrderState
int
`json:"orderState"`
//订单状态。0为取消订单 1为有效
State
int
`json:"state"`
//物流状态。0 是新建 1是妥投 2是拒收
POrder
struct
{
JdOrderID
int64
`json:"jdOrderId"`
//京东订单编号
Freight
float64
`json:"freight"`
//运费
OrderPrice
float64
`json:"orderPrice"`
//订单总金额
OrderNakedPrice
float64
`json:"orderNakedPrice"`
//订单未含税金额
Sku
[]
*
OrderSkuItem
`json:"sku"`
//商品列表
}
`json:"pOrder"`
COrder
[]
struct
{
POrder
string
`json:"pOrder"`
//父订单号。为0时,此订单为父单。
JdOrderID
int
`json:"jdOrderId"`
//京东订单编号
Freight
float64
`json:"freight"`
//运费
OrderPrice
float64
`json:"orderPrice"`
//订单总金额
OrderNakedPrice
float64
`json:"orderNakedPrice"`
//订单未含税金额
Sku
[]
OrderSkuItem
`json:"sku"`
//商品列表
}
`json:"cOrder"`
JdOrderID
int64
`json:"jdOrderId"`
//京东订单编号
Type
int
`json:"type"`
//订单类型。1是父订单 2是子订单
}
}
//OrderDetailRes 订单详情
type
OrderDetailRes
struct
{
CommonRes
Result
struct
{
SubmitState
int
`json:"submitState"`
//预占确认状态。0没确认预占。 1已确认预占。
Type
int
`json:"type"`
//订单类型。1是父订单 2是子订单
OrderState
int
`json:"orderState"`
//订单状态。0为取消订单 1为有效
POrder
OrderDetailPOrder
`json:"pOrder"`
COrder
[]
OrderDetailCOrder
`json:"cOrder"`
}
`json:"result"`
}
//GetFreightRes 运费
type
GetFreightRes
struct
{
type
OrderDetailPOrder
struct
{
JdOrderId
int64
`json:"jdOrderId"`
//京东主订单编号
Freight
float64
`json:"freight"`
//运费
OrderPrice
float64
`json:"orderPrice"`
//订单总金额
OrderNakedPrice
float64
`json:"orderNakedPrice"`
//订单未含税金额
Sku
[]
OrderSkuItem
`json:"sku"`
//商品列表
OrderTaxPrice
float64
`json:"orderTaxPrice"`
//订单税额
}
type
OrderDetailCOrder
struct
{
POrder
int64
`json:"pOrder"`
//京东主订单编号
OrderState
int
`json:"orderState"`
JdOrderId
int64
`json:"jdOrderId"`
//京东子订单编号
State
int
`json:"state"`
Freight
float64
`json:"freight"`
SubmitState
int
`json:"submitState"`
OrderPrice
float64
`json:"orderPrice"`
OrderNakedPrice
float64
`json:"orderNakedPrice"`
Type
int
`json:"type"`
//商品类型。 0 普通、1 附件、2 赠品、3延保
Sku
[]
OrderSkuItem
`json:"sku"`
OrderTaxPrice
float64
`json:"orderTaxPrice"`
}
type
OrderDetailChild
struct
{
CommonRes
Result
OrderDetailCOrder
`json:"result"`
}
//OrderFreightRes 运费
type
OrderFreightRes
struct
{
*
CommonRes
Result
struct
{
Freight
float64
`json:"freight"`
//总运费
...
...
@@ -131,23 +129,8 @@ type SkuNums struct {
Num
int
`json:"num"`
//商品数量
}
// GetDelivery 物流信息
func
(
*
orderJD
)
GetDelivery
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
GetDeliveryRes
,
err
error
)
{
method
:=
"order/orderTrack"
param
:=
g
.
Map
{
"jdOrderId"
:
OrderID
,
"waybillCode"
:
"1"
,
}
result
,
err
:=
server
.
requestApi
(
ctx
,
method
,
param
)
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
// PlaceOrder 下单
func
(
*
orderJD
)
PlaceOrder
(
ctx
context
.
Context
,
req
*
PlaceOrderReq
)
(
res
*
PlaceOrderRes
,
err
error
)
{
// Create 下单
func
(
*
orderJD
)
Create
(
ctx
context
.
Context
,
req
*
OrderCreateReq
)
(
res
*
OrderCreateRes
,
err
error
)
{
method
:=
"order/submitOrder"
var
param
=
g
.
Map
{
"thirdOrder"
:
req
.
OrderSn
,
...
...
@@ -180,8 +163,8 @@ func (*orderJD) PlaceOrder(ctx context.Context, req *PlaceOrderReq) (res *PlaceO
return
}
// Reflect
Order
反查订单
func
(
*
orderJD
)
Reflect
Order
(
ctx
context
.
Context
,
thirdOrder
string
)
(
res
*
ReflectOrder
Res
,
err
error
)
{
// Reflect 反查订单
func
(
*
orderJD
)
Reflect
(
ctx
context
.
Context
,
thirdOrder
string
)
(
res
*
OrderReflect
Res
,
err
error
)
{
method
:=
"order/selectJdOrderIdByThirdOrder"
param
:=
g
.
Map
{
"thirdOrder"
:
thirdOrder
,
...
...
@@ -194,22 +177,47 @@ func (*orderJD) ReflectOrder(ctx context.Context, thirdOrder string) (res *Refle
return
}
//
GetOrderInfo
订单详情
func
(
*
orderJD
)
GetOrderInfo
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
GetOrder
Res
,
err
error
)
{
//
Detail
订单详情
func
(
*
orderJD
)
Detail
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
OrderDetail
Res
,
err
error
)
{
method
:=
"order/selectJdOrder"
param
:=
g
.
Map
{
"jdOrderId"
:
OrderID
,
}
result
,
err
:=
server
.
requestApi
(
ctx
,
method
,
param
)
if
err
!=
nil
{
return
}
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
var
base
*
OrderDetailBase
_
=
gjson
.
New
(
result
)
.
Scan
(
&
base
)
if
base
.
Result
.
Type
==
1
{
_
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
else
{
var
child
*
OrderDetailChild
_
=
gjson
.
New
(
result
)
.
Scan
(
&
child
)
res
=
&
OrderDetailRes
{}
res
.
CommonRes
=
child
.
CommonRes
res
.
Result
.
Type
=
child
.
Result
.
Type
res
.
Result
.
SubmitState
=
child
.
Result
.
SubmitState
res
.
Result
.
OrderState
=
child
.
Result
.
OrderState
res
.
Result
.
POrder
=
OrderDetailPOrder
{
JdOrderId
:
child
.
Result
.
JdOrderId
,
Freight
:
child
.
Result
.
Freight
,
OrderPrice
:
child
.
Result
.
OrderPrice
,
OrderNakedPrice
:
child
.
Result
.
OrderNakedPrice
,
OrderTaxPrice
:
child
.
Result
.
OrderTaxPrice
,
Sku
:
child
.
Result
.
Sku
,
}
res
.
Result
.
COrder
=
append
(
res
.
Result
.
COrder
,
child
.
Result
)
}
return
}
//
GetFreight
查询运费
func
(
*
orderJD
)
GetFreight
(
ctx
context
.
Context
,
sku
[]
*
SkuNums
,
province
,
city
,
county
,
town
string
)
(
res
*
Get
FreightRes
,
err
error
)
{
//
Freight
查询运费
func
(
*
orderJD
)
Freight
(
ctx
context
.
Context
,
sku
[]
*
SkuNums
,
province
,
city
,
county
,
town
string
)
(
res
*
Order
FreightRes
,
err
error
)
{
method
:=
"order/getFreight"
param
:=
g
.
Map
{
"sku"
:
gjson
.
New
(
sku
)
.
MustToJsonString
(),
...
...
@@ -227,8 +235,8 @@ func (*orderJD) GetFreight(ctx context.Context, sku []*SkuNums, province, city,
return
}
// Confirm
Received
确认收货
func
(
*
orderJD
)
Confirm
Received
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
CommonRes
,
err
error
)
{
// Confirm 确认收货
func
(
*
orderJD
)
Confirm
(
ctx
context
.
Context
,
OrderID
string
)
(
res
*
CommonRes
,
err
error
)
{
method
:=
"order/confirmReceived"
param
:=
g
.
Map
{
"jdOrderId"
:
OrderID
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论