提交 39d52ade authored 作者: zhanglibo's avatar zhanglibo

天猫sdk

上级 aa50a3d0
......@@ -19,15 +19,8 @@ import (
const Source = 7
type Config struct {
ApiUrl string
AppKey string
AppSecret string
BizId string
Version string
SignatureMethod string
RegionId string
SignatureVersion string
Format string
BizUid string
}
......@@ -92,7 +85,7 @@ func hmacsha1Base64(str string) string {
return base64.StdEncoding.EncodeToString(mac.Sum(nil))
}
func post(ctx context.Context, method string, params map[string]string) (str string) {
func post(ctx context.Context, method string, params map[string]string) (str string, err error) {
Start := gtime.TimestampMilli()
curtime := time.Now().UTC()
params["Action"] = method
......@@ -137,3 +130,9 @@ func convert(pre string, req []g.Map) (res map[string]string) {
}
return
}
type CommonRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}
......@@ -7,9 +7,9 @@ import (
)
//Regist 注册单个淘宝账号接口(同步)
func (s *Config) Regist(ctx context.Context, thirdPartyUserId interface{}) (res *TmCommon, err error) {
func (s *Config) Regist(ctx context.Context, thirdPartyUserId interface{}) (res *CommonRes, err error) {
method := "RegistAnonymousTbAccount"
result := post(ctx, method, map[string]string{
result, err := post(ctx, method, map[string]string{
"BizUid": s.BizUid,
"ThirdPartyUserId": gconv.String(thirdPartyUserId),
})
......
......@@ -25,7 +25,7 @@ type DeliverInfoRes struct {
} `json:"LogisticsDetailList"`
} `json:"LogisticsDetailList"`
LogisticsCompanyName string `json:"LogisticsCompanyName"` //本单物流公司名称
logisticsCompanyCode string `json:"logisticsCompanyCode"` //本单物流公司Code
LogisticsCompanyCode string `json:"logisticsCompanyCode"` //本单物流公司Code
MailNo string `json:"MailNo"` //运单号
DataProviderTitle string `json:"DataProviderTitle"` //数据来源说明,如:本数据由菜鸟裹裹提供
} `json:"Data"`
......@@ -33,7 +33,7 @@ type DeliverInfoRes struct {
}
//Info 物流查询接口
func (s *deliverTm) Info(ctx context.Context, AppID interface{}, LmOrderId string) (res *DeliverInfoRes) {
func (s *deliverTm) Info(ctx context.Context, AppID interface{}, LmOrderId string) (res *DeliverInfoRes, err error) {
method := "queryLogistics"
......@@ -44,7 +44,7 @@ func (s *deliverTm) Info(ctx context.Context, AppID interface{}, LmOrderId strin
"ThirdPartyUserId": gconv.String(AppID),
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
......@@ -41,7 +41,7 @@ func (s *goodsTm) Inventory(ctx context.Context, DivisionCode string, req []Good
method := "queryItemInventory"
request := convert("ItemList", gconv.Maps(req))
request["DivisionCode"] = DivisionCode
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
......
package tm
type RenderOrderRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Success bool `json:"Success"`
Model struct {
RenderOrderInfos struct {
RenderOrderInfos []struct {
LmItemInfos struct {
LmItemInfos []struct {
ItemId int64 `json:"ItemId"`
Quantity int `json:Quantity`
CanSell bool `json:CanSell`
SkuId int64 `json:SkuId`
Message string `json:Message`
ItemName string `json:ItemName`
} `json:"LmItemInfos"`
} `json:"LmItemInfos"`
DeliveryInfos struct {
DeliveryInfos []struct {
ServiceType int `json:"ServiceType"`
Id string `json:"Id"`
PostFee int64 `json:"PostFee"`
DisplayName string `json:"string"`
} `json:"DeliveryInfos"`
} `json:"DeliveryInfos"`
} `json:"RenderOrderInfos"`
} `json:"RenderOrderInfos"`
} `json:"Model"`
}
type TmCommon struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}
type BatchRegistAnonymousTbAccountRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
BatchId string `json:"BatchId"`
}
type LeavePictureList struct {
Picture string `json:"Picture"` //图片地址
Desc string `json:"Desc"` //图片描述
}
type GetCustomServiceUrlRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
UrlData struct {
ReturnUrl string `json:"ReturnUrl"`
} `json:"UrlData"`
}
type SubmitReturnGoodLogisticsRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}
type SubmitReturnCancelRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}
type BeforeData struct {
Reasons []Reasons `json:"reasons"`
ServiceType []ServiceType `json:"serviceType"`
MaxRefundFeeData struct {
MaxRefundFee int64 `json:"MaxRefundFee"` //本单最大可退款金额
MinRefundFee int64 `json:"MinRefundFee"` //本单最小可退款金额
} `json:"MaxRefundFeeData"`
}
type Reasons struct {
Id int64 `json:"id"` //原因id
Name string `json:"name"` //原因
NeedVoucher bool `json:"needVoucher"` //凭证是否必须上传
NoRefundCarriage bool `json:"noRefundCarriage"` //是否支持退运费
Tip string `json:"tip"` //提示
ServiceType string `json:"serviceType"` //提示
RefundDescRequired bool `json:"refundDescRequired"` //是否要求留言
}
type ServiceType struct {
Code string `json:"code"`
Name string `json:"name"`
}
type Detail struct {
RefundCarriage int64 `json:"refundCarriage"` //运费的实际退款金额,单位:分
RejectReason string `json:"rejectReason"` // 拒绝原因
SellerReceiveAddress string `json:"sellerReceiveAddress"` //卖家地址
RefundPayment int64 `json:"refundPayment"` //实际退款金额,单位:分
SellerMobile string `json:"sellerMobile "` //收货人手机
SellerRealName string `json:"sellerRealName"` //收货人姓名
SellerTel string `json:"sellerTel"` //收货人电话
GoodsStatus int `json:"goodsStatus"` //状态1:买家未收到货 2:买家已收到货 3:买家已退货
RefundGoods bool `json:"refundGoods"` //是否要求退货
OnlyRefund bool `json:"onlyRefund"` //是否仅退款
RejectTimes int `json:"rejectTimes"` //退款单被拒绝的次数
Status string `json:"status"` //
}
......@@ -26,8 +26,39 @@ type OrderAddress struct {
AddressDetail string `json:"AddressDetail"`
}
type OrderBeforeRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Success bool `json:"Success"`
Model struct {
RenderOrderInfos struct {
RenderOrderInfos []struct {
LmItemInfos struct {
LmItemInfos []struct {
ItemId int64 `json:"ItemId"`
Quantity int `json:"Quantity"`
CanSell bool `json:"CanSell"`
SkuId int64 `json:"SkuId"`
Message string `json:"Message"`
ItemName string `json:"ItemName"`
} `json:"LmItemInfos"`
} `json:"LmItemInfos"`
DeliveryInfos struct {
DeliveryInfos []struct {
ServiceType int `json:"ServiceType"`
Id string `json:"Id"`
PostFee int64 `json:"PostFee"`
DisplayName string `json:"string"`
} `json:"DeliveryInfos"`
} `json:"DeliveryInfos"`
} `json:"RenderOrderInfos"`
} `json:"RenderOrderInfos"`
} `json:"Model"`
}
//Before 验证订单商品
func (s *orderTm) Before(ctx context.Context, addr OrderAddress, itemLists []OrderGoodsItem) (res *RenderOrderRes) {
func (s *orderTm) Before(ctx context.Context, addr OrderAddress, itemLists []OrderGoodsItem) (res *OrderBeforeRes, err error) {
method := "renderOrder"
request := convert("ItemList", gconv.Maps(itemLists))
......@@ -35,7 +66,7 @@ func (s *orderTm) Before(ctx context.Context, addr OrderAddress, itemLists []Ord
request["BizUid"] = server.BizUid
request["AccountType"] = typeEp
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
......@@ -69,7 +100,7 @@ type OrderCreateRes struct {
}
//Create 下单接口
func (s *Config) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes) {
func (s *Config) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes, err error) {
method := "createOrderV2"
request := convert("ItemList", gconv.Maps(req.ItemLists))
......@@ -79,7 +110,7 @@ func (s *Config) Create(ctx context.Context, req OrderCreateReq) (res *OrderCrea
request["AccountType"] = typeAnony
request["ThirdPartyUserId"] = gconv.String(req.AppID)
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
......@@ -91,9 +122,9 @@ type OrderPayReq struct {
}
//Pay 订单支付
func (s *Config) Pay(ctx context.Context, req OrderPayReq) (res *OrderCreateRes) {
func (s *Config) Pay(ctx context.Context, req OrderPayReq) (res *OrderCreateRes, err error) {
method := "enableOrder"
result := post(ctx, method, map[string]string{
result, err := post(ctx, method, map[string]string{
"BizUid": server.BizUid,
"LmOrderId": req.LmOrderId,
"OutTradeId": req.ChannelOrder,
......@@ -177,7 +208,7 @@ type OrderListRes struct {
}
//List 列表
func (s *orderTm) List(ctx context.Context, req OrderListReq) (res *OrderListRes) {
func (s *orderTm) List(ctx context.Context, req OrderListReq) (res *OrderListRes, err error) {
method := "queryOrderList"
var filterOption = OrderFilter{
......@@ -201,7 +232,7 @@ func (s *orderTm) List(ctx context.Context, req OrderListReq) (res *OrderListRes
"ThirdPartyUserId": gconv.String(req.AppID),
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = gjson.New(result).Scan(&res)
return
}
......@@ -212,10 +243,10 @@ type OrderCancelReq struct {
}
//Cancel 仅适⽤下单[Create]未⽀付[Pay]的订单
func (s *orderTm) Cancel(ctx context.Context, req OrderCancelReq) (res *OrderListRes) {
func (s *orderTm) Cancel(ctx context.Context, req OrderCancelReq) (res *OrderListRes, err error) {
method := "cancelOrder"
result := post(ctx, method, map[string]string{
result, err := post(ctx, method, map[string]string{
"BizUid": server.BizUid,
"LmOrderId": req.LmOrderId,
"AccountType": typeAnony,
......
......@@ -20,7 +20,7 @@ type RefundSubmitReq struct {
}
//Submit 提交退货物流信息接口
func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *SubmitReturnGoodLogisticsRes) {
func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *CommonRes, err error) {
method := "submitReturnGoodLogistics"
request := map[string]string{
......@@ -33,13 +33,13 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Submit
"AccountType": typeAnony,
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
//Cancel 取消退款申请接口
func (s *refundTm) Cancel(ctx context.Context, AppID uint, subLmOrderId, disputeId string) (res *SubmitReturnCancelRes) {
func (s *refundTm) Cancel(ctx context.Context, AppID uint, subLmOrderId, disputeId string) (res *CommonRes, err error) {
method := "cancelRefund"
request := map[string]string{
......@@ -50,7 +50,7 @@ func (s *refundTm) Cancel(ctx context.Context, AppID uint, subLmOrderId, dispute
"AccountType": typeAnony,
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
......@@ -85,7 +85,7 @@ type RefundBeforeRes struct {
}
// Before 前置
func (s *refundTm) Before(ctx context.Context, req RefundBeforeReq) (res *RefundBeforeRes) {
func (s *refundTm) Before(ctx context.Context, req RefundBeforeReq) (res *RefundBeforeRes, err error) {
method := "initApplyRefund"
request := map[string]string{
......@@ -97,7 +97,7 @@ func (s *refundTm) Before(ctx context.Context, req RefundBeforeReq) (res *Refund
"AccountType": typeAnony,
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
......@@ -110,10 +110,15 @@ type RefundApplyReq struct {
ApplyRefundCount string //退货数量
ApplyReasonTextId string //退款原因ID
LeaveMessage string //留言
LeavePictureList []*LeavePictureList //凭证,某些原因要求必须有凭证。
LeavePictureList []*RefundApplyPicture //凭证,某些原因要求必须有凭证。
GoodsStatus string //当退款类型:仅退款时,货物状态:为4未 发货。所有状态:4: 未发货, 6: 已发货, 1: 未收到货, 2: 已收到货, 3:已寄回, 5: 卖家确 认收货
}
type RefundApplyPicture struct {
Picture string `json:"Picture"` //图片地址
Desc string `json:"Desc"` //图片描述
}
type RefundApplyRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
......@@ -126,7 +131,7 @@ type RefundApplyRes struct {
}
//Apply 申请
func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundApplyRes) {
func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundApplyRes, err error) {
method := "applyRefund"
request := convert("LeavePictureList", gconv.Maps(req.LeavePictureList))
......@@ -141,7 +146,7 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA
request["AccountType"] = typeAnony
request["ThirdPartyUserId"] = gconv.String(req.AppID)
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
......@@ -181,7 +186,7 @@ type RefundInfoRes struct {
}
//Info 详情
func (s *refundTm) Info(ctx context.Context, AppID uint, subLmOrderId string) (res *RefundInfoRes) {
func (s *refundTm) Info(ctx context.Context, AppID uint, subLmOrderId string) (res *RefundInfoRes, err error) {
method := "queryRefundApplicationDetail"
request := map[string]string{
......@@ -191,7 +196,7 @@ func (s *refundTm) Info(ctx context.Context, AppID uint, subLmOrderId string) (r
"AccountType": typeAnony,
}
result := post(ctx, method, request)
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论