提交 bd552da5 authored 作者: 张立波's avatar 张立波

tm v3

上级 3be98394
package tmv3
import (
"context"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
)
type Config struct {
AppKey string
AppSecret string
}
var server *client.Client
const (
PkgName = "tmv3"
Endpoint = "linkedmall-distributor.cn-zhangjiakou.aliyuncs.com"
RegionId = "cn-zhangjiakou"
PurchaserId = "PID2200006434"
)
func New(req *Config) {
config := &openapi.Config{
AccessKeyId: tea.String(req.AppKey),
AccessKeySecret: tea.String(req.AppSecret),
RegionId: tea.String(RegionId),
}
config.Endpoint = tea.String(Endpoint)
server = &client.Client{}
server, _ = client.NewClient(config)
return
}
func Log(ctx context.Context, req interface{}, res interface{}, err error, start int64) {
if err != nil {
g.Log().Ctx(ctx).Cat(PkgName).Errorf("参数【%v】错误【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), err.Error(), gtime.TimestampMilli()-start)
} else {
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), gjson.New(res).MustToJsonString(), gtime.TimestampMilli()-start)
}
}
type CommonRes struct {
Code string `json:"Code"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
}
package tmv3
type accountTm struct {
}
var Account = accountTm{}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type categoryTm struct {
}
var Category = categoryTm{}
type CategoryListReq struct {
ParentId int64
CategoryIds []int64
}
type CategoryListRes struct {
Categories []struct {
CategoryId int `json:"categoryId"`
IsLeaf bool `json:"isLeaf"`
Level int `json:"level"`
Name string `json:"name"`
ParentId int `json:"parentId"`
} `json:"categories"`
RequestId string `json:"requestId"`
}
func (s categoryTm) List(ctx context.Context, req CategoryListReq) (res *CategoryListRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListCategories")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.ListCategoriesRequest{}
var Body = new(client.CategoryListQuery)
if req.ParentId != 0 {
Body.SetParentCategoryId(req.ParentId)
}
var list []*int64
for _, item := range req.CategoryIds {
list = append(list, tea.Int64(item))
}
Body.SetCategoryIds(list)
Request.SetBody(Body)
r, err := server.ListCategories(Request)
if err != nil {
return
}
//
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
type goodsTm struct {
}
var Goods = goodsTm{}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type GoodsDetailReq struct {
ProductId string
PurchaserId string
DivisionCode string
}
type GoodsDetailRes struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
LmItemId string `json:"lmItemId"`
ProductId string `json:"productId"`
ProductStatus string `json:"productStatus"`
Quantity int `json:"quantity"`
RequestId string `json:"requestId"`
ShopId string `json:"shopId"`
Skus []struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
MarkPrice int `json:"markPrice"`
Price int `json:"price"`
ProductId string `json:"productId"`
Quantity int `json:"quantity"`
ShopId string `json:"shopId"`
SkuId string `json:"skuId"`
SkuStatus string `json:"skuStatus"`
Title string `json:"title"`
} `json:"skus"`
Title string `json:"title"`
}
// Detail 查询选品池商品详情
func (s goodsTm) Detail(ctx context.Context, req GoodsDetailReq) (res *GoodsDetailRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "GetSelectionProductSaleInfo")
defer func() {
Log(ctx, req, res, err, Start)
}()
if req.PurchaserId == "" {
req.PurchaserId = PurchaserId
}
Request := &client.GetSelectionProductSaleInfoRequest{
PurchaserId: tea.String(req.PurchaserId),
}
if req.DivisionCode != "" {
Request.SetDivisionCode(req.DivisionCode)
}
r, err := server.GetSelectionProductSaleInfo(tea.String(req.ProductId), Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type GoodsListReq struct {
PageNumber int32
PageSize int32
PurchaserId string
}
type GoodsListRes struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
Products []struct {
BrandName string `json:"brandName"`
CanSell bool `json:"canSell"`
CategoryChain []struct {
CategoryId int `json:"categoryId"`
IsLeaf bool `json:"isLeaf"`
Level int `json:"level"`
Name string `json:"name"`
ParentId int `json:"parentId"`
} `json:"categoryChain"`
CategoryLeafId int `json:"categoryLeafId"`
DescPath string `json:"descPath"`
FuzzyQuantity string `json:"fuzzyQuantity"`
Images []string `json:"images"`
LmItemId string `json:"lmItemId"`
PicUrl string `json:"picUrl"`
ProductId string `json:"productId"`
ProductSpecs []struct {
Key string `json:"key"`
KeyId int `json:"keyId"`
Values []struct {
Value string `json:"value"`
ValueId int64 `json:"valueId"`
} `json:"values"`
} `json:"productSpecs,omitempty"`
ProductStatus string `json:"productStatus"`
ProductType string `json:"productType"`
Properties []struct {
Text string `json:"text"`
Values []string `json:"values"`
} `json:"properties"`
Quantity int `json:"quantity"`
ShopId string `json:"shopId"`
Skus []struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
MarkPrice int `json:"markPrice"`
PlatformPrice int `json:"platformPrice"`
Price int `json:"price"`
ProductId string `json:"productId"`
Quantity int `json:"quantity"`
RankValue int `json:"rankValue"`
ShopId string `json:"shopId"`
SkuId string `json:"skuId"`
SkuSpecs []struct {
Key string `json:"key"`
KeyId int `json:"keyId"`
Value string `json:"value"`
ValueId int64 `json:"valueId"`
} `json:"skuSpecs"`
SkuSpecsCode string `json:"skuSpecsCode"`
SkuStatus string `json:"skuStatus"`
Title string `json:"title"`
PicUrl string `json:"picUrl,omitempty"`
Barcode string `json:"barcode,omitempty"`
} `json:"skus"`
SoldQuantity string `json:"soldQuantity"`
TaxCode string `json:"taxCode"`
TaxRate int `json:"taxRate"`
Title string `json:"title"`
ExtendProperties []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"extendProperties,omitempty"`
} `json:"products"`
RequestId string `json:"requestId"`
Total int `json:"total"`
}
// List 查询选品池商品列表
func (s goodsTm) List(ctx context.Context, req GoodsListReq) (res *GoodsListRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListSelectionProducts")
defer func() {
Log(ctx, req, res, err, Start)
}()
if req.PageNumber == 0 {
req.PageNumber = 1
}
if req.PageSize == 0 {
req.PageSize = 10
}
if req.PurchaserId == "" {
req.PurchaserId = PurchaserId
}
Request := &client.ListSelectionProductsRequest{
PageNumber: tea.Int32(req.PageNumber),
PageSize: tea.Int32(req.PageSize),
PurchaserId: tea.String(req.PurchaserId),
}
r, err := server.ListSelectionProducts(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type GoodsSkuReq struct {
DivisionCode string
PurchaserId string
SkuQueryParams []GoodsSkuItem
}
type GoodsSkuItem struct {
ProductId string `json:"productId"`
SkuId string `json:"skuId"`
}
type GoodsSkuRes struct {
RequestId string `json:"requestId"`
SkuSaleInfos []struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
MarkPrice int `json:"markPrice"`
Price int `json:"price"`
ProductId string `json:"productId"`
Quantity int `json:"quantity"`
ShopId string `json:"shopId"`
SkuId string `json:"skuId"`
SkuStatus string `json:"skuStatus"`
Title string `json:"title"`
} `json:"skuSaleInfos"`
}
// Sku 批量查询选品池SKU销售信息
func (s goodsTm) Sku(ctx context.Context, req GoodsSkuReq) (res *GoodsSkuRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListSelectionSkuSaleInfos")
defer func() {
Log(ctx, req, res, err, Start)
}()
if req.PurchaserId == "" {
req.PurchaserId = PurchaserId
}
Request := &client.ListSelectionSkuSaleInfosRequest{}
var Body = new(client.SkuSaleInfoListQuery)
Body.SetPurchaserId(req.PurchaserId)
if req.DivisionCode != "" {
Body.SetDivisionCode(req.DivisionCode)
}
var list []*client.SkuQueryParam
for _, item := range req.SkuQueryParams {
list = append(list, &client.SkuQueryParam{
ProductId: tea.String(item.ProductId),
SkuId: tea.String(item.SkuId),
})
}
Body.SetSkuQueryParams(list)
Request.SetBody(Body)
r, err := server.ListSelectionSkuSaleInfos(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type GoodsSpuReq struct {
DivisionCode string
PurchaserId string
ProductIds []string
}
type GoodsSpuRes struct {
ProductSaleInfos []struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
LmItemId string `json:"lmItemId"`
ProductId string `json:"productId"`
ProductStatus string `json:"productStatus"`
Quantity int `json:"quantity"`
ShopId string `json:"shopId"`
Skus []struct {
CanSell bool `json:"canSell"`
FuzzyQuantity string `json:"fuzzyQuantity"`
MarkPrice int `json:"markPrice"`
Price int `json:"price"`
ProductId string `json:"productId"`
Quantity int `json:"quantity"`
ShopId string `json:"shopId"`
SkuId string `json:"skuId"`
SkuStatus string `json:"skuStatus"`
Title string `json:"title"`
} `json:"skus"`
Title string `json:"title"`
} `json:"productSaleInfos"`
RequestId string `json:"requestId"`
}
// Spu 批量查询选品池商品销售信息
func (s goodsTm) Spu(ctx context.Context, req GoodsSpuReq) (res *GoodsSpuRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListSelectionProductSaleInfos")
defer func() {
Log(ctx, req, res, err, Start)
}()
if req.PurchaserId == "" {
req.PurchaserId = PurchaserId
}
Request := &client.ListSelectionProductSaleInfosRequest{}
var Body = new(client.ProductSaleInfoListQuery)
Body.SetPurchaserId(req.PurchaserId)
if req.DivisionCode != "" {
Body.SetDivisionCode(req.DivisionCode)
}
var list []*string
for _, item := range req.ProductIds {
list = append(list, tea.String(item))
}
Body.SetProductIds(list)
Request.SetBody(Body)
r, err := server.ListSelectionProductSaleInfos(Request)
if err != nil {
return
}
//
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
type logisticsTm struct {
}
var Logistics = logisticsTm{}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type LogisticsConfirmReq struct {
OrderId string
}
// Confirm 确认收货
func (s logisticsTm) Confirm(ctx context.Context, req LogisticsConfirmReq) (res *LogisticsTraceRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ConfirmDisburse")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.ConfirmDisburseRequest{}
var Body = new(client.ConfirmDisburseCmd)
Body.SetOrderId(req.OrderId)
Request.SetBody(Body)
r, err := server.ConfirmDisburse(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type LogisticsTraceReq struct {
OrderId string
}
type LogisticsTraceRes struct {
RequestId string `json:"requestId"`
LogisticsOrderList []struct {
DataProvider string `json:"dataProvider"`
DataProviderTitle string `json:"dataProviderTitle"`
Goods []struct {
GoodName string `json:"goodName"`
ProductId interface{} `json:"productId"`
Quantity int `json:"quantity"`
} `json:"goods"`
LogisticsCompanyCode string `json:"logisticsCompanyCode"`
LogisticsCompanyName string `json:"logisticsCompanyName"`
LogisticsDetailList []struct {
OcurrTimeStr string `json:"ocurrTimeStr"`
StanderdDesc string `json:"standerdDesc"`
} `json:"logisticsDetailList"`
MailNo string `json:"mailNo"`
} `json:"logisticsOrderList"`
}
// Trace 查询订单物流信息
func (s logisticsTm) Trace(ctx context.Context, req LogisticsTraceReq) (res *LogisticsTraceRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "ListLogisticsOrders")
defer func() {
Log(ctx, req, res, err, Start)
}()
r, err := server.ListLogisticsOrders(tea.String(req.OrderId))
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
type orderTm struct {
}
var Order = orderTm{}
type OrderDeliveryAddress struct {
DivisionCode string
AddressDetail string
ReceiverPhone string
Receiver string
TownDivisionCode string
}
type OrderItem struct {
Quantity interface{} `json:"quantity"`
ProductId string `json:"productId"`
PurchaserId string `json:"purchaserId"`
SkuId string `json:"skuId"`
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
)
type OrderBeforeReq struct {
DeliveryAddress OrderDeliveryAddress `json:"deliveryAddress"`
BuyerId string `json:"buyerId"`
ProductList []OrderItem `json:"productList"`
}
type OrderBeforeRes struct {
DeliveryAddress struct {
DivisionCode string `json:"divisionCode"`
AddressDetail string `json:"addressDetail"`
ReceiverPhone string `json:"receiverPhone"`
Receiver string `json:"receiver"`
TownDivisionCode string `json:"townDivisionCode"`
} `json:"deliveryAddress"`
BuyerId string `json:"buyerId"`
ProductList []struct {
Quantity int `json:"quantity"`
ProductId string `json:"productId"`
PurchaserId string `json:"purchaserId"`
SkuId string `json:"skuId"`
} `json:"productList"`
}
// Before 采购单渲染
func (s orderTm) Before(ctx context.Context, req OrderBeforeReq) (res *OrderBeforeRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "RenderPurchaseOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.RenderPurchaseOrderRequest{}
var Body = new(client.PurchaseOrderRenderQuery)
Body.SetBuyerId(req.BuyerId)
var DeliveryAddress = new(client.AddressInfo)
DeliveryAddress.SetDivisionCode(req.DeliveryAddress.DivisionCode)
DeliveryAddress.SetAddressDetail(req.DeliveryAddress.AddressDetail)
DeliveryAddress.SetReceiverPhone(req.DeliveryAddress.ReceiverPhone)
DeliveryAddress.SetReceiver(req.DeliveryAddress.Receiver)
DeliveryAddress.SetTownDivisionCode(req.DeliveryAddress.TownDivisionCode)
Body.SetDeliveryAddress(DeliveryAddress)
var list []*client.OrderRenderProductDTO
for _, item := range req.ProductList {
list = append(list, &client.OrderRenderProductDTO{
ProductId: tea.String(item.ProductId),
PurchaserId: tea.String(PurchaserId),
Quantity: tea.Int32(gconv.Int32(item.Quantity)),
SkuId: tea.String(item.SkuId),
})
}
Body.SetProductList(list)
Request.SetBody(Body)
r, err := server.RenderPurchaseOrder(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
)
type OrderCreateReq struct {
DeliveryAddress OrderDeliveryAddress `json:"deliveryAddress"`
BuyerId string `json:"buyerId"`
ProductList []OrderItem `json:"productList"`
OuterPurchaseOrderId string
}
type OrderCreateRes struct {
OuterPurchaseOrderId string `json:"outerPurchaseOrderId"`
DeliveryAddress struct {
DivisionCode string `json:"divisionCode"`
AddressDetail string `json:"addressDetail"`
ReceiverPhone string `json:"receiverPhone"`
Receiver string `json:"receiver"`
TownDivisionCode string `json:"townDivisionCode"`
} `json:"deliveryAddress"`
BuyerId string `json:"buyerId"`
ProductList []struct {
Quantity int `json:"quantity"`
ProductId string `json:"productId"`
PurchaserId string `json:"purchaserId"`
SkuId string `json:"skuId"`
} `json:"productList"`
}
// Create 创建采购单
func (s orderTm) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "CreatePurchaseOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.CreatePurchaseOrderRequest{}
var Body = new(client.PurchaseOrderCreateCmd)
Body.SetBuyerId(req.BuyerId)
Body.SetOuterPurchaseOrderId(req.OuterPurchaseOrderId)
var DeliveryAddress = new(client.AddressInfo)
DeliveryAddress.SetDivisionCode(req.DeliveryAddress.DivisionCode)
DeliveryAddress.SetAddressDetail(req.DeliveryAddress.AddressDetail)
DeliveryAddress.SetReceiverPhone(req.DeliveryAddress.ReceiverPhone)
DeliveryAddress.SetReceiver(req.DeliveryAddress.Receiver)
DeliveryAddress.SetTownDivisionCode(req.DeliveryAddress.TownDivisionCode)
Body.SetDeliveryAddress(DeliveryAddress)
var list []*client.ProductDTO
for _, item := range req.ProductList {
list = append(list, &client.ProductDTO{
ProductId: tea.String(item.ProductId),
PurchaserId: tea.String(PurchaserId),
Quantity: tea.Int32(gconv.Int32(item.Quantity)),
SkuId: tea.String(item.SkuId),
})
}
Body.SetProductList(list)
Request.SetBody(Body)
r, err := server.CreatePurchaseOrder(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type OrderDetailReq struct {
OrderId string //订单 id
}
type OrderDetailRes struct {
CreateDate string `json:"createDate"`
DistributorId string `json:"distributorId"`
LogisticsStatus string `json:"logisticsStatus"`
OrderId string `json:"orderId"`
OrderAmount string `json:"orderAmount"`
OrderStatus string `json:"orderStatus"`
OrderLineList []struct {
ProductPic string `json:"productPic"`
ProductPrice []struct {
FundAmountMoney string `json:"fundAmountMoney"`
} `json:"productPrice"`
ProductTitle string `json:"productTitle"`
ProductId string `json:"productId"`
Number string `json:"number"`
OrderLineStatus string `json:"orderLineStatus"`
LogisticsStatus string `json:"logisticsStatus"`
SkuId string `json:"skuId"`
SkuTitle string `json:"skuTitle"`
OrderLineId string `json:"orderLineId"`
OrderId string `json:"orderId"`
} `json:"orderLineList"`
}
// Detail 获取订单详情
func (s orderTm) Detail(ctx context.Context, req OrderDetailReq) (res *OrderDetailRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "GetOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
r, err := server.GetOrder(tea.String(req.OrderId))
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type OrderListReq struct {
PageNumber int32
PageSize int32
OrderIdList []string
}
// List 查询订单列表
func (s orderTm) List(ctx context.Context, req OrderListReq) (res *OrderDetailRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "QueryOrders")
defer func() {
Log(ctx, req, res, err, Start)
}()
if req.PageNumber == 0 {
req.PageNumber = 1
}
if req.PageSize == 0 {
req.PageSize = 10
}
Request := &client.QueryOrdersRequest{}
var Body = new(client.OrderPageQuery)
Body.SetPageNumber(req.PageNumber)
Body.SetPageSize(req.PageSize)
var list []*string
for _, item := range req.OrderIdList {
list = append(list, tea.String(item))
}
Body.SetOrderIdList(list)
Request.SetBody(Body)
r, err := server.QueryOrders(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type OrderStatusReq struct {
PurchaseOrderId string //采购单 ID
}
type OrderStatusRes struct {
RequestId string `json:"requestId"`
Status string `json:"status"`
//1:分销单创建中。
//10:采购中。
//20:采购成功,待发货。
//21:采购成功,部分发货。
//22:采购成功,全部发货。
//30:部分采购成功,待发货。
//31:部分采购成功,部分发货。
//32:部分采购成功,全部发货。
//80:交易失败。
//99:交易成功。
}
// Status 获取采购单状态
func (s orderTm) Status(ctx context.Context, req OrderStatusReq) (res *OrderStatusRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "GetPurchaseOrderStatus")
defer func() {
Log(ctx, req, res, err, Start)
}()
r, err := server.GetPurchaseOrderStatus(tea.String(req.PurchaseOrderId))
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
type refundTm struct {
}
var Refund = refundTm{}
type RefundCommonReq struct {
DisputeId string //售后单 ID
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type RefundBeforeReq struct {
BizClaimType int32 //退款类型 1 仅退款,3 退货退款
GoodsStatus int32 //货物状态 4: 未发货, 1: 未收到货, 2: 已收到货
OrderLineId string //子分销订单 ID
}
type RefundBeforeRes struct {
RequestId string `json:"requestId"`
OrderLineId string `json:"orderLineId"` //子分销订单号
BizClaimType int `json:"bizClaimType"` //支持的订单退货方式
MaxRefundFeeData struct {
MaxRefundFee int `json:"maxRefundFee"`
MinRefundFee int `json:"minRefundFee"`
} `json:"maxRefundFeeData"`
RefundReasonList []struct { //退款理由
ReasonTextId string `json:"reasonTextId"` //理由文本 id
ProofRequired bool `json:"proofRequired"` //是否要求上传凭证
ReasonTips string `json:"reasonTips"` //理由文本
RefundDescRequired bool `json:"refundDescRequired"` //是否要求留言
} `json:"refundReasonList"`
}
// Before 售后单渲染
func (s refundTm) Before(ctx context.Context, req RefundBeforeReq) (res *RefundBeforeRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "RenderRefundOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.RenderRefundOrderRequest{}
var Body = new(client.RefundRenderCmd)
Body.SetBizClaimType(req.BizClaimType)
Body.SetGoodsStatus(req.GoodsStatus)
Body.SetOrderLineId(req.OrderLineId)
Request.SetBody(Body)
r, err := server.RenderRefundOrder(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type RefundCancelRes struct {
OrderLineId string `json:"orderLineId"` //当前发起逆向的子分销订单号
DisputeId string `json:"disputeId"` //纠纷 id
DisputeStatus int `json:"disputeStatus"` //逆向的状态 1-退货待处理 2-待买家退货 3-待商家收货 4-退款关闭 5-退款成功 6-已拒绝退款 17-取消退款中
RequestId string `json:"requestId"`
}
// Cancel 取消售后单
func (s refundTm) Cancel(ctx context.Context, req RefundCommonReq) (res *RefundCancelRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "CancelRefundOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
r, err := server.CancelRefundOrder(tea.String(req.DisputeId))
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type RefundCreateReq struct {
BizClaimType int32 //退款类型 1 仅退款,3 退货退款
GoodsStatus int32 //货物状态 4: 未发货, 1: 未收到货, 2: 已收到货
OrderLineId string //子分销订单 ID
ApplyRefundCount int32
LeaveMessage string
ApplyReasonTextId int64
ApplyReasonTips string
ApplyRefundFee int64
LeavePictureList []string
}
type RefundCreateRes struct {
OrderLineId string `json:"orderLineId"` //当前发起逆向的子分销订单号
DisputeId string `json:"disputeId"` //纠纷 id
DisputeStatus int `json:"disputeStatus"` //逆向的状态 1-退货待处理 2-待买家退货 3-待商家收货 4-退款关闭 5-退款成功 6-已拒绝退款 17-取消退款中
RequestId string `json:"requestId"`
}
// Create 创建售后单
func (s refundTm) Create(ctx context.Context, req RefundCreateReq) (res *RefundCreateRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "CreateRefundOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.CreateRefundOrderRequest{}
var Body = new(client.RefundOrderCmd)
Body.SetBizClaimType(req.BizClaimType)
Body.SetGoodsStatus(req.GoodsStatus)
Body.SetOrderLineId(req.OrderLineId)
Body.SetApplyRefundCount(req.ApplyRefundCount)
Body.SetLeaveMessage(req.LeaveMessage)
Body.SetApplyReasonTextId(req.ApplyReasonTextId)
Body.SetApplyReasonTips(req.ApplyReasonTips)
Body.SetApplyRefundFee(req.ApplyRefundFee)
var list []*client.LeavePictureList
for _, item := range req.LeavePictureList {
if item == "" {
continue
}
list = append(list, &client.LeavePictureList{
Picture: tea.String(item),
})
}
if len(list) > 0 {
Body.SetLeavePictureLists(list)
}
Request.SetBody(Body)
r, err := server.CreateRefundOrder(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
package tmv3
import (
"context"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
)
type RefundDetailRes struct {
ApplyDisputeDesc string `json:"applyDisputeDesc"`
ApplyReason struct {
ReasonTextId int `json:"reasonTextId"`
ReasonTips string `json:"reasonTips"`
} `json:"applyReason"`
BizClaimType int `json:"bizClaimType"`
DisputeCreateTime string `json:"disputeCreateTime"`
DisputeDesc string `json:"disputeDesc"`
DisputeEndTime string `json:"disputeEndTime"`
DisputeId string `json:"disputeId"` //逆向单 ID
DisputeStatus int `json:"disputeStatus"` //逆向的状态 1-退货待处理 2-待买家退货 3-待商家收货 4-退款关闭 5-退款成功 6-已拒绝退款 17-取消退款中
DisputeType int `json:"disputeType"`
OrderId string `json:"orderId"`
RefundFeeData struct { //退费区间
MaxRefundFee int `json:"maxRefundFee"`
MinRefundFee int `json:"minRefundFee"`
} `json:"refundFeeData"`
OrderLogisticsStatus int `json:"orderLogisticsStatus"` //订单物流状态 1-未发货 -> 等待卖家发货 2-已发货 -> 等待买家确认收货 3-已收货 -> 交易成功 6-部分发货中 8-还未创建物流订单
RefundFee int `json:"refundFee"` //退费金额
RefunderAddress string `json:"refunderAddress"` //商家退货地址(disputeStatus=2,待买家退货状态时可获取退货地址,如需保存退货地址请在此状态时保存)
RefunderName string `json:"refunderName"` //退货收货人
RefunderTel string `json:"refunderTel"`
RefunderZipCode string `json:"refunderZipCode"` //退货地址邮编
ReturnGoodCount int `json:"returnGoodCount"`
ReturnGoodLogisticsStatus int `json:"returnGoodLogisticsStatus"` //退货物流状态 0-未退货 1-等待揽收 2-快件已揽收 3-物流走件中 4-派送中 5-已签收 6-签收失败
SellerAgreeMsg string `json:"sellerAgreeMsg"`
SellerRefuseAgreementMessage string `json:"sellerRefuseAgreementMessage"` //卖家拒绝的留言说明
SellerRefuseReason string `json:"sellerRefuseReason"`
OrderLineId string `json:"orderLineId"`
}
// Detail 获取售后单详情
func (s refundTm) Detail(ctx context.Context, req RefundCommonReq) (res *RefundDetailRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "GetRefundOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
r, err := server.GetRefundOrder(tea.String(req.DisputeId))
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}
......@@ -17,9 +17,10 @@ const (
Dwd = 14 //好食期
Itao = 15 //淘特
Hdh = 16 //会订货
TmNew = 17 //新版天猫
TmNew = 17 //天猫精选
AliNew = 18 //精选1688
Yunzmall = 19
Tmv3 = 20 //天猫优选
)
var (
......@@ -101,6 +102,10 @@ func GetUpstreamList() (res interface{}, err error) {
"key": Yunzmall,
"name": GetUpstreamName(Yunzmall),
},
g.Map{
"key": Tmv3,
"name": GetUpstreamName(Tmv3),
},
}
return
}
......@@ -137,6 +142,8 @@ func GetUpstreamName(source int) string {
return "厂家直供"
case Yunzmall:
return "云仓优选"
case Tmv3:
return "天猫优选"
default:
return "未知来源"
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论