Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9fbd72fa16 | ||
![]() |
b535467e6f | ||
![]() |
3957f3b5b9 | ||
![]() |
79f36b239b |
@@ -19,7 +19,7 @@ func setupMockServer(path string, method string, response string, t *testing.T)
|
||||
}
|
||||
|
||||
func newClientWithServer(ts *httptest.Server) *wps.WeiPinShangClient {
|
||||
return wps.NewWeiPinShangClient(wps.Config{
|
||||
return wps.NewWeiPinShangClient(wps.WpsConfig{
|
||||
BaseURL: wps.DevHost,
|
||||
ChannelType: "AILEHUI",
|
||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||
|
@@ -112,10 +112,10 @@ type GetGoodsdeptRes struct {
|
||||
}
|
||||
|
||||
type Goodsdept struct {
|
||||
PageIndex string `json:"pageIndex"`
|
||||
PageCount int `json:"pageCount"`
|
||||
DataCount int `json:"dataCount"`
|
||||
List []Goods `json:"list"`
|
||||
PageIndex interface{} `json:"pageIndex"`
|
||||
PageCount int `json:"pageCount"`
|
||||
DataCount int `json:"dataCount"`
|
||||
List []Goods `json:"list"`
|
||||
}
|
||||
|
||||
// GetDetailsGoodsReq 获取批量商品详情接口
|
||||
|
@@ -32,7 +32,7 @@ const (
|
||||
)
|
||||
|
||||
// Config 客户端配置
|
||||
type Config struct {
|
||||
type WpsConfig struct {
|
||||
ChannelType string
|
||||
Key string
|
||||
BaseURL string
|
||||
@@ -48,7 +48,7 @@ type WeiPinShangClient struct {
|
||||
}
|
||||
|
||||
// NewWeiPinShangClient 创建客户端
|
||||
func NewWeiPinShangClient(cfg Config) *WeiPinShangClient {
|
||||
func NewWeiPinShangClient(cfg WpsConfig) *WeiPinShangClient {
|
||||
if cfg.ChannelType == "" {
|
||||
cfg.ChannelType = "AILEHUI"
|
||||
}
|
||||
|
@@ -35,8 +35,8 @@ type PreOrderReq struct {
|
||||
}
|
||||
|
||||
type GoodsInfo struct {
|
||||
GoodSpecId string `json:"goodSpecId"` //商品ID goodSpecId 是 String 商品ID(c_goods_id)
|
||||
GoodsId string `json:"goodsId"` //商品父 goodsId 是 String 商品父ID(c_father_goods_id)
|
||||
GoodSpecId string `json:"goodSpecId"` //SKU ID goodSpecId 是 String 商品ID(c_goods_id)
|
||||
GoodsId string `json:"goodsId"` //商品ID goodsId 是 String 商品父ID(c_father_goods_id)
|
||||
Num string `json:"num"` // 数量
|
||||
}
|
||||
|
||||
|
@@ -46,8 +46,9 @@ type GetOrderInfoRes struct {
|
||||
Data []Data `json:"data"` // 返回数据 data array
|
||||
}
|
||||
type Data struct {
|
||||
CThirdUserCode string `json:"c_third_user_code"` // 用户编码
|
||||
COrderNoThird string `json:"c_order_no_third"` // 渠道订单号
|
||||
CThirdUserCode string `json:"c_third_user_code"` // 用户编码
|
||||
//COrderNoThird string `json:"c_order_no_third"` // 渠道订单号
|
||||
COrderNo string `json:"c_order_no"` // 渠道订单号
|
||||
COrderNoPayservice string `json:"c_order_no_payservice"` //支付订单号
|
||||
CSendStatus string `json:"c_send_status"` // 订单状态 订单所处阶段【’’CHECKED订单被创建’’,’INSTOCK已备货’,’’SENDED已发货’’,’’RECEIVED已收货’’】
|
||||
CIsPay int `json:"c_is_pay"` // 支付状态(0-未支付,1-已支付)
|
||||
@@ -81,6 +82,8 @@ type GetOrderInfoByThirdNORes struct {
|
||||
Data []OrderInfoData `json:"data"` // 返回数据 data array
|
||||
}
|
||||
type OrderInfoData struct {
|
||||
GoodsId string `json:"goodsId"` //商品ID goodsId 是 String 商品父ID(c_father_goods_id)
|
||||
GoodSpecId string `json:"goodSpecId"` //SKU ID goodSpecId 是 String 商品ID(c_goods_id)
|
||||
OrderItemNo string `json:"order_item_no"` // 子订单号
|
||||
SendStatus string `json:"send_status"` //发货状态【’CHECKED订单被创建’,’INSTOCK已备货’,’SENDED已发货’,’RECEIVED已收货’】
|
||||
DeliveryName string `json:"delivery_name"` // 快递公司
|
||||
|
@@ -25,6 +25,8 @@ func NewWeiPinShangClient(host, channelType, key string) *WeiPinShangClient {
|
||||
}
|
||||
}
|
||||
|
||||
// pay
|
||||
|
||||
func (w *WeiPinShangClient) GetManyPostage(getManyPostageReq *GetManyPostageReq) (res *GetManyPostageRes, err error) {
|
||||
fmt.Println("getManyPostageReq", getManyPostageReq)
|
||||
paramMap := make(map[string]any)
|
||||
@@ -97,6 +99,8 @@ func (w *WeiPinShangClient) CreateOrder(createOrderReq *CreateOrderReq) (res *Cr
|
||||
return
|
||||
}
|
||||
|
||||
// GetOrderInfo 1
|
||||
|
||||
func (w *WeiPinShangClient) GetOrderInfo(orderNo string) (res *GetOrderInfoRes, err error) {
|
||||
fmt.Println("orderNo", orderNo)
|
||||
paramMap := make(map[string]any)
|
||||
@@ -115,6 +119,28 @@ func (w *WeiPinShangClient) GetOrderInfo(orderNo string) (res *GetOrderInfoRes,
|
||||
return
|
||||
}
|
||||
|
||||
// GetOrderInfo n
|
||||
|
||||
func (w *WeiPinShangClient) GetOrderInfoByThirdNO(orderNo string) (res *GetOrderInfoByThirdNORes, err error) {
|
||||
fmt.Println("orderNo", orderNo)
|
||||
paramMap := make(map[string]any)
|
||||
paramMap["orderNo"] = orderNo
|
||||
postRes, err := w.WPSPost("mcang/Order/getOrderInfoByThirdNO", paramMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(postRes, &res)
|
||||
if err != nil || res == nil {
|
||||
err = fmt.Errorf("转换GetOrderInfoByThirdNORes结构体失败: %s", string(postRes))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// refund
|
||||
|
||||
func (w *WeiPinShangClient) GetOrderInfoByItemNO(mcOrderNo string) (res *GetOrderInfoByItemNORes, err error) {
|
||||
fmt.Println("mcOrderNo", mcOrderNo)
|
||||
//paramMap := make(map[string]any)
|
||||
@@ -136,24 +162,6 @@ func (w *WeiPinShangClient) GetOrderInfoByItemNO(mcOrderNo string) (res *GetOrde
|
||||
return
|
||||
}
|
||||
|
||||
func (w *WeiPinShangClient) GetOrderInfoByThirdNO(orderNo string) (res *GetOrderInfoByThirdNORes, err error) {
|
||||
fmt.Println("orderNo", orderNo)
|
||||
paramMap := make(map[string]any)
|
||||
paramMap["orderNo"] = orderNo
|
||||
postRes, err := w.WPSPost("mcang/Order/getOrderInfoByThirdNO", paramMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(postRes, &res)
|
||||
if err != nil || res == nil {
|
||||
err = fmt.Errorf("转换GetOrderInfoByThirdNORes结构体失败: %s", string(postRes))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (w *WeiPinShangClient) IsRefund(mcOrderNo string) (res *IsRefundRes, err error) {
|
||||
fmt.Println("mcOrderNo", mcOrderNo)
|
||||
paramMap := make(map[string]any)
|
||||
|
@@ -159,6 +159,53 @@ func TestWeiPinShangClient_CreateOrder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWeiPinShangClient_GetOrderInfo(t *testing.T) {
|
||||
type fields struct {
|
||||
Host string
|
||||
ChannelType string
|
||||
Key string
|
||||
}
|
||||
type args struct {
|
||||
orderNo string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
wantRes *GetOrderInfoRes
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
fields: fields{
|
||||
Host: "https://uat.api.weipinshang.net/",
|
||||
ChannelType: "AILEHUI",
|
||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||
},
|
||||
args: args{
|
||||
orderNo: "20250527172503439229",
|
||||
},
|
||||
},
|
||||
}
|
||||
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.GetOrderInfo(test.args.orderNo)
|
||||
|
||||
log.Println(gotRes, err)
|
||||
|
||||
if (err != nil) != test.wantErr {
|
||||
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWeiPinShangClient_GetOrderInfoByItemNO(t *testing.T) {
|
||||
type fields struct {
|
||||
Host string
|
||||
@@ -233,6 +280,17 @@ func TestWeiPinShangClient_GetOrderInfoByThirdNO(t *testing.T) {
|
||||
orderNo: "10000000000",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "test1",
|
||||
fields: fields{
|
||||
Host: "https://uat.api.weipinshang.net/",
|
||||
ChannelType: "AILEHUI",
|
||||
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
||||
},
|
||||
args: args{
|
||||
orderNo: "20250527172503439229",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user