对接新供应链-唯品尚
This commit is contained in:
parent
79f36b239b
commit
c9190ea4d4
@ -45,3 +45,16 @@ type CreateOrderReq struct {
|
|||||||
OrderNo string `json:"orderNo"` //对接方业务单号 orderNo 是 String
|
OrderNo string `json:"orderNo"` //对接方业务单号 orderNo 是 String
|
||||||
NoticeUrl string `json:"noticeUrl"` //合作方通知地址 noticeUrl 否 String 规定值 如支持,订单更新实时通知。此参数可不用传,统一走异步回调
|
NoticeUrl string `json:"noticeUrl"` //合作方通知地址 noticeUrl 否 String 规定值 如支持,订单更新实时通知。此参数可不用传,统一走异步回调
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test ------------------------------------------------
|
||||||
|
|
||||||
|
type DeliverGoodsReq struct {
|
||||||
|
COrderItemNo string `json:"c_order_item_no"` //c_order_item_no 子订单号 是 int 下单时候返回子订单号 20190704124955600363
|
||||||
|
CDeliveryName string `json:"c_delivery_name"` // 快递公司
|
||||||
|
CDeliveryNo string `json:"c_delivery_no"` // 快递单号
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateServiceReq struct {
|
||||||
|
COrderItemNo string `json:"c_order_item_no"` //c_order_item_no 子订单号 是 int 下单时候返回子订单号 20190704124955600363
|
||||||
|
CType string `json:"c_type"` //c_type 快递名称 是 String [处理类型 1 同意售后 2 拒绝 3 退款完成]
|
||||||
|
}
|
||||||
|
@ -36,8 +36,9 @@ type SkuData struct {
|
|||||||
GoodSpecId string `json:"goodSpecId"` //商品ID(c_goods_id)
|
GoodSpecId string `json:"goodSpecId"` //商品ID(c_goods_id)
|
||||||
GoodsId string `json:"goodsId"` //商品ID(c_father_goods_id)
|
GoodsId string `json:"goodsId"` //商品ID(c_father_goods_id)
|
||||||
GoodName string `json:"goodName"` //商品名称
|
GoodName string `json:"goodName"` //商品名称
|
||||||
Num string `json:"num"` //数量
|
//Num string `json:"num"` //数量
|
||||||
Price string `json:"price"` //单价
|
Num int `json:"num"` //数量
|
||||||
|
Price string `json:"price"` //单价
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetOrderInfoRes struct {
|
type GetOrderInfoRes struct {
|
||||||
@ -91,8 +92,13 @@ type OrderInfoData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IsRefundRes struct {
|
type IsRefundRes struct {
|
||||||
Code int `json:"code"` // 0为成功,其它为失败
|
Code int `json:"code"` // 0为成功,其它为失败
|
||||||
Msg string `json:"msg"` // 请求接口消息
|
Msg string `json:"msg"` // 请求接口消息
|
||||||
|
Data IsRefundData `json:"data"` // 返回数据 data array
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type IsRefundData struct {
|
||||||
ResultType []Param `json:"resultType"` // 售后类型
|
ResultType []Param `json:"resultType"` // 售后类型
|
||||||
WareReturn []Param `json:"wareReturn"` // 服务类型
|
WareReturn []Param `json:"wareReturn"` // 服务类型
|
||||||
}
|
}
|
||||||
@ -112,3 +118,10 @@ type OrderCancelRes struct {
|
|||||||
Code int `json:"code"` // 0为成功,其它为失败
|
Code int `json:"code"` // 0为成功,其它为失败
|
||||||
Msg string `json:"msg"` // 请求接口消息
|
Msg string `json:"msg"` // 请求接口消息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test -------------------------------------
|
||||||
|
|
||||||
|
type TestRes struct {
|
||||||
|
Code int `json:"code"` // 0为成功,其它为失败
|
||||||
|
Msg string `json:"msg"` // 请求接口消息
|
||||||
|
}
|
||||||
|
@ -283,3 +283,42 @@ func (w *WeiPinShangClient) WPSPost(url string, paramMap map[string]any) (res []
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
func (w *WeiPinShangClient) DeliverGoods(deliverGoodsReq *DeliverGoodsReq) (res *TestRes, err error) {
|
||||||
|
fmt.Println("deliverGoodsReq", deliverGoodsReq)
|
||||||
|
paramMap := make(map[string]any)
|
||||||
|
paramMap["c_order_item_no"] = deliverGoodsReq.COrderItemNo
|
||||||
|
paramMap["c_delivery_name"] = deliverGoodsReq.CDeliveryName
|
||||||
|
paramMap["c_delivery_no"] = deliverGoodsReq.CDeliveryNo
|
||||||
|
postRes, err := w.WPSPost("mcang/Cycle/deliverGoods", paramMap)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(postRes, &res)
|
||||||
|
if err != nil || res == nil {
|
||||||
|
err = fmt.Errorf("转换TestRes结构体失败: %s", string(postRes))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WeiPinShangClient) UpdateService(updateServiceReq *UpdateServiceReq) (res *TestRes, err error) {
|
||||||
|
fmt.Println("updateServiceReq", updateServiceReq)
|
||||||
|
paramMap := make(map[string]any)
|
||||||
|
paramMap["c_order_item_no"] = updateServiceReq.COrderItemNo
|
||||||
|
paramMap["c_type"] = updateServiceReq.CType
|
||||||
|
postRes, err := w.WPSPost("mcang/Cycle/updateService", paramMap)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(postRes, &res)
|
||||||
|
if err != nil || res == nil {
|
||||||
|
err = fmt.Errorf("转换TestRes结构体失败: %s", string(postRes))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -80,14 +80,14 @@ func TestWeiPinShangClient_PreOrder(t *testing.T) {
|
|||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
},
|
},
|
||||||
args: PreOrderReq{
|
args: PreOrderReq{
|
||||||
GoodsInfo: "[{\"goodsId\":\"WPS9_282520\",\"goodSpecId\":\"WPS9_1221183858889276\",\"num\":1}]",
|
GoodsInfo: "[{\"goodsId\":\"WPS9_282520\",\"goodSpecId\":\"WPS9_1221183858889276\",\"num\":2},{\"goodsId\":\"WPS2_0213160707208717\",\"goodSpecId\":\"WPS2_0213160707965791\",\"num\":2}]",
|
||||||
Province: "广东省",
|
Province: "广东省",
|
||||||
Address: "奥园",
|
Address: "奥园",
|
||||||
City: "广州市",
|
City: "广州市",
|
||||||
Area: "番禺区",
|
Area: "番禺区",
|
||||||
ConsigneePhone: "15375390426",
|
ConsigneePhone: "15375390426",
|
||||||
ConsigneeContacts: "张三",
|
ConsigneeContacts: "张三",
|
||||||
LockCode: "L1234567890",
|
LockCode: "L0123456789",
|
||||||
Source: "AILEHUI",
|
Source: "AILEHUI",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -135,8 +135,8 @@ func TestWeiPinShangClient_CreateOrder(t *testing.T) {
|
|||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
},
|
},
|
||||||
args: CreateOrderReq{
|
args: CreateOrderReq{
|
||||||
LockCode: "L1234567890",
|
LockCode: "L0123456789",
|
||||||
OrderNo: "10000000000",
|
OrderNo: "20000000000",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -183,7 +183,9 @@ func TestWeiPinShangClient_GetOrderInfo(t *testing.T) {
|
|||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
orderNo: "20250527172503439229",
|
//orderNo: "20250527172503439229",
|
||||||
|
//orderNo: "10000000000",
|
||||||
|
orderNo: "20000000000",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -230,7 +232,8 @@ func TestWeiPinShangClient_GetOrderInfoByItemNO(t *testing.T) {
|
|||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
mcOrderNo: "mc20250527174640537475",
|
//mcOrderNo: "mc20250527174640537475",
|
||||||
|
mcOrderNo: "mc20250529102347907570",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -277,7 +280,8 @@ func TestWeiPinShangClient_GetOrderInfoByThirdNO(t *testing.T) {
|
|||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
orderNo: "10000000000",
|
//orderNo: "10000000000",
|
||||||
|
orderNo: "20000000000",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -310,3 +314,171 @@ func TestWeiPinShangClient_GetOrderInfoByThirdNO(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWeiPinShangClient_IsRefund(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Host string
|
||||||
|
ChannelType string
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
type args struct {
|
||||||
|
mcOrderNo string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args args
|
||||||
|
wantRes *IsRefundRes
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "test1",
|
||||||
|
fields: fields{
|
||||||
|
Host: "https://uat.api.weipinshang.net/",
|
||||||
|
ChannelType: "AILEHUI",
|
||||||
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
mcOrderNo: "mc20250529102347907570",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
h := &WeiPinShangClient{
|
||||||
|
Host: test.fields.Host,
|
||||||
|
ChannelType: test.fields.ChannelType,
|
||||||
|
Key: test.fields.Key,
|
||||||
|
}
|
||||||
|
|
||||||
|
gotRes, err := h.IsRefund(test.args.mcOrderNo)
|
||||||
|
|
||||||
|
log.Println(gotRes, err)
|
||||||
|
|
||||||
|
if (err != nil) != test.wantErr {
|
||||||
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test ---------------------------------------------------
|
||||||
|
|
||||||
|
func TestWeiPinShangClient_DeliverGoods(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Host string
|
||||||
|
ChannelType string
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args DeliverGoodsReq
|
||||||
|
wantRes *TestRes
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "test1",
|
||||||
|
fields: fields{
|
||||||
|
Host: "https://uat.api.weipinshang.net/",
|
||||||
|
ChannelType: "AILEHUI",
|
||||||
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
},
|
||||||
|
args: DeliverGoodsReq{
|
||||||
|
COrderItemNo: "mc20250527172503957733",
|
||||||
|
CDeliveryName: "顺丰",
|
||||||
|
CDeliveryNo: "1234567890",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "test1",
|
||||||
|
fields: fields{
|
||||||
|
Host: "https://uat.api.weipinshang.net/",
|
||||||
|
ChannelType: "AILEHUI",
|
||||||
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
},
|
||||||
|
args: DeliverGoodsReq{
|
||||||
|
COrderItemNo: "mc20250527172503673418",
|
||||||
|
CDeliveryName: "京东",
|
||||||
|
CDeliveryNo: "1234567890",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
h := &WeiPinShangClient{
|
||||||
|
Host: test.fields.Host,
|
||||||
|
ChannelType: test.fields.ChannelType,
|
||||||
|
Key: test.fields.Key,
|
||||||
|
}
|
||||||
|
|
||||||
|
gotRes, err := h.DeliverGoods(&test.args)
|
||||||
|
|
||||||
|
log.Println(gotRes, err)
|
||||||
|
|
||||||
|
if (err != nil) != test.wantErr {
|
||||||
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func TestWeiPinShangClient_UpdateService(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Host string
|
||||||
|
ChannelType string
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args UpdateServiceReq
|
||||||
|
wantRes *TestRes
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "test1",
|
||||||
|
fields: fields{
|
||||||
|
Host: "https://uat.api.weipinshang.net/",
|
||||||
|
ChannelType: "AILEHUI",
|
||||||
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
},
|
||||||
|
args: UpdateServiceReq{
|
||||||
|
COrderItemNo: "20250527172503439229",
|
||||||
|
CType: "1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "test1",
|
||||||
|
fields: fields{
|
||||||
|
Host: "https://uat.api.weipinshang.net/",
|
||||||
|
ChannelType: "AILEHUI",
|
||||||
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
},
|
||||||
|
args: UpdateServiceReq{
|
||||||
|
COrderItemNo: "10000000000",
|
||||||
|
CType: "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
h := &WeiPinShangClient{
|
||||||
|
Host: test.fields.Host,
|
||||||
|
ChannelType: test.fields.ChannelType,
|
||||||
|
Key: test.fields.Key,
|
||||||
|
}
|
||||||
|
|
||||||
|
gotRes, err := h.UpdateService(&test.args)
|
||||||
|
|
||||||
|
log.Println(gotRes, err)
|
||||||
|
|
||||||
|
if (err != nil) != test.wantErr {
|
||||||
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user