限售
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package shop_getStoreSaleLimit_request
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
shop_getStoreSaleLimit_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreSaleLimit/response"
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type ShopGetStoreSaleLimitRequest struct {
|
||||
doudian_sdk.BaseDoudianOpApiRequest
|
||||
Param *ShopGetStoreSaleLimitParam
|
||||
}
|
||||
|
||||
func (c *ShopGetStoreSaleLimitRequest) GetUrlPath() string {
|
||||
return "/shop/getStoreSaleLimit"
|
||||
}
|
||||
|
||||
func New() *ShopGetStoreSaleLimitRequest {
|
||||
request := &ShopGetStoreSaleLimitRequest{
|
||||
Param: &ShopGetStoreSaleLimitParam{},
|
||||
}
|
||||
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
func (c *ShopGetStoreSaleLimitRequest) Execute(accessToken *doudian_sdk.AccessToken) (*shop_getStoreSaleLimit_response.ShopGetStoreSaleLimitResponse, error) {
|
||||
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &shop_getStoreSaleLimit_response.ShopGetStoreSaleLimitResponse{}
|
||||
_ = json.Unmarshal([]byte(responseJson), response)
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *ShopGetStoreSaleLimitRequest) GetParamObject() interface{} {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c *ShopGetStoreSaleLimitRequest) GetParams() *ShopGetStoreSaleLimitParam {
|
||||
return c.Param
|
||||
}
|
||||
|
||||
type ShopGetStoreSaleLimitParam struct {
|
||||
// 门店ID
|
||||
StoreId int64 `json:"store_id"`
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package shop_getStoreSaleLimit_response
|
||||
|
||||
import (
|
||||
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
)
|
||||
|
||||
type ShopGetStoreSaleLimitResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *ShopGetStoreSaleLimitData `json:"data"`
|
||||
}
|
||||
type StoreSaleLimitsItem struct {
|
||||
// 门店id
|
||||
StoreId int64 `json:"store_id"`
|
||||
// 模版id
|
||||
SaleLimitId int64 `json:"sale_limit_id"`
|
||||
}
|
||||
type ShopGetStoreSaleLimitData struct {
|
||||
// 门店关联的限售模版
|
||||
StoreSaleLimits []StoreSaleLimitsItem `json:"store_sale_limits"`
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
shop_batchCreateStore_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_batchCreateStore/response"
|
||||
shop_bindStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreFreight/request"
|
||||
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_getStoreDetail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreDetail/request"
|
||||
@@ -24,6 +23,7 @@ import (
|
||||
shop_getStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreFreight/request"
|
||||
shop_getStoreList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreList/request"
|
||||
shop_getStoreList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreList/response"
|
||||
shop_getStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreSaleLimit/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"
|
||||
@@ -148,17 +148,38 @@ func (a *API) CreateTradeLimitTemplate(param *trade_createTradeLimitTemplate_req
|
||||
}
|
||||
|
||||
//门店绑定限售模板
|
||||
func (a *API) BindStoreSaleLimit(param *shop_bindStoreSaleLimit_request.ShopBindStoreSaleLimitParam) (*shop_bindStoreSaleLimit_response.ShopBindStoreSaleLimitData, error) {
|
||||
func (a *API) BindStoreSaleLimit(param *shop_bindStoreSaleLimit_request.ShopBindStoreSaleLimitParam) error {
|
||||
request := shop_bindStoreSaleLimit_request.New()
|
||||
request.Param = param
|
||||
response, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg)
|
||||
}
|
||||
return response.Data, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// 门店查询限售模板
|
||||
func (a *API) StoreQuerySaleLimitTemp(storeId int64) (int64, error) {
|
||||
request := shop_getStoreSaleLimit_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 result.Data == nil || len(result.Data.StoreSaleLimits) == 0 {
|
||||
return 0, errors.New("未绑定限售模板,请先绑定")
|
||||
}
|
||||
|
||||
return result.Data.StoreSaleLimits[0].SaleLimitId, nil
|
||||
|
||||
}
|
||||
|
||||
// 创建运费模板
|
||||
|
||||
Reference in New Issue
Block a user