Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -9,11 +9,12 @@ const (
|
||||
|
||||
type RiderInfo struct {
|
||||
OrderId string `json:"order_id"` // 发单平台订单id(美团,京西,京,京东)
|
||||
ThirdCarrierOrderId string `json:"third_carrier_order_id"` // 京西平台id
|
||||
ThirdCarrierOrderId string `json:"third_carrier_order_id"` // 京西平台id(运单id)
|
||||
CourierName string `json:"courier_name"` // 骑手名称
|
||||
CourierPhone string `json:"courier_phone"` // 骑手电话
|
||||
LogisticsProviderCode string `json:"logistics_provider_code"` // 配送平台code 10001-顺丰, 10002-达达, 10003-闪送, 10004-蜂鸟, 10005 UU跑腿,10006 快跑者, 10007 极客快送,10008-点我达,10009 同达, 10010-生活半径,10011 邻趣,10012 趣送, 10013 快服务 10014 菜鸟新配盟 10015 商家自建配送 10016 风先生,10017-其他,10032-美团跑腿
|
||||
LogisticsStatus int `json:"logistics_status"` // 配送状态
|
||||
LogisticsContext string `json:"logistics_context"` // 配送状态描述
|
||||
Latitude string `json:"latitude"` // 骑手当前的纬度,美团使用的是高德坐标系。
|
||||
Longitude string `json:"longitude"` // 骑手当前的经度,美团使用的是高德坐标系。
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package logistics_indTrackPush_reqeust
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
logistics_indTrackPush_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/logistics_indTrackPush/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type LogisticsIndTrackPushRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *LogisticsIndTrackPushParam
|
||||
}
|
||||
|
||||
// GetUrlPath 同步配送坐标,配送轨迹推送
|
||||
func (c *LogisticsIndTrackPushRequest) GetUrlPath() string {
|
||||
return "/logistics/indTrackPush"
|
||||
}
|
||||
|
||||
func New() *LogisticsIndTrackPushRequest {
|
||||
request := &LogisticsIndTrackPushRequest{
|
||||
Param: &LogisticsIndTrackPushParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackPushRequest) Execute(accessToken *doudian_sdk.AccessToken) (*logistics_indTrackPush_response.LogisticsIndTrackPushResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &logistics_indTrackPush_response.LogisticsIndTrackPushResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackPushRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackPushRequest) GetParams() *LogisticsIndTrackPushParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type LogisticsIndTrackPushParam struct {
|
||||
// 请求时间
|
||||
CurTime string `json:"cur_time"`
|
||||
// 公司编码
|
||||
Company string `json:"company"`
|
||||
// 轨迹信息
|
||||
TraceMsgs []TraceMsgList `json:"trace_msgs"`
|
||||
// 未知
|
||||
AuthorityId string `json:"authority_id"`
|
||||
}
|
||||
|
||||
type TraceMsgList struct {
|
||||
// 运单号
|
||||
TrackNo string `json:"track_no"`
|
||||
// 轨迹列表
|
||||
Traces []TracesList `json:"traces"`
|
||||
}
|
||||
|
||||
type TracesList struct {
|
||||
// 事件编码
|
||||
Opcode string `json:"opcode"`
|
||||
// 时间操作时间
|
||||
OpTime string `json:"op_time"`
|
||||
// 文案
|
||||
Content string `json:"content"`
|
||||
// 骑手信息
|
||||
Rider ReiderInfo `json:"rider"`
|
||||
// 三方运力公司,顺丰同城 sftc 闪送 shansong 达达 dada UU uupt 美团 meituan 蜂鸟 fengniao
|
||||
ThirdPartyCompany string `json:"third_party_company"`
|
||||
// 异常编码
|
||||
ExceptionCode string `json:"exception_code"`
|
||||
// 异常原因
|
||||
ExceptionDesc string `json:"exception_desc"`
|
||||
// 取消编码
|
||||
CancelCode string `json:"cancel_code"`
|
||||
// 取消原因
|
||||
CancelDesc string `json:"cancel_desc"`
|
||||
}
|
||||
|
||||
type ReiderInfo struct {
|
||||
Name string `json:"name"` // 骑手姓名
|
||||
Mobile string `json:"mobile"` // 骑手电话号码
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package logistics_indTrackPush_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type LogisticsIndTrackPushResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *LogisticsIndTrackPushData `json:"data"`
|
||||
}
|
||||
type LogisticsIndTrackPushData struct {
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package logistics_indTrackRegister_reqeust
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
logistics_indTrackRegister_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/logistics_indTrackRegister/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type LogisticsIndTrackRegisterRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *LogisticsIndTrackRegisterRequestParam
|
||||
}
|
||||
|
||||
// GetUrlPath 根据即时配单号和公司编码订阅轨迹,用于即时配服务商推送轨迹
|
||||
func (c *LogisticsIndTrackRegisterRequest) GetUrlPath() string {
|
||||
return "/logistics/ind/track/register"
|
||||
}
|
||||
|
||||
func New() *LogisticsIndTrackRegisterRequest {
|
||||
request := &LogisticsIndTrackRegisterRequest{
|
||||
Param: &LogisticsIndTrackRegisterRequestParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackRegisterRequest) Execute(accessToken *doudian_sdk.AccessToken) (*logistics_indTrackRegister_response.LogisticsIndTrackRegisterRequestResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &logistics_indTrackRegister_response.LogisticsIndTrackRegisterRequestResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackRegisterRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *LogisticsIndTrackRegisterRequest) GetParams() *LogisticsIndTrackRegisterRequestParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type LogisticsIndTrackRegisterRequestParam struct {
|
||||
// 运单号
|
||||
TrackNo string `json:"track_no"`
|
||||
// 回调地址
|
||||
CallbackUrl string `json:"callback_url"`
|
||||
// 物流商编码
|
||||
Company string `json:"company"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package logistics_indTrackRegister_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type LogisticsIndTrackRegisterRequestResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *LogisticsIndTrackRegisterRequestData `json:"data"`
|
||||
}
|
||||
|
||||
type LogisticsIndTrackRegisterRequestData struct {
|
||||
Result bool `json:"result"` // 请求结果
|
||||
ReturnCode string `json:"return_code"` // 响应码
|
||||
Message string `json:"message"` // 错误消息
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package order_addressModify_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
order_addressModify_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_addressModify/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type OrderAddressModifyRequest struct {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package order_getSettleBillDetailV3_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
order_getSettleBillDetailV3_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type OrderGetSettleBillDetailV3Request struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *OrderAddressModifyParam
|
||||
}
|
||||
|
||||
func (c *OrderGetSettleBillDetailV3Request) GetUrlPath() string {
|
||||
return "/order/getSettleBillDetailV3"
|
||||
}
|
||||
|
||||
func New() *OrderGetSettleBillDetailV3Request {
|
||||
request := &OrderGetSettleBillDetailV3Request{
|
||||
Param: &OrderAddressModifyParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *OrderGetSettleBillDetailV3Request) Execute(accessToken *doudian_sdk.AccessToken) (*order_getSettleBillDetailV3_response.OrderGetSettleBillDetailV3Response, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &order_getSettleBillDetailV3_response.OrderGetSettleBillDetailV3Response{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *OrderGetSettleBillDetailV3Request) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *OrderGetSettleBillDetailV3Request) GetParams() *OrderAddressModifyParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type OrderAddressModifyParam struct {
|
||||
// 页数,支持范围1~100
|
||||
Size int64 `json:"size"`
|
||||
// 查询开始时间,格式为:yyyy-MM-dd HH:mm:ss,订单号未传的情况下,开始时间必须传,注意:分页查询时,除首次查询外,应填入上一次返回的next_start_time
|
||||
StartTime string `json:"start_time"`
|
||||
// 查询结束时间,和end_time的时间间隔建议不超过7天,格式为:yyyy-MM-dd HH:mm:ss,订单号未传的情况下,结束时间必须传
|
||||
EndTime string `json:"end_time"`
|
||||
// SKU单,子订单号,支持通过英文逗号分隔传入多个参数
|
||||
OrderId string `json:"order_id"`
|
||||
// 商品id
|
||||
ProductId string `json:"product_id"`
|
||||
// 结算账户,不传则默认为全部,枚举: 1(微信:升级前)、 2(微信)、 3(支付宝)、 4(合众支付)、 5(聚合账户),支持通过英文逗号分隔传入多个参数
|
||||
PayType string `json:"pay_type"`
|
||||
// 业务类型,不传则默认为全部,枚举: 1(鲁班广告)、2(值点商城), 3(精选联盟)、 4(小店自卖)
|
||||
FlowType string `json:"flow_type"`
|
||||
// 时间类型 ,不传则默认为结算时间,枚举: 0(结算时间) 1(下单时间)
|
||||
TimeType string `json:"time_type"`
|
||||
// 查询开始索引,注意:分页查询时,除首次查询可不填外,应填入上一次返回的next_start_index
|
||||
StartIndex string `json:"start_index"`
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package order_getSettleBillDetailV3_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type OrderGetSettleBillDetailV3Response struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *OrderGetSettleBillDetailV3Data `json:"data"`
|
||||
}
|
||||
type OrderGetSettleBillDetailV3Data struct {
|
||||
Code string `json:"code"` // 返回code 100000为成功,其他为失败
|
||||
CodeMsg string `json:"code_msg"` // 返回信息描述,失败状态下会有失败描述
|
||||
Data []DataList `json:"data"` // 订单流水明细列表
|
||||
DataSize string `json:"data_size"` // 结果data的大小
|
||||
IsEnd string `json:"is_end"` // 判断查询是否结束。0 未结束, 1 结束。未结束时,需要把next_start_index作为下一次请求的start_index,next_start_time作为下一次请求的start_time
|
||||
NextStartIndex string `json:"next_start_index"` // 下一次查询start_index
|
||||
NextStartTime string `json:"next_start_time"` // 下一次查询start_time
|
||||
Size string `json:"size"` // 请求的size
|
||||
}
|
||||
|
||||
type DataList struct {
|
||||
AuthorCoupon string `json:"author_coupon"` // 达人补贴(分)
|
||||
ChannelPromotionFee string `json:"channel_promotion_fee"` // 直播间站外推广(分)
|
||||
ColonelServiceFee string `json:"colonel_service_fee"` // 团长服务费(分)
|
||||
Commission string `json:"commission"` // 佣金(分)
|
||||
FlowTypeDesc string `json:"flow_type_desc"` // 业务类型: 鲁班广告、值点商城、精选联盟、小店自卖等
|
||||
GoodLearnChannelFee string `json:"good_learn_channel_fee"` // 渠道分成(分)
|
||||
GoodsCount string `json:"goods_count"` // 商品数量
|
||||
IsContainsRefundBeforeSettle string `json:"is_contains_refund_before_settle"` // 是否包含结算前退款 0:不包含 1:包含
|
||||
OrderId string `json:"order_id"` // 子订单号
|
||||
OrderTime string `json:"order_time"` // 下单时间
|
||||
OrderType string `json:"order_type"` // 订单类型:普通订单、尾款(尾款已支付)、尾款(已退款)、定金(已退款)、定金(尾款已支付)、定金(尾款未支付)
|
||||
OtherSharingAmount string `json:"other_sharing_amount"` // 其他分成(学浪)(分)
|
||||
PackingAmount string `json:"packing_amount"` // 打包费,单位:分
|
||||
PayTypeDesc string `json:"pay_type_desc"` // 货款结算对应的账户类型: “聚合账户”“微信”“支付宝”“微信升级前”“合众支付”等
|
||||
PlatformCoupon string `json:"platform_coupon"` // 平台补贴(分)
|
||||
PlatformServiceFee string `json:"platform_service_fee"` // 平台服务费(分)
|
||||
PostAmount string `json:"post_amount"` // 运费(分)
|
||||
ProductId string `json:"product_id"` // 商品id
|
||||
RealPayAmount string `json:"real_pay_amount"` // 用户实付(分)
|
||||
RefundBeforeSettle string `json:"refund_before_settle"` // 结算前退款金额(分) (结算前退货+运费-店铺券)
|
||||
Remark string `json:"remark"` // 备注
|
||||
RequestNo string `json:"request_no"` // 结算单号
|
||||
SettleAmount string `json:"settle_amount"` // 商家实收(分)
|
||||
SettleTime string `json:"settle_time"` // 结算时间
|
||||
ShopCoupon string `json:"shop_coupon"` // 店铺券(分)
|
||||
ShopOrderId string `json:"shop_order_id"` // 订单号
|
||||
TotalAmount string `json:"total_amount"` // 订单总价(分)
|
||||
TotalGoodsAmount string `json:"total_goods_amount"` // 商品总价(分)
|
||||
TotalIncome string `json:"total_income"` // 收入合计(分)
|
||||
TotalOutcome string `json:"total_outcome"` // 合计支出
|
||||
TradeType string `json:"trade_type"` // 结算单类型 0 :已结算 1 :结算后退款-原路退回 2: 保证金退款-支出退回 3: 结算后退款-非原路退回
|
||||
ZrPayPromotion string `json:"zr_pay_promotion"` // DOU分期营销补贴(分)
|
||||
ZtPayPromotion string `json:"zt_pay_promotion"` // 抖音支付补贴(分)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package order_logisticsAddSinglePack_response
|
||||
|
||||
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
|
||||
type OrderLogisticsAddSinglePackResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *OrderLogisticsAddSinglePackData `json:"data"`
|
||||
|
||||
@@ -2,6 +2,8 @@ package token_create_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
token_create_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/token_create/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type TokenCreateRequest struct {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package token_create_response
|
||||
|
||||
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
|
||||
type TokenCreateResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *TokenCreateData `json:"data"`
|
||||
|
||||
@@ -15,9 +15,12 @@ func (at *AccessToken) IsSuccess() bool {
|
||||
}
|
||||
|
||||
type BuildAccessTokenParam struct {
|
||||
Code string
|
||||
ShopId int64
|
||||
Config *DoudianOpConfig
|
||||
Code string
|
||||
ShopId int64
|
||||
TestShop string `json:"test_shop"`
|
||||
AuthId string `json:"auth_id"`
|
||||
AuthSubjectType string `json:"auth_subject_type"`
|
||||
Config *DoudianOpConfig
|
||||
}
|
||||
|
||||
type RefreshAccessTokenParam struct {
|
||||
|
||||
16
platformapi/tiktok_shop/tiktok_api/afs_test.go
Normal file
16
platformapi/tiktok_shop/tiktok_api/afs_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package tiktok_api
|
||||
|
||||
import "testing"
|
||||
|
||||
var token = `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}`
|
||||
var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
|
||||
// 查询售后单详情
|
||||
func TestAfsOrder(t *testing.T) {
|
||||
a.QueryAfsOrderDetail("7154266161041899779", true)
|
||||
}
|
||||
|
||||
// 同意/拒绝售后单
|
||||
func TestAggreOrNotAggreAfs(t *testing.T) {
|
||||
//a.AfterSaleOperate()
|
||||
}
|
||||
@@ -9,13 +9,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
CallbackSuccessCode = 0
|
||||
CallbackSuccess = "success"
|
||||
CallbackFailCode = 1000
|
||||
CallbackFail = "fail"
|
||||
)
|
||||
|
||||
type API struct {
|
||||
appKey string
|
||||
appSecret string
|
||||
@@ -72,7 +65,7 @@ func (a *API) CreateToken(code string) (*doudian_sdk.CreateTokenData, error) {
|
||||
doudian_sdk.GlobalConfig.AppKey = a.appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = a.appSecret
|
||||
buildParam := &doudian_sdk.BuildAccessTokenParam{
|
||||
Code: code, // 定死还是自动获取
|
||||
Code: code,
|
||||
ShopId: 0,
|
||||
Config: nil,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package tiktok_api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
order_getSettleBillDetailV3_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/request"
|
||||
order_logisticsAdd_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAdd/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
@@ -29,7 +31,8 @@ func TestQueryOrderDetail(t *testing.T) {
|
||||
|
||||
func TestRefaseToken(t *testing.T) {
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", "")
|
||||
a.CreateToken("41155cd5-d30f-4075-9c44-b75ffa1a84ee")
|
||||
a.CreateToken("bb52688c-7bca-4b64-8747-5258a9a6ba33")
|
||||
// {"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}
|
||||
//{"access_token":"37f41ac7-49ac-4848-a0ee-ea86bb0dfd9f","expires_in":519389,"scope":"SCOPE","shop_id":"","shop_name":"抖店开放平台测试专用店","refresh_token":"3dd8f638-fdf1-46e7-b974-88df382f03c6","authority_id" :""}
|
||||
}
|
||||
|
||||
@@ -37,3 +40,53 @@ func TestTimeNow(t *testing.T) {
|
||||
h, m, s := time.Now().Clock()
|
||||
fmt.Println(h, m, s)
|
||||
}
|
||||
|
||||
func TestSendGoods(t *testing.T) {
|
||||
param := &order_logisticsAdd_request.OrderLogisticsAddParam{
|
||||
OrderId: "4989178132980723098",
|
||||
Company: "",
|
||||
CompanyCode: "chengdouruoxi",
|
||||
LogisticsCode: "4989178132980723098111",
|
||||
IsRefundReject: false,
|
||||
IsRejectRefund: false,
|
||||
SerialNumberList: nil,
|
||||
AddressId: 0,
|
||||
StoreId: 63114504,
|
||||
}
|
||||
a.OrderDelivering(param)
|
||||
}
|
||||
|
||||
// 创建物流token
|
||||
func TestCreateExpss(t *testing.T) {
|
||||
a := NewExpress("7152420904331429407", "cc7ba367-2394-4cbb-81c6-26f0e929d1c6", "")
|
||||
a.CreateToken()
|
||||
}
|
||||
|
||||
// 同意退货申请
|
||||
func TestReturnGoodsToWareHouseSuccess(t *testing.T) {
|
||||
token := `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
a.ReturnGoodsToWareHouseSuccess("7154200345302827303")
|
||||
}
|
||||
|
||||
// 获取订单结算信息
|
||||
func TestGetSettleBillDetailV3(t *testing.T) {
|
||||
token := `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
a.GetSettleBillDetailV3(&order_getSettleBillDetailV3_request.OrderAddressModifyParam{
|
||||
Size: 100,
|
||||
StartTime: "2022-10-07 00:00:00",
|
||||
EndTime: "2022-10-14 00:00:00",
|
||||
//OrderId: "4980573848886616007",
|
||||
ProductId: "",
|
||||
PayType: "",
|
||||
FlowType: "",
|
||||
TimeType: "1",
|
||||
StartIndex: "",
|
||||
})
|
||||
}
|
||||
|
||||
// 多订单同一个物流包裹
|
||||
func TestLogisticsAddSinglePack(t *testing.T) {
|
||||
a.LogisticsAddSinglePack()
|
||||
}
|
||||
|
||||
160
platformapi/tiktok_shop/tiktok_api/logistics_express.go
Normal file
160
platformapi/tiktok_shop/tiktok_api/logistics_express.go
Normal file
@@ -0,0 +1,160 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
logistics_indTrackPush_reqeust "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/logistics_indTrackPush/request"
|
||||
token_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/token_create/request"
|
||||
token_create_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/token_create/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type APIExpress struct {
|
||||
appKey string
|
||||
appSecret string
|
||||
accessToken string
|
||||
refreshToken string
|
||||
expiresIn int64 // 当前时间的七天内为有效期
|
||||
locker sync.RWMutex
|
||||
accessTokenObj *doudian_sdk.AccessToken // 存储数据库
|
||||
}
|
||||
|
||||
func NewExpress(appKey, appSecret, accessToken string) *APIExpress {
|
||||
var access *doudian_sdk.AccessToken
|
||||
doudian_sdk.GlobalConfig.AppKey = appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = appSecret
|
||||
if accessToken != "" {
|
||||
if err := json.Unmarshal([]byte(accessToken), &access); err != nil {
|
||||
globals.SugarLogger.Debug("accessToken init err :", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
api := &APIExpress{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
accessToken: access.AccessToken,
|
||||
refreshToken: access.RefreshToken,
|
||||
expiresIn: access.ExpiresIn,
|
||||
accessTokenObj: access,
|
||||
}
|
||||
if access.ExpiresIn < time.Now().Unix() {
|
||||
api.RefreshToken()
|
||||
}
|
||||
return api
|
||||
}
|
||||
return &APIExpress{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
}
|
||||
}
|
||||
|
||||
// CreateToken 创建token只有第一次授权或者更新授权才需要,其他时候直接刷新就可以啦
|
||||
func (a *APIExpress) CreateToken() (*token_create_response.TokenCreateData, error) {
|
||||
request := token_create_request.New()
|
||||
param := request.GetParams()
|
||||
param.Code = ""
|
||||
param.GrantType = "authorization_self"
|
||||
param.AuthId = TiktokExpressCode
|
||||
param.AuthSubjectType = "WuLiuShang"
|
||||
response, err := request.Execute(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
}
|
||||
|
||||
a.accessTokenObj.CreateTokenData = doudian_sdk.CreateTokenData{
|
||||
AccessToken: response.Data.AccessToken,
|
||||
ExpiresIn: time.Now().Unix() + response.Data.ExpiresIn,
|
||||
Scope: response.Data.Scope,
|
||||
ShopId: utils.Int64ToStr(response.Data.ShopId),
|
||||
ShopName: response.Data.ShopName,
|
||||
RefreshToken: response.Data.RefreshToken,
|
||||
AuthorityId: response.Data.AuthorityId,
|
||||
}
|
||||
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// RefreshToken 刷新token
|
||||
func (a *APIExpress) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
||||
doudian_sdk.GlobalConfig.AppKey = a.appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = a.appSecret
|
||||
refresh := doudian_sdk.NewRefreshTokenRequest()
|
||||
refresh.GetParam().RefreshToken = a.refreshToken
|
||||
refresh.GetParam().GrantType = "refresh_token"
|
||||
|
||||
createToken, err := refresh.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if createToken.Code != RequestSuccessCode {
|
||||
return nil, errors.New(createToken.SubMsg)
|
||||
}
|
||||
a.accessToken = createToken.Data.AccessToken
|
||||
a.refreshToken = createToken.Data.RefreshToken
|
||||
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
||||
globals.SugarLogger.Debug("===============data", createToken.Data)
|
||||
|
||||
// 不要
|
||||
createToken.Data.ExpiresIn = a.expiresIn
|
||||
strData, _ := json.Marshal(createToken.Data)
|
||||
a.accessTokenObj.CreateTokenData = createToken.Data
|
||||
globals.SugarLogger.Debug("=========", string(strData))
|
||||
return &createToken.Data, nil
|
||||
}
|
||||
|
||||
// OrderStatusAndPsInfo 三方配送同步骑手位置信息
|
||||
// 抖音物流信息和抖音小时达完全区分开(这边的appKey和APPSecret完全不同于小时达)
|
||||
func (a *APIExpress) OrderStatusAndPsInfo(param map[string]interface{}) error {
|
||||
// 组合参数
|
||||
request := logistics_indTrackPush_reqeust.New()
|
||||
psInfo := &logistics_indTrackPush_reqeust.LogisticsIndTrackPushParam{
|
||||
CurTime: utils.Time2Str(time.Now()),
|
||||
Company: TiktokExpressCode,
|
||||
TraceMsgs: nil,
|
||||
AuthorityId: "",
|
||||
}
|
||||
traceMsgs := make([]logistics_indTrackPush_reqeust.TraceMsgList, 0, 1)
|
||||
traceMsg := logistics_indTrackPush_reqeust.TraceMsgList{
|
||||
TrackNo: param["third_carrier_order_id"].(string),
|
||||
Traces: []logistics_indTrackPush_reqeust.TracesList{
|
||||
{
|
||||
Opcode: "ORDER_RECEIVED",
|
||||
OpTime: utils.Time2TimeStr(time.Now()),
|
||||
Content: param["logistics_context"].(string),
|
||||
Rider: logistics_indTrackPush_reqeust.ReiderInfo{
|
||||
Name: param["courier_name"].(string),
|
||||
Mobile: param["courier_phone"].(string),
|
||||
},
|
||||
ThirdPartyCompany: TiktokExpressCode,
|
||||
ExceptionCode: "",
|
||||
ExceptionDesc: "",
|
||||
CancelCode: "",
|
||||
CancelDesc: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
traceMsgs = append(traceMsgs, traceMsg)
|
||||
psInfo.TraceMsgs = traceMsgs
|
||||
request.Param = psInfo
|
||||
|
||||
if a.accessTokenObj == nil || a.accessTokenObj.CreateTokenData.AccessToken == "" {
|
||||
a.CreateToken()
|
||||
} else if a.accessTokenObj.CreateTokenData.ExpiresIn < time.Now().Unix() {
|
||||
a.RefreshToken()
|
||||
}
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package tiktok_api
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
address_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/address_list/request"
|
||||
afterSale_applyMarketAfterSale_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_ApplyMarketAfterSale/request"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
afterSale_rejectReasonCodeList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_rejectReasonCodeList/response"
|
||||
afterSale_returnGoodsToWareHouseSuccess_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_returnGoodsToWareHouseSuccess/request"
|
||||
order_logisticsAdd_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAdd/request"
|
||||
order_logisticsAddSinglePack_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAddSinglePack/request"
|
||||
order_orderDetail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/request"
|
||||
order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response"
|
||||
order_searchList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_searchList/request"
|
||||
@@ -273,7 +275,7 @@ func (a *API) ReturnGoodsToWareHouseSuccess(afsOrderId string) error {
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
return err // 202210141114300102101071350D6F3847
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
@@ -595,7 +597,34 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, *Callb
|
||||
return "", &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
|
||||
// OrderStatusAndPsInfo 三方配送同步骑手位置信息
|
||||
func (a *API) OrderStatusAndPsInfo(param map[string]interface{}) error {
|
||||
// OrderDelivering 订单发货
|
||||
func (a *API) OrderDelivering(param *order_logisticsAdd_request.OrderLogisticsAddParam) error {
|
||||
request := order_logisticsAdd_request.New()
|
||||
request.Param = param
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LogisticsAddSinglePack 支持多个订单发同一个物流包裹
|
||||
func (a *API) LogisticsAddSinglePack() {
|
||||
request := order_logisticsAddSinglePack_request.New()
|
||||
request.Param.OrderIdList = []string{"4989180160180927898"}
|
||||
request.Param.ShippedOrderInfo = []order_logisticsAddSinglePack_request.ShippedOrderInfoItem{
|
||||
{ShippedOrderId: "4989180160180927898", ShippedNum: 1},
|
||||
}
|
||||
request.Param.LogisticsCode = "4989180160180927898fake"
|
||||
request.Param.RequestId = "1267250f-8b9d-4d9e-9fad-0cd9629c83de"
|
||||
request.Param.CompanyCode = "dajiangwangluo"
|
||||
request.Param.StoreId = 63114504
|
||||
|
||||
data, err := request.Execute(a.accessTokenObj)
|
||||
fmt.Println(data)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
package tiktok_api
|
||||
|
||||
const RequestSuccessCode = 10000
|
||||
const TiktokExpressCode = "chengduruoxi"
|
||||
|
||||
const (
|
||||
CallbackSuccessCode = 0
|
||||
CallbackSuccess = "success"
|
||||
CallbackFailCode = 1000
|
||||
CallbackFail = "fail"
|
||||
)
|
||||
|
||||
// 订单消息回调类型(正向订单)
|
||||
const (
|
||||
|
||||
22
platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go
Normal file
22
platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
order_getSettleBillDetailV3_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
// GetSettleBillDetailV3 商家结算账单
|
||||
// 已结算的订单才会有数据,数据T+1生成,建议第二天15点之后查询。如因任务积压导致延迟的情况,建议重试。
|
||||
// 1、推荐使用start_index方式查询
|
||||
func (a *API) GetSettleBillDetailV3(param *order_getSettleBillDetailV3_request.OrderAddressModifyParam) {
|
||||
request := order_getSettleBillDetailV3_request.New()
|
||||
request.Param = param
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
globals.SugarLogger.Debugf("======:%s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("======:%s", err)
|
||||
}
|
||||
@@ -37,6 +37,7 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err
|
||||
request := sku_syncStock_request.New()
|
||||
request.Param = param
|
||||
resp, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debug("======/sku/syncStock:%s", utils.Format4Output(resp, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -116,7 +117,7 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
||||
return nil, err
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debug("=========", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debug("=========/product/addV2", utils.Format4Output(result, false))
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
@@ -232,10 +232,7 @@ func TestGetSkuDetail(t *testing.T) {
|
||||
|
||||
// 查询商品详情本地商品id
|
||||
func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
data, err := a.GetSkuDetail("", "")
|
||||
data, err := a.GetSkuDetail("3576767557912375101", "")
|
||||
fmt.Println(err)
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestUploadImg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRefundToken(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652252,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对 接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authorit y_id":""}`
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
a.RefreshToken()
|
||||
|
||||
Reference in New Issue
Block a user