抖店api
This commit is contained in:
@@ -15,15 +15,14 @@ const (
|
||||
CallbackFail = "fail"
|
||||
)
|
||||
|
||||
var AccessToken *doudian_sdk.AccessToken // 存储数据库
|
||||
|
||||
type API struct {
|
||||
appKey string
|
||||
appSecret string
|
||||
accessToken string
|
||||
refreshToken string
|
||||
expiresIn int64 // 当前时间的七天内为有效期
|
||||
locker sync.RWMutex
|
||||
appKey string
|
||||
appSecret string
|
||||
accessToken string
|
||||
refreshToken string
|
||||
expiresIn int64 // 当前时间的七天内为有效期
|
||||
locker sync.RWMutex
|
||||
accessTokenObj *doudian_sdk.AccessToken // 存储数据库
|
||||
}
|
||||
|
||||
func New(appKey, appSecret, accessToken string) *API {
|
||||
@@ -32,15 +31,17 @@ func New(appKey, appSecret, accessToken string) *API {
|
||||
if err := json.Unmarshal([]byte(accessToken), &access); err != nil {
|
||||
globals.SugarLogger.Debug("accessToken init err :", err)
|
||||
return nil
|
||||
} else {
|
||||
AccessToken = access
|
||||
}
|
||||
}
|
||||
doudian_sdk.GlobalConfig.AppKey = appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = appSecret
|
||||
return &API{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
accessToken: access.AccessToken,
|
||||
refreshToken: access.RefreshToken,
|
||||
expiresIn: access.ExpiresIn,
|
||||
accessTokenObj: access,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +74,8 @@ func (a *API) CreateToken(code string) (*doudian_sdk.CreateTokenData, error) {
|
||||
a.accessToken = access.AccessToken
|
||||
a.refreshToken = access.RefreshToken
|
||||
a.expiresIn = time.Now().Unix() + access.ExpiresIn
|
||||
AccessToken = access
|
||||
a.accessTokenObj = access
|
||||
// 不要
|
||||
strData, _ := json.Marshal(access)
|
||||
globals.SugarLogger.Debug("=========", string(strData))
|
||||
return &access.CreateTokenData, nil
|
||||
@@ -87,20 +89,28 @@ func (a *API) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
||||
refresh.GetParam().RefreshToken = a.refreshToken
|
||||
refresh.GetParam().GrantType = "refresh_token"
|
||||
|
||||
createToken, err := refresh.Execute(AccessToken)
|
||||
createToken, err := refresh.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.accessToken = createToken.Data.AccessToken
|
||||
a.refreshToken = createToken.Data.RefreshToken
|
||||
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
||||
AccessToken.CreateTokenData = createToken.Data
|
||||
a.accessTokenObj.CreateTokenData = createToken.Data
|
||||
|
||||
// 不要
|
||||
strData, _ := json.Marshal(createToken.Data)
|
||||
globals.SugarLogger.Debug("=========", string(strData))
|
||||
return &createToken.Data, nil
|
||||
}
|
||||
|
||||
func (a *API) SetToken(token string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
var access *doudian_sdk.AccessToken
|
||||
if err := json.Unmarshal([]byte(token), &access); err != nil {
|
||||
return
|
||||
}
|
||||
a.accessToken = token
|
||||
}
|
||||
|
||||
@@ -109,3 +119,22 @@ func (a *API) SetRefreshToken(token string) {
|
||||
defer a.locker.Unlock()
|
||||
a.refreshToken = token
|
||||
}
|
||||
|
||||
// GetAppId 获取appid
|
||||
func (a *API) GetAppId() string {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
return a.appKey
|
||||
}
|
||||
|
||||
func (a *API) SetAccessToken(token string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
var access *doudian_sdk.AccessToken
|
||||
if err := json.Unmarshal([]byte(token), &access); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
a.accessTokenObj = access
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
address_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/address_create/request"
|
||||
afterSale_Detail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_Detail/request"
|
||||
afterSale_rejectReasonCodeList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_rejectReasonCodeList/request"
|
||||
shop_batchCreateStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_batchCreateStore/request"
|
||||
"go.uber.org/zap"
|
||||
"testing"
|
||||
@@ -32,10 +34,18 @@ func TestCreateToken(t *testing.T) {
|
||||
fmt.Println(accessToken)
|
||||
}
|
||||
|
||||
func TestRefreshToken(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}`
|
||||
api2 := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
data, err := api2.RefreshToken()
|
||||
fmt.Println(err)
|
||||
fmt.Println(data)
|
||||
}
|
||||
|
||||
// {"access_token":"90868a42-1287-4453-ba71-34c72f22e886","expires_in":555553,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"4e8cf946-8df1-4489-be88-f96f2d4603a8","authority_id ":""}
|
||||
func TestCreateStore(t *testing.T) {
|
||||
accesstoken := `{"access_token":"90868a42-1287-4453-ba71-34c72f22e886","expires_in":555553,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"4e8cf946-8df1-4489-be88-f96f2d4603a8","authority_id ":""}`
|
||||
New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接 专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_ id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
request := address_create_request.New()
|
||||
param := request.GetParams()
|
||||
param.StoreId = 666667
|
||||
@@ -52,34 +62,64 @@ func TestCreateStore(t *testing.T) {
|
||||
storeParam.FixedPhone = "13688039650"
|
||||
storeParam.Remark = "抖音火车南站测试门店"
|
||||
param.Address = storeParam
|
||||
data, err := request.Execute(AccessToken)
|
||||
data, err := request.Execute(a.accessTokenObj)
|
||||
t.Fatal("err===========", err)
|
||||
fmt.Println("data==", fmt.Sprintf("%v", data))
|
||||
}
|
||||
|
||||
func TestCreateStoreList(t *testing.T) {
|
||||
accesstoken := `{"access_token":"90868a42-1287-4453-ba71-34c72f22e886","expires_in":555553,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"4e8cf946-8df1-4489-be88-f96f2d4603a8","authority_id ":""}`
|
||||
New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接 专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_ id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
request := shop_batchCreateStore_request.New()
|
||||
//param := request.GetParams()
|
||||
|
||||
//storeList := make([]*shop_batchCreateStore_request.ShopBatchCreateStoreParam, 0)
|
||||
list := &shop_batchCreateStore_request.StoreList{
|
||||
RowID: 1,
|
||||
Name: "京西菜市小时达测试店铺",
|
||||
StoreCode: "666667",
|
||||
Longitude: "104.065132",
|
||||
Latitude: "30.610506",
|
||||
Name: "黄田市场店测试",
|
||||
StoreCode: "667510",
|
||||
Longitude: "113.846355",
|
||||
Latitude: "22.62557",
|
||||
Province: "510000",
|
||||
City: "510100",
|
||||
District: "510107",
|
||||
Address: "武侯区火车南站综合市场蔬菜区27-28号",
|
||||
Address: "深圳西乡黄田市场大夫天路北三巷八号",
|
||||
Contact: "18981810340",
|
||||
OpenTime: shop_batchCreateStore_request.OpenTime{DayMap: map[string]string{"1": "07:00-19:00"}},
|
||||
}
|
||||
request.Param.StoreList = append(request.Param.StoreList, list)
|
||||
resp, err := request.Execute(AccessToken)
|
||||
resp, err := request.Execute(a.accessTokenObj)
|
||||
t.Fatal("err===========", err)
|
||||
t.Fatalf("resp===========:%v", resp)
|
||||
|
||||
}
|
||||
|
||||
func TestNamGetRejectReasonCodeList(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接 专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_ id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
request := afterSale_rejectReasonCodeList_request.New()
|
||||
date, _ := request.Execute(a.accessTokenObj)
|
||||
for _, v := range date.Data.Items {
|
||||
fmt.Println(v.RejectReasonCode)
|
||||
fmt.Println(v.Reason)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSturctToMap(t *testing.T) {
|
||||
aa := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接 专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_ id":""}`
|
||||
fmt.Println(len(aa))
|
||||
}
|
||||
|
||||
func TestGetOrder(t *testing.T) {
|
||||
accesstoken := `{"access_token":"90868a42-1287-4453-ba71-34c72f22e886","expires_in":30536,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"4e8cf946-8df1-4489-be88-f96f2d4603a8","authority_id ":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
|
||||
request := afterSale_Detail_request.New()
|
||||
param := request.GetParams()
|
||||
param.AfterSaleId = "4981791596669925176"
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
|
||||
fmt.Println("err", err)
|
||||
fmt.Println("result===", result)
|
||||
}
|
||||
|
||||
@@ -4,11 +4,24 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"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"
|
||||
afterSale_Detail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_Detail/request"
|
||||
afterSale_Detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_Detail/response"
|
||||
afterSale_buyerExchangeConfirm_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_buyerExchangeConfirm/request"
|
||||
afterSale_operate_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_operate/request"
|
||||
afterSale_rejectReasonCodeList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/afterSale_rejectReasonCodeList/request"
|
||||
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_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"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GetTiktokOrderDetail 获取订单详情
|
||||
@@ -18,19 +31,300 @@ func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.
|
||||
ShopOrderId: orderId,
|
||||
IsSearchable: false,
|
||||
}
|
||||
orderDetail, err := reqParam.Execute(AccessToken)
|
||||
orderDetail, err := reqParam.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if orderDetail.Code != 1000 {
|
||||
if orderDetail.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetail.Msg)
|
||||
}
|
||||
|
||||
return orderDetail.Data.ShopOrderDetail, nil
|
||||
}
|
||||
|
||||
// QueryAfsOrderDetail 查询售后订单详情 needOperationRecord (是否需要协商记录默认不需要)
|
||||
// https://op.jinritemai.com/docs/api-docs/17/1095 返回值说明
|
||||
func (a *API) QueryAfsOrderDetail(afterSaleId string, needOperationRecord bool) (*afterSale_Detail_response.AfterSaleDetailResponse, error) {
|
||||
request := afterSale_Detail_request.New()
|
||||
param := request.GetParams()
|
||||
param.IsSearchable = needOperationRecord
|
||||
param.AfterSaleId = afterSaleId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ApplyMarketAfterSale 拣货时商户发现订单缺货或者缺重
|
||||
func (a *API) ApplyMarketAfterSale(skuOrderId int64, afterSaleReason int32) (afterSaleId string, err error) {
|
||||
request := afterSale_applyMarketAfterSale_request.New()
|
||||
param := request.GetParams()
|
||||
param.SkuOrderId = skuOrderId
|
||||
param.AfterSaleReason = 2 // 目前固定值为2缺货
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return "", errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data.AfterSaleId, nil
|
||||
}
|
||||
|
||||
// AfterSaleOperate 售后审核接口聚合版
|
||||
// 售后审核接口聚合版
|
||||
// 售后统一操作接口,此接口可以提供所有售后操作类型。通过此接口操作时,需要通过type字段说明本次期望的操作(详情可见下表)。
|
||||
// 此接口每次最多支持对20个售后单进行操作。但任意一个售后单操作失败,接口遍会整体报错,因此推荐使用此接口每次操作一个售后单,从而获得更加明确的报错信息。
|
||||
// type说明:
|
||||
// 值 前置条件-售后类型 前置条件-售后状态 说明 必须参数
|
||||
// 101 0 6,27 同意退货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
// 102 0 6 拒绝退货申请(一次审核) reason , evidence
|
||||
// 111 0 7,11,29 同意退货(二次审核)
|
||||
// 112 0 11 拒绝退货 (二次审核) reason , evidence
|
||||
// 121 0 6,27 退货转退款
|
||||
// 201 1 6,27 同意仅退款
|
||||
// 202 1 6 拒绝仅退款 reason , evidence
|
||||
// 203 1 6 同意拒签后退款
|
||||
// 301 3 6,27 同意换货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
// 302 3 6 拒绝换货申请(一次审核) reason,evidence
|
||||
// 311 3 7,11,29 同意换货(二次审核) logistics.companyCode,logistics.logisticsCode
|
||||
// 312 3 11 拒绝换货(二次审核) reason,evidence
|
||||
// 321 3 6,7,11,29 换货转退款
|
||||
// 401 2 6 同意售前退申请(拒绝售前退款请使用发货接口)
|
||||
// 501 7 6,27 同意补寄
|
||||
// 502 7 6 拒绝补寄
|
||||
func (a *API) AfterSaleOperate(refundType int32, refundId, remark string, storeId int64) error {
|
||||
request := afterSale_operate_request.New()
|
||||
param := request.GetParams()
|
||||
param.Type = refundType
|
||||
|
||||
refundListParam := make([]afterSale_operate_request.ItemsItem, 0, 0)
|
||||
switch refundType {
|
||||
// 101同意退货申请(一次审核) 301 同意换货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
case AfterSaleEmuAgreeToReturnOneApply, AfterSaleEmuAgreeChangeGoodsOneApply: // 101 // 同意退货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
var paramList = afterSale_operate_request.ItemsItem{}
|
||||
addressId, err := a.GetRefundAddressId(storeId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
paramList.AftersaleId = refundId
|
||||
paramList.Logistics.ReceiverAddressId = addressId
|
||||
refundListParam = append(refundListParam, paramList)
|
||||
// 102拒绝退货申请(一次审核) 112拒绝退货 202拒绝仅退款 reason , evidence 302拒绝换货申请(一次审核) 312换货转退款
|
||||
case AfterSaleEmuRefuseToReturnOneApply, AfterSaleEmuRefuseToReturnTwoApply, AfterSaleEmuRefuseOnlyRefundApply, AfterSaleEmuRefundChangeGoodsOneApply, AfterSaleEmuRefundChangeGoodsTwoApply:
|
||||
reasonItem, err := a.QueryAllReason(utils.Str2Int64(refundId))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
evidence := afterSale_operate_request.EvidenceItem{}
|
||||
evidenceList := make([]afterSale_operate_request.EvidenceItem, 0, 1)
|
||||
if reasonItem[0].EvidenceNeed == "Y" {
|
||||
evidence = afterSale_operate_request.EvidenceItem{
|
||||
Type: 4,
|
||||
Url: "",
|
||||
Desc: "拒绝退货/拒绝仅退款/拒绝换货申请,请电话联系商家",
|
||||
}
|
||||
evidenceList = append(evidenceList, evidence)
|
||||
}
|
||||
var paramList = afterSale_operate_request.ItemsItem{}
|
||||
paramList.AftersaleId = refundId
|
||||
paramList.Evidence = evidenceList
|
||||
paramList.RejectReasonCode = reasonItem[0].RejectReasonCode
|
||||
paramList.Reason = reasonItem[0].Reason
|
||||
paramList.Remark = remark
|
||||
// 111同意退货(二次审核) 121退货转退款 201同意仅退款 203同意拒签后退款 321换货转退款 401同意售前退申请 501同意补寄 502 拒绝补寄
|
||||
case AfterSaleEmuAgreeToReturnTwoApply, AfterSaleEmuReturnGoodsToRefundApply, AfterSaleEmuAgreeOnlyRefundApply, AfterSaleEmuRefundAfterRefusalApply, AfterSaleEmuChangeGoodsToRefundApply, AfterSaleEmuAgreePreSaleReturnApply, AfterSaleEmuAgreeReissueApply, AfterSaleEmuRefundReissueApply:
|
||||
var paramList = afterSale_operate_request.ItemsItem{}
|
||||
paramList.AftersaleId = refundId
|
||||
refundListParam = append(refundListParam, paramList)
|
||||
case AfterSaleEmuAgreeChangeGoodsTwoApply: // 311 // 同意换货(二次审核) logistics.companyCode,logistics.logisticsCode
|
||||
// 不好处理,暂时不处理
|
||||
return nil
|
||||
}
|
||||
param.Items = refundListParam
|
||||
// 同意退货
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRefundAddressId 获取抖店售后地址列表
|
||||
func (a *API) GetRefundAddressId(storeID int64) (int64, error) {
|
||||
request := address_list_request.New()
|
||||
param := request.GetParams()
|
||||
param.PageSize = 10
|
||||
param.PageNo = 1
|
||||
param.OrderField = "create_time"
|
||||
param.OrderBy = "desc"
|
||||
param.StoreId = storeID
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
}
|
||||
if len(result.Data.AddressList) < 1 {
|
||||
return 0, errors.New("门店详细地址获取错误")
|
||||
}
|
||||
return result.Data.AddressList[0].AddressId, nil
|
||||
}
|
||||
|
||||
// QueryAllReason 查询所有的售后审核处理原因详情
|
||||
func (a *API) QueryAllReason(afterSaleId int64) ([]afterSale_rejectReasonCodeList_response.ItemsItem, error) {
|
||||
request := afterSale_rejectReasonCodeList_request.New()
|
||||
param := request.GetParams()
|
||||
if afterSaleId > 0 {
|
||||
param.AfterSaleId = afterSaleId
|
||||
}
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data.Items, nil
|
||||
}
|
||||
|
||||
// GetStoreOrderList 获取门店订单列表
|
||||
func (a *API) GetStoreOrderList(queryData time.Time, storeId int64) ([]string, error) {
|
||||
request := order_searchList_request.New()
|
||||
param := request.GetParams()
|
||||
|
||||
createTime := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 0, 0, 0, 0, queryData.Location())
|
||||
endTime := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 23, 59, 59, 59, queryData.Location())
|
||||
param.CreateTimeStart = createTime.Unix()
|
||||
param.CreateTimeEnd = endTime.Unix()
|
||||
param.Page = 0
|
||||
param.Size = 100
|
||||
|
||||
orderDetailList, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if orderDetailList.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetailList.Msg)
|
||||
}
|
||||
|
||||
orderList := make([]string, 0, 0)
|
||||
for _, v := range orderDetailList.Data.ShopOrderList {
|
||||
if v.ShopId == storeId {
|
||||
orderList = append(orderList, v.OrderId)
|
||||
}
|
||||
}
|
||||
if orderDetailList.Data.Total < 100 {
|
||||
return orderList, nil
|
||||
}
|
||||
|
||||
totalPage := 0
|
||||
if orderDetailList.Data.Total%100 != 0 {
|
||||
totalPage = int(math.Floor(utils.Int64ToFloat64(orderDetailList.Data.Total)/utils.Int64ToFloat64(100)) + 1)
|
||||
} else {
|
||||
totalPage = int(math.Floor(utils.Int64ToFloat64(orderDetailList.Data.Total) / utils.Int64ToFloat64(100)))
|
||||
}
|
||||
|
||||
for i := 1; i < totalPage; i++ {
|
||||
createTime := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 0, 0, 0, 0, queryData.Location())
|
||||
endTime := time.Date(queryData.Year(), queryData.Month(), queryData.Day(), 23, 59, 59, 59, queryData.Location())
|
||||
param.CreateTimeStart = createTime.Unix()
|
||||
param.CreateTimeEnd = endTime.Unix()
|
||||
param.Page = int64(i)
|
||||
param.Size = 100
|
||||
|
||||
orderDetailList, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if orderDetailList.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetailList.Msg)
|
||||
}
|
||||
for _, v := range orderDetailList.Data.ShopOrderList {
|
||||
if v.ShopId == storeId {
|
||||
orderList = append(orderList, v.OrderId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return orderList, nil
|
||||
}
|
||||
|
||||
// ReturnGoodsToWareHouseSuccess
|
||||
//商家确认售后单对应的用户退货入仓成功
|
||||
//商家在抖店后台售后小助手配置退货入仓自动退策略;
|
||||
//当用户发起退货退款申请,商家同意且退货商品返回到商家仓内,由商家确认质检无误后入仓;
|
||||
//命中策略后该售后单自动执行退款操作。
|
||||
func (a *API) ReturnGoodsToWareHouseSuccess(afsOrderId string) error {
|
||||
request := afterSale_returnGoodsToWareHouseSuccess_request.New()
|
||||
param := request.GetParams()
|
||||
param.AftersaleId = afsOrderId
|
||||
param.OpTime = time.Now().Unix()
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConfirmReceivedReturnGoods 用户填写换货物流后,商家处理,确认是否收到换货,收货之后退款
|
||||
func (a *API) ConfirmReceivedReturnGoods(afsOrderId int64, agree bool) {
|
||||
request := afterSale_buyerExchangeConfirm_request.New()
|
||||
param := request.GetParams()
|
||||
param.AfterSaleId = afsOrderId
|
||||
param.IsReject = agree
|
||||
if !agree {
|
||||
param.Action = "refund_agree" // 同意换货转退款
|
||||
param.LogisticsCode = ""
|
||||
param.CompanyCode = ""
|
||||
} else {
|
||||
param.Comment = "11"
|
||||
}
|
||||
}
|
||||
|
||||
// CancelSendGoodsSuccess 商家在未发货仅退款途中发送取消发货状态
|
||||
func (a *API) CancelSendGoodsSuccess() {}
|
||||
|
||||
// LogisticsAdd 订单发货接口
|
||||
// 暂时只支持整单出库,即接口调用时入参只能传父订单号。
|
||||
// Tips:部分发货状态下的父订单,调此接口发货,会报错:该订单当前为“部分发货”状态,无法调用此接口
|
||||
// orderId主订单id,companyCode 物流公司code,isRefundReject 是否拒绝退款申请(true表示拒绝退款,并继续发货),addressId发货地址id
|
||||
func (a *API) LogisticsAdd(orderId string, companyCode string, isRefundReject bool, addressId int64) error {
|
||||
request := order_logisticsAdd_request.New()
|
||||
request.Param = &order_logisticsAdd_request.OrderLogisticsAddParam{
|
||||
OrderId: orderId,
|
||||
CompanyCode: companyCode,
|
||||
IsRefundReject: isRefundReject,
|
||||
AddressId: addressId,
|
||||
}
|
||||
data, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if data.Code != RequestSuccessCode {
|
||||
return errors.New(data.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/***********************************************/
|
||||
// CreateOrderCallback 订单创建,抖店创建订单后,回调消息通知本服务器
|
||||
func (a *API) CreateOrderCallback(request *http.Request) ([]*OrderCallback, *CallbackResponse) {
|
||||
func (a *API) CreateOrderCallback(request *http.Request) (map[string][]interface{}, *CallbackResponse) {
|
||||
orderStatus, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
return nil, &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
@@ -42,133 +336,343 @@ func (a *API) CreateOrderCallback(request *http.Request) ([]*OrderCallback, *Cal
|
||||
return nil, &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
|
||||
callbackResult := make(map[string][]interface{}, 0)
|
||||
for _, data := range resp {
|
||||
switch data.Tag {
|
||||
case CallbackCreatedOrderMsgTagId: // 创建订单
|
||||
create := CreateOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackCreatedOrderMsgTagId] = append(data.Body[CallbackCreatedOrderMsgTagId], create)
|
||||
//create := CreateOrderData{}
|
||||
//if err := json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackCreatedOrderMsgTagId] = append(callbackResult[CallbackCreatedOrderMsgTagId], create)
|
||||
callbackResult[CallbackCreatedOrderMsgTagId] = append(callbackResult[CallbackCreatedOrderMsgTagId], data.Data)
|
||||
case CallbackPayOrderMsgTagId: // 支付订单
|
||||
create := PayOrderData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackPayOrderMsgTagId] = append(data.Body[CallbackPayOrderMsgTagId], create)
|
||||
//create := PayOrderData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackPayOrderMsgTagId] = append(callbackResult[CallbackPayOrderMsgTagId], create)
|
||||
callbackResult[CallbackPayOrderMsgTagId] = append(callbackResult[CallbackPayOrderMsgTagId], data.Data)
|
||||
case CallbackWaitOrderMsgTagId: // 支付订单待处理(风控审核)
|
||||
create := WaitOrderData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackWaitOrderMsgTagId] = append(data.Body[CallbackWaitOrderMsgTagId], create)
|
||||
//create := WaitOrderData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackWaitOrderMsgTagId] = append(callbackResult[CallbackWaitOrderMsgTagId], create)
|
||||
callbackResult[CallbackWaitOrderMsgTagId] = append(callbackResult[CallbackWaitOrderMsgTagId], data.Data)
|
||||
case CallbackPartGoodsMsgTagId: // 卖家部分发货
|
||||
create := SomeSendOrderData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackPartGoodsMsgTagId] = append(data.Body[CallbackPartGoodsMsgTagId], create)
|
||||
//create := SomeSendOrderData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackPartGoodsMsgTagId] = append(callbackResult[CallbackPartGoodsMsgTagId], create)
|
||||
callbackResult[CallbackPartGoodsMsgTagId] = append(callbackResult[CallbackPartGoodsMsgTagId], data.Data)
|
||||
case CallbackPartAllGoodsMsgTagId: // 卖家发货
|
||||
create := BusinessDeliveryData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackPartAllGoodsMsgTagId] = append(data.Body[CallbackPartAllGoodsMsgTagId], create)
|
||||
//create := BusinessDeliveryData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackPartAllGoodsMsgTagId] = append(callbackResult[CallbackPartAllGoodsMsgTagId], create)
|
||||
callbackResult[CallbackPartAllGoodsMsgTagId] = append(callbackResult[CallbackPartAllGoodsMsgTagId], data.Data)
|
||||
case CallbackCancelOrderMsgTagId: // 取消订单
|
||||
create := CancelOrderData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackCancelOrderMsgTagId] = append(data.Body[CallbackCancelOrderMsgTagId], create)
|
||||
//create := CancelOrderData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackCancelOrderMsgTagId] = append(callbackResult[CallbackCancelOrderMsgTagId], create)
|
||||
callbackResult[CallbackCancelOrderMsgTagId] = append(callbackResult[CallbackCancelOrderMsgTagId], data.Data)
|
||||
case CallbackSuccessOrderMsgTagId: // 卖家确认收货时,会自动完成
|
||||
create := SuccessOrderData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackSuccessOrderMsgTagId] = append(data.Body[CallbackSuccessOrderMsgTagId], create)
|
||||
//create := SuccessOrderData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackSuccessOrderMsgTagId] = append(callbackResult[CallbackSuccessOrderMsgTagId], create)
|
||||
callbackResult[CallbackSuccessOrderMsgTagId] = append(callbackResult[CallbackSuccessOrderMsgTagId], data.Data)
|
||||
case CallbackWayBillChangeOrderMsgTagId: // 发货物流消息便跟
|
||||
create := WayBillChangeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackWayBillChangeOrderMsgTagId] = append(data.Body[CallbackWayBillChangeOrderMsgTagId], create)
|
||||
//create := WayBillChangeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackWayBillChangeOrderMsgTagId] = append(callbackResult[CallbackWayBillChangeOrderMsgTagId], create)
|
||||
callbackResult[CallbackWayBillChangeOrderMsgTagId] = append(callbackResult[CallbackWayBillChangeOrderMsgTagId], data.Data)
|
||||
case CallbackReceivingChangeOrderMsgTagId: // 收货地址消息变更(商家审核通过触发)
|
||||
create := ReceivingAddressChangeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackReceivingChangeOrderMsgTagId] = append(data.Body[CallbackReceivingChangeOrderMsgTagId], create)
|
||||
//create := ReceivingAddressChangeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackReceivingChangeOrderMsgTagId] = append(callbackResult[CallbackReceivingChangeOrderMsgTagId], create)
|
||||
callbackResult[CallbackReceivingChangeOrderMsgTagId] = append(callbackResult[CallbackReceivingChangeOrderMsgTagId], data.Data)
|
||||
case CallbackChangeMoneyMsgTagId: // 卖家修改订单/运单金额回调
|
||||
create := UpdateAmountChangeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackChangeMoneyMsgTagId] = append(data.Body[CallbackChangeMoneyMsgTagId], create)
|
||||
//create := UpdateAmountChangeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackChangeMoneyMsgTagId] = append(callbackResult[CallbackChangeMoneyMsgTagId], create)
|
||||
callbackResult[CallbackChangeMoneyMsgTagId] = append(callbackResult[CallbackChangeMoneyMsgTagId], data.Data)
|
||||
case CallbackBusinessRemarkMsgTagId: // 买家收货消息变更(手机,地址,姓名),用户C端修改触发(需要上面审核接口)
|
||||
create := BuyerUpdateWayBillData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackBusinessRemarkMsgTagId] = append(data.Body[CallbackBusinessRemarkMsgTagId], create)
|
||||
//create := BuyerUpdateWayBillData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackBusinessRemarkMsgTagId] = append(callbackResult[CallbackBusinessRemarkMsgTagId], create)
|
||||
callbackResult[CallbackBusinessRemarkMsgTagId] = append(callbackResult[CallbackBusinessRemarkMsgTagId], data.Data)
|
||||
case CallbackApplyUpdateAddressMsgTagId: // 商家修改交易备注回调
|
||||
create := BusinessUpdateRemakeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackApplyUpdateAddressMsgTagId] = append(data.Body[CallbackApplyUpdateAddressMsgTagId], create)
|
||||
//create := BusinessUpdateRemakeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackApplyUpdateAddressMsgTagId] = append(callbackResult[CallbackApplyUpdateAddressMsgTagId], create)
|
||||
callbackResult[CallbackApplyUpdateAddressMsgTagId] = append(callbackResult[CallbackApplyUpdateAddressMsgTagId], data.Data)
|
||||
case CallbackSendOrderTimeChangeMsgTagId: // 订单发货时消息变更回调
|
||||
create := AppointmentChangeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackSendOrderTimeChangeMsgTagId] = append(data.Body[CallbackSendOrderTimeChangeMsgTagId], create)
|
||||
//create := AppointmentChangeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
callbackResult[CallbackSendOrderTimeChangeMsgTagId] = append(callbackResult[CallbackSendOrderTimeChangeMsgTagId], data.Data)
|
||||
/*********下面属于订单退货消息************/
|
||||
case CallbackRefundOrderMsgTagId: // 买家发起售后申请消息
|
||||
create := BuyerRefundCreatedData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackRefundOrderMsgTagId] = append(data.Body[CallbackRefundOrderMsgTagId], create)
|
||||
//create := BuyerRefundCreatedData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackRefundOrderMsgTagId] = append(callbackResult[CallbackRefundOrderMsgTagId], create)
|
||||
callbackResult[CallbackRefundOrderMsgTagId] = append(callbackResult[CallbackRefundOrderMsgTagId], data.Data)
|
||||
case CallbackUpdateRefundOrderMsgTagId: // 买家修改售后申请消息
|
||||
create := BuyerRefundModifiedData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackUpdateRefundOrderMsgTagId] = append(data.Body[CallbackUpdateRefundOrderMsgTagId], create)
|
||||
//create := BuyerRefundModifiedData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackUpdateRefundOrderMsgTagId] = append(callbackResult[CallbackUpdateRefundOrderMsgTagId], create)
|
||||
callbackResult[CallbackUpdateRefundOrderMsgTagId] = append(callbackResult[CallbackUpdateRefundOrderMsgTagId], data.Data)
|
||||
case CallbackRefundOrderSuccessMsgTagId: // 退款成功消息
|
||||
create := BusinessRefundSuccessData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackRefundOrderSuccessMsgTagId] = append(data.Body[CallbackRefundOrderSuccessMsgTagId], create)
|
||||
//create := BusinessRefundSuccessData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackRefundOrderSuccessMsgTagId] = append(callbackResult[CallbackRefundOrderSuccessMsgTagId], create)
|
||||
callbackResult[CallbackRefundOrderSuccessMsgTagId] = append(callbackResult[CallbackRefundOrderSuccessMsgTagId], data.Data)
|
||||
case CallbackRefundOrderRefuseMsgTagId: // 拒绝退款消息
|
||||
create := BusinessNotRefundRefusedData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackRefundOrderRefuseMsgTagId] = append(data.Body[CallbackRefundOrderRefuseMsgTagId], create)
|
||||
//create := BusinessNotRefundRefusedData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackRefundOrderRefuseMsgTagId] = append(callbackResult[CallbackRefundOrderRefuseMsgTagId], create)
|
||||
callbackResult[CallbackRefundOrderRefuseMsgTagId] = append(callbackResult[CallbackRefundOrderRefuseMsgTagId], data.Data)
|
||||
case CallbackRefundShopMsgTagId: // 拒绝退货申请消息
|
||||
create := BusinessNotReturnApplyRefusedData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackRefundShopMsgTagId] = append(data.Body[CallbackRefundShopMsgTagId], create)
|
||||
//create := BusinessNotReturnApplyRefusedData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackRefundShopMsgTagId] = append(callbackResult[CallbackRefundShopMsgTagId], create)
|
||||
callbackResult[CallbackRefundShopMsgTagId] = append(callbackResult[CallbackRefundShopMsgTagId], data.Data)
|
||||
case CallbackReturnApplyAgreedMsgTagId: // 卖家同意时,推送此消息
|
||||
create := BusinessReturnApplyAgreedData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackReturnApplyAgreedMsgTagId] = append(data.Body[CallbackReturnApplyAgreedMsgTagId], create)
|
||||
//create := BusinessReturnApplyAgreedData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
callbackResult[CallbackReturnApplyAgreedMsgTagId] = append(callbackResult[CallbackReturnApplyAgreedMsgTagId], data.Data)
|
||||
case CallbackReturnRefundAgreedMsgTagId: // 同意退款消息
|
||||
create := AppointmentChangeData{}
|
||||
if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
if utils.IsNil(data.Data) {
|
||||
continue
|
||||
}
|
||||
data.Body[CallbackReturnRefundAgreedMsgTagId] = append(data.Body[CallbackReturnRefundAgreedMsgTagId], create)
|
||||
//create := AppointmentChangeData{}
|
||||
//if err = json.Unmarshal([]byte(utils.Interface2String(data.Data)), create); err != nil {
|
||||
// return nil, CallbackResponseErr(false)
|
||||
//}
|
||||
//callbackResult[CallbackReturnRefundAgreedMsgTagId] = append(callbackResult[CallbackReturnRefundAgreedMsgTagId], create)
|
||||
callbackResult[CallbackReturnRefundAgreedMsgTagId] = append(callbackResult[CallbackReturnRefundAgreedMsgTagId], data.Data)
|
||||
default:
|
||||
return nil, CallbackResponseErr(false)
|
||||
}
|
||||
}
|
||||
|
||||
return resp, &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
return callbackResult, &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
|
||||
// GetCallbackOrderId 获取回调函数订单id
|
||||
func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, *CallbackResponse) {
|
||||
switch msgId {
|
||||
case CallbackCreatedOrderMsgTagId: // 创建订单
|
||||
create := CreateOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", Err2CallbackResponse(err, "")
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPayOrderMsgTagId: // 支付订单
|
||||
create := PayOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackWaitOrderMsgTagId: // 支付订单待处理(风控审核)
|
||||
create := WaitOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPartGoodsMsgTagId: // 卖家部分发货
|
||||
create := SomeSendOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackPartAllGoodsMsgTagId: // 卖家发货
|
||||
create := BusinessDeliveryData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackCancelOrderMsgTagId: // 取消订单
|
||||
create := CancelOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackSuccessOrderMsgTagId: // 卖家确认收货时,会自动完成
|
||||
create := SuccessOrderData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackWayBillChangeOrderMsgTagId: // 发货物流消息便跟
|
||||
create := WayBillChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReceivingChangeOrderMsgTagId: // 收货地址消息变更(商家审核通过触发)
|
||||
create := ReceivingAddressChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackChangeMoneyMsgTagId: // 卖家修改订单/运单金额回调
|
||||
create := UpdateAmountChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackBusinessRemarkMsgTagId: // 买家收货消息变更(手机,地址,姓名),用户C端修改触发(需要上面审核接口)
|
||||
create := BuyerUpdateWayBillData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackApplyUpdateAddressMsgTagId: // 商家修改交易备注回调
|
||||
create := BusinessUpdateRemakeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackSendOrderTimeChangeMsgTagId: // 订单发货时消息变更回调
|
||||
create := AppointmentChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return create.PId, Err2CallbackResponse(nil, "")
|
||||
/*********下面属于订单退货消息************/
|
||||
case CallbackRefundOrderMsgTagId: // 买家发起售后申请消息
|
||||
create := BuyerRefundCreatedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackUpdateRefundOrderMsgTagId: // 买家修改售后申请消息
|
||||
create := BuyerRefundModifiedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundOrderSuccessMsgTagId: // 退款成功消息
|
||||
create := BusinessRefundSuccessData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundOrderRefuseMsgTagId: // 拒绝退款消息
|
||||
create := BusinessNotRefundRefusedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundShopMsgTagId: // 拒绝退货申请消息
|
||||
create := BusinessNotReturnApplyRefusedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReturnApplyAgreedMsgTagId: // 卖家同意时,推送此消息
|
||||
create := BusinessReturnApplyAgreedData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReturnRefundAgreedMsgTagId: // 同意退款消息
|
||||
create := AppointmentChangeData{}
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), create); err != nil {
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
return create.PId, Err2CallbackResponse(nil, "")
|
||||
default:
|
||||
return "", CallbackResponseErr(false)
|
||||
}
|
||||
|
||||
return "", &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package tiktok_api
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CallbackResponse struct {
|
||||
Code int `json:"code"`
|
||||
@@ -14,10 +17,10 @@ type PublicOrderCallback struct {
|
||||
}
|
||||
|
||||
type OrderCallback struct {
|
||||
Tag string `json:"tag"` // 消息种类,订单创建消息的tag值为"100"
|
||||
MsgId string `json:"msgId"` //消息记录id
|
||||
Data interface{} `json:"data"` // 消息正文
|
||||
Body map[string][]interface{} `json:"body"`
|
||||
Tag string `json:"tag"` // 消息种类,订单创建消息的tag值为"100"
|
||||
MsgId string `json:"msgId"` //消息记录id
|
||||
Data interface{} `json:"data"` // 消息正文
|
||||
FormData url.Values
|
||||
}
|
||||
|
||||
//#region 创建订单消息通知
|
||||
@@ -29,13 +32,13 @@ type CreateOrderCallback struct {
|
||||
}
|
||||
|
||||
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
|
||||
Biz int64 `json:"biz"` // 业务来源 1-鲁班.....
|
||||
CreateTime int64 `json:"create_time"` // 订单创建时间
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,订单创建消息的order_status值为"1"
|
||||
OrderType int64 `json:"order_type"` // 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单 ID
|
||||
SIds []int64 `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int64 `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -48,15 +51,15 @@ type PayOrderCallback struct {
|
||||
}
|
||||
|
||||
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
|
||||
Biz int64 `json:"biz"` // 订单业务类型
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,订单支付消息的status值为"2"
|
||||
OrderType int64 `json:"order_type"` // 订单类型: 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单ID
|
||||
PayAmount int64 `json:"pay_amount"` // 订单实付金额
|
||||
PayTime int64 `json:"pay_time"` // 1: 在线订单支付时间 2: 货到付款订单确认时间
|
||||
PayType int64 `json:"pay_type"` // 订单支付方式: 0:货到付款,1:微信,2:支付宝,4:银行卡,5:抖音零钱,7:无需支付,8:DOU分期,9:新卡支付,12:先用后付,13:组合支付
|
||||
SIds []int64 `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int64 `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -69,15 +72,15 @@ type WaitOrderCallback struct {
|
||||
}
|
||||
|
||||
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
|
||||
Biz int64 `json:"biz"` // 订单业务类型
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,订单支付消息的status值为"2"
|
||||
OrderType int64 `json:"order_type"` // 订单类型: 0: 实物 2: 普通虚拟 4: poi核销 5: 三方核销 6: 服务市场
|
||||
PId int64 `json:"p_id"` // 父订单ID
|
||||
PayAmount int64 `json:"pay_amount"` // 订单实付金额
|
||||
PayTime int64 `json:"pay_time"` // 1: 在线订单支付时间 2: 货到付款订单确认时间
|
||||
PayType int64 `json:"pay_type"` // 订单支付方式: 0:货到付款,1:微信,2:支付宝,4:银行卡,5:抖音零钱,7:无需支付,8:DOU分期,9:新卡支付,12:先用后付,13:组合支付
|
||||
SIds []int64 `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int64 `json:"shop_id"` // 店铺ID
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -89,30 +92,30 @@ type SomeSendOrderCallback struct {
|
||||
Data *SomeSendOrderData `json:"data"`
|
||||
}
|
||||
type SomeSendOrderData struct {
|
||||
Biz int `json:"biz"` // 订单业务来源类型
|
||||
Biz int64 `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"` // 发货数量
|
||||
ProductId int64 `json:"product_id"` // 商品id
|
||||
ShippedNum int64 `json:"shipped_num"` // 发货数量
|
||||
ShippedOrderId int64 `json:"shipped_order_id"` // 已发货子订单
|
||||
SkuId int `json:"sku_id"` // 对应skuid
|
||||
SkuNum int `json:"sku_num"` // 购买sku数量
|
||||
SkuId int64 `json:"sku_id"` // 对应skuid
|
||||
SkuNum int64 `json:"sku_num"` // 购买sku数量
|
||||
} `json:"shipped_order_info"`
|
||||
} `json:"logistics_msg"`
|
||||
OrderStatus int `json:"order_status"` // 父订单状态,卖家发货消息的status值为"2"
|
||||
OrderType int `json:"order_type"` // 订单类型
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,卖家发货消息的status值为"2"
|
||||
OrderType int64 `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"` // 更新时间
|
||||
SIds []int64 `json:"s_ids"` // 子订单ID列表
|
||||
ShopId int64 `json:"shop_id"` // 门店id
|
||||
UpdateTime int64 `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -125,22 +128,22 @@ type BusinessDeliveryCallback struct {
|
||||
}
|
||||
|
||||
type BusinessDeliveryData struct {
|
||||
Biz int `json:"biz"`
|
||||
Biz int64 `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"` // 订单类型
|
||||
OrderStatus int64 `json:"order_status"` //父订单状态,卖家发货消息的status值为"3"
|
||||
OrderType int64 `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"`
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
UpdateTime int64 `json:"update_time"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -153,14 +156,14 @@ type CancelOrderCallback struct {
|
||||
}
|
||||
|
||||
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"`
|
||||
Biz int64 `json:"biz"`
|
||||
CancelReason string `json:"cancel_reason"` // 取消原因
|
||||
CancelTime int64 `json:"cancel_time"` // 取消时间
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,订单取消消息的status值为"4"
|
||||
OrderType int64 `json:"order_type"` // 订单类型
|
||||
PId int64 `json:"p_id"`
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -172,13 +175,13 @@ type SuccessOrderCallback struct {
|
||||
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"`
|
||||
Biz int64 `json:"biz"`
|
||||
CompleteTime int64 `json:"complete_time"` // 交易完成时间
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态,交易完成消息的status值为"5"
|
||||
OrderType int64 `json:"order_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -187,26 +190,26 @@ type SuccessOrderData struct {
|
||||
|
||||
type WayBillChangeCallback struct {
|
||||
PublicOrderCallback
|
||||
Data *SuccessOrderData `json:"data"`
|
||||
Data *WayBillChangeData `json:"data"`
|
||||
}
|
||||
|
||||
type WayBillChangeData struct {
|
||||
Biz int `json:"biz"`
|
||||
Biz int64 `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"` // 订单类型
|
||||
OrderStatus int64 `json:"order_status"` // 父订单状态-3变更物流
|
||||
OrderType int64 `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"` // 更新时间
|
||||
SIds []int64 `json:"s_ids"` // 子id
|
||||
ShopId int64 `json:"shop_id"` // 门店id
|
||||
UpdateTime int64 `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -219,17 +222,17 @@ type ReceivingAddressChangeCallback struct {
|
||||
}
|
||||
|
||||
type ReceivingAddressChangeData struct {
|
||||
OrderStatus int `json:"order_status"` // 收货地址变更状态为2
|
||||
OrderType int `json:"order_type"`
|
||||
OrderStatus int64 `json:"order_status"` // 收货地址变更状态为2
|
||||
OrderType int64 `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"`
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
UpdateTime int64 `json:"update_time"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -242,15 +245,15 @@ type UpdateAmountChangeCallback struct {
|
||||
}
|
||||
|
||||
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"` // 主订单金额不含邮费
|
||||
Biz int64 `json:"biz"`
|
||||
ModifyTime int64 `json:"modify_time"` // 订单修改时间
|
||||
OrderStatus int64 `json:"order_status"` // 订单状态 1
|
||||
OrderType int64 `json:"order_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
PostAmount int64 `json:"post_amount"` // 邮费
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
TotalAmount int64 `json:"total_amount"` // 主订单金额不含邮费
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -263,7 +266,7 @@ type BuyerUpdateWayBillCallback struct {
|
||||
}
|
||||
|
||||
type BuyerUpdateWayBillData struct {
|
||||
ApplyTime int `json:"apply_time"` // 申请时间
|
||||
ApplyTime int64 `json:"apply_time"` // 申请时间
|
||||
PId int64 `json:"p_id"`
|
||||
PostReceiverMsg struct {
|
||||
Addr string `json:"addr"`
|
||||
@@ -275,7 +278,7 @@ type BuyerUpdateWayBillData struct {
|
||||
Name string `json:"name"`
|
||||
Tel string `json:"tel"`
|
||||
} `json:"receiver_msg"` // 变更后地址信息
|
||||
ShopId int `json:"shop_id"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -289,9 +292,9 @@ type BusinessUpdateRemakeCallback struct {
|
||||
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"` // 修改时间
|
||||
ShopId int64 `json:"shop_id"` // 门店id
|
||||
Star int64 `json:"star"` // 标星等级,范围0~5,0为灰色旗标,5为红色旗标,数字越大颜色越深 0灰 1紫 2青 3绿 4橙 5红
|
||||
UpdateTime int64 `json:"update_time"` // 修改时间
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@@ -304,11 +307,22 @@ type AppointmentChangeCallback struct {
|
||||
}
|
||||
|
||||
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"`
|
||||
ExpDeliveryTime int64 `json:"exp_delivery_time"` // 变更后预期发货时间
|
||||
OrderType int64 `json:"order_type"`
|
||||
PId string `json:"p_id"`
|
||||
SIds []int64 `json:"s_ids"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 假的拣货完成
|
||||
type FakePickUpGoodsCallback struct {
|
||||
PublicOrderCallback
|
||||
}
|
||||
type FakePickUpGoodsData struct {
|
||||
PId string `json:"p_id"`
|
||||
VendorStatus string `json:"vendor_status"`
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package tiktok_api
|
||||
|
||||
const RequestSuccessCode = 10000
|
||||
|
||||
// 订单消息回调类型(正向订单)
|
||||
const (
|
||||
CallbackCreatedOrderMsgTagId = "100" // 创建订单回调
|
||||
CallbackPayOrderMsgTagId = "101" // 支付订单回调
|
||||
CallbackWaitOrderMsgTagId = "110" // 支付订待处理
|
||||
CallbackPartGoodsMsgTagId = "108" // 部分发货回调
|
||||
CallbackPartAllGoodsMsgTagId = "102" // 商品发货完成回调
|
||||
CallbackCreatedOrderMsgTagId = "100" // 创建订单回调 ok
|
||||
CallbackPayOrderMsgTagId = "101" // 支付订单回调 ok
|
||||
CallbackWaitOrderMsgTagId = "110" // 支付订待处理 ok
|
||||
CallbackPartGoodsMsgTagId = "108" // 部分发货回调 ok
|
||||
CallbackPartAllGoodsMsgTagId = "102" // 商品发货完成回调 ok
|
||||
CallbackCancelOrderMsgTagId = "106" // 取消订单回调
|
||||
CallbackSuccessOrderMsgTagId = "103" // 确认收货订单回调
|
||||
CallbackWayBillChangeOrderMsgTagId = "104" // 物流消息变更
|
||||
@@ -17,16 +19,46 @@ const (
|
||||
CallbackSendOrderTimeChangeMsgTagId = "126" // 订单发货时效变更
|
||||
)
|
||||
|
||||
// 订单状态 order_status
|
||||
// 订单状态 order_status(回调消息状态)
|
||||
const (
|
||||
CallBackCreateOrderStatus = 1 // 订单状态1:创建/卖家修改订单金额运费
|
||||
CallBackPayOrderStatus = 2 // 2支付 ,卖家发货消息的status值为"2"(部分)/收货地址变更
|
||||
CallBackPayOrderStatus = 2 // 2支付/卖家发货消息的status值为"2"(部分)/收货地址变更
|
||||
CallBackWaitOrderStatus = 105 // 订单等待处理状态105
|
||||
CallBackSendAllOrderStatus = 3 // 商家全部发货(已发货)/物流消息变更
|
||||
CallBackCancelOrderStatus = 4 // 取消订单装填
|
||||
CallBackSuccessOrderStatus = 5 // 订单交易完成
|
||||
)
|
||||
|
||||
// 订单状态(正向订单创建状态)
|
||||
const (
|
||||
CreateOrderStatusWaitPay = 1 // 1待支付
|
||||
CreateOrderStatusStockUp = 2 // 2备货中(代发货)
|
||||
CreateOrderStatusDelivery = 3 // 3发货
|
||||
CreateOrderStatusCancel = 4 // 4取消
|
||||
CreateOrderStatusOver = 5 // 5完成
|
||||
CreateOrderStatusBeginRefund = 21 // 21发货前退款完成
|
||||
CreateOrderStatusEndRefund = 22 // 22发货后退款
|
||||
CreateOrderStatusReceiptRefund = 39 // 39收货后退款
|
||||
CreateOrderStatusPartialDelivery = 101 // 101部分发货
|
||||
CreateOrderStatusSomePay = 103 // 103部分支付
|
||||
CreateOrderStatusAllPay = 105 // 105已支付
|
||||
)
|
||||
|
||||
// 订单售后状态
|
||||
const (
|
||||
AfterSaleStatusApply = 6 // 申请售后
|
||||
AfterSaleStatusRefuse = 27 // 拒绝售后申请
|
||||
AfterSaleStatusSuccess = 12 // 售后成功
|
||||
AfterSaleStatusLoading = 7 // 售后退货中
|
||||
AfterSaleStatusSendBag = 11 // 售后已发货
|
||||
AfterSaleStatusRefuseBag = 29 // 售后退货拒绝
|
||||
AfterSaleStatusChangeBag = 13 // 【换货返回:换货售后换货商家发货】,【补寄返回:补寄待用户收货】
|
||||
AfterSaleStatusReplenishment = 14 // 【换货返回:(换货)售后换货用户收货】,【补寄返回:(补寄)用户已收货】
|
||||
AfterSaleStatusRefuseFail = 28 // 售后失败
|
||||
AfterSaleStatusCancelOrder = 51 // 取消订单
|
||||
AfterSaleStatusReverseSuccess = 53 // 逆向交易已完成
|
||||
)
|
||||
|
||||
// 支付类型
|
||||
const (
|
||||
PayMethodPayOnArrival = 0 // 到付
|
||||
@@ -55,11 +87,91 @@ const (
|
||||
|
||||
// CallbackRefundOrderMsgTagId 订单退款状态,逆向订单
|
||||
const (
|
||||
// 需要处理的退单消息
|
||||
CallbackRefundOrderMsgTagId = "200" // 买家发起售后申请消息
|
||||
CallbackUpdateRefundOrderMsgTagId = "208" // 买家修改售后申请消息
|
||||
CallbackRefundOrderSuccessMsgTagId = "206" // 退款成功消息
|
||||
CallbackRefundOrderRefuseMsgTagId = "204" // 拒绝退款消息
|
||||
CallbackRefundShopMsgTagId = "205" // 拒绝退货申请消息
|
||||
CallbackReturnApplyAgreedMsgTagId = "202" // 卖家同意时,推送此消息
|
||||
CallbackReturnApplyAgreedMsgTagId = "202" // 同意退货申请消息
|
||||
CallbackReturnRefundAgreedMsgTagId = "201" // 同意退款消息
|
||||
|
||||
// 不需要处理的退单消息
|
||||
CallbackExchangeComfirmedMsgTagId = "211" // 卖家收到买家换货包裹,确认换货并二次发货消息
|
||||
CallbackArbitrateDiscussUploadMsgTagId = "218" // 协商期上传凭证消息
|
||||
CallbackArbitrateServiceInterveneMsgTagId = "217" // 仲裁客服介入消息
|
||||
CallbackArbitrateCancelledMsgTagId = "215" // 买家取消仲裁消息
|
||||
CallbackArbitrateAuditedMsgTagId = "216" // 客服仲裁结果消息
|
||||
CallbackArbitrateSubmitedMsgTagId = "214" // 商家上传仲裁凭证消息
|
||||
CallbackArbitrateSubmitingMsgTagId = "213" // 客服要求商家上传凭证消息
|
||||
CallbackArbitrateAppliedMsgTagId = "212" // 买家发起客服仲裁消息
|
||||
CallbackExpirationChangeMsgTagId = "209" // 售后超时时长变更消息
|
||||
CallbackRefundClosedMsgTagId = "207" // 售后关闭消息
|
||||
CallbackBuyerReturnGoodsMsgTagId = "203" // 买家退货给卖家消息
|
||||
CallbackSpecialRefundMsgTagId = "224" // 特殊权益售后消息
|
||||
CallbackSpecialRefundSuccessMsgTagId = "225" // 特殊权益售后退款成功消息
|
||||
CallbackAuditAgreeResendMsgTagId = "227" // 同意补寄申请
|
||||
CallbackResendFillLogisticsMsgTagId = "226" // 补寄商家发货
|
||||
)
|
||||
|
||||
// 订单售后方式
|
||||
const (
|
||||
AfterSaleTypeAll = 0 // 退货退款
|
||||
AfterSaleTypeSendPkgOnlyReturnMoney = 1 // 已发货仅退款
|
||||
AfterSaleTypeReturnMoney = 2 // 未发货仅退款
|
||||
AfterSaleTypeChangePkg = 3 // 换货
|
||||
AfterSaleTypeSystemCancel = 4 // 系统取消
|
||||
AfterSaleTypeUserCancel = 5 // 用户取消
|
||||
AfterSaleTypeInsuredPrice = 6 // 价保
|
||||
AfterSaleTypeReissue = 7 // 补寄
|
||||
)
|
||||
|
||||
// 订单售后退款商户操作枚举
|
||||
// 售后审核接口聚合版
|
||||
// 售后统一操作接口,此接口可以提供所有售后操作类型。通过此接口操作时,需要通过type字段说明本次期望的操作(详情可见下表)。
|
||||
// 此接口每次最多支持对20个售后单进行操作。但任意一个售后单操作失败,接口遍会整体报错,因此推荐使用此接口每次操作一个售后单,从而获得更加明确的报错信息。
|
||||
// type说明:
|
||||
// 值 前置条件-售后类型 前置条件-售后状态 说明 必须参数
|
||||
// 101 0 6,27 同意退货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
// 102 0 6 拒绝退货申请(一次审核) reason , evidence
|
||||
// 111 0 7,11,29 同意退货(二次审核)
|
||||
// 112 0 11 拒绝退货 (二次审核) reason , evidence
|
||||
// 121 0 6,27 退货转退款
|
||||
// 201 1 6,27 同意仅退款
|
||||
// 202 1 6 拒绝仅退款 reason , evidence
|
||||
// 203 1 6 同意拒签后退款
|
||||
// 301 3 6,27 同意换货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
// 302 3 6 拒绝换货申请(一次审核) reason,evidence
|
||||
// 311 3 7,11,29 同意换货(二次审核) logistics.companyCode,logistics.logisticsCode
|
||||
// 312 3 11 拒绝换货(二次审核) reason,evidence
|
||||
// 321 3 6,7,11,29 换货转退款
|
||||
// 401 2 6 同意售前退申请(拒绝售前退款请使用发货接口)
|
||||
// 501 7 6,27 同意补寄
|
||||
// 502 7 6 拒绝补寄
|
||||
const (
|
||||
AfterSaleEmuAgreeToReturnOneApply = 101 // 同意退货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
AfterSaleEmuRefuseToReturnOneApply = 102 // 拒绝退货申请(一次审核) reason , evidence
|
||||
AfterSaleEmuAgreeToReturnTwoApply = 111 // 同意退货(二次审核)
|
||||
AfterSaleEmuRefuseToReturnTwoApply = 112 // 拒绝退货 (二次审核) reason , evidence
|
||||
AfterSaleEmuReturnGoodsToRefundApply = 121 // 退货转退款
|
||||
AfterSaleEmuAgreeOnlyRefundApply = 201 // 同意仅退款
|
||||
AfterSaleEmuRefuseOnlyRefundApply = 202 // 拒绝仅退款 reason , evidence
|
||||
AfterSaleEmuRefundAfterRefusalApply = 203 // 同意拒签后退款
|
||||
AfterSaleEmuAgreeChangeGoodsOneApply = 301 // 同意换货申请(一次审核) Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
|
||||
AfterSaleEmuRefundChangeGoodsOneApply = 302 // 拒绝换货申请(一次审核) reason,evidence
|
||||
AfterSaleEmuAgreeChangeGoodsTwoApply = 311 // 同意换货(二次审核) logistics.companyCode,logistics.logisticsCode
|
||||
AfterSaleEmuRefundChangeGoodsTwoApply = 312 // 拒绝换货(二次审核) reason,evidence
|
||||
AfterSaleEmuChangeGoodsToRefundApply = 321 // 换货转退款
|
||||
AfterSaleEmuAgreePreSaleReturnApply = 401 // 同意售前退申请(拒绝售前退款请使用发货接口)
|
||||
AfterSaleEmuAgreeReissueApply = 501 // 同意补寄
|
||||
AfterSaleEmuRefundReissueApply = 502 // 拒绝补寄
|
||||
)
|
||||
|
||||
const (
|
||||
MaxSkuNameCharCount = 30 // SkuName的最大字符数
|
||||
MaxStoreSkuBatchSize = 200 // retail/sku/stock, retail/sku/sellStatus和retail/sku/price这些批量操作的最大值
|
||||
MaxRetailListPageSize = 200
|
||||
MaxBatchDeleteSize = 100 // retailCat/batchdelete/catandretail这个接口的批量最大值
|
||||
MaxRetailDiscountCreateBatchSize = 200
|
||||
MaxRetailDiscountDeleteBatchSize = 100
|
||||
)
|
||||
|
||||
@@ -6,52 +6,13 @@ import (
|
||||
"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
|
||||
//}
|
||||
func GetCmd(request *http.Request) (cmd string) {
|
||||
cmd, _ = url.QueryUnescape(request.FormValue("tag"))
|
||||
return cmd
|
||||
}
|
||||
|
||||
// EventSignChange 回调消息防伪标签校验
|
||||
func (a *API) EventSignChange(c *http.Request) *CallbackResponse {
|
||||
@@ -72,3 +33,16 @@ func CallbackResponseErr(param bool) (callbackResponse *CallbackResponse) {
|
||||
}
|
||||
return &CallbackResponse{Code: CallbackFailCode, Msg: CallbackFail}
|
||||
}
|
||||
|
||||
func Err2CallbackResponse(err error, data string) *CallbackResponse {
|
||||
if err == nil {
|
||||
return &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess}
|
||||
}
|
||||
if data == "" {
|
||||
data = err.Error()
|
||||
}
|
||||
return &CallbackResponse{
|
||||
Code: CallbackFailCode,
|
||||
Msg: data,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,20 @@ package tiktok_api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||
product_addV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/response"
|
||||
product_del_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_del/request"
|
||||
product_detail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/request"
|
||||
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
||||
product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request"
|
||||
product_getCatePropertyV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_getCatePropertyV2/request"
|
||||
product_getCatePropertyV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_getCatePropertyV2/response"
|
||||
product_listV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/request"
|
||||
product_listV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/response"
|
||||
product_setOffline_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_setOffline/request"
|
||||
shop_getShopCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getShopCategory/request"
|
||||
sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request"
|
||||
sku_syncStockBatch_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStockBatch/request"
|
||||
)
|
||||
|
||||
// UpdateSkuStock
|
||||
@@ -14,13 +27,183 @@ import (
|
||||
func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) error {
|
||||
request := sku_syncStock_request.New()
|
||||
request.Param = param
|
||||
resp, err := request.Execute(AccessToken)
|
||||
resp, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.Code != 1000 {
|
||||
if resp.Code != RequestSuccessCode {
|
||||
return errors.New(resp.Msg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetShopCategory 获取商品类目
|
||||
// 请一定使用最小层级类目id,发布商品或更新商品。
|
||||
// 接口使用注意点:
|
||||
// 1、第一次请求cid=0获取所有一级类目
|
||||
// 2、先判断enable=true,如果enable=false表示该类目已经失效,请勿使用。
|
||||
// 3、循环获取最小层级类目id方式:再判断is_leaf=true或false。is_leaf=true表示是叶子节点,最小层级类目id。is_leaf=false表示不是子节点,请求参数cid=上一次响应参数id,直到获取最小层级类目id。
|
||||
func (a *API) GetShopCategory(cid int64) ([]*RetailCategoryInfo, error) {
|
||||
// 如果cid为0,则获取所有的分类,如果cid不为0,则获取该分类下面的所有子分类
|
||||
request := shop_getShopCategory_request.New()
|
||||
param := request.GetParams()
|
||||
param.Cid = cid
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
categoryAll := make([]*RetailCategoryInfo, 0, 0)
|
||||
for i := 0; i < len(result.Data); i++ {
|
||||
if result.Data[i].Enable != true { // 失效了
|
||||
continue
|
||||
}
|
||||
if result.Data[i].IsLeaf == false {
|
||||
categoryAll = append(categoryAll, &RetailCategoryInfo{
|
||||
DataItem: result.Data[i],
|
||||
Children: make([]*RetailCategoryInfo, 0, 0),
|
||||
})
|
||||
parentNode, _ := a.GetShopCategory(result.Data[i].Id)
|
||||
categoryAll[i].Children = append(categoryAll[i].Children, parentNode...)
|
||||
} else {
|
||||
node := RetailCategoryInfo{
|
||||
DataItem: result.Data[i],
|
||||
Children: nil,
|
||||
}
|
||||
categoryAll = append(categoryAll, &node)
|
||||
}
|
||||
}
|
||||
return categoryAll, nil
|
||||
}
|
||||
|
||||
// GetCatePropertyV2 根据商品分类获取对应的属性列表
|
||||
// 参数为最终的子节点id下面再无子节点
|
||||
func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV2_response.ProductGetCatePropertyV2Response, error) {
|
||||
request := product_getCatePropertyV2_request.New()
|
||||
param := request.GetParams()
|
||||
param.CategoryLeafId = categoryLeftId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateStoreCommodity (新增总部商品)
|
||||
func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2Param) (*product_addV2_response.ProductAddV2Data, error) {
|
||||
request := product_addV2_request.New()
|
||||
request.Param = skuParam
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// SyncStockBatch 库存批量同步
|
||||
func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatchParam) error {
|
||||
request := sku_syncStockBatch_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
|
||||
}
|
||||
|
||||
// EditStoreCommodity 编辑商品
|
||||
func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param) error {
|
||||
request := product_editV2_request.New()
|
||||
request.Param = sku
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteStoreCommodity 删除商品
|
||||
func (a *API) DeleteStoreCommodity(productId int64) error {
|
||||
request := product_del_request.New()
|
||||
param := request.GetParams()
|
||||
param.ProductId = productId
|
||||
param.DeleteForever = true
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProductSetOffline 商品上下架
|
||||
func (a *API) ProductSetOffline(productId int64) error {
|
||||
request := product_setOffline_request.New()
|
||||
param := request.GetParams()
|
||||
param.ProductId = productId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSkuDetail 查询单个商品详情 美团商品id(19位),本地商品id
|
||||
func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_response.ProductDetailData, error) {
|
||||
request := product_detail_request.New()
|
||||
param := request.GetParams()
|
||||
param.ProductId = productId
|
||||
param.OutProductId = outProductId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, err
|
||||
}
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// GetSkuDetailList 批量获取商品列表
|
||||
func (a *API) GetSkuDetailList(param *product_listV2_request.ProductListV2Param) (*product_listV2_response.ProductListV2Data, error) {
|
||||
request := product_listV2_request.New()
|
||||
request.Param = param
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
34
platformapi/tiktok_shop/tiktok_api/sku_param.go
Normal file
34
platformapi/tiktok_shop/tiktok_api/sku_param.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package tiktok_api
|
||||
|
||||
import shop_getShopCategory_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getShopCategory/response"
|
||||
|
||||
// RetailCategoryInfo 获取抖店所有的节点信息
|
||||
type RetailCategoryInfo struct {
|
||||
shop_getShopCategory_response.DataItem
|
||||
Children []*RetailCategoryInfo `json:"children"`
|
||||
}
|
||||
|
||||
// SpecDetailList 商品库总商品创建结构体
|
||||
type SpecDetailList struct {
|
||||
SpecDetailName1 string `json:"spec_detail_name1"` // 规格名字1
|
||||
SpecDetailName2 string `json:"spec_detail_name2"` // 规格名字2
|
||||
SpecDetailName3 string `json:"spec_detail_name3"` // 规格名字3
|
||||
StockNum int `json:"stock_num"` // 库存数
|
||||
Price int `json:"price"` // 价格
|
||||
Code string `json:"code"` // sku外部编码
|
||||
StepStockNum int `json:"step_stock_num"` // 阶梯库存,规则详见名称解释:https://op.jinritemai.com/docs/guide-docs/202/170
|
||||
SupplierID string `json:"supplier_id"` // 供应商ID
|
||||
OuterSkuID string `json:"outer_sku_id"` // 商家编码(nameID)
|
||||
DeliveryInfos []*DeliveryInfos `json:"delivery_infos"`
|
||||
}
|
||||
type DeliveryInfos struct {
|
||||
InfoType string `json:"info_type"` // 单位类型(weight)
|
||||
InfoValue string `json:"info_value"` // 数量
|
||||
InfoUnit string `json:"info_unit"` // 单位(g,kg,mg)
|
||||
}
|
||||
|
||||
type ProductFormatNewList struct {
|
||||
Value int64 `json:"value"`
|
||||
Name string `json:"name"` // property_name
|
||||
DiyType int64 `json:"diy_type"`
|
||||
}
|
||||
214
platformapi/tiktok_shop/tiktok_api/sku_test.go
Normal file
214
platformapi/tiktok_shop/tiktok_api/sku_test.go
Normal file
@@ -0,0 +1,214 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
address_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/address_create/request"
|
||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"go.uber.org/zap"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func init() {
|
||||
logger, _ := zap.NewDevelopment()
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// sandbox
|
||||
// api = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
||||
// prod
|
||||
api = address_create_request.New()
|
||||
}
|
||||
|
||||
func TestCategory(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":462248,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
data, err := a.GetShopCategory(0)
|
||||
fmt.Println("err=====", err)
|
||||
fmt.Println("data====", data)
|
||||
}
|
||||
|
||||
func TestGetCatePropertyV2(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}
|
||||
`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
data, err := a.GetCatePropertyV2(23065)
|
||||
fmt.Println("err=====", err)
|
||||
fmt.Println("data====", data) // 202209281558450102081001701D7B32C5
|
||||
}
|
||||
|
||||
// 新增总部商品
|
||||
func TestCreateStoreCommodity(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":462248,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}`
|
||||
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
param := &product_addV2_request.ProductAddV2Param{
|
||||
ProductType: 0,
|
||||
CategoryLeafId: 23065,
|
||||
ProductFormat: "",
|
||||
Name: "精华补水液",
|
||||
RecommendRemark: "商家推荐话术",
|
||||
Pic: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/mXJgSMMc_m_b3dbe91196472e0f4bb05e779a21bf81_sx_112313_www800-800|https://p3-aio.ecombdimg.com/obj/ecom-shop-material/mXJgSMMc_m_8433e90bec56f791d4bfa4d47ee1e12c_sx_206128_www800-800", //轮播图,第一张为主图
|
||||
Description: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/mXJgSMMc_m_b3dbe91196472e0f4bb05e779a21bf81_sx_112313_www800-800|https://p3-aio.ecombdimg.com/obj/ecom-shop-material/mXJgSMMc_m_8433e90bec56f791d4bfa4d47ee1e12c_sx_206128_www800-800", //商品描述图
|
||||
PayType: 0,
|
||||
DeliveryMethod: 0,
|
||||
CdfCategory: "",
|
||||
ReduceType: SkuReduceTypePayMakeOrder, //1 减库存类型:1-拍下减库存 2-付款减库存
|
||||
AssocIds: "",
|
||||
FreightId: 11111, // 运费模板id
|
||||
Weight: 0,
|
||||
WeightUnit: 0,
|
||||
DeliveryDelayDay: DeliveryDelayDayToDay, // 现货发货(presell_type=0)和阶梯发货模式(presell_type=2)时必填
|
||||
PresellType: SendGoodsTypeNow, // 0现发货/1预售发货/2阶梯发货
|
||||
PresellDelay: 0,
|
||||
PresellEndTime: "",
|
||||
Supply7dayReturn: 0,
|
||||
Mobile: "18981810340",
|
||||
Commit: false,
|
||||
BrandId: 0,
|
||||
Remark: "商家备注",
|
||||
OutProductId: 0,
|
||||
QualityList: nil,
|
||||
SpecName: "",
|
||||
Specs: "颜色|红色,黑色",
|
||||
SpecPrices: "",
|
||||
SpecPic: "",
|
||||
MaximumPerOrder: 0,
|
||||
LimitPerBuyer: 0,
|
||||
MinimumPerOrder: 0,
|
||||
ProductFormatNew: "",
|
||||
SpuId: 0,
|
||||
AppointDeliveryDay: 0,
|
||||
ThirdUrl: "",
|
||||
Extra: "",
|
||||
Src: "",
|
||||
StandardBrandId: 0,
|
||||
NeedCheckOut: true,
|
||||
PoiResource: nil,
|
||||
CarVinCode: "",
|
||||
PresellConfigLevel: 0,
|
||||
NeedRechargeMode: true,
|
||||
AccountTemplateId: "",
|
||||
PresellDeliveryType: 0,
|
||||
WhiteBackGroundPicUrl: "",
|
||||
LongPicUrl: "",
|
||||
AfterSaleService: nil,
|
||||
SellChannel: nil,
|
||||
StartSaleType: 0, // 立即上架
|
||||
DelayRule: nil,
|
||||
MaterialVideoId: "",
|
||||
PickupMethod: "0",
|
||||
SizeInfoTemplateId: 0,
|
||||
SubstituteGoodsUrl: "",
|
||||
SaleChannelType: "",
|
||||
RecruitInfo: nil,
|
||||
StoreId: 0,
|
||||
MainProductId: 0,
|
||||
SaleLimitId: 0,
|
||||
NamePrefix: "",
|
||||
}
|
||||
|
||||
// 获取属性
|
||||
category, err := a.GetCatePropertyV2(param.CategoryLeafId)
|
||||
format := make(map[string][]*ProductFormatNewList, 0)
|
||||
for _, v := range category.Data.Data {
|
||||
for _, d := range v.Options {
|
||||
formateNew := &ProductFormatNewList{
|
||||
Value: utils.Str2Int64(d.Value),
|
||||
Name: d.Name,
|
||||
DiyType: v.DiyType,
|
||||
}
|
||||
format[utils.Int64ToStr(v.CategoryId)] = append(format[utils.Int64ToStr(v.CategoryId)], formateNew)
|
||||
}
|
||||
}
|
||||
productFormatNew, err := json.Marshal(format)
|
||||
param.ProductFormatNew = string(productFormatNew)
|
||||
|
||||
skuSize := make([]*SpecDetailList, 0, 0)
|
||||
skuDetail := param.Specs
|
||||
detail1 := strings.Split(skuDetail, "^")
|
||||
if len(detail1) > 3 {
|
||||
return
|
||||
}
|
||||
|
||||
switch len(detail1) {
|
||||
case 1:
|
||||
name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
||||
for i := 0; i < len(name1); i++ {
|
||||
sku := &SpecDetailList{
|
||||
SpecDetailName1: name1[i],
|
||||
StockNum: 750,
|
||||
Price: 100,
|
||||
Code: "19930826",
|
||||
StepStockNum: 0,
|
||||
SupplierID: "jxcs1993",
|
||||
OuterSkuID: "1997338" + utils.Int2Str(i),
|
||||
DeliveryInfos: []*DeliveryInfos{
|
||||
{InfoType: "weight", InfoUnit: "kg", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "g", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "mg", InfoValue: "250"},
|
||||
},
|
||||
}
|
||||
skuSize = append(skuSize, sku)
|
||||
}
|
||||
case 2:
|
||||
name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
||||
name2 := strings.Split(strings.Split(detail1[1], "|")[1], ",")
|
||||
for i := 0; i < len(name1); i++ {
|
||||
for j := 0; j < len(name2); j++ {
|
||||
sku := &SpecDetailList{
|
||||
SpecDetailName1: name1[i],
|
||||
SpecDetailName2: name2[j],
|
||||
StockNum: 750,
|
||||
Price: 100,
|
||||
Code: "19930826",
|
||||
StepStockNum: 0,
|
||||
SupplierID: "jxcs1993",
|
||||
OuterSkuID: "1997338",
|
||||
DeliveryInfos: []*DeliveryInfos{
|
||||
{InfoType: "weight", InfoUnit: "kg", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "g", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "mg", InfoValue: "250"},
|
||||
},
|
||||
}
|
||||
skuSize = append(skuSize, sku)
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
||||
name2 := strings.Split(strings.Split(detail1[1], "|")[1], ",")
|
||||
name3 := strings.Split(strings.Split(detail1[2], "|")[1], ",")
|
||||
for i := 0; i < len(name1); i++ {
|
||||
for j := 0; j < len(name2); j++ {
|
||||
for k := 0; k < len(name3); k++ {
|
||||
sku := &SpecDetailList{
|
||||
SpecDetailName1: name1[i],
|
||||
SpecDetailName2: name2[j],
|
||||
SpecDetailName3: name3[k],
|
||||
StockNum: 750,
|
||||
Price: 100,
|
||||
Code: "19930826",
|
||||
StepStockNum: 0,
|
||||
SupplierID: "jxcs1993",
|
||||
OuterSkuID: "1997338",
|
||||
DeliveryInfos: []*DeliveryInfos{
|
||||
{InfoType: "weight", InfoUnit: "kg", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "g", InfoValue: "250"},
|
||||
{InfoType: "weight", InfoUnit: "mg", InfoValue: "250"},
|
||||
},
|
||||
}
|
||||
skuSize = append(skuSize, sku)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
specPricesString, _ := json.Marshal(skuSize)
|
||||
param.SpecPrices = string(specPricesString)
|
||||
data, err := a.CreateStoreCommodity(param)
|
||||
fmt.Println("err=============", err)
|
||||
fmt.Println("data===", fmt.Sprintf("%v", data))
|
||||
}
|
||||
@@ -1,5 +1,44 @@
|
||||
package tiktok_api
|
||||
|
||||
type Imgs struct {
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
// 抖店文件夹id写死两个
|
||||
const (
|
||||
TiktokFolder1 = "71482708738494630701960"
|
||||
TiktokFolder2 = "71482723234545339291960"
|
||||
)
|
||||
|
||||
// 商品减库存类型
|
||||
const (
|
||||
SkuReduceTypeReduceMakeOrder = 1 // 拍下减库存
|
||||
SkuReduceTypePayMakeOrder = 2 // 付款减库存
|
||||
)
|
||||
|
||||
const (
|
||||
TiktokPayType0 = 0 // 0货到付款
|
||||
TiktokPayType1 = 1 // 1在线支付,
|
||||
TiktokPayType2 = 2 // 2货到付款+在线支付
|
||||
)
|
||||
|
||||
// 发货模式
|
||||
const (
|
||||
SendGoodsTypeNow = 0 // 现发货
|
||||
SendGoodsTypeAppointment = 1 // 预约发货
|
||||
SendGoodsTypeLadder = 2 // 阶梯发货
|
||||
DeliveryDelayDayToDay = 9999 // 当日
|
||||
DeliveryDelayDayTomorrow = 1 // 明天
|
||||
DeliveryDelayDayAfterTomorrow = 2 // 后天
|
||||
)
|
||||
|
||||
// 重量单位
|
||||
const (
|
||||
WeightUint_G = 1 // g
|
||||
WeightUint_KG = 0 // g
|
||||
)
|
||||
|
||||
//const (
|
||||
// OrderSourceLuBan = 1 // 鲁班
|
||||
// OrderSourceSmallShop = 2 // 小店
|
||||
@@ -19,8 +58,3 @@ package tiktok_api
|
||||
// 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-上门取件收款
|
||||
|
||||
67
platformapi/tiktok_shop/tiktok_api/sku_warehouse.go
Normal file
67
platformapi/tiktok_shop/tiktok_api/sku_warehouse.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
material_batchUploadImageSync_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/material_batchUploadImageSync/request"
|
||||
material_batchUploadImageSync_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/material_batchUploadImageSync/response"
|
||||
material_createFolder_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/material_createFolder/request"
|
||||
material_createFolder_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/material_createFolder/response"
|
||||
)
|
||||
|
||||
// CreateFolder 创建商品库文件夹(存放商品图片素材)
|
||||
//1. 文件夹名称最多20个字符
|
||||
//2. 每个文件夹下最多包含100个子文件夹
|
||||
//3. 文件夹的最大层级为10层
|
||||
//4. 一个父文件夹下的子文件夹不允许重名
|
||||
//5. 累计创建的文件夹数量不能超过10万
|
||||
func (a *API) CreateFolder(fileName string) (*material_createFolder_response.MaterialCreateFolderResponse, error) {
|
||||
request := material_createFolder_request.New()
|
||||
param := request.GetParams()
|
||||
param.Name = fileName
|
||||
if param.Name == "" {
|
||||
param.Name = "jxcs_folder2"
|
||||
}
|
||||
param.ParentFolderId = "0" // 根目录创建文件夹
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// BatchUploadImages 批量上传文件到目录
|
||||
//1. 一次上传的数量限制50张图片;
|
||||
//2. 图片大小限10M
|
||||
//3. 素材中心会对素材进行异步审核,对于审核失败的素材,素材中心会在一定时间内将其删除。
|
||||
func (a *API) BatchUploadImages(imgs []Imgs) (*material_batchUploadImageSync_response.MaterialBatchUploadImageSyncData, error) {
|
||||
request := material_batchUploadImageSync_request.New()
|
||||
var param = make([]material_batchUploadImageSync_request.MaterialsItem, 0, len(imgs))
|
||||
|
||||
for i := 0; i < len(imgs); i++ {
|
||||
img := material_batchUploadImageSync_request.MaterialsItem{
|
||||
RequestId: imgs[i].Name,
|
||||
FolderId: TiktokFolder1, // 默认存储
|
||||
MaterialType: "photo",
|
||||
Name: imgs[i].Name,
|
||||
Url: imgs[i].Url,
|
||||
}
|
||||
param = append(param, img)
|
||||
}
|
||||
|
||||
imgParam := request.GetParams()
|
||||
imgParam.Materials = param
|
||||
imgParam.NeedDistinct = true
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data, nil
|
||||
}
|
||||
46
platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go
Normal file
46
platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
address_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/address_create/request"
|
||||
"go.uber.org/zap"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func init() {
|
||||
logger, _ := zap.NewDevelopment()
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// sandbox
|
||||
// api = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
||||
// prod
|
||||
api = address_create_request.New()
|
||||
}
|
||||
|
||||
func TestCreateFolad(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":604800,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}
|
||||
`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
data, err := a.CreateFolder("")
|
||||
fmt.Println("err=====", err)
|
||||
fmt.Println("LogId====", data.LogId) //2022092811422001020812109607601B77
|
||||
fmt.Println("data====", data.Data.Name) // jxcs_folder
|
||||
fmt.Println("data====", data.Data.Type) // 0
|
||||
fmt.Println("data====", data.Data.FolderId) // 71482708738494630701960 /71482723234545339291960(两个文件夹的id)
|
||||
fmt.Println("data====", data.Data.ParentFolderId) // 0
|
||||
}
|
||||
|
||||
func TestUploadImg(t *testing.T) {
|
||||
accesstoken := `{"access_token":"6c4d71b3-831c-4a96-8d2e-977e37afba5a","expires_in":462248,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"65aae144-4cc0-44d2-89ba-5d3062caca41","authority_id":""}`
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
|
||||
param := []Imgs{
|
||||
{Name: "测试图片1", Url: "https://image.jxc4.com/image/3f8d9759eda4863e28a0fff523f9d477.jpg"},
|
||||
{Name: "测试图片2", Url: "https://image.jxc4.com/image/06a488c740fe9f6e40a7fffe67a39570.jpg"},
|
||||
}
|
||||
data, err := a.BatchUploadImages(param)
|
||||
fmt.Println(err)
|
||||
fmt.Println(data)
|
||||
// logid 202209281425150101351501360B6DB460
|
||||
}
|
||||
@@ -2,10 +2,12 @@ package tiktok_api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request"
|
||||
shop_bindStoreSaleLimit_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/response"
|
||||
shop_editStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_editStore/request"
|
||||
shop_editStore_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_editStore/response"
|
||||
shop_getStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreFreight/request"
|
||||
shop_storeSuspend_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_storeSuspend/request"
|
||||
shop_storeSuspend_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_storeSuspend/response"
|
||||
shop_unsuspendStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_unsuspendStore/request"
|
||||
@@ -63,7 +65,7 @@ func (a *API) EditStore(storeInfo EditStoreReq) (*shop_editStore_response.ShopEd
|
||||
OpenTime: storeInfo.OpenTime,
|
||||
StoreID: int64(storeInfo.StoreID),
|
||||
}
|
||||
response, err := request.Execute(AccessToken)
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -80,7 +82,7 @@ func (a *API) StoreSuspend(info StoreSuspendReq) (*shop_storeSuspend_response.Sh
|
||||
StoreID: int64(info.StoreID),
|
||||
Reason: info.Reason,
|
||||
}
|
||||
response, err := request.Execute(AccessToken)
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,7 +99,7 @@ func (a *API) UnsuspendStore(info UnsuspendStoreReq) (*shop_unsuspendStore_respo
|
||||
StoreID: int64(info.StoreID),
|
||||
Reason: info.Reason,
|
||||
}
|
||||
response, err := request.Execute(AccessToken)
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -117,7 +119,7 @@ func (a *API) CreateTradeLimitTemplate(info CreateTradeLimitTemplateReq) (*trade
|
||||
TradeLimitPattern: info.TradeLimitPattern,
|
||||
TimePeriod: info.TimePeriod,
|
||||
}
|
||||
response, err := request.Execute(AccessToken)
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -134,7 +136,7 @@ func (a *API) BindStoreSaleLimit(info BindBindStoreSaleLimitReq) (*shop_bindStor
|
||||
StoreID: info.StoreID,
|
||||
SaleLimitID: info.SaleLimitID,
|
||||
}
|
||||
response, err := request.Execute(AccessToken)
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -144,7 +146,21 @@ func (a *API) BindStoreSaleLimit(info BindBindStoreSaleLimitReq) (*shop_bindStor
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
//门店新增查询发货地址
|
||||
func AddressCreate() {
|
||||
// GetStoreFreight 获取门店绑定的限售模板
|
||||
func (a *API) GetStoreFreight(storeId int64) (int64, error) {
|
||||
request := shop_getStoreFreight_request.New()
|
||||
request.Param.StoreId = storeId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
if len(result.Data.StoreFreights) == 0 {
|
||||
return 0, errors.New(fmt.Sprintf("此门[%d]店暂未绑定运费模板", storeId))
|
||||
}
|
||||
return result.Data.StoreFreights[0].FreightId, nil
|
||||
}
|
||||
|
||||
3
platformapi/tiktok_shop/tiktok_api/store_liulei.go
Normal file
3
platformapi/tiktok_shop/tiktok_api/store_liulei.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package tiktok_api
|
||||
|
||||
// huoqu
|
||||
Reference in New Issue
Block a user