1
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package superm_product_batchApplyStoreProductPrice_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
superm_product_batchApplyStoreProductPrice_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchApplyStoreProductPrice/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductBatchApplyStoreProductPriceRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *SupermProductBatchApplyStoreProductPriceParam
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchApplyStoreProductPriceRequest) GetUrlPath() string {
|
||||
return "/superm/product/batchApplyStoreProductPrice"
|
||||
}
|
||||
|
||||
func New() *SupermProductBatchApplyStoreProductPriceRequest {
|
||||
request := &SupermProductBatchApplyStoreProductPriceRequest{
|
||||
Param: &SupermProductBatchApplyStoreProductPriceParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchApplyStoreProductPriceRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_product_batchApplyStoreProductPrice_response.SupermProductBatchApplyStoreProductPriceResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &superm_product_batchApplyStoreProductPrice_response.SupermProductBatchApplyStoreProductPriceResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchApplyStoreProductPriceRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchApplyStoreProductPriceRequest) GetParams() *SupermProductBatchApplyStoreProductPriceParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type TaskParams struct {
|
||||
// 店铺主商品ID
|
||||
MainProductId int64 `json:"main_product_id"`
|
||||
}
|
||||
type SupermProductBatchApplyStoreProductPriceParam struct {
|
||||
// 异步任务参数
|
||||
TaskParams *TaskParams `json:"task_params"`
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package superm_product_batchApplyStoreProductPrice_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductBatchApplyStoreProductPriceResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *SupermProductBatchApplyStoreProductPriceData `json:"data"`
|
||||
}
|
||||
type SupermProductBatchApplyStoreProductPriceData struct {
|
||||
// 异步任务根任务ID
|
||||
RootTaskId int64 `json:"root_task_id"`
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package superm_product_batchRedistributeStoreProduct_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
superm_product_batchRedistributeStoreProduct_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchRedistributeStoreProduct/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductBatchRedistributeStoreProductRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *SupermProductBatchRedistributeStoreProductParam
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchRedistributeStoreProductRequest) GetUrlPath() string {
|
||||
return "/superm/product/batchRedistributeStoreProduct"
|
||||
}
|
||||
|
||||
func New() *SupermProductBatchRedistributeStoreProductRequest {
|
||||
request := &SupermProductBatchRedistributeStoreProductRequest{
|
||||
Param: &SupermProductBatchRedistributeStoreProductParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchRedistributeStoreProductRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_product_batchRedistributeStoreProduct_response.SupermProductBatchRedistributeStoreProductResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &superm_product_batchRedistributeStoreProduct_response.SupermProductBatchRedistributeStoreProductResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchRedistributeStoreProductRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *SupermProductBatchRedistributeStoreProductRequest) GetParams() *SupermProductBatchRedistributeStoreProductParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type TaskParams struct {
|
||||
// 店铺主商品ID
|
||||
MainProductId int64 `json:"main_product_id"`
|
||||
// 需要铺品的门店ID列表
|
||||
AddStoreIds []int64 `json:"add_store_ids"`
|
||||
// 需要删除子品的门店ID列表
|
||||
DelStoreIds []int64 `json:"del_store_ids"`
|
||||
}
|
||||
type SupermProductBatchRedistributeStoreProductParam struct {
|
||||
// 重新分配任务参数
|
||||
TaskParams *TaskParams `json:"task_params"`
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package superm_product_batchRedistributeStoreProduct_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductBatchRedistributeStoreProductResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *SupermProductBatchRedistributeStoreProductData `json:"data"`
|
||||
}
|
||||
type SupermProductBatchRedistributeStoreProductData struct {
|
||||
// 异步任务根任务ID
|
||||
RootTaskId int64 `json:"root_task_id"`
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package superm_product_createSubProduct_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
superm_product_createSubProduct_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_createSubProduct/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductCreateSubProductRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *SupermProductCreateSubProductParam
|
||||
}
|
||||
|
||||
func (c *SupermProductCreateSubProductRequest) GetUrlPath() string {
|
||||
return "/superm/product/createSubProduct"
|
||||
}
|
||||
|
||||
func New() *SupermProductCreateSubProductRequest {
|
||||
request := &SupermProductCreateSubProductRequest{
|
||||
Param: &SupermProductCreateSubProductParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductCreateSubProductRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_product_createSubProduct_response.SupermProductCreateSubProductResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &superm_product_createSubProduct_response.SupermProductCreateSubProductResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductCreateSubProductRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *SupermProductCreateSubProductRequest) GetParams() *SupermProductCreateSubProductParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type SkuInfoItem struct {
|
||||
// 子商品规格值列表
|
||||
SellPropertyNames []string `json:"sell_property_names"`
|
||||
// 子商品SKU价格 (单位:分)
|
||||
Price int64 `json:"price"`
|
||||
// 子商品SKU库存
|
||||
Stock int64 `json:"stock"`
|
||||
}
|
||||
type SupermProductCreateSubProductParam struct {
|
||||
// 店铺主商品ID
|
||||
MainProductId int64 `json:"main_product_id"`
|
||||
// 门店ID
|
||||
StoreId int64 `json:"store_id"`
|
||||
// 子商品SKU的库存、价格信息
|
||||
SkuInfo []SkuInfoItem `json:"sku_info"`
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package superm_product_createSubProduct_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductCreateSubProductResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *SupermProductCreateSubProductData `json:"data"`
|
||||
}
|
||||
type SupermProductCreateSubProductData struct {
|
||||
// 门店子商品ID
|
||||
SubProductId int64 `json:"sub_product_id"`
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package superm_product_launchProduct_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
superm_product_launchProduct_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_launchProduct/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductLaunchProductRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *SupermProductLaunchProductParam
|
||||
}
|
||||
|
||||
func (c *SupermProductLaunchProductRequest) GetUrlPath() string {
|
||||
return "/superm/product/launchProduct"
|
||||
}
|
||||
|
||||
func New() *SupermProductLaunchProductRequest {
|
||||
request := &SupermProductLaunchProductRequest{
|
||||
Param: &SupermProductLaunchProductParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductLaunchProductRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_product_launchProduct_response.SupermProductLaunchProductResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &superm_product_launchProduct_response.SupermProductLaunchProductResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *SupermProductLaunchProductRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *SupermProductLaunchProductRequest) GetParams() *SupermProductLaunchProductParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type SupermProductLaunchProductParam struct {
|
||||
// 商品ID,支持主品上架,支持子品上架; (主品需要审核通过后上架)
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package superm_product_launchProduct_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type SupermProductLaunchProductResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *SupermProductLaunchProductData `json:"data"`
|
||||
}
|
||||
type SupermProductLaunchProductData struct {
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
order_getSettleBillDetailV3_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/request"
|
||||
"testing"
|
||||
)
|
||||
@@ -11,3 +12,7 @@ func TestBillDetail(t *testing.T) {
|
||||
OrderId: "5006155889577954309",
|
||||
})
|
||||
}
|
||||
|
||||
func TestLen(t *testing.T) {
|
||||
fmt.Println(len("【新鲜】带皮猪五花肉约500g/份"))
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestCategory(t *testing.T) {
|
||||
data, err := a.GetShopCategory(0)
|
||||
data, err := a.GetShopCategory(20314)
|
||||
for _, v := range data {
|
||||
fmt.Println(v.Id, "---", v.Name, "---", v.IsLeaf, "---", v.Level)
|
||||
}
|
||||
@@ -224,8 +224,9 @@ func TestInt16(t *testing.T) {
|
||||
|
||||
// 查询商品详情(抖音平台id)
|
||||
func TestGetSkuDetail(t *testing.T) {
|
||||
data, err := a.GetSkuDetail("3580251132888538614", "")
|
||||
data, err := a.GetSkuDetailLocalID("", "30204")
|
||||
fmt.Println(err)
|
||||
// 3582171870197365727 3582171870197365727
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
|
||||
@@ -408,3 +409,7 @@ func TestGetProductAuditList(t *testing.T) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func Test111(t *testing.T) {
|
||||
fmt.Println(time.Now().Sub(time.Now().Add(time.Minute * 120)))
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ package tiktok_api
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"go.uber.org/zap"
|
||||
"math"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -51,3 +54,86 @@ func TestRefundToken(t *testing.T) {
|
||||
a.RefreshToken()
|
||||
|
||||
}
|
||||
|
||||
func TestComposeSkuNameOriginal(t *testing.T) {
|
||||
i := 0
|
||||
for {
|
||||
if i >= 30 {
|
||||
break
|
||||
}
|
||||
name1 := ComposeSkuNameOriginal("", "【新鲜】凤尾 莴笋尖 莴笋叶", "", "份", 500, "g", 0)
|
||||
//fmt.Println("name1 == ", name1)
|
||||
|
||||
name2 := ComposeSkuNameOriginal("", name1, "", "份", 500, "g", 0)
|
||||
//fmt.Println("name2 == ", name2)
|
||||
|
||||
name11 := LimitUTF8StringLen(name1, 60)
|
||||
name22 := LimitUTF8StringLen(name2, 60)
|
||||
fmt.Println("name11 = ", name11)
|
||||
fmt.Println("name22 = ", name22)
|
||||
i++
|
||||
}
|
||||
|
||||
}
|
||||
func ComposeSkuNameOriginal(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int) (skuName string) {
|
||||
strBuilder := &strings.Builder{}
|
||||
if prefix != "" {
|
||||
strBuilder.WriteString("[")
|
||||
strBuilder.WriteString(prefix)
|
||||
strBuilder.WriteString("]")
|
||||
}
|
||||
skuName += name
|
||||
strBuilder.WriteString(name)
|
||||
if unit == "份" {
|
||||
strBuilder.WriteString("约")
|
||||
}
|
||||
if unit != "" {
|
||||
strBuilder.WriteString(ComposeSkuSpec(spec_quality, spec_unit))
|
||||
strBuilder.WriteString("/")
|
||||
strBuilder.WriteString(unit)
|
||||
}
|
||||
if comment != "" {
|
||||
strBuilder.WriteString("(")
|
||||
strBuilder.WriteString(comment)
|
||||
strBuilder.WriteString(")")
|
||||
}
|
||||
skuName = strBuilder.String()
|
||||
if maxLen > 0 {
|
||||
skuName = utils.LimitUTF8StringLen(skuName, maxLen)
|
||||
}
|
||||
return skuName
|
||||
}
|
||||
|
||||
func ComposeSkuSpec(spec_quality float32, spec_unit string) (spec string) {
|
||||
if spec_unit != "" {
|
||||
if math.Round(float64(spec_quality)) == float64(spec_quality) || (spec_unit != "L" && spec_unit != "kg") {
|
||||
spec = fmt.Sprintf("%d", int(spec_quality))
|
||||
} else {
|
||||
spec = strings.TrimRight(fmt.Sprintf("%.2f", spec_quality), "0.")
|
||||
}
|
||||
spec += spec_unit
|
||||
}
|
||||
return spec
|
||||
}
|
||||
func LimitUTF8StringLen(str string, maxRuneCount int) (limitedStr string) {
|
||||
if maxRuneCount > 0 {
|
||||
if len(str) > maxRuneCount {
|
||||
runeList := []rune(str)
|
||||
if len(runeList) > maxRuneCount {
|
||||
str = string(runeList[:maxRuneCount])
|
||||
}
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func Test1111(t *testing.T) {
|
||||
fmt.Println(len("【新鲜】凤尾 莴笋尖 莴笋叶约500g/份"))
|
||||
fmt.Println(len("【新鲜】凤尾 莴笋尖 莴笋叶约500g/份约500g/ 份"))
|
||||
fmt.Println(len("【新鲜】凤尾 莴笋尖 莴笋叶约500g/份约500g/份"))
|
||||
}
|
||||
|
||||
func Test22222(t *testing.T) {
|
||||
fmt.Println(len("【新鲜】凤尾 莴笋尖 莴笋叶"))
|
||||
fmt.Println(len("凤尾 莴笋尖 莴笋叶 约350g"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user