增加运力api

This commit is contained in:
richboo111
2022-12-12 14:23:10 +08:00
parent 84453aabc0
commit 2bc0d518cd
11 changed files with 435 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
package spu_queryBookNameByISBN_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SpuQueryBookNameByISBNResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SpuQueryBookNameByISBNData `json:"data"`

View File

@@ -0,0 +1,54 @@
package superm_applyPlatformPickUp_request
import (
"encoding/json"
superm_applyPlatformPickUp_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_applyPlatformPickUp/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermApplyPlatformPickUpRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermApplyPlatformPickUpParam
}
func (c *SupermApplyPlatformPickUpRequest) GetUrlPath() string {
return "/superm/applyPlatformPickUp"
}
func New() *SupermApplyPlatformPickUpRequest {
request := &SupermApplyPlatformPickUpRequest{
Param: &SupermApplyPlatformPickUpParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermApplyPlatformPickUpRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_applyPlatformPickUp_response.SupermApplyPlatformPickUpResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_applyPlatformPickUp_response.SupermApplyPlatformPickUpResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermApplyPlatformPickUpRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermApplyPlatformPickUpRequest) GetParams() *SupermApplyPlatformPickUpParam {
return c.Param
}
type SupermApplyPlatformPickUpParam struct {
AfterSaleID int64 `json:"afterSaleID"` //售后单ID
//SelectedCalendarPeriod *CalendarPeriod `json:"selectedCalendarPeriod"` //选择的时间段
}
type CalendarPeriod struct {
TimeBeginTs int64 `json:"timeBeginTs"`
TimeEndTs int64 `json:"timeEndTs"`
}

View File

@@ -0,0 +1,12 @@
package superm_applyPlatformPickUp_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermApplyPlatformPickUpResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermApplyPlatformPickUpData `json:"data"`
}
type SupermApplyPlatformPickUpData struct {
LogisticsID string `json:"logisticsID"` //物流单ID
}

View File

@@ -0,0 +1,50 @@
package superm_cancelPlatformPickUp_request
import (
"encoding/json"
superm_cancelPlatformPickUp_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_cancelPlatformPickUp/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermCancelPlatformPickUpRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermCancelPlatformPickUpParam
}
func (c *SupermCancelPlatformPickUpRequest) GetUrlPath() string {
return "/superm/cancelPlatformPickUp"
}
func New() *SupermCancelPlatformPickUpRequest {
request := &SupermCancelPlatformPickUpRequest{
Param: &SupermCancelPlatformPickUpParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermCancelPlatformPickUpRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_cancelPlatformPickUp_response.SupermCancelPlatformPickUpResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_cancelPlatformPickUp_response.SupermCancelPlatformPickUpResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermCancelPlatformPickUpRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermCancelPlatformPickUpRequest) GetParams() *SupermCancelPlatformPickUpParam {
return c.Param
}
type SupermCancelPlatformPickUpParam struct {
AfterSaleID int64 `json:"afterSaleID"` //售后单ID
//CancelReason string `json:"cancelReason"` //取消原因
}

View File

@@ -0,0 +1,11 @@
package superm_cancelPlatformPickUp_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermCancelPlatformPickUpResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermCancelPlatformPickUpResponseData `json:"data"`
}
type SupermCancelPlatformPickUpResponseData struct {
}

View File

@@ -0,0 +1,55 @@
package superm_getPlatformPickUpEstimatedCharge_request
import (
"encoding/json"
superm_getPlatformPickUpEstimatedCharge_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getPlatformPickUpEstimatedCharge/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermGetPlatformPickUpEstimatedChargeRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermGetPlatformPickUpEstimatedChargeParam
}
func (c *SupermGetPlatformPickUpEstimatedChargeRequest) GetUrlPath() string {
return "/superm/getPlatformPickUpEstimatedCharge"
}
func New() *SupermGetPlatformPickUpEstimatedChargeRequest {
request := &SupermGetPlatformPickUpEstimatedChargeRequest{
Param: &SupermGetPlatformPickUpEstimatedChargeParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermGetPlatformPickUpEstimatedChargeRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_getPlatformPickUpEstimatedCharge_response.SupermGetPlatformPickUpEstimatedChargeResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_getPlatformPickUpEstimatedCharge_response.SupermGetPlatformPickUpEstimatedChargeResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermGetPlatformPickUpEstimatedChargeRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermGetPlatformPickUpEstimatedChargeRequest) GetParams() *SupermGetPlatformPickUpEstimatedChargeParam {
return c.Param
}
type SupermGetPlatformPickUpEstimatedChargeParam struct {
AfterSaleID int64 `json:"afterSaleID"` //售后单ID
//SelectedCalendarPeriod *CalendarPeriod `json:"selectedCalendarPeriod"` //选择的时间段
InquiryType int32 `json:"inquiryType"` //1配送 2取消 默认配送
}
type CalendarPeriod struct {
TimeBeginTs int64 `json:"timeBeginTs"`
TimeEndTs int64 `json:"timeEndTs"`
}

View File

@@ -0,0 +1,12 @@
package superm_getPlatformPickUpEstimatedCharge_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermGetPlatformPickUpEstimatedChargeResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermGetPlatformPickUpEstimatedChargeData `json:"data"`
}
type SupermGetPlatformPickUpEstimatedChargeData struct {
PlatformPickupEstimatedCharge int64 `json:"platformPickupEstimatedCharge"` //平台运力取件-预计费用,单位分
}

