1
This commit is contained in:
@@ -57,7 +57,7 @@ var (
|
||||
|
||||
const (
|
||||
DeliveryServiceCodeSuperRapid = 4002 // 飞速达
|
||||
DeliveryServiceCodeRapid = 100004 // 快速达
|
||||
DeliveryServiceCodeRapid = 4011 // 快速达
|
||||
DeliveryServiceCodeIntime = 100006 // 及时达
|
||||
DeliveryServiceCodeTogether = 4013 // 集中送
|
||||
)
|
||||
|
||||
@@ -2,6 +2,8 @@ package sku_syncStock_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
sku_syncStock_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SkuSyncStockRequest struct {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package sku_syncStock_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SkuSyncStockResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *SkuSyncStockData `json:"data"`
|
||||
|
||||
@@ -4,20 +4,29 @@ import (
|
||||
"encoding/json"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
CallbackSuccessCode = 0
|
||||
CallbackSuccess = "success"
|
||||
CallbackFailCode = 1000
|
||||
CallbackFail = "fail"
|
||||
)
|
||||
|
||||
var AccessToken *doudian_sdk.AccessToken // 存储数据库
|
||||
|
||||
type Api struct {
|
||||
type API struct {
|
||||
appKey string
|
||||
appSecret string
|
||||
accessToken string
|
||||
refreshToken string
|
||||
expiresIn int64
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
func New(appKey, appSecret, accessToken string) *Api {
|
||||
func New(appKey, appSecret, accessToken string) *API {
|
||||
var access *doudian_sdk.AccessToken
|
||||
if accessToken != "" {
|
||||
if err := json.Unmarshal([]byte(accessToken), &access); err != nil {
|
||||
@@ -28,17 +37,17 @@ func New(appKey, appSecret, accessToken string) *Api {
|
||||
}
|
||||
}
|
||||
|
||||
return &Api{
|
||||
return &API{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Api) GetToken() string {
|
||||
func (a *API) GetToken() string {
|
||||
if a.expiresIn != 0 && a.expiresIn > time.Now().Unix() && a.accessToken != "" {
|
||||
return a.accessToken
|
||||
} else {
|
||||
if err := a.RefreshToken(); err != nil {
|
||||
if _, err := a.RefreshToken(); err != nil {
|
||||
globals.SugarLogger.Debug("Tiktok RefreshToken Err : ", err)
|
||||
return ""
|
||||
}
|
||||
@@ -47,7 +56,7 @@ func (a *Api) GetToken() string {
|
||||
}
|
||||
|
||||
// CreateToken 创建token只有第一次授权或者更新授权才需要,其他时候直接刷新就可以啦
|
||||
func (a *Api) CreateToken(code string) error {
|
||||
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{
|
||||
@@ -57,29 +66,41 @@ func (a *Api) CreateToken(code string) error {
|
||||
}
|
||||
access, err := doudian_sdk.BuildAccessToken(buildParam)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.accessToken = access.AccessToken
|
||||
a.refreshToken = access.RefreshToken
|
||||
a.expiresIn = access.ExpiresIn
|
||||
AccessToken = access
|
||||
return nil
|
||||
return &access.CreateTokenData, nil
|
||||
}
|
||||
|
||||
// RefreshToken 刷新token
|
||||
func (a *Api) RefreshToken() error {
|
||||
func (a *API) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
||||
refresh := doudian_sdk.NewRefreshTokenRequest()
|
||||
refresh.GetParam().RefreshToken = a.refreshToken
|
||||
refresh.GetParam().GrantType = "refresh_token"
|
||||
|
||||
createToken, err := refresh.Execute(AccessToken)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
a.accessToken = createToken.Data.AccessToken
|
||||
a.refreshToken = createToken.Data.RefreshToken
|
||||
a.expiresIn = createToken.Data.ExpiresIn
|
||||
AccessToken.CreateTokenData = createToken.Data
|
||||
return nil
|
||||
return &createToken.Data, nil
|
||||
}
|
||||
|
||||
func (a *API) SetToken(token string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
a.accessToken = token
|
||||
}
|
||||
|
||||
func (a *API) SetRefreshToken(token string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
a.refreshToken = token
|
||||
}
|
||||
|
||||
44
platformapi/tiktok_shop/tiktok_api/order.go
Normal file
44
platformapi/tiktok_shop/tiktok_api/order.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
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"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetTiktokOrderDetail 获取订单详情
|
||||
func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.ShopOrderDetail, error) {
|
||||
reqParam := order_orderDetail_request.New()
|
||||
reqParam.Param = &order_orderDetail_request.OrderOrderDetailParam{
|
||||
ShopOrderId: orderId,
|
||||
IsSearchable: false,
|
||||
}
|
||||
orderDetail, err := reqParam.Execute(AccessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if orderDetail.Code != 1000 {
|
||||
return nil, errors.New(orderDetail.Msg)
|
||||
}
|
||||
|
||||
return orderDetail.Data.ShopOrderDetail, nil
|
||||
}
|
||||
|
||||
// CreateOrderCallback 订单创建,抖店创建订单后,回调消息通知本服务器
|
||||
func (a *API) CreateOrderCallback(request *http.Request) (resp []*OrderCallback, callbackResponse *CallbackResponse) {
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
return nil, &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
|
||||
orderNotify := []*OrderCallback{}
|
||||
if err := json.Unmarshal(data, &orderNotify); err != nil {
|
||||
baseapi.SugarLogger.Debugf("Tiktok Notify failed with err:%v", err)
|
||||
return nil, &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
return orderNotify, &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
312
platformapi/tiktok_shop/tiktok_api/order_type.go
Normal file
312
platformapi/tiktok_shop/tiktok_api/order_type.go
Normal file
@@ -0,0 +1,312 @@
|
||||
package tiktok_api
|
||||
|
||||
type CallbackResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
// PublicOrderCallback 抖店创建订单回调
|
||||
type PublicOrderCallback struct {
|
||||
Tag string `json:"tag"` // 消息种类,订单创建消息的tag值为"100"
|
||||
MsgId string `json:"msgId"` //消息记录id
|
||||
}
|
||||
|
||||
type OrderCallback struct {
|
||||
Tag string `json:"tag"` // 消息种类,订单创建消息的tag值为"100"
|
||||
MsgId string `json:"msgId"` //消息记录id
|
||||
Data string `json:"data"` // 消息正文
|
||||
Body map[string]interface{} `json:"body"`
|
||||
}
|
||||
|
||||
//#region 创建订单消息通知
|
||||
|
||||
// 创建订单回调
|
||||
type CreateOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *CreateOrderData `json:"data"`
|
||||
}
|
||||
|
||||
type CreateOrderData struct {
|
||||
Biz int `json:"biz"` // 业务来源 1-鲁班.....
|
||||
CreateTime int `json:"create_time"` // 订单创建时间
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,订单创建消息的order_status值为"1"
|
||||
OrderType int `json:"order_type"` // 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单 ID
|
||||
SIds []int `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//region 订单支付回调通知
|
||||
|
||||
type PayOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *PayOrderData `json:"data"`
|
||||
}
|
||||
|
||||
type PayOrderData struct {
|
||||
Biz int `json:"biz"` // 订单业务类型
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,订单支付消息的status值为"2"
|
||||
OrderType int `json:"order_type"` // 订单类型: 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单ID
|
||||
PayAmount int `json:"pay_amount"` // 订单实付金额
|
||||
PayTime int `json:"pay_time"` // 1: 在线订单支付时间 2: 货到付款订单确认时间
|
||||
PayType int `json:"pay_type"` // 订单支付方式: 0:货到付款,1:微信,2:支付宝,4:银行卡,5:抖音零钱,7:无需支付,8:DOU分期,9:新卡支付,12:先用后付,13:组合支付
|
||||
SIds []int `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//region 订单支付待处理(风控,审核,未成团...)
|
||||
|
||||
type WaitOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *PayOrderData `json:"data"`
|
||||
}
|
||||
|
||||
type WaitOrderData struct {
|
||||
Biz int `json:"biz"` // 订单业务类型
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,订单支付消息的status值为"2"
|
||||
OrderType int `json:"order_type"` // 订单类型: 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单ID
|
||||
PayAmount int `json:"pay_amount"` // 订单实付金额
|
||||
PayTime int `json:"pay_time"` // 1: 在线订单支付时间 2: 货到付款订单确认时间
|
||||
PayType int `json:"pay_type"` // 订单支付方式: 0:货到付款,1:微信,2:支付宝,4:银行卡,5:抖音零钱,7:无需支付,8:DOU分期,9:新卡支付,12:先用后付,13:组合支付
|
||||
SIds []int `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 卖家部分发货
|
||||
|
||||
type SomeSendOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *SomeSendOrderData `json:"data"`
|
||||
}
|
||||
type SomeSendOrderData struct {
|
||||
Biz int `json:"biz"` // 订单业务来源类型
|
||||
LogisticsMsg struct {
|
||||
ExpressCompanyId string `json:"express_company_id"` // 发货快递公司
|
||||
LogisticsCode string `json:"logistics_code"` // 发货物流code
|
||||
PackId string `json:"pack_id"` // 包裹id
|
||||
ShippedOrderInfo []struct {
|
||||
ProductId int `json:"product_id"` // 商品id
|
||||
ShippedNum int `json:"shipped_num"` // 发货数量
|
||||
ShippedOrderId int64 `json:"shipped_order_id"` // 已发货子订单
|
||||
SkuId int `json:"sku_id"` // 对应skuid
|
||||
SkuNum int `json:"sku_num"` // 购买sku数量
|
||||
} `json:"shipped_order_info"`
|
||||
} `json:"logistics_msg"`
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,卖家发货消息的status值为"2"
|
||||
OrderType int `json:"order_type"` // 订单类型
|
||||
PId int64 `json:"p_id"` // 父订单id
|
||||
ReceiverMsg struct {
|
||||
Addr string `json:"addr"` // 收货地址
|
||||
Name string `json:"name"` // 收货名字
|
||||
Tel string `json:"tel"` // 收货电话
|
||||
} `json:"receiver_msg"`
|
||||
SIds []int `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int `json:"shop_id"` // 门店id
|
||||
UpdateTime int `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region卖家发货
|
||||
|
||||
type BusinessDeliveryCallback struct {
|
||||
PublicOrderCallback
|
||||
data *BusinessDeliveryData `json:"data"`
|
||||
}
|
||||
|
||||
type BusinessDeliveryData struct {
|
||||
Biz int `json:"biz"`
|
||||
LogisticsMsg struct {
|
||||
ExpressCompanyId string `json:"express_company_id"` // 发货快递公司
|
||||
LogisticsCode string `json:"logistics_code"` //发货物流单号
|
||||
} `json:"logistics_msg"`
|
||||
OrderStatus int `json:"order_status"` //父订单状态,卖家发货消息的status值为"3"
|
||||
OrderType int `json:"order_type"` // 订单类型
|
||||
PId int64 `json:"p_id"`
|
||||
ReceiverMsg struct {
|
||||
Addr string `json:"addr"`
|
||||
Name string `json:"name"`
|
||||
Tel string `json:"tel"`
|
||||
} `json:"receiver_msg"`
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
UpdateTime int `json:"update_time"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 取消订单
|
||||
|
||||
type CancelOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *CreateOrderData `json:"data"`
|
||||
}
|
||||
|
||||
type CancelOrderData struct {
|
||||
Biz int `json:"biz"`
|
||||
CancelReason string `json:"cancel_reason"` // 取消原因
|
||||
CancelTime int `json:"cancel_time"` // 取消时间
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,订单取消消息的status值为"4"
|
||||
OrderType int `json:"order_type"` // 订单类型
|
||||
PId int64 `json:"p_id"`
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 卖家确认收货时,会自动完成
|
||||
|
||||
type SuccessOrderCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *SuccessOrderData `json:"data"`
|
||||
}
|
||||
type SuccessOrderData struct {
|
||||
Biz int `json:"biz"`
|
||||
CompleteTime int `json:"complete_time"` // 交易完成时间
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,交易完成消息的status值为"5"
|
||||
OrderType int `json:"order_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 发货物流消息便跟
|
||||
|
||||
type WayBillChangeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *SuccessOrderData `json:"data"`
|
||||
}
|
||||
|
||||
type WayBillChangeData struct {
|
||||
Biz int `json:"biz"`
|
||||
LogisticsMsg struct {
|
||||
ExpressCompanyId string `json:"express_company_id"` // 物流公司id
|
||||
LogisticsCode string `json:"logistics_code"` // 订单号
|
||||
} `json:"logistics_msg"`
|
||||
OrderStatus int `json:"order_status"` // 父订单状态-3变更物流
|
||||
OrderType int `json:"order_type"` // 订单类型
|
||||
PId int64 `json:"p_id"` // 订单id
|
||||
ReceiverMsg struct {
|
||||
Addr string `json:"addr"` // 收货地址
|
||||
Name string `json:"name"` // 收货名称
|
||||
Tel string `json:"tel"` // 电话
|
||||
} `json:"receiver_msg"`
|
||||
SIds []int `json:"s_ids"` // 子id
|
||||
ShopId int `json:"shop_id"` // 门店id
|
||||
UpdateTime int `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 收货地址消息变更(商家审核通过触发)
|
||||
|
||||
type ReceivingAddressChangeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *ReceivingAddressChangeData `json:"data"`
|
||||
}
|
||||
|
||||
type ReceivingAddressChangeData struct {
|
||||
OrderStatus int `json:"order_status"` // 收货地址变更状态为2
|
||||
OrderType int `json:"order_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
ReceiverMsg struct {
|
||||
Addr string `json:"addr"`
|
||||
Name string `json:"name"`
|
||||
Tel string `json:"tel"`
|
||||
} `json:"receiver_msg"`
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
UpdateTime int `json:"update_time"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 卖家修改订单/运单金额回调
|
||||
|
||||
type UpdateAmountChangeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *UpdateAmountChangeData `json:"data"`
|
||||
}
|
||||
|
||||
type UpdateAmountChangeData struct {
|
||||
Biz int `json:"biz"`
|
||||
ModifyTime int `json:"modify_time"` // 订单修改时间
|
||||
OrderStatus int `json:"order_status"` // 订单状态 1
|
||||
OrderType int `json:"order_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
PostAmount int `json:"post_amount"` // 邮费
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
TotalAmount int `json:"total_amount"` // 主订单金额不含邮费
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 买家收货消息变更(手机,地址,姓名),用户C端修改触发(需要上面审核接口)
|
||||
|
||||
type BuyerUpdateWayBillCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *BuyerUpdateWayBillData `json:"data"`
|
||||
}
|
||||
|
||||
type BuyerUpdateWayBillData struct {
|
||||
ApplyTime int `json:"apply_time"` // 申请时间
|
||||
PId int64 `json:"p_id"`
|
||||
PostReceiverMsg struct {
|
||||
Addr string `json:"addr"`
|
||||
Name string `json:"name"`
|
||||
Tel string `json:"tel"`
|
||||
} `json:"post_receiver_msg"` // 变更前地址信息
|
||||
ReceiverMsg struct {
|
||||
Addr string `json:"addr"`
|
||||
Name string `json:"name"`
|
||||
Tel string `json:"tel"`
|
||||
} `json:"receiver_msg"` // 变更后地址信息
|
||||
ShopId int `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region商家修改交易备注回调
|
||||
|
||||
type BusinessUpdateRemakeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *BusinessUpdateRemakeData `json:"data"`
|
||||
}
|
||||
type BusinessUpdateRemakeData struct {
|
||||
PId int64 `json:"p_id"` // 订单
|
||||
Remark string `json:"remark"` // 备注
|
||||
ShopId int `json:"shop_id"` // 门店id
|
||||
Star int `json:"star"` // 标星等级,范围0~5,0为灰色旗标,5为红色旗标,数字越大颜色越深 0灰 1紫 2青 3绿 4橙 5红
|
||||
UpdateTime int `json:"update_time"` // 修改时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 订单发货时消息变更回调
|
||||
|
||||
type AppointmentChangeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *AppointmentChangeData `json:"data"`
|
||||
}
|
||||
|
||||
type AppointmentChangeData struct {
|
||||
ExpDeliveryTime int `json:"exp_delivery_time"` // 变更后预期发货时间
|
||||
OrderType int `json:"order_type"`
|
||||
PId string `json:"p_id"`
|
||||
SIds []int `json:"s_ids"`
|
||||
ShopId int `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
54
platformapi/tiktok_shop/tiktok_api/order_type_const.go
Normal file
54
platformapi/tiktok_shop/tiktok_api/order_type_const.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package tiktok_api
|
||||
|
||||
// 回调类型
|
||||
const (
|
||||
CallbackCreatedOrderMsgTagId = "100" // 创建订单回调
|
||||
CallbackPayOrderMsgTagId = "101" // 支付订单回调
|
||||
CallbackWaitOrderMsgTagId = "110" // 支付订待处理
|
||||
CallbackPartGoodsMsgTagId = "108" // 部分发货回调
|
||||
CallbackPartAllGoodsMsgTagId = "102" // 商品发货完成回调
|
||||
CallbackCancelOrderMsgTagId = "106" // 取消订单回调
|
||||
CallbackSuccessOrderMsgTagId = "103" // 确认收货订单回调
|
||||
CallbackWayBillChangeOrderMsgTagId = "104" // 物流消息变更
|
||||
CallbackReceivingChangeOrderMsgTagId = "105" // 收货地址变更(商家确认后触发)
|
||||
CallbackChangeMoneyMsgTagId = "109" // 卖家修改订单/运单金额
|
||||
CallbackApplyUpdateAddressMsgTagId = "111" // 买家申请修改配送信息
|
||||
CallbackBusinessRemarkMsgTagId = "113" // 卖家添加备注消息的
|
||||
CallbackSendOrderTimeChangeMsgTagId = "126" // 订单发货时效变更
|
||||
)
|
||||
|
||||
// 订单状态 order_status
|
||||
const (
|
||||
CallBackCreateOrderStatus = 1 // 订单状态1:创建/卖家修改订单金额运费
|
||||
CallBackPayOrderStatus = 2 // 2支付 ,卖家发货消息的status值为"2"(部分)/收货地址变更
|
||||
CallBackWaitOrderStatus = 105 // 订单等待处理状态105
|
||||
CallBackSendAllOrderStatus = 3 // 商家全部发货(已发货)/物流消息变更
|
||||
CallBackCancelOrderStatus = 4 // 取消订单装填
|
||||
CallBackSuccessOrderStatus = 5 // 订单交易完成
|
||||
)
|
||||
|
||||
// 支付类型
|
||||
const (
|
||||
PayMethodPayOnArrival = 0 // 到付
|
||||
PayMethodWeChat = 1 // 微信支付
|
||||
PayMethodAliPay = 2 // 支付宝
|
||||
PayMethodCard = 4 // 银行卡
|
||||
PayMethodTiktok = 5 // 抖音钱包
|
||||
PayMethodNo = 7 // 无需支付
|
||||
PayMethodByStages = 8 // dou分期
|
||||
PayMethodNewCard = 9 // 新卡支付
|
||||
PayMethodUsePay = 12 // 先用后付
|
||||
PayMethodCombinationPay = 13 // 组合支付
|
||||
)
|
||||
|
||||
// OrderComeLuBan 订单业务类型,表示买家从哪里看到的这个商品、产生了订单
|
||||
const (
|
||||
OrderComeLuBan = 1 // 鲁班广告
|
||||
OrderComeLianMeng = 2 // 联盟
|
||||
OrderComeShop = 4 // 商城
|
||||
OrderComeMyselfStore = 8 // 自主经营
|
||||
OrderComePayTable = 10 // 线索通支付表单
|
||||
OrderComeTiktokStore = 12 // 抖音门店
|
||||
OrderComeTiktokBig = 14 // 抖+
|
||||
OrderComePangolin = 15 // 穿山甲
|
||||
)
|
||||
76
platformapi/tiktok_shop/tiktok_api/order_utils.go
Normal file
76
platformapi/tiktok_shop/tiktok_api/order_utils.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
//
|
||||
//func (a *API) GetCallbackMsg(request *http.Request) (msg *OrderCallback, callbackResponse *CallbackResponse) {
|
||||
// err := request.ParseForm()
|
||||
// if err == nil {
|
||||
// params := make(url.Values)
|
||||
// for k := range request.PostForm {
|
||||
// decodedValue, _ := url.QueryUnescape(request.PostFormValue(k))
|
||||
// params.Set(k, decodedValue)
|
||||
// }
|
||||
// msg = new(OrderCallback)
|
||||
// msg.Tag = GetCmd(request)
|
||||
// if callbackResponse = a.EventSignChange(request); callbackResponse != nil {
|
||||
// return nil, callbackResponse
|
||||
// }
|
||||
// if callbackResponse = a.unmarshalData([]byte(params.Get("data")), &msg.Body); callbackResponse != nil {
|
||||
// return nil, callbackResponse
|
||||
// }
|
||||
//
|
||||
// msg.Tag = params.Get("tag")
|
||||
// msg.MsgId = params.Get("msgId")
|
||||
//
|
||||
//
|
||||
// var tmpObj interface{}
|
||||
// switch msg.Tag {
|
||||
// case CmdOrderPartRefund:
|
||||
// var partRefundData CBPartRefundInfo
|
||||
// tmpObj = &partRefundData
|
||||
// case CmdOrderUserCancel:
|
||||
// var userCancelData CBUserCancelInfo
|
||||
// tmpObj = &userCancelData
|
||||
// }
|
||||
// if tmpObj != nil {
|
||||
// if utils.Map2StructByJson(msg.Body, tmpObj, true) == nil {
|
||||
// msg.Data = tmpObj
|
||||
// }
|
||||
// }
|
||||
// return msg, nil
|
||||
// }
|
||||
// return nil, a.Err2CallbackResponse("", err, nil)
|
||||
//}
|
||||
|
||||
func GetCmd(request *http.Request) (cmd string) {
|
||||
cmd, _ = url.QueryUnescape(request.FormValue("tag"))
|
||||
return cmd
|
||||
}
|
||||
|
||||
// EventSignChange 回调消息防伪标签校验
|
||||
func (a *API) EventSignChange(c *http.Request) *CallbackResponse {
|
||||
body, _ := ioutil.ReadAll(c.Body)
|
||||
signParam := a.appKey + string(body) + a.appSecret
|
||||
sign := fmt.Sprintf("%X", md5.Sum([]byte(signParam)))
|
||||
return CallbackResponseErr(sign != c.Header.Get("event-sign"))
|
||||
}
|
||||
|
||||
func (a *API) unmarshalData(data []byte, msg interface{}) (callbackResponse *CallbackResponse) {
|
||||
err := utils.UnmarshalUseNumber(data, msg)
|
||||
return CallbackResponseErr(err == nil)
|
||||
}
|
||||
|
||||
func CallbackResponseErr(param bool) (callbackResponse *CallbackResponse) {
|
||||
if param {
|
||||
return &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
return &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
@@ -2,24 +2,25 @@ package tiktok_api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
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"
|
||||
sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request"
|
||||
)
|
||||
|
||||
// GetTiktokOrderDetail 获取订单详情
|
||||
func (a *Api) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.ShopOrderDetail, error) {
|
||||
reqParam := order_orderDetail_request.New()
|
||||
reqParam.Param = &order_orderDetail_request.OrderOrderDetailParam{
|
||||
ShopOrderId: orderId,
|
||||
IsSearchable: false,
|
||||
}
|
||||
orderDetail, err := reqParam.Execute(AccessToken)
|
||||
// UpdateSkuStock
|
||||
// 1、支持修改普通库存,区域库存,阶梯库存
|
||||
// 2、支持增量更新,当incremental=true时idempotent_id字段参数必传。例:原商品库存是10个,接口传入5个,执行成功商品库存是15个。
|
||||
// 3、支持全量更新。例:原商品库存是10个,接口传入5个,执行成功商品库存是5个。
|
||||
// 4、可以设置库存为0
|
||||
// 5、超市小时达店铺类型,更新库存out_warehouse_id= store_id(门店id)表示更新门店商品库存。
|
||||
func (a *Api) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) error {
|
||||
request := sku_syncStock_request.New()
|
||||
request.Param = param
|
||||
resp, err := request.Execute(AccessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if orderDetail.Code != 1000 {
|
||||
return nil, errors.New(orderDetail.Msg)
|
||||
if resp.Code != 1000 {
|
||||
return errors.New(resp.Msg)
|
||||
}
|
||||
|
||||
return orderDetail.Data.ShopOrderDetail, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
26
platformapi/tiktok_shop/tiktok_api/sku_type.go
Normal file
26
platformapi/tiktok_shop/tiktok_api/sku_type.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package tiktok_api
|
||||
|
||||
//const (
|
||||
// OrderSourceLuBan = 1 // 鲁班
|
||||
// OrderSourceSmallShop = 2 // 小店
|
||||
// OrderSourceSmallGoodStudy = 3 // 好好学习
|
||||
// OrderSourceEv = 4 // ev
|
||||
// OrderSourceFictitious = 5 // 虚拟
|
||||
// OrderSourceStation = 6 // 建站
|
||||
// OrderSourceWriteOff = 7 // 核销
|
||||
// OrderSourceJade = 8 // 玉石
|
||||
// OrderSourceEz = 9 // Ez
|
||||
// OrderSourceEp = 10 // Ep
|
||||
// OrderSourceFictitiousCard = 11 // 虚拟卡券
|
||||
// OrderSourceServer = 12 // 服务市场
|
||||
// OrderSourceEpVideoCourse = 13 // ep视频课
|
||||
// OrderSourceEpLiveCourse = 14 // ep直播
|
||||
// OrderSourceFictitious = 5 // 虚拟
|
||||
// OrderSourceFictitious = 5 // 虚拟
|
||||
//
|
||||
//)
|
||||
|
||||
//1 -鲁班 2 -小店 3 -好好学习 4 -ev 5 -虚拟 6 -建站 7 -核销 8 -玉石 9 -ez 10 -ep 11 -虚拟卡券
|
||||
//12 -服务市场 13 - EP 视频课 14 - EP 直播课 21 -跨境BBC 22 -跨境BC 23 -跨境CC|UPU 24 -手机充值
|
||||
//25 -拍卖保证金 26 -懂车帝抵扣券 27 -懂车帝返现券 28 -离岛免税 29 -海南会员购 30 -抽奖 31 -清北-企业代付
|
||||
//32 -抖+券 33 -联盟寄样 49 -刀剑 53 -通信卡 66 -加油包 76 -大闸蟹 99 -保险 102-小店海外 108-上门取件收款
|
||||
Reference in New Issue
Block a user