抖音运力api

This commit is contained in:
richboo111
2022-12-22 14:14:47 +08:00
parent a6f3a604d3
commit 4ef2985566
13 changed files with 313 additions and 26 deletions

View File

@@ -4,8 +4,8 @@ import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/c
type SupermCancelPlatformPickUpResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermCancelPlatformPickUpResponseData `json:"data"`
Data *SupermCancelPlatformPickUpData `json:"data"`
}
type SupermCancelPlatformPickUpResponseData struct {
type SupermCancelPlatformPickUpData struct {
}

View File

@@ -1 +1,49 @@
package request
package superm_createVirtualMobile_request
import (
"encoding/json"
superm_createVirtualMobile_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_createVirtualMobile/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermCreateVirtualMobileRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermOrderDispatcherParam
}
func (c *SupermCreateVirtualMobileRequest) GetUrlPath() string {
return "/superm/createVirtualMobile"
}
func New() *SupermCreateVirtualMobileRequest {
request := &SupermCreateVirtualMobileRequest{
Param: &SupermOrderDispatcherParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermCreateVirtualMobileRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_createVirtualMobile_response.SupermCreateVirtualMobileResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_createVirtualMobile_response.SupermCreateVirtualMobileResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermCreateVirtualMobileRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermCreateVirtualMobileRequest) GetParams() *SupermOrderDispatcherParam {
return c.Param
}
type SupermOrderDispatcherParam struct {
ShopOrderID int64 `json:"shopOrderID"` //店铺父订单号
}

View File

@@ -1 +1,17 @@
package response
package superm_createVirtualMobile_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermCreateVirtualMobileResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermCreateVirtualMobileData `json:"data"`
}
type MobileInfo struct {
IsNewCreate bool `json:"isNewCreate"` //是否新创建的
MobileVirtual string `json:"mobileVirtual"` //虚拟号值
ExpireTime string `json:"expireTime"` //过期时间 格式为yyyy-MM-dd HH:mm:ss 2016-01-01 12:00:00
}
type SupermCreateVirtualMobileData struct {
MobileInfo *MobileInfo `json:"mobileInfo"` //虚拟隐私小号信息
}

View File

@@ -1 +1,51 @@
package request
package superm_getDispatcherInfo_request
import (
"encoding/json"
superm_getDispatcherInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getDispatcherInfo/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermGetDispatcherInfoRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermGetDispatcherInfoParam
}
func (c *SupermGetDispatcherInfoRequest) GetUrlPath() string {
return "/superm/getDispatcherInfo"
}
func New() *SupermGetDispatcherInfoRequest {
request := &SupermGetDispatcherInfoRequest{
Param: &SupermGetDispatcherInfoParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermGetDispatcherInfoRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_getDispatcherInfo_response.SupermGetDispatcherInfoResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_getDispatcherInfo_response.SupermGetDispatcherInfoResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermGetDispatcherInfoRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermGetDispatcherInfoRequest) GetParams() *SupermGetDispatcherInfoParam {
return c.Param
}
type SupermGetDispatcherInfoParam struct {
StoreID int64 `json:"storeID"`
ShopOrderID int64 `json:"shopOrderID"`
DispatcherType int32 `json:"dispatcherType"`
}

View File

@@ -1 +1,12 @@
package response
package superm_getDispatcherInfo_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermGetDispatcherInfoResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermGetDispatcherInfoData `json:"data"`
}
type SupermGetDispatcherInfoData struct {
DispatcherFee int64 `json:"dispatcherFee"` //呼叫运力费用,单位 分
}

View File

@@ -1 +1,51 @@
package request
package superm_orderDispatcher_request
import (
"encoding/json"
superm_getDispatcherInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getDispatcherInfo/response"
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)
type SupermOrderDispatcherRequest struct {
doudian_sdk.BaseDoudianOpApiRequest
Param *SupermOrderDispatcherParam
}
func (c *SupermOrderDispatcherRequest) GetUrlPath() string {
return "/superm/orderDispatcher"
}
func New() *SupermOrderDispatcherRequest {
request := &SupermOrderDispatcherRequest{
Param: &SupermOrderDispatcherParam{},
}
request.SetConfig(doudian_sdk.GlobalConfig)
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
return request
}
func (c *SupermOrderDispatcherRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_getDispatcherInfo_response.SupermGetDispatcherInfoResponse, error) {
responseJson, err := c.GetClient().Request(c, accessToken)
if err != nil {
return nil, err
}
response := &superm_getDispatcherInfo_response.SupermGetDispatcherInfoResponse{}
_ = json.Unmarshal([]byte(responseJson), response)
return response, nil
}
func (c *SupermOrderDispatcherRequest) GetParamObject() interface{} {
return c.Param
}
func (c *SupermOrderDispatcherRequest) GetParams() *SupermOrderDispatcherParam {
return c.Param
}
type SupermOrderDispatcherParam struct {
StoreID int64 `json:"storeID"`
ShopOrderID int64 `json:"shopOrderID"`
DispatcherType int32 `json:"dispatcherType"`
}

View File

@@ -1 +1,12 @@
package response
package superm_orderDispatcher_response
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
type SupermOrderDispatcherResponse struct {
doudian_sdk.BaseDoudianOpApiResponse
Data *SupermOrderDispatcherData `json:"data"`
}
type SupermOrderDispatcherData struct {
DispatcherFee int64 `json:"dispatcherFee"` //呼叫运力费用
}

View File

@@ -472,6 +472,12 @@ func (a *API) CreateOrderCallback(orderStatus []byte) (map[string][]interface{},
return nil, CallbackResponseErr(false)
}
callbackResult[CallbackRefundClosedMsgTagId] = append(callbackResult[CallbackRefundClosedMsgTagId], create)
case CallbackShipmentInfoChange: //运单状态回调
create := ShipmentInfoData{}
if err := json.Unmarshal([]byte(data.Data), &create); err != nil {
return nil, CallbackResponseErr(false)
}
callbackResult[CallbackShipmentInfoChange] = append(callbackResult[CallbackShipmentInfoChange], create)
default:
return nil, CallbackResponseErr(false)
}
@@ -610,6 +616,13 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, int64,
return "", 0, CallbackResponseErr(false)
}
return utils.Int64ToStr(create.PId), int64(create.ShopId), Err2CallbackResponse(nil, "")
case CallbackShipmentInfoChange: //商家从运力平台呼叫运力以后,推送运力状态变更消息
create := ShipmentInfoData{}
if err := utils.Map2StructByJson(data, &create, false); err != nil {
return "", 0, CallbackResponseErr(false)
}
//返回 骑手运单号 抖音店铺ID
return create.TrackNo, create.ShopID, Err2CallbackResponse(nil, "")
default:
return "", 0, CallbackResponseErr(false)
}