View File

@@ -0,0 +1,51 @@
package superm_getShipmentInfo_request
import (
"encoding/json"
superm_getShipmentInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermGetShipmentInfoRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermGetShipmentInfoParam
}
func (c *SupermGetShipmentInfoRequest) GetUrlPath() string {
return "/superm/getShipmentInfo"
}
func New() *SupermGetShipmentInfoRequest {
request := &SupermGetShipmentInfoRequest{
Param: &SupermGetShipmentInfoParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermGetShipmentInfoRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_getShipmentInfo_response.SupermGetShipmentInfoResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_getShipmentInfo_response.SupermGetShipmentInfoResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermGetShipmentInfoRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermGetShipmentInfoRequest) GetParams() *SupermGetShipmentInfoParam {
return c.Param
}
type SupermGetShipmentInfoParam struct {
ShopOrderID int64 `json:"shopOrderID"` //店铺父订单号
//AfterSaleID int64 `json:"afterSaleID"` //售后单号
ShipmentType int64 `json:"shipmentType"` //履约类型
}

View File

@@ -0,0 +1,24 @@
package superm_getShipmentInfo_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermGetShipmentInfoResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermGetShipmentInfoData `json:"data"`
}
type ShipmentInfo struct {
ShopOrderID int64 `json:"shopOrderID"` //交易单号
AfterSaleID int64 `json:"afterSaleID"` //售后单号
TrackNo string `json:"trackNo"` //运单号
ShopID int64 `json:"shopID"` //店铺ID
ShipmentStatus int64 `json:"shipmentStatus"` //运单状态
ShipmentError int64 `json:"shipmentError"` //异常状态
RiderName string `json:"riderName"` //骑手名称
RiderPhone string `json:"riderPhone"` //骑手电话
RiderLongitude string `json:"riderLongitude"` //骑手经度
RiderLatitude string `json:"riderLatitude"` //骑手纬度
OccurredTime string `json:"occurredTime"` //当前状态变更时间
}
type SupermGetShipmentInfoData struct {
ShipmentInfo *ShipmentInfo `json:"shipmentInfo"`
}

View File

@@ -0,0 +1,86 @@
package tiktok_api
import (
"errors"
superm_applyPlatformPickUp_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_applyPlatformPickUp/request"
superm_cancelPlatformPickUp_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_cancelPlatformPickUp/request"
superm_getPlatformPickUpEstimatedCharge_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getPlatformPickUpEstimatedCharge/request"
superm_getShipmentInfo_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/request"
superm_getShipmentInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/response"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
)
// /superm/getPlatformPickUpEstimatedCharge 运力呼叫询价/运力取消询价(逆向)
func (a *API) getPlatformPickUpEstimatedCharge(afterSaleID int64, inquiryType int32) (int64, error) {
request := superm_getPlatformPickUpEstimatedCharge_request.New()
request.Param = &superm_getPlatformPickUpEstimatedCharge_request.SupermGetPlatformPickUpEstimatedChargeParam{
AfterSaleID: afterSaleID,
InquiryType: inquiryType,
}
response, err := request.Execute(a.accessTokenObj)
globals.SugarLogger.Debugf("运力呼叫询价/运力取消询价=========:%s", request.GetUrlPath())
globals.SugarLogger.Debugf("运力呼叫询价/运力取消询价:=%s", utils.Format4Output(response, false))
if err != nil {
return 0, err
}
if response.Code != RequestSuccessCode {
return 0, errors.New(response.SubMsg)
}
return response.Data.PlatformPickupEstimatedCharge, err
}
// /superm/applyPlatformPickUp 呼叫运力售后取件
func (a *API) ApplyPlatformPickUp(afterSaleID int64) (string, error) {
request := superm_applyPlatformPickUp_request.New()
request.Param = &superm_applyPlatformPickUp_request.SupermApplyPlatformPickUpParam{
AfterSaleID: afterSaleID,
}
response, err := request.Execute(a.accessTokenObj)
globals.SugarLogger.Debugf("呼叫运力售后取件=========:%s", request.GetUrlPath())
globals.SugarLogger.Debugf("呼叫运力售后取件:=%s", utils.Format4Output(response, false))
if err != nil {
return "", err
}
if response.Code != RequestSuccessCode {
return "", errors.New(response.SubMsg)
}
return response.Data.LogisticsID, err
}
// /superm/getShipmentInfo 查询运力订单信息
func (a *API) GetShipmentInfo(shopOrderID, afterSaleID, shipmentType int64) (*superm_getShipmentInfo_response.ShipmentInfo, error) {
request := superm_getShipmentInfo_request.New()
request.Param = &superm_getShipmentInfo_request.SupermGetShipmentInfoParam{
ShopOrderID: shopOrderID,
ShipmentType: shipmentType,
}
response, err := request.Execute(a.accessTokenObj)
globals.SugarLogger.Debugf("查询运力订单信息=========:%s", request.GetUrlPath())
globals.SugarLogger.Debugf("查询运力订单信息:=%s", utils.Format4Output(response, false))
if err != nil {
return nil, err
}
if response.Code != RequestSuccessCode {
return nil, errors.New(response.SubMsg)
}
return response.Data.ShipmentInfo, err
}
// /superm/cancelPlatformPickUp 取消运力 (逆向)
func (a *API) CancelPlatformPickUp(afterSaleID int64) error {
request := superm_cancelPlatformPickUp_request.New()
request.Param = &superm_cancelPlatformPickUp_request.SupermCancelPlatformPickUpParam{
AfterSaleID: afterSaleID,
}
response, err := request.Execute(a.accessTokenObj)
globals.SugarLogger.Debugf("取消运力=========:%s", request.GetUrlPath())
globals.SugarLogger.Debugf("取消运力:=%s", utils.Format4Output(response, false))
if err != nil {
return err
}
if response.Code != RequestSuccessCode {
return errors.New(response.SubMsg)
}
return err
}

