提交 f51c4b44 authored 作者: 赵雪如's avatar 赵雪如

tmNew

上级 57159e65
package tm
import (
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
)
type Config struct {
AppKey string
AppSecret string
TenantId string
DistributorId string
DistributionMallId string
DistributionSupplierId string
}
var server *Config
const PkgName = "tm"
const (
apiUrl string = "http://linkedmall.aliyuncs.com/"
regionId string = "cn-hangzhou"
bizId string = "LMALL201912050002"
signatureVersion string = "1.0"
signatureMethod string = "HMAC-SHA1"
version string = "2022-05-31"
format string = "JSON"
typeAnony string = "ANONY"
typeEp string = "EP"
)
func New(req *Config) {
server = req
return
}
func initClient() (client *link.Client, err error){
config:=&openapi.Config{
AccessKeyId: tea.String(server.AppKey),
AccessKeySecret: tea.String(server.AppSecret),
}
// 访问的域名
config.Endpoint = tea.String("linkedmall.aliyuncs.com")
client, err = link.NewClient(config)
return
}
// todo 部分接口验签通过,部分不通过天猫技术不支持对接,后续有时间再自己写
//func specialUrlEncode(req string) (res string) {
// req = url.QueryEscape(req)
// req = strings.Replace(req, "+", "%20", -1)
// req = strings.Replace(req, "*", "%2A", -1)
// req = strings.Replace(req, "*7E", "~", -1)
// res = req
// return
//}
//
//func sign(param map[string]string) {
// var keys []string
//
// mewparam := param
// for k := range mewparam {
// keys = append(keys, k)
// }
//
// sort.Strings(keys)
//
// var signStr string
//
// u := url.Values{}
// for _, v := range keys {
// u.Set(v, mewparam[v])
// }
// signStr += specialUrlEncode(u.Encode())
// signStr = "POST&" + specialUrlEncode("/") + "&" + signStr
//
// param["Signature"] = hmacsha1Base64(signStr)
//
// return
//}
//
//func hmacsha1Base64(str string) string {
// appSecret := []byte(server.AppSecret + "&")
// mac := hmac.New(sha1.New, appSecret)
// mac.Write([]byte(str))
// return base64.StdEncoding.EncodeToString(mac.Sum(nil))
//}
//
//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
// params["AccessKeyId"] = server.AppKey
// params["RegionId"] = regionId
// params["SignatureMethod"] = signatureMethod
// params["SignatureVersion"] = signatureVersion
// params["Version"] = version
// params["Format"] = format
// params["SignatureNonce"] = grand.S(32)
// params["Timestamp"] = curtime.Format("2006-01-02T15:04:05Z")
// params["Style"] = "RPC"
// params["ReqBodyType"] = "formData"
// params["BodyType"] = "json"
//
// sign(params)
//
// Request := g.Client()
// Request.SetHeader("Content-Type", "application/x-www-form-urlencoded")
// Request.Timeout(3 * time.Second)
// resp, err := Request.Post(apiUrl, params)
// defer func() {
// _ = resp.Close()
// paramStr := gjson.New(params).MustToJsonString()
// ctx = context.WithValue(ctx, "Method", "POST")
// ctx = context.WithValue(ctx, "URI", apiUrl+params["Action"])
// if err != nil {
// g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
// } else {
// g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start)
// }
// }()
// str = resp.ReadAllString()
// return
//
//}
//
//func convert(pre string, req []map[string]interface{}) (res map[string]string) {
// res = make(map[string]string)
// for k, v := range req {
// for key, val := range v {
// if reflect.TypeOf(val).String() == "[]string" {
// for key2, val2 := range gconv.Strings(val) {
// res[pre+"."+gconv.String(k+1)+"."+key+"."+gconv.String(key2+1)] = gconv.String(val2)
// }
// } else {
// res[pre+"."+gconv.String(k+1)+"."+key] = gconv.String(val)
// }
// }
// }
// return
//}
//
//type CommonRes struct {
// Code string `json:"Code"`
// Message string `json:"Message"`
// RequestId string `json:"RequestId"`
//}
package tm
type accountTm struct {
}
var Account = accountTm{}
//Regist 注册单个淘宝账号接口(同步)
//func (s *accountTm) Regist(ctx context.Context, UserId string) (res *CommonRes, err error) {
// method := "RegistAnonymousTbAccount"
// result, err := post(ctx, method, map[string]string{
// "BizUid": server.BizUid,
// "ThirdPartyUserId": UserId,
// })
// _ = json.Unmarshal([]byte(result), &res)
// return
//}
package tm
import (
"context"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
)
type category struct {
}
var Category = category{}
type QueryMallCategoryListRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
Model []struct {
CategoryId int `json:"CategoryId"`
ParentId int `json:"ParentId"`
Leaf bool `json:"Leaf"`
Name string `json:"Name"`
} `json:"Model"`
Code string `json:"Code"`
Success bool `json:"Success"`
}
//区域库存商品详情
func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *QueryMallCategoryListRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryMallCategoryList(&link.QueryMallCategoryListRequest{
DistributionMallId: tea.String(server.DistributionMallId),
DistributorId: tea.String(server.DistributorId),
CategoryId: tea.Int64(item),
TenantId: tea.String(server.TenantId),
})
if err !=nil{
return
}
if result==nil{
return
}
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
//req ,_:=gjson.Encode(item)
//resultString ,_:=gjson.Encode(result)
//log(ctx,string(req),err,string(resultString))
return
}
type CategoryListRes struct {
Code string `json:"Code"` //成功 0000
Message string `json:"Message"`
RequestId string `json:"RequestId"`
CategoryList struct {
Category []struct {
CategoryId int `json:"CategoryId"`
Name string `json:"Name"`
} `json:"Category"`
} `json:"CategoryList"`
}
//func (category) List(ctx context.Context, req string) (res *CategoryListRes, err error) {
// method := "GetCategoryList"
//
// request := map[string]string{
// "CategoryId": req,
// }
//
// result, err := post(ctx, method, request)
// err = gjson.New(result).Scan(&res)
// return
//}
package tm
import (
"context"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
)
type goodsTmNew struct {
}
var Goods = goodsTmNew{}
//type QueryItemDetailWithDivisionReq struct {
// ItemId string `json:"ItemId"`
// //SkuIdList []string `json:"SkuIdList"`
//}
type QueryItemDetailWithDivisionRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
Model struct {
CanSell bool `json:"CanSell"`
CategoryID int `json:"CategoryId"`
CategoryIds []int `json:"CategoryIds"`
City string `json:"City"`
Current string `json:"Current"`
DescOption string `json:"DescOption"`
DescPath string `json:"DescPath"`
DistributionMallID string `json:"DistributionMallId"`
Features struct {
DeliveryVersion string `json:"delivery_version"`
ExtraPeriod string `json:"extraPeriod"`
FoodProDate string `json:"food_pro_date"`
} `json:"Features"`
FirstPicURL string `json:"FirstPicUrl"`
HasQuantity bool `json:"HasQuantity"`
IforestProps []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"IforestProps"`
ItemID int64 `json:"ItemId"`
ItemImages []string `json:"ItemImages"`
ItemTitle string `json:"ItemTitle"`
ItemTotalSimpleValue string `json:"ItemTotalSimpleValue"`
ItemTotalValue int `json:"ItemTotalValue"`
LmItemCategory string `json:"LmItemCategory"`
LmItemID string `json:"LmItemId"`
MainPicURL string `json:"MainPicUrl"`
MinPrice int `json:"MinPrice"`
Properties map[string][]string `json:"Properties"`
Prov string `json:"Prov"`
Quantity int `json:"Quantity"`
ReservePrice int `json:"ReservePrice"`
SecuredTransactions int `json:"SecuredTransactions"`
SellerPayPostfee bool `json:"SellerPayPostfee"`
SimpleQuantity string `json:"SimpleQuantity"`
SkuModels []struct {
DistributionMallID string `json:"DistributionMallId"`
ExtJSON string `json:"ExtJson"`
HasQuantity bool `json:"HasQuantity"`
ItemID int64 `json:"ItemId"`
LmItemID string `json:"LmItemId"`
PriceCent int `json:"PriceCent"`
Quantity int `json:"Quantity"`
ReservePrice int `json:"ReservePrice"`
SimpleQuantity string `json:"SimpleQuantity"`
SkuID int64 `json:"SkuId"`
SkuPicURL string `json:"SkuPicUrl"`
SkuPvs string `json:"SkuPvs"`
SkuTitle string `json:"SkuTitle"`
Status int `json:"Status"`
SupplierPrice int `json:"SupplierPrice"`
CanNotBeSoldCode string `json:"CanNotBeSoldCode,omitempty"`
CanNotBeSoldMassage string `json:"CanNotBeSoldMassage,omitempty"`
} `json:"SkuModels"`
SkuPropertys []struct {
ID int `json:"Id"`
Text string `json:"Text"`
Values []struct {
ID int64 `json:"Id"`
Text string `json:"Text"`
} `json:"Values"`
} `json:"SkuPropertys"`
UserType int `json:"UserType"`
} `json:"Model"`
RequestID string `json:"RequestId"`
Success bool `json:"Success"`
}
type ListDistributionItemReq struct {
Page string `json:"page"`
Limit string `json:"limit"`
LmItemId string `json:"LmItemId"`
}
type ListDistributionItemRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
Model []struct {
CategoryID int `json:"CategoryId"`
CategoryIds []int `json:"CategoryIds"`
City string `json:"City"`
Current string `json:"Current"`
DescPath string `json:"DescPath"`
DistributionMallID string `json:"DistributionMallId"`
Features struct {
DeliveryVersion string `json:"delivery_version"`
TaxInvoice string `json:"tax_invoice"`
TaxRateCode string `json:"tax_rate_code"`
} `json:"Features"`
FirstPicURL string `json:"FirstPicUrl"`
HasQuantity bool `json:"HasQuantity"`
IforestProps []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"IforestProps"`
IsCanSell bool `json:"IsCanSell"`
IsSellerPayPostfee bool `json:"IsSellerPayPostfee"`
ItemID int64 `json:"ItemId"`
ItemImages []string `json:"ItemImages"`
ItemTitle string `json:"ItemTitle"`
ItemTotalSimpleValue string `json:"ItemTotalSimpleValue"`
ItemTotalValue int `json:"ItemTotalValue"`
LmItemAttributeMap struct {
TaxInvoice string `json:"taxInvoice"`
TaxRateCode string `json:"taxRateCode"`
} `json:"LmItemAttributeMap"`
LmItemCategory string `json:"LmItemCategory"`
LmItemID string `json:"LmItemId"`
MainPicURL string `json:"MainPicUrl"`
Properties map[string][]string `json:"Properties"`
Prov string `json:"Prov"`
Quantity int `json:"Quantity"`
ReservedPrice int `json:"ReservedPrice"`
SecuredTransactions int `json:"SecuredTransactions"`
SimpleQuantity string `json:"SimpleQuantity"`
SkuModels []struct {
DistributionMallID string `json:"DistributionMallId"`
HasQuantity bool `json:"HasQuantity"`
ItemID int64 `json:"ItemId"`
LmItemID string `json:"LmItemId"`
LmSkuAttributeMap struct {
TaxInvoice string `json:"taxInvoice"`
TaxRateCode string `json:"taxRateCode"`
} `json:"LmSkuAttributeMap"`
PriceCent int `json:"PriceCent"`
Quantity int `json:"Quantity"`
ReservedPrice int `json:"ReservedPrice"`
SimpleQuantity string `json:"SimpleQuantity"`
SkuID int `json:"SkuId"`
SkuPicURL string `json:"SkuPicUrl"`
SkuPvs string `json:"SkuPvs"`
Status int `json:"Status"`
SupplierPrice int `json:"SupplierPrice"`
} `json:"SkuModels"`
UserType int `json:"UserType"`
VideoPicURL string `json:"VideoPicUrl"`
VideoURL string `json:"VideoUrl"`
} `json:"Model"`
PageNumber int `json:"PageNumber"`
PageSize int `json:"PageSize"`
RequestID string `json:"RequestId"`
Success bool `json:"Success"`
TotalCount int `json:"TotalCount"`
}
//区域库存商品详情
func (s *goodsTmNew) QueryItemDetailWithDivision(ctx context.Context,item string) (res *QueryItemDetailWithDivisionRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryItemDetailWithDivision(&link.QueryItemDetailWithDivisionRequest{
DistributionMallId: tea.String(server.DistributionMallId),
DistributorId: tea.String(server.DistributorId),
LmItemId: tea.String(item),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
return
}
////商品列表
func (s *goodsTmNew) ListDistributionItem(ctx context.Context,item *ListDistributionItemReq) (res *ListDistributionItemRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.ListDistributionItemWithoutCache(&link.ListDistributionItemWithoutCacheRequest{
DistributionMallId: tea.String(server.DistributionMallId),
DistributorId: tea.String(server.DistributorId),
//LmItemId: tea.String(item),
TenantId: tea.String(server.TenantId),
PageNumber: tea.Int32(1),
PageSize: tea.Int32(10),
})
if err!=nil{
return
}
if result==nil{
return
}
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
return
}
//Detail 详情 todo 该接口正确通过,由于订单部分接口不通过天猫技术不支持对接,后续有时间再自己写
//func (*goodsTmNew) QueryItemDetailWithDivision(ctx context.Context, req string) (res *QueryItemDetailWithDivisionRes, err error) {
// method := "QueryItemDetailWithDivision"
// request := g.MapStrStr{
// "DistributionMallId": server.DistributionMallId,
// "DistributorId": server.DistributorId,
// "LmItemId": req,
// "TenantId": server.TenantId,
// }
// result, err := post(ctx, method, request)
//
// _ = gjson.NewWithOptions(result, gjson.Options{
// StrNumber: true,
// }).Scan(&res)
// return
//}
//todo 部分接口验签通过, 该接口正确通过,由于订单部分接口不通过天猫技术不支持对接,后续有时间再自己写
//func (*goodsTmNew) ListDistributionItem(ctx context.Context, req *ListDistributionItemReq) (res *ListDistributionItemRes, err error) {
// method := "ListDistributionItem"
// request := g.MapStrStr{
// "DistributionMallId": server.DistributionMallId,
// "DistributorId": server.DistributorId,
// //"LmItemId": req.LmItemId,
// "TenantId": server.TenantId,
// "PageNumber": req.Page,
// "PageSize": req.Limit,
// }
// result, err := post(ctx, method, request)
// _ = gjson.NewWithOptions(result, gjson.Options{
// StrNumber: true,
// }).Scan(&res)
// return
//}
\ No newline at end of file
package tm
import (
"context"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
)
type logisticsTmNew struct {
}
var Logistics = logisticsTmNew{}
type LogisticsTraceRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Model []struct{
MailNo string `json:"MailNo"`
DataProvIDer string `json:"DataProvIDer"`
DataProvIDerTitle string `json:"DataProvIDerTitle"`
LogisticsCompanyCode string `json:"LogisticsCompanyCode"`
LogisticsCompanyName string `json:"LogisticsCompanyName"`
LogisticsDetailList []struct {
OcurrTimeStr string `json:"OcurrTimeStr"`
StanderdDesc string `json:"StanderdDesc"`
} `json:"LogisticsDetailList"`
Goods []struct {
GoodName string `json:"GoodName"`
Quantity interface{} `json:"Quantity"`
ItemID string `json:"ItemID"`
} `json:"Goods"`
} `json:"Model"`
}
//Trace 物流查询接口
func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn string) (res *LogisticsTraceRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryLogistics4Distribution(&link.QueryLogistics4DistributionRequest{
DistributorId: tea.String(server.DistributorId),
MainDistributionOrderId: tea.String(orderSn),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
\ No newline at end of file
package tm
import (
"context"
"encoding/json"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type orderTm struct {
}
var Order = orderTm{}
type OrderAddress struct {
AddressDetail string `json:"AddressDetail"`
DivisionCode string `json:"DivisionCode"`
FullName string `json:"FullName"`
Mobile string `json:"Mobile"`
TownDivisionCode string `json:"TownDivisionCode"`
}
type RenderDistributionOrderReq struct {
ItemInfoLists []*ItemInfo `json:"ItemInfoLists"`
BuyerId string `json:"BuyerId"`
Addr string `json:"Addr"`
}
type ItemInfo struct{
DistributionMallId string `json:"DistributionMallId,omitempty" xml:"DistributionMallId,omitempty"`
LmItemId string `json:"LmItemId,omitempty" xml:"LmItemId,omitempty"`
Quantity int32 `json:"Quantity,omitempty" xml:"Quantity,omitempty"`
SkuId string `json:"SkuId,omitempty" xml:"SkuId,omitempty"`
}
type RenderDistributionOrderRes struct {
Code string `json:" Code"`
Message string `json:"Message"`
Model struct {
AddressInfos []struct {
AddressDetail string `json:"AddressDetail"`
AddressId int64 `json:"AddressId"`
DivisionCode string `json:"DivisionCode"`
Receiver string `json:"Receiver"`
ReceiveRPhone string `json:"Receive rPhone"`
TownDivisionCode string `json:"TownDivisionCode"`
} `json:"AddressInfos"`
CanSell bool `json:"CanSell"`
RenderOrderInfos []struct {
CanSell bool `json:"CanSell"`
DeliveryInfos []struct {
DisplayName string `json:"DisplayName"`
Id string `json:"Id"`
PostFee int `json:"PostFee"`
ServiceType int `json:"ServiceType"`
} `json:"DeliveryInfos"`
InvoiceInfo struct {
} `json:"InvoiceInfo"`
ItemInfos []struct {
CanSell bool `json:"CanSell"`
DistributionMallId string `json:"DistributionMallId"`
Features struct {
DeliveryVersion string `json:"delivery_version"`
ExTraPeriod string `json:"ex traPeriod"`
TaxInvoice string `json:"tax_invoice"`
} `json:"Features"`
ItemId string `json:"ItemId"`
ItemName string `json:"ItemName"`
ItemPicUrl string `json:"ItemPicUrl"`
Price int `json:"Price"`
Quantity int `json:"Quantity"`
SkuId int64 `json:"SkuId"`
SkuName string `json:"SkuName"`
} `json:"ItemInfos"`
} `json:"RenderOrderInfos"`
} `json:"Model"`
RequestId string `json:"RequestId"`
Success bool `json:"Success"`
}
type OrderCreateReq struct {
UserId string
ChannelOrder string
Address OrderAddress
ItemLists []OrderGoodsItem
}
type OrderGoodsItem struct {
LmItemId string `json:"LmItemId"`
Quantity string `json:"Quantity"`
SkuId string `json:"SkuId"`
DistributionMallId string `json:"DistributionMallId"`
}
type OrderCreateRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
Model string `json:"Model"`
Code string `json:"Code"`
Success bool `json:"Success"`
}
type OrderFilter struct {
DistributionTradeId string `json:"DistributionTradeId,omitempty"`
OrderList []string `json:"OrderList,omitempty"`
LogisticsStatus string `json:"LogisticsStatus,omitempty"`
OrderStatus string `json:"OrderStatus,omitempty"`
}
type T struct {
CreateDate string `json:"createDate"`
DistributionOrderId string `json:"distributionOrderId"`
DistributorId string `json:"distributorId"`
LogisticsStatus string `json:"logisticsStatus"`
OrderAmount string `json:"orderAmount"`
OrderStatus string `json:"orderStatus"`
SubOrderList []struct {
ItemId string `json:"itemId"`
ItemPic string `json:"itemPic"`
ItemPrice []struct {
FundAmountMoney string `json:"fundAmountMoney"`
} `json:"itemPrice"`
ItemTitle string `json:"itemTitle"`
Number string `json:"number"`
SkuId string `json:"skuId"`
SkuName string `json:"skuName"`
OrderStatus string `json:"orderStatus"`
LogisticsStatus string `json:"logisticsStatus"`
SubDistributionOrderId string `json:"subDistributionOrderId"`
MainDistributionOrderId string `json:"mainDistributionOrderId"`
} `json:"subOrderList"`
}
type OrderListRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
PageSize int `json:"PageSize"`
PageNumber int `json:"PageNumber"`
Code string `json:"Code"`
Model []struct{
CreateDate string `json:"CreateDate"`
DistributionOrderId string `json:"DistributionOrderId"`
DistributorId string `json:"DistributorId"`
LogisticsStatus string `json:"LogisticsStatus"`
OrderAmount string `json:"OrderAmount"`
OrderStatus string `json:"OrderStatus"`
SubOrderList []struct {
ItemId string `json:"ItemId"`
ItemPic string `json:"ItemPic"`
ItemPrice []struct {
FundAmountMoney string `json:"FundAmountMoney"`
} `json:"ItemPrice"`
ItemTitle string `json:"ItemTitle"`
Number string `json:"Number"`
SkuId string `json:"SkuId"`
SkuName string `json:"SkuName"`
OrderStatus string `json:"OrderStatus"`
LogisticsStatus string `json:"LogisticsStatus"`
SubDistributionOrderId string `json:"SubDistributionOrderId"`
MainDistributionOrderId string `json:"MainDistributionOrderId"`
} `json:"SubOrderList"`
}
}
type OrderListReq struct {
DistributorId string `json:"DistributorId"`
FilterOption struct{
DistributionTradeId string `json:"DistributionTradeId"`
OrderList []string `json:"OrderList"`
} `json:"FilterOption"`
PageNumber int32 `json:"PageNumber"`
PageSize int32 `json:"PageSize"`
LogisticsStatus string `json:"LogisticsStatus"`
OrderStatus string `json:"OrderStatus"`
}
type FilterOption struct {
}
type OrderInfoReq struct {
MainDistributionOrderId string `json:"MainDistributionOrderId"`
UserId string `json:"UserId"`
LmOrderId string `json:"LmOrderId"`
LogisticsStatus string `json:"LogisticsStatus"`
OrderStatus string `json:"OrderStatus"`
}
type OrderInfoRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
Code string `json:"Code"`
Model struct{
CreateDate string `json:"CreateDate"`
DistributionOrderId string `json:"DistributionOrderId"`
DistributorId string `json:"DistributorId"`
LogisticsStatus string `json:"LogisticsStatus"`
OrderAmount string `json:"OrderAmount"`
OrderStatus string `json:"OrderStatus"`
SubOrderList []struct {
ItemId string `json:"ItemId"`
ItemPic string `json:"ItemPic"`
ItemPrice []struct {
FundAmountMoney string `json:"FundAmountMoney"`
} `json:"ItemPrice"`
ItemTitle string `json:"ItemTitle"`
Number string `json:"Number"`
SkuId string `json:"SkuId"`
SkuName string `json:"SkuName"`
OrderStatus string `json:"OrderStatus"`
LogisticsStatus string `json:"LogisticsStatus"`
SubDistributionOrderId string `json:"SubDistributionOrderId"`
MainDistributionOrderId string `json:"MainDistributionOrderId"`
} `json:"SubOrderList"`
} `json:"Model"`
}
type OrderStatusReq struct {
DistributionTradeId string `json:"DistributionTradeId"`
}
type OrderStatusRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
Code string `json:"Code"`
Model string `json:"Model"`
//1:分销单创建中
//
//10:采购中
//
//20:采购成功,待发货
//
//21:采购成功,部分发货
//
//22:采购成功,全部发货
//
//30:部分采购成功,待发货
//
//31:部分采购成功,部分发货
//
//32:部分采购成功,全部发货
//
//80:交易失败
//
//81:采购失败
//
//99:交易成功
}
//Before 验证订单商品
func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderReq) (res *RenderDistributionOrderRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
if itemInfo==nil{
return
}
var itemInfoLists []*link.RenderDistributionOrderRequestItemInfoLists
err =gjson.New(itemInfo.ItemInfoLists).Scan(&itemInfoLists)
result ,err :=client.RenderDistributionOrder(&link.RenderDistributionOrderRequest{
BuyerId: tea.String(itemInfo.BuyerId),
DistributorId: tea.String(server.DistributorId),
ItemInfoLists: itemInfoLists,
TenantId: tea.String(server.TenantId),
DeliveryAddress: tea.String(gjson.New(itemInfo.Addr).MustToJsonString()),
DistributionSupplierId: tea.String(server.DistributionSupplierId),
})
if err!=nil{
return
}
if result==nil{
return
}
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
return
}
//订单列表
func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryOrderList4Distribution(&link.QueryOrderList4DistributionRequest{
DistributorId: tea.String(server.DistributorId),
FilterOption: tea.String(gjson.New(item.FilterOption).MustToJsonString()),
PageNumber: tea.Int32(item.PageNumber),
PageSize: tea.Int32(item.PageSize),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
a,_ :=json.Marshal(result.Body)
if err := json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
}
return
}
//创建订单
func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCreateRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
if item==nil{
return
}
var itemInfoLists []*link.ApplyCreateDistributionOrderRequestItemInfoLists
err =gjson.New(item.ItemLists).Scan(&itemInfoLists)
result ,err :=client.ApplyCreateDistributionOrder(&link.ApplyCreateDistributionOrderRequest{
DistributorId: tea.String(server.DistributorId),
TenantId: tea.String(server.TenantId),
DistributionSupplierId: tea.String(server.DistributionSupplierId),
BuyerId: tea.String(item.UserId),
ItemInfoLists: itemInfoLists,
DeliveryAddress: tea.String(gjson.New(item.Address).MustToJsonString()),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//订单详情
func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfoRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
g.Dump(item.MainDistributionOrderId,"item.MainDistributionOrderId")
result ,err :=client.QueryOrderDetail4Distribution(&link.QueryOrderDetail4DistributionRequest{
DistributorId: tea.String(server.DistributorId),
MainDistributionOrderId: tea.String(item.MainDistributionOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//订单交易状态
func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderStatusRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryDistributionTradeStatus(&link.QueryDistributionTradeStatusRequest{
DistributorId: tea.String(server.DistributorId),
DistributionTradeId: tea.String(item.DistributionTradeId),
TenantId: tea.String(server.TenantId),
DistributionSupplierId: tea.String(server.DistributionSupplierId),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//订单详情
//func (s *orderTm) Detail(ctx context.Context,req OrderInfoReq) (res OrderInfoRes,err error) {
//
// method := "QueryOrderDetail4Distribution"
//
//
// request := map[string]string{
// "DistributorId" : server.DistributorId,
// "MainDistributionOrderId" :req.MainDistributionOrderId,
// }
//
// result, err := post(ctx, method, request)
// g.Dump(result,"resuelet--------")
// //_ = json.Unmarshal([]byte(result), &res)
// return
//}
//Before 验证订单商品 todo 该接口正确通过,由于订单部分接口不通过天猫技术不支持对接,后续有时间再自己写
//func (s *orderTm) RenderDistributionOrder(ctx context.Context, addr OrderAddress, itemInfo *RenderDistributionOrderReq) (res *RenderDistributionOrderRes, err error) {
// method := "RenderDistributionOrder"
// fmt.Println(1)
// request := g.MapStrStr{
// //"ItemInfoLists" :gjson.New(itemInfo.ItemInfoLists).MustToJsonString(),
// // "ItemInfoLists":fmt.Sprintf(`{
// // "lmItemId" : "10027642-706637605402",
// // "distributionMallId":"9e7b3e4ba5e24dd49b89498f09d05cf1",
// // "skuId" : "46059969",
// // "quantity": 1
// //}`),
// "DeliveryAddress": gjson.New(addr).MustToJsonString(),
// "BuyerId": itemInfo.BuyerId,
// "TenantId": server.TenantId,
// "DistributorId": server.DistributorId,
// "DistributionSupplierId": server.DistributionSupplierId,
// }
// g.Dump("request=====", request)
//
// result, err := post(ctx, method, request)
// err = gjson.New(result).Scan(&res)
// return
//}
//Create 下单接口
//func (s *orderTm) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes, err error) {
// method := "ApplyCreateDistributionOrder"
// g.Dump("req.ItemLists=====",req.ItemLists)
// request := convert("ItemInfoLists", gconv.Maps(req.ItemLists))
// request["DeliveryAddress"] = gjson.New(req.Address).MustToJsonString()
// request["TenantId"] = server.TenantId
// request["DistributorId"] = server.DistributorId
// request["BuyerId"] = req.UserId
// request["DistributionSupplierId"] = server.DistributionSupplierId
// request["DistributionOutTradeId"] = req.ChannelOrder
// result, err := post(ctx, method, request)
// err =gjson.New(result).Scan(&res)
// return
//}
//
//type OrderListReq struct {
// UserId string
// ChannelOrder string
// LmOrderId string
// LogisticsStatus string
// OrderStatus string
//}
//
//List 列表
//func (s *orderTm) QueryOrderList4Distribution(ctx context.Context,req OrderListReq) (res OrderListRes,err error) {
// method := "QueryOrderList4Distribution"
//
// var filterOption = OrderFilter{
// LogisticsStatus: "1",
// OrderStatus: req.OrderStatus,
// }
// //if req.LmOrderId != "" {
// // filterOption.LmOrderList = garray.NewStrArray().Append(req.LmOrderId).Slice()
// //}
// //if req.ChannelOrder != "" {
// // filterOption.ChannelOrder = garray.NewStrArray().Append(req.ChannelOrder).Slice()
// //
// //}
//
// request := map[string]string{
// "FilterOption": gjson.New(filterOption).MustToJsonString(),
// "PageNumber": "1",
// "PageSize": "20",
// "DistributorId" : server.DistributorId,
// "TenantId" :server.TenantId,
//
// }
//
// result, err := post(ctx, method, request)
// g.Dump(result,"resuelet--------")
// //_ = json.Unmarshal([]byte(result), &res)
// return
//}
//type OrderCancelReq struct {
// UserId string
// LmOrderId string
//}
//
package tm
import (
"context"
"encoding/json"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type refundTm struct {
}
var Refund = refundTm{}
type RefundSubmitReq struct {
UserId string
SubLmOrderId string //子订单号
DisputeId string //售后ID
CpCode string //物流编码
LogisticsNo string //物流单号
}
type RefundCancelRes struct {
Code string `json:" Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Success bool `json:"Success"`
Model struct{
SubDistributionOrderId string `json:"SubDistributionOrderId"`
DisputeStatus int `json:"DisputeStatus"`
DisputeType int `json:"DisputeType"`
} `json:"Model"`
}
type CommonRes struct {
Code string `json:" Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Success bool `json:"Success"`
}
type RefundBeforeReq struct {
SubDistributionOrderId string `json:"SubDistributionOrderId"`
BizClaimType int32 `json:"BizClaimType"`
GoodsStatus string `json:"GoodsStatus"`
}
type RefundBeforeRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Model struct {
SubDistributionOrderId string `json:"SubDistributionOrderId"`
BizClaimType int `json:"BizClaimType"`
MainOrderRefund bool `json:"MainOrderRefund"`
MaxRefundFeeData struct {
MaxRefundFee int `json:"MaxRefundFee"`
MinRefundFee int `json:"MinRefundFee"`
} `json:"MaxRefundFeeData"`
RefundReasonList []struct {
ReasonTextId string `json:"ReasonTextId"`
ReasonTips string `json:"ReasonTips"`
ProofRequired bool `json:"ProofRequired"`
RefundDescRequired bool `json:"RefundDescRequired"`
} `json:"RefundReasonList"`
}
}
type RefundApplyReq struct {
UserId string
SubLmOrderId string //子订单号
BizClaimType string //退款类型
ApplyRefundFee int64 //申请退款金额
ApplyRefundCount int32 //退货数量
ApplyReasonTextId int64 //退款原因ID
LeaveMessage string //留言
LeavePictureList []*RefundApplyPicture //凭证,某些原因要求必须有凭证。
GoodsStatus int32 //当退款类型:仅退款时,货物状态:为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"`
RequestId string `json:"RequestId"`
Model struct {
SubDistributionOrderId string `json:"SubDistributionOrderId"` //当前发起逆向的子订单号
DisputeStatus int `json:"DisputeStatus"` //逆向的状态
DisputeType int `json:"DisputeType"` //任意退款类型
DisputeId int64 `json:"DisputeId"` //shou
} `json:"Model"`
}
//Before 前置
func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *RefundBeforeRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.InitApplyRefund4Distribution(&link.InitApplyRefund4DistributionRequest{
BizClaimType: tea.Int32(req.BizClaimType),
DistributorId: tea.String(server.DistributorId),
SubDistributionOrderId: tea.String(req.SubDistributionOrderId),
TenantId: tea.String(server.TenantId),
GoodsStatus: tea.Int32(gconv.Int32(req.GoodsStatus)),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//Apply 申请
func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundApplyRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.ApplyRefund4Distribution(&link.ApplyRefund4DistributionRequest{
ApplyReasonTextId: tea.Int64(req.ApplyReasonTextId),
ApplyRefundCount: tea.Int32(req.ApplyRefundCount),
ApplyRefundFee: tea.Int64(req.ApplyRefundFee),
BizClaimType: tea.Int32(req.ApplyRefundCount),
DistributorId: tea.String(server.DistributorId),
GoodsStatus: tea.Int32(req.GoodsStatus),
//LeaveMessage: tea.String("测试退款"),
LeavePictureLists: nil,
SubDistributionOrderId: tea.String(req.SubLmOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
type RefundInfoRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Model struct{
DistributionOrderId string `json:"DistributionOrderId"`
SubDistributionOrderId string `json:"SubDistributionOrderId"`
BizClaimType int `json:"BizClaimType"`
OrderLogisticsStatus int `json:"OrderLogisticsStatus"`
DisputeStatus int `json:"DisputeStatus"`
ReturnGoodLogisticsStatus int `json:"ReturnGoodLogisticsStatus"`
DisputeType int `json:"DisputeType"`
RefundFeeData struct {
MaxRefundFee int `json:"MaxRefundFee"`
MinRefundFee int `json:"MinRefundFee"`
} `json:"RefundFeeData"`
SellerRefuseReason string `json:"SellerRefuseReason"`
RefundFee int `json:"RefundFee"`
RealRefundFee int `json:"RealRefundFee"`
DisputeDesc string `json:"DisputeDesc"`
SellerAgreeMsg string `json:"SellerAgreeMsg"`
SellerRefuseAgreementMessage string `json:"SellerRefuseAgreementMessage"`
ApplyReason struct {
ReasonTextId int `json:"ReasonTextId"`
ReasonTips string `json:"ReasonTips"`
} `json:"ApplyReason"`
ApplyDisputeDesc string `json:"ApplyDisputeDesc"`
DisputeCreateTime string `json:"DisputeCreateTime"`
DisputeEndTime string `json:"DisputeEndTime"`
DisputeId int `json:"DisputeId"`
RefunderAddress string `json:"RefunderAddress"`
RefunderName string `json:"RefunderName"`
RefunderTel string `json:"RefunderTel"`
RefunderZipCode string `json:"RefunderZipCode"`
} `json:"Model"`
}
//Submit 提交退货物流信息接口
func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *CommonRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.SubmitReturnGoodLogistics4Distribution(&link.SubmitReturnGoodLogistics4DistributionRequest{
DisputeId: tea.Int64(gconv.Int64(req.DisputeId)),
DistributorId: tea.String(server.DistributorId),
SubDistributionOrderId: tea.String(req.SubLmOrderId),
TenantId: tea.String(server.TenantId),
LogisticsNo: tea.String(req.LogisticsNo),
CpCode: tea.String(req.CpCode),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//Cancel 取消退款申请接口
func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId string) (res *RefundCancelRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.CancelRefund4Distribution(&link.CancelRefund4DistributionRequest{
DisputeId: tea.Int64(gconv.Int64(disputeId)),
DistributorId: tea.String(server.DistributorId),
SubDistributionOrderId: tea.String(subLmOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
err =gjson.New(result.Body).Scan(&res)
return
}
//Info 详情
func (s *refundTm) Detail(ctx context.Context,subOrderId string) (res *RefundInfoRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryRefundApplicationDetail4Distribution(&link.QueryRefundApplicationDetail4DistributionRequest{
DistributorId: tea.String(server.DistributorId),
SubDistributionOrderId: tea.String(subOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
a,_ :=json.Marshal(result.Body)
if err := json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
}
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论