View File

@@ -4,15 +4,77 @@ 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_createVirtualMobile_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_createVirtualMobile/request"
superm_createVirtualMobile_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_createVirtualMobile/response"
superm_getDispatcherInfo_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getDispatcherInfo/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"
superm_orderDispatcher_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_orderDispatcher/request"
"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) {
// /superm/getDispatcherInfo 运力呼叫询价/运力取消询价(向)
func (a *API) GetDispatcherInfo(storeID, shopOrderID int64, dispatcherType int32) (int64, error) {
request := superm_getDispatcherInfo_request.New()
request.Param = &superm_getDispatcherInfo_request.SupermGetDispatcherInfoParam{
StoreID: storeID,
ShopOrderID: shopOrderID,
DispatcherType: dispatcherType,
}
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.DispatcherFee, nil
}
// /superm/orderDispatcher 呼叫运力并发货/重新发货、取消运力
func (a *API) OrderDispatcher(storeID, shopOrderID int64, dispatcherType int32) error {
request := superm_orderDispatcher_request.New()
request.Param = &superm_orderDispatcher_request.SupermOrderDispatcherParam{
StoreID: storeID,
ShopOrderID: shopOrderID,
DispatcherType: dispatcherType,
}
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 nil
}
// /superm/createVirtualMobile 隐私小号获取
func (a *API) CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobile_response.SupermCreateVirtualMobileData, error) {
request := superm_createVirtualMobile_request.New()
request.Param = &superm_createVirtualMobile_request.SupermOrderDispatcherParam{
ShopOrderID: shopOrderID,
}
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, nil
}
// /superm/getPlatformPickUpEstimate]dCharge 运力呼叫询价/运力取消询价(逆向)
func (a *API) GetPlatformPickUpEstimatedCharge(afterSaleID int64, inquiryType int32) (int64, error) {
request := superm_getPlatformPickUpEstimatedCharge_request.New()
request.Param = &superm_getPlatformPickUpEstimatedCharge_request.SupermGetPlatformPickUpEstimatedChargeParam{
AfterSaleID: afterSaleID,

View File

@@ -1,5 +1,7 @@
package tiktok_api
const CallbackShipmentInfoChange = "12001" //小时达运力状态变更标识
const (
DispatcherFeeTypeCall = 1 //呼叫运力
DispatcherFeeTypeCancel = 2 //取消运力
@@ -29,7 +31,7 @@ const (
ShipmentStatusCanceled = 9
)
var ShipmentStatus = map[int]string{
var ShipmentStatus = map[int64]string{
ShipmentStatusCalling: "骑手呼叫中",
ShipmentStatusReceived: "骑手已接单",
ShipmentStatusArrived: "骑手已到取货点",
@@ -76,3 +78,17 @@ var ShipmentError = map[int]string{
ShipmentErrorConsumerModifyAddress: "消费者线下联系修改地址",
ShipmentErrorOther: "其他",
}
//小时达运力状态变更消息体
type ShipmentInfoData struct {
AfterSaleID int64 `json:"afterSaleID"` //上门取运力对应售后单号
TrackNo string `json:"trackNo"` //骑手配送运单号
RiderName string `json:"riderName"` //骑手名称
RiderPhone string `json:"riderPhone"` //骑手电话
RiderLatitude string `json:"riderLatitude"` //骑手坐标纬度
RiderLongitude string `json:"riderLongitude"` //骑手坐标经度
ShopOrderID int64 `json:"shopOrderID"` //店铺订单号
ShopID int64 `json:"shopID"` //抖店门店ID
ShipmentStatus int64 `json:"shipmentStatus"` //运单状态
OccurredTime string `json:"occurredTime"` //当前状态变更时间
}

View File

@@ -1 +1,8 @@
package tiktok_api
import "testing"
//运力呼叫询价(正向)
func TestGetDispatcherInfo(t *testing.T) {
//dispatcherFee, err := a.GetDispatcherInfo()
}