View File

@@ -0,0 +1,78 @@
package tiktok_api
const (
DispatcherFeeTypeCall = 1 //呼叫运力
DispatcherFeeTypeCancel = 2 //取消运力
InquiryTypeDelivery = 1 //配送 默认
InquiryTypeCancel = 2 //取消
ServiceTypeCallNow = 0 //立即呼叫
ServiceTypeDelayCall = 1 //延迟呼叫
ServiceStatusClose = 1 //自动呼叫运力设置关闭
ServiceStatusOpen = 2 //自动呼叫运力设置开启
ShipmentTypeInvoice = 1 //发货单
ShipmentTypeVisitInDoor = 2 //上门取
)
const (
ShipmentStatusCalling = 1
ShipmentStatusReceived = 2
ShipmentStatusArrived = 3
ShipmentStatusDelivering = 4
ShipmentStatusRejected = 5
ShipmentStatusReturning = 6
ShipmentStatusReturned = 7
ShipmentStatusDelivered = 8
ShipmentStatusCanceled = 9
)
var ShipmentStatus = map[int]string{
ShipmentStatusCalling: "骑手呼叫中",
ShipmentStatusReceived: "骑手已接单",
ShipmentStatusArrived: "骑手已到取货点",
ShipmentStatusDelivering: "骑手配送中",
ShipmentStatusRejected: "收货人已拒收",
ShipmentStatusReturning: "返回中",
ShipmentStatusReturned: "返回完成",
ShipmentStatusDelivered: "订单妥投",
ShipmentStatusCanceled: "订单取消",
}
const (
ShipmentErrorMerchantDeliverSlow = 1001
ShipmentErrorMerchantDeliverError = 1002
ShipmentErrorMerchantStockOut = 1003
ShipmentErrorGoodsDamaged = 2001
ShipmentErrorGoodsLost = 2002
ShipmentErrorRiderWrongGoods = 2003
ShipmentErrorRiderUndeliverable = 2004
ShipmentErrorWrongReceiptCode = 3001
ShipmentErrorMerchantWrongAddress = 3002
ShipmentErrorConsumerWrongAddress = 3003
ShipmentErrorWeightDeviationTooLarge = 3004
ShipmentErrorConsumerCallNoAnswer = 4002
ShipmentErrorConsumerStayOut = 4003
ShipmentErrorConsumerModifyAddress = 4004
ShipmentErrorOther = 5001
)
var ShipmentError = map[int]string{
ShipmentErrorMerchantDeliverSlow: "商家出货慢",
ShipmentErrorMerchantDeliverError: "商家出错货",
ShipmentErrorMerchantStockOut: "商家缺货",
ShipmentErrorGoodsDamaged: "破损",
ShipmentErrorGoodsLost: "丢失",
ShipmentErrorRiderWrongGoods: "骑手取错货",
ShipmentErrorRiderUndeliverable: "骑手无法送达",
ShipmentErrorWrongReceiptCode: "小票码错误",
ShipmentErrorMerchantWrongAddress: "商家地址错误",
ShipmentErrorConsumerWrongAddress: "消费者地址错误",
ShipmentErrorWeightDeviationTooLarge: "订单重量偏差过大",
ShipmentErrorConsumerCallNoAnswer: "消费者电话未接通",
ShipmentErrorConsumerStayOut: "消费者不在家",
ShipmentErrorConsumerModifyAddress: "消费者线下联系修改地址",
ShipmentErrorOther: "其他",
}