Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -8,7 +8,18 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var token = `{"access_token":"e8b6c1bc-2477-40ff-bd8e-faf547669d77","expires_in":1671431173,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3cd84170-73a0-485c-b55a-74e128618693","authority_id":""}`
|
||||
//var token = `{
|
||||
// "access_token": "b668f8cc-d875-4887-a613-5452f05e752e",
|
||||
// "expires_in": 1671432212,
|
||||
// "scope": "SCOPE",
|
||||
// "shop_id": 63141688,
|
||||
// "shop_name": "小时达开放平台专用店",
|
||||
// "refresh_token": "fa64fedf-05a7-4c1b-b6c4-f97f90e10b75",
|
||||
// "authority_id": ""
|
||||
//}`
|
||||
|
||||
//var token = `{"access_token":"e8b6c1bc-2477-40ff-bd8e-faf547669d77","expires_in":1671431173,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3cd84170-73a0-485c-b55a-74e128618693","authority_id":""}`
|
||||
var token = `{"access_token":"83e52462-ad46-4297-98c4-242ee6b7a5c8","expires_in":1672033612,"scope":"SCOPE","shop_id":63141688,"shop_name":"二期-抖音超市小时达测试店铺","refresh_token":"8f690bc3-3f3e-49bd-bbf7-31c9e868e980","authority_id":""}`
|
||||
var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
|
||||
// 查询售后单详情
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestApi(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryOrderDetail(t *testing.T) {
|
||||
data, err := a.GetTiktokOrderDetail("5008526050099613284")
|
||||
data, err := a.GetTiktokOrderDetail("5012575500183489614")
|
||||
globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("=====%s", err)
|
||||
}
|
||||
@@ -42,15 +42,15 @@ func TestTimeNow(t *testing.T) {
|
||||
|
||||
func TestSendGoods(t *testing.T) {
|
||||
param := &order_logisticsAdd_request.OrderLogisticsAddParam{
|
||||
OrderId: "4989178132980723098",
|
||||
OrderId: "5013254696638589999",
|
||||
Company: "",
|
||||
CompanyCode: "chengdouruoxi",
|
||||
LogisticsCode: "4989178132980723098111",
|
||||
LogisticsCode: "5013254696638589999",
|
||||
IsRefundReject: false,
|
||||
IsRejectRefund: false,
|
||||
SerialNumberList: nil,
|
||||
AddressId: 0,
|
||||
StoreId: 63114504,
|
||||
StoreId: 63520894,
|
||||
}
|
||||
a.OrderDelivering(param)
|
||||
}
|
||||
|
||||
32
platformapi/tiktok_shop/tiktok_api/delete_test.go
Normal file
32
platformapi/tiktok_shop/tiktok_api/delete_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDeleteSku(t *testing.T) {
|
||||
var tiktokId = []int64{
|
||||
3589392977455372474,
|
||||
}
|
||||
for _, v := range tiktokId {
|
||||
if err := a.DeleteStoreCommodity(v); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestTryCatName2Code(t *testing.T) {
|
||||
code := tryCatName2Code("3039")
|
||||
fmt.Println(code)
|
||||
}
|
||||
|
||||
func tryCatName2Code(originName string) (catCodeStr string) {
|
||||
if intValue := utils.Str2Int64WithDefault(originName, 0); intValue > 0 {
|
||||
catCodeStr = utils.Int64ToStr(intValue)
|
||||
if catCodeStr != originName {
|
||||
catCodeStr = ""
|
||||
}
|
||||
}
|
||||
return catCodeStr
|
||||
}
|
||||
@@ -32,8 +32,6 @@ func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.
|
||||
IsSearchable: false,
|
||||
}
|
||||
orderDetail, err := reqParam.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("获取订单详情%s", reqParam.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("获取订单详情:=%s", utils.Format4Output(orderDetail, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -53,8 +51,6 @@ func (a *API) QueryAfsOrderDetail(afterSaleId string, needOperationRecord bool)
|
||||
param.AfterSaleId = afterSaleId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("查询售后订单详情%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("查询售后订单详情:=%s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -196,3 +196,14 @@ const (
|
||||
TiktokLogisticsINDDELIVERYEXCEPTION = "IND_DELIVERY_EXCEPTION" // 订单配送异常,异常原因
|
||||
TiktokLogisticsCANCELDELIVERY = "CANCEL_DELIVERY" // 订单配送取消
|
||||
)
|
||||
|
||||
// 商品审核状态: 1-未提交;2-待审核;3-审核通过;4-审核未通过;5-封禁;7-审核通过待上架;详见商品状态机:https://op.jinritemai.com/docs/question-docs/92/2070
|
||||
|
||||
const (
|
||||
SkuCheckStatusNotCommit = 1 // 未提交
|
||||
SkuCheckStatusWaitCheck = 2 // 待审核
|
||||
SkuCheckStatusPass = 3 // 审核通过
|
||||
SkuCheckStatusNotPass = 4 // 审核未通过
|
||||
SkuCheckStatusProhibit = 5 // 禁封
|
||||
SkuCheckStatusPassNotPutOn = 7 // 通过待上架
|
||||
)
|
||||
|
||||
@@ -14,5 +14,7 @@ func TestBillDetail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLen(t *testing.T) {
|
||||
fmt.Println(len("【新鲜】带皮猪五花肉约500g/份"))
|
||||
fmt.Println((57 & 1) != 0)
|
||||
fmt.Println((57 & 64) != 0)
|
||||
fmt.Println((0 & 8))
|
||||
}
|
||||
|
||||
@@ -121,11 +121,11 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
||||
request.Param = skuParam
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("======CreateStoreCommodity logid: %s,%d", result.LogId, skuParam.MainProductId)
|
||||
globals.SugarLogger.Debugf("======CreateStoreCommodity logid: %s,%d,%d", result.LogId, skuParam.MainProductId, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
globals.SugarLogger.Debugf("======CreateStoreCommodity logid: %s,%d", result.LogId, skuParam.MainProductId)
|
||||
globals.SugarLogger.Debugf("======CreateStoreCommodity logid: %s,%d,%d", result.LogId, skuParam.MainProductId, result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data, nil
|
||||
@@ -151,12 +151,14 @@ func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param)
|
||||
request.Param = sku
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("====skuparam %s", utils.Format4Output(sku, false))
|
||||
globals.SugarLogger.Debugf("====result %s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("======EditStoreCommodity logid: %s,%d", result.LogId, sku.MainProductId)
|
||||
globals.SugarLogger.Debugf("LogId %s ,err %s", result.LogId, err.Error())
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
globals.SugarLogger.Debugf("======EditStoreCommodity logid: %s,%d", result.LogId, sku.MainProductId)
|
||||
globals.SugarLogger.Debugf("LogId %s ,err %s", result.LogId, result.SubMsg)
|
||||
return errors.New(result.SubMsg)
|
||||
}
|
||||
return nil
|
||||
@@ -168,8 +170,6 @@ func (a *API) EditStoreCommodityCommit(sku *product_editV2_commit_request.Produc
|
||||
request.Param = sku
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("商品上架=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("商品上架:=%s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -187,8 +187,6 @@ func (a *API) DeleteStoreCommodity(productId int64) error {
|
||||
param.DeleteForever = true
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("删除商品=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("删除商品:=%s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -206,8 +204,6 @@ func (a *API) ProductSetOffline(productId int64) error {
|
||||
param.ProductId = productId
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("商品下架=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("商品下架:=%s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -224,13 +220,10 @@ func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_resp
|
||||
if productId != "" {
|
||||
param.ProductId = productId
|
||||
}
|
||||
if outProductId != "" {
|
||||
//param.OutProductId = outProductId
|
||||
}
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("获取商品详情=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("获取商品详情:=%s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("=GetSkuDetail By productId %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("=GetSkuDetail By err %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -250,8 +243,8 @@ func (a *API) GetSkuDetailLocalID(productId, outProductId string) (*product_deta
|
||||
}
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("获取商品详情=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("获取商品详情:=%s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("=GetSkuDetail By productId %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("=GetSkuDetail By err %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -511,10 +504,12 @@ func (a *API) CreateSubProduct(mainProductId int64, storeId int64) (int64, error
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("基于店铺主品创建门店子品:err =%s ,%s", utils.Format4Output(err, false), result.LogId)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if result.Code != CallbackSuccessCode {
|
||||
if result.Code != RequestSuccessCode {
|
||||
globals.SugarLogger.Debugf("基于店铺主品创建门店子品:err =%s ,%s", result.SubMsg, result.LogId)
|
||||
return 0, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ func TestInt16(t *testing.T) {
|
||||
|
||||
// 查询商品详情(抖音平台id)
|
||||
func TestGetSkuDetail(t *testing.T) {
|
||||
data, err := a.GetSkuDetailLocalID("", "30204")
|
||||
data, err := a.GetSkuDetailLocalID("", "6099286")
|
||||
fmt.Println(err)
|
||||
// 3582171870197365727 3582171870197365727
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
@@ -232,7 +232,7 @@ func TestGetSkuDetail(t *testing.T) {
|
||||
|
||||
// 查询商品详情本地商品id
|
||||
func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
data, err := a.GetSkuDetail("3579214355667024761", "")
|
||||
data, err := a.GetSkuDetail("3588469215562226655", "")
|
||||
fmt.Println(err)
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
@@ -270,16 +270,26 @@ func TestEiduPrice(t *testing.T) {
|
||||
|
||||
// s上架1
|
||||
func TestEditStoreCommodity(t *testing.T) {
|
||||
data, _ := a.GetSkuDetail("3580251132888538614", "")
|
||||
globals.SugarLogger.Debugf("=============%s", data.ProductFormatNew)
|
||||
specPrice, _ := json.Marshal(data.SpecPrices)
|
||||
a.EditStoreCommodity(&product_editV2_request.ProductEditV2Param{
|
||||
ProductId: 1748169491056643,
|
||||
ProductFormatNew: data.ProductFormatNew,
|
||||
SpecPrices: string(specPrice),
|
||||
Specs: "重量|250g",
|
||||
Commit: true,
|
||||
})
|
||||
err := a.EditStoreCommodity(&product_editV2_request.ProductEditV2Param{
|
||||
CategoryLeafId: 22428,
|
||||
Name: "净芹菜约350g/份(净菜芹菜摘叶洗净,保鲜膜包装)",
|
||||
Pic: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/PTWpUjYg_m_78dbc86c51be55406cd2f51bc863b2e0_sx_32178_www800-800",
|
||||
Description: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/PTWpUjYg_m_4fdaab3dd1df6ed4aa8d0990b0e99ee7_sx_456574_www750-3527",
|
||||
PayType: 1,
|
||||
ReduceType: 2,
|
||||
Weight: 350,
|
||||
WeightUnit: 1,
|
||||
DeliveryDelayDay: 9999,
|
||||
Mobile: "18048531223",
|
||||
Commit: true,
|
||||
Specs: "重量|350g",
|
||||
SpecPrices: "[{\"spec_detail_name1\":\"350g\",\"spec_detail_name2\":\"\",\"spec_detail_name3\":\"\",\"stock_num\":9999,\"price\":850,\"code\":\"23010\",\"step_stock_num\":0,\"supplier_id\":\"\",\"outer_sku_id\":\"23010\",\"sku_type\":1,\"stock_num_map\":{\"79226307\":9999},\"delivery_infos\":[{\"info_type\":\"weight\",\"info_value\":\"350\",\"info_unit\":\"g\"}]}]",
|
||||
ProductFormatNew: "{\n\t\"1687\": [\n\t\t{\n\t\t\t\"diy_type\": 0,\n\t\t\t\"name\": \"品牌\",\n\t\t\t\"value\": 789194134\n\t\t}\n\t]\n}",
|
||||
StandardBrandId: 789194134,
|
||||
NeedCheckOut: false,
|
||||
ForceUseQualityList: false,
|
||||
NeedRechargeMode: false})
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// 上架2
|
||||
|
||||
@@ -9,6 +9,7 @@ type Imgs struct {
|
||||
const (
|
||||
TiktokFolder1 = "71580417560930552391570" // 文件夹(京西菜市)
|
||||
TiktokFolder2 = "71482723234545339291960"
|
||||
TiktokFolder3 = "71762017122139835211688" // (方案二测试文件夹)
|
||||
)
|
||||
|
||||
// 商品减库存类型
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
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"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
// CreateFolder 创建商品库文件夹(存放商品图片素材)
|
||||
@@ -51,6 +49,10 @@ func (a *API) BatchUploadImages(imgs []Imgs) (map[string]material_batchUploadIma
|
||||
Name: imgs[i].Name,
|
||||
Url: imgs[i].Url,
|
||||
}
|
||||
// 测试文件夹
|
||||
if a.accessTokenObj.ShopId == 63141688 {
|
||||
img.FolderId = TiktokFolder3
|
||||
}
|
||||
param = append(param, img)
|
||||
}
|
||||
|
||||
@@ -58,16 +60,15 @@ func (a *API) BatchUploadImages(imgs []Imgs) (map[string]material_batchUploadIma
|
||||
imgParam.Materials = param
|
||||
imgParam.NeedDistinct = true
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("===BatchUploadImages=======result %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("===BatchUploadImages=======err %s", utils.Format4Output(err, false))
|
||||
if len(result.Data.SuccessMap) > 0 {
|
||||
return result.Data.SuccessMap, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New("==============logId" + result.LogId + ":" + result.SubMsg)
|
||||
}
|
||||
if len(result.Data.SuccessMap) > 0 {
|
||||
return result.Data.SuccessMap, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestCreateFolad(t *testing.T) {
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
data, err := a.CreateFolder("测试创建文件夹1019")
|
||||
data, err := a.CreateFolder("shop_63141688")
|
||||
fmt.Println("err=====", err)
|
||||
fmt.Println("LogId====", data.LogId) //2022092811422001020812109607601B77
|
||||
fmt.Println("data====", data.Data.Name) // jxcs_folder
|
||||
|
||||
@@ -447,8 +447,6 @@ func (a *API) BindFenceByStore(param *warehouse_bindFencesByStore_request.Wareho
|
||||
request := warehouse_bindFencesByStore_request.New()
|
||||
request.Param = param
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
globals.SugarLogger.Debugf("门店绑定电子围栏=========:%s", request.GetUrlPath())
|
||||
globals.SugarLogger.Debugf("门店绑定电子围栏:=%s", utils.Format4Output(response, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user