1
This commit is contained in:
83
platformapi/ali_logistics_query/api.go
Normal file
83
platformapi/ali_logistics_query/api.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package ali_logistics_query
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
BastUrl = "http://express3.market.alicloudapi.com" // 基础访问路由
|
||||
GetOrderDetailApi = "express3" // 获取物流订单详情
|
||||
)
|
||||
|
||||
type API struct {
|
||||
appKey string
|
||||
appSecret string
|
||||
appCode string
|
||||
client *http.Client
|
||||
config *platformapi.APIConfig
|
||||
}
|
||||
|
||||
func New(appKey, appSecret, appCode string, config ...*platformapi.APIConfig) (a *API) {
|
||||
curConfig := platformapi.DefAPIConfig
|
||||
if len(config) > 0 {
|
||||
curConfig = *config[0]
|
||||
}
|
||||
|
||||
a = &API{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
appCode: appCode,
|
||||
client: &http.Client{Timeout: curConfig.ClientTimeout},
|
||||
config: &curConfig,
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *API) GetAppCode() string {
|
||||
return a.appCode
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
// 序列化
|
||||
data, err := json.Marshal(bizParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 发送请求
|
||||
sendUrl := func() *http.Request {
|
||||
var request *http.Request
|
||||
if http.MethodPost == method {
|
||||
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(baseUrl, actionApi, nil), strings.NewReader(string(data)))
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(baseUrl, actionApi, bizParams), nil)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Authorization", "APPCODE "+a.appCode)
|
||||
return request
|
||||
}
|
||||
|
||||
// 数据解析
|
||||
dataMarshal := func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if utils.MustInterface2Int64(jsonResult1["code"]) != 200 {
|
||||
errLevel = platformapi.ErrLevelGeneralFail
|
||||
err = utils.NewErrorCode(jsonResult1["msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResult1["code"])))
|
||||
}
|
||||
retVal = jsonResult1
|
||||
return errLevel, err
|
||||
}
|
||||
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client, sendUrl, a.config, dataMarshal)
|
||||
return retVal, err
|
||||
}
|
||||
79
platformapi/ali_logistics_query/logistics_model.go
Normal file
79
platformapi/ali_logistics_query/logistics_model.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package ali_logistics_query
|
||||
|
||||
// LogisticsStatusReceive 物流状态标签说明
|
||||
// https://market.aliyun.com/products/57126001/cmapi00054243.html?spm=5176.2020520132.101.2.3c557218Al5EBA#sku=yuncode4824300001
|
||||
const (
|
||||
// 揽件
|
||||
LogisticsStatusRECEVIE = "RECEVIE" // 接单中
|
||||
LogisticsStatusWAIT_ACCEPT = "WAIT_ACCEPT" // 待揽件
|
||||
LogisticsStatusACCEPT = "ACCEPT" // 已揽收
|
||||
|
||||
// 运输中
|
||||
LogisticsStatusTRANSPORT = "TRANSPORT" // 运输中
|
||||
LogisticsStatusSEND_ON = "SEND_ON" // 转单或修改地址
|
||||
LogisticsStatusARRIVE_CITY = "ARRIVE_CITY" // 到达目的城市
|
||||
|
||||
// 派件
|
||||
LogisticsStatusDELIVERING = "DELIVERING" // 派件中
|
||||
LogisticsStatusSTA_INBOUND = "STA_INBOUND" // 已放入快递柜或者驿站
|
||||
|
||||
// 签收
|
||||
LogisticsStatusAGENT_SIGN = "AGENT_SIGN" // 已代签收
|
||||
LogisticsStatusSIGN = "SIGN" // 已签收
|
||||
LogisticsStatusSTA_SIGN = "STA_SIGN" // 从快递柜或驿站取出
|
||||
LogisticsStatusRETURN_SIGN = "RETURN_SIGN" // 退回签收
|
||||
|
||||
// 包裹异常
|
||||
LogisticsStatusFAILED = "FAILED" // 包裹异常
|
||||
LogisticsStatusREFUSE_SIGN = "REFUSE_SIGN" // 拒收
|
||||
LogisticsStatusDELIVER_ABNORMAL = "DELIVER_ABNORMAL" // 派件异常
|
||||
LogisticsStatusRETENTION = "RETENTION" // 滞留件
|
||||
LogisticsStatusISSUE = "ISSUE" // 问题件
|
||||
LogisticsStatusRETURN = "RETURN" // 退回件
|
||||
LogisticsStatusDAMAGE = "DAMAGE" // 破损
|
||||
LogisticsStatusCANCEL_ORDER = "CANCEL_ORDER" // 揽件取消
|
||||
)
|
||||
|
||||
// BaseModel 基础物流返回值
|
||||
type BaseModel struct {
|
||||
Msg string `json:"msg"` // 请求返回通知
|
||||
Success bool `json:"success"` // 是否成功
|
||||
Code int `json:"code"` // 返回code
|
||||
}
|
||||
|
||||
// OrderDetail 物流订单详情
|
||||
type OrderDetail struct {
|
||||
OrderNo string `json:"orderNo"` // 订单id
|
||||
Info []struct { // 物流详情
|
||||
TheLastTime string `json:"theLastTime"` // 运单号物流流转当前最新变更时间
|
||||
CpCode string `json:"cpCode"` // 快递公司代号
|
||||
MailNo string `json:"mailNo"` // 快递单号
|
||||
CpMobile string `json:"cpMobile"` // 快递公司电话
|
||||
TheLastMessage string `json:"theLastMessage"` // 运单号物流流转当前最新描述
|
||||
LogisticsCompanyName string `json:"logisticsCompanyName"` // 快递公司名称
|
||||
CpUrl string `json:"cpUrl"` // 快递公司官网
|
||||
Courier string `json:"courier"` // 配送人名称
|
||||
LogisticsStatusDesc string `json:"logisticsStatusDesc"` // 运单号当前物流状态文字描述
|
||||
LogisticsTraceDetailList []struct {
|
||||
AreaCode string `json:"areaCode,omitempty"` // 当前节点所在地址行政编码
|
||||
AreaName string `json:"areaName,omitempty"` // 当前节点所在地区,省,市,区或省,市
|
||||
SubLogisticsStatus string `json:"subLogisticsStatus"` // 物流流转子状态,详见:物流状态编码对照表
|
||||
Time int64 `json:"time"` // 时间,单位毫秒
|
||||
LogisticsStatus string `json:"logisticsStatus"` // 物流流转状态,详见:物流状态编码对照表
|
||||
Desc string `json:"desc"` // 物流流转描述
|
||||
Courier string `json:"courier,omitempty"` // 配送人名称
|
||||
CourierPhone string `json:"courierPhone,omitempty"` // 配送人电话
|
||||
} `json:"logisticsTraceDetailList"`
|
||||
CourierPhone string `json:"courierPhone"` // 配送人电话
|
||||
LogisticsStatus string `json:"logisticsStatus"` // 物流流转状态
|
||||
} `json:"info"`
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
|
||||
type GetOrderDetail struct {
|
||||
Msg string `json:"msg"` // 请求返回通知
|
||||
Success bool `json:"success"` // 是否成功
|
||||
Code int `json:"code"` // 返回code
|
||||
Data *OrderDetail `json:"data"`
|
||||
}
|
||||
32
platformapi/ali_logistics_query/logistics_query.go
Normal file
32
platformapi/ali_logistics_query/logistics_query.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package ali_logistics_query
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (a *API) GetLogisticsInfo(logisticsNumber string) (*OrderDetail, error) {
|
||||
if len(logisticsNumber) == 0 {
|
||||
return nil, errors.New("参数不能为空")
|
||||
}
|
||||
param := make(map[string]interface{}, 1)
|
||||
param["number"] = logisticsNumber
|
||||
|
||||
result, err := a.AccessAPI(BastUrl, GetOrderDetailApi, http.MethodGet, param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var detail *GetOrderDetail
|
||||
if err := utils.Map2StructByJson(result, &detail, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if detail.Code != 200 || !detail.Success {
|
||||
return nil, errors.New(detail.Msg)
|
||||
}
|
||||
|
||||
return detail.Data, nil
|
||||
|
||||
}
|
||||
20
platformapi/ali_logistics_query/logistics_test.go
Normal file
20
platformapi/ali_logistics_query/logistics_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package ali_logistics_query
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
appKey = "23537670"
|
||||
appSecret = "4a77a431c0bf01f6dfa63d1a1ec9ecd2"
|
||||
appCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
api := New(appKey, appSecret, appCode)
|
||||
result, err := api.GetLogisticsInfo("JD0088184529553")
|
||||
globals.SugarLogger.Debugf("result======== %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("err======== %s", utils.Format4Output(err, false))
|
||||
}
|
||||
@@ -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