Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3e765809e1 | ||
![]() |
ecfa733a9b | ||
![]() |
448d47d0cb | ||
![]() |
fa3ae27283 | ||
![]() |
094d4abdf4 | ||
![]() |
c9190ea4d4 | ||
![]() |
9fbd72fa16 | ||
![]() |
b535467e6f |
@@ -19,7 +19,7 @@ func setupMockServer(path string, method string, response string, t *testing.T)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newClientWithServer(ts *httptest.Server) *wps.WeiPinShangClient {
|
func newClientWithServer(ts *httptest.Server) *wps.WeiPinShangClient {
|
||||||
return wps.NewWeiPinShangClient(wps.Config{
|
return wps.NewWeiPinShangClient(wps.WpsConfig{
|
||||||
BaseURL: wps.DevHost,
|
BaseURL: wps.DevHost,
|
||||||
ChannelType: "AILEHUI",
|
ChannelType: "AILEHUI",
|
||||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||||
|
@@ -112,7 +112,7 @@ type GetGoodsdeptRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Goodsdept struct {
|
type Goodsdept struct {
|
||||||
PageIndex string `json:"pageIndex"`
|
PageIndex interface{} `json:"pageIndex"`
|
||||||
PageCount int `json:"pageCount"`
|
PageCount int `json:"pageCount"`
|
||||||
DataCount int `json:"dataCount"`
|
DataCount int `json:"dataCount"`
|
||||||
List []Goods `json:"list"`
|
List []Goods `json:"list"`
|
||||||
|
@@ -32,7 +32,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Config 客户端配置
|
// Config 客户端配置
|
||||||
type Config struct {
|
type WpsConfig struct {
|
||||||
ChannelType string
|
ChannelType string
|
||||||
Key string
|
Key string
|
||||||
BaseURL string
|
BaseURL string
|
||||||
@@ -48,7 +48,7 @@ type WeiPinShangClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWeiPinShangClient 创建客户端
|
// NewWeiPinShangClient 创建客户端
|
||||||
func NewWeiPinShangClient(cfg Config) *WeiPinShangClient {
|
func NewWeiPinShangClient(cfg WpsConfig) *WeiPinShangClient {
|
||||||
if cfg.ChannelType == "" {
|
if cfg.ChannelType == "" {
|
||||||
cfg.ChannelType = "AILEHUI"
|
cfg.ChannelType = "AILEHUI"
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package weipinshang_api
|
package weipinshang_api
|
||||||
|
|
||||||
type CreateAfsApplyReq struct {
|
type CreateAfsApplyReq struct {
|
||||||
McOrderNo int `json:"mcOrderNo"` // 子订单号 是 int 下单时候返回子订单号 20190704124955600363
|
McOrderNo string `json:"mcOrderNo"` // 子订单号 是 int 下单时候返回子订单号 20190704124955600363
|
||||||
CustomerExpect int `json:"customerExpect"` // 售后类型 是 int [退货(10)、仅退款(40)] 10
|
CustomerExpect int `json:"customerExpect"` // 售后类型 是 int [退货(10)、仅退款(40)] 10
|
||||||
QuestionDesc string `json:"questionDesc"` // 原因描述 否 String [产品问题描述,最多600字符] 看下面请求示例
|
QuestionDesc string `json:"questionDesc"` // 原因描述 否 String [产品问题描述,最多600字符] 看下面请求示例
|
||||||
QuestionPic string `json:"questionPic"` //问题描述图片 否 String [问题描述图片.最多2000字符] 支持多张图片,用逗号分隔(英文逗号)
|
QuestionPic string `json:"questionPic"` //问题描述图片 否 String [问题描述图片.最多2000字符] 支持多张图片,用逗号分隔(英文逗号)
|
||||||
@@ -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,7 +36,8 @@ 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"` //数量
|
||||||
|
Num int `json:"num"` //数量
|
||||||
Price string `json:"price"` //单价
|
Price string `json:"price"` //单价
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +69,12 @@ type Data struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetOrderInfoByItemNORes struct {
|
type GetOrderInfoByItemNORes struct {
|
||||||
|
Code int `json:"code"` // 0为成功,其它为失败
|
||||||
|
Msg string `json:"msg"` // 请求接口消息
|
||||||
|
Data OrderInfoByItemNOData `json:"data"` // 返回数据 data array
|
||||||
|
|
||||||
|
}
|
||||||
|
type OrderInfoByItemNOData struct {
|
||||||
OrderItemNo string `json:"order_item_no"` // 子订单号
|
OrderItemNo string `json:"order_item_no"` // 子订单号
|
||||||
SendStatus string `json:"send_status"` //发货状态【’CHECKED订单被创建’,’INSTOCK已备货’,’SENDED已发货’,’RECEIVED已收货’】
|
SendStatus string `json:"send_status"` //发货状态【’CHECKED订单被创建’,’INSTOCK已备货’,’SENDED已发货’,’RECEIVED已收货’】
|
||||||
DeliveryName string `json:"delivery_name"` // 快递公司
|
DeliveryName string `json:"delivery_name"` // 快递公司
|
||||||
@@ -93,6 +100,11 @@ 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 +124,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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user