- 将飞鹅的一些信息转化得更易懂
This commit is contained in:
50
platformapi/ebaiapi/activity.go
Normal file
50
platformapi/ebaiapi/activity.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package ebaiapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
const (
|
||||
ActivityTypeDirectDown = 2 // 商品直降
|
||||
ActivityTypeMoneyOff = 8 // 品类满减
|
||||
|
||||
ActivityPFBaidu = 1
|
||||
ActivityPFELM = 2
|
||||
ActivityPFAll = 4
|
||||
|
||||
ActivityConflictShare = 0
|
||||
ActivityConfilictExclude = 1
|
||||
)
|
||||
|
||||
func (a *API) ActivityCreate(params map[string]interface{}) (activityID int64, err error) {
|
||||
result, err := a.AccessAPI("activity.create", params)
|
||||
if err == nil {
|
||||
return utils.MustInterface2Int64(result.Data.(map[string]interface{})["activity_id"]), nil
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (a *API) ActivityDisable(activityID int64, shopID string, baiduShopID, supplierID int64) (err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID, supplierID)
|
||||
params[KeyActivityID] = activityID
|
||||
_, err = a.AccessAPI("activity.disable", params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) ActivityGet(activityID int64, shopID string, baiduShopID, supplierID int64) (activityInfo map[string]interface{}, err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID, supplierID)
|
||||
params[KeyActivityID] = activityID
|
||||
result, err := a.AccessAPI("activity.disable", params)
|
||||
if err == nil {
|
||||
return result.Data.(map[string]interface{}), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) ActivitySkuAddBatch(activityID int64, shopID string, baiduShopID, supplierID int64, skuIDs []int64, customSkuIDs []string) (successIDs []int64, err error) {
|
||||
// params := a.genShopIDParams(shopID, baiduShopID, supplierID)
|
||||
// params[KeyActivityID] = activityID
|
||||
// result, err := a.AccessAPI("activity.sku.add.batch", params)
|
||||
// if err == nil {
|
||||
// return result.Data.(map[string]interface{}), nil
|
||||
// }
|
||||
return nil, err
|
||||
}
|
||||
@@ -31,6 +31,9 @@ const (
|
||||
const (
|
||||
KeyShopID = "shop_id"
|
||||
KeyBaiduShopID = "baidu_shop_id"
|
||||
KeySupplierID = "supplier_id"
|
||||
|
||||
KeyActivityID = "activity_id"
|
||||
|
||||
KeyCustomSkuID = "custom_sku_id"
|
||||
KeySkuID = "sku_id"
|
||||
@@ -72,15 +75,17 @@ type ShopInfo struct {
|
||||
OrderStatusPush int `json:"order_status_push"`
|
||||
}
|
||||
|
||||
func (a *API) genShopIDParams(shopID string, baiduShopID int64) map[string]interface{} {
|
||||
if shopID == "" && baiduShopID == 0 || shopID != "" && baiduShopID != 0 {
|
||||
panic("shopID and baiduShopID can not all be empty or all not be empty")
|
||||
}
|
||||
func (a *API) genShopIDParams(shopID string, baiduShopID, supplierID int64) map[string]interface{} {
|
||||
// if shopID == "" && baiduShopID == 0 || shopID != "" && baiduShopID != 0 {
|
||||
// panic("shopID and baiduShopID can not all be empty or all not be empty")
|
||||
// }
|
||||
params := map[string]interface{}{}
|
||||
if shopID != "" {
|
||||
params[KeyShopID] = shopID
|
||||
} else {
|
||||
} else if baiduShopID != 0 {
|
||||
params[KeyBaiduShopID] = baiduShopID
|
||||
} else if supplierID != 0 {
|
||||
params[KeySupplierID] = supplierID
|
||||
}
|
||||
return params
|
||||
}
|
||||
@@ -124,7 +129,7 @@ func (a *API) ShopCreate(params map[string]interface{}) (baiduShopID int64, err
|
||||
}
|
||||
|
||||
func (a *API) ShopGet(shopID string, baiduShopID int64) (shop map[string]interface{}, err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
result, err := a.AccessAPI("shop.get", params)
|
||||
if err == nil {
|
||||
return result.Data.(map[string]interface{}), nil
|
||||
@@ -141,7 +146,7 @@ func (a *API) ShopUpdate(params map[string]interface{}) (err error) {
|
||||
}
|
||||
|
||||
func (a *API) ShopBusStatusGet(shopID string, baiduShopID int64, platformFlag string) (busStatus int, err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
params["platformFlag"] = platformFlag
|
||||
result, err := a.AccessAPI("shop.busstatus.get", params)
|
||||
if err == nil {
|
||||
@@ -160,7 +165,7 @@ func (a *API) ShopIDBatchUpdate(baiduShopIDs []string, shopIDs []string) (err er
|
||||
}
|
||||
|
||||
func (a *API) ShopOnline(shopID string, baiduShopID int64) (err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
_, err = a.AccessAPI("shop.open", params)
|
||||
if err == nil {
|
||||
return nil
|
||||
@@ -169,7 +174,7 @@ func (a *API) ShopOnline(shopID string, baiduShopID int64) (err error) {
|
||||
}
|
||||
|
||||
func (a *API) ShopOffline(shopID string, baiduShopID int64) (err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
_, err = a.AccessAPI("shop.offline", params)
|
||||
if err == nil {
|
||||
return nil
|
||||
@@ -178,7 +183,7 @@ func (a *API) ShopOffline(shopID string, baiduShopID int64) (err error) {
|
||||
}
|
||||
|
||||
func (a *API) ShopClose(shopID string, baiduShopID int64) (err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
_, err = a.AccessAPI("shop.close", params)
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []map[string]interface{}, err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
if !utils.IsTimeZero(startTime) {
|
||||
params["startTime"] = startTime
|
||||
}
|
||||
@@ -35,7 +35,7 @@ func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime
|
||||
}
|
||||
|
||||
func (a *API) OrderRatesReply(shopID string, baiduShopID int64, commentID, content string) (err error) {
|
||||
params := a.genShopIDParams(shopID, baiduShopID)
|
||||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||
params["comment_id"] = commentID
|
||||
params["content"] = content
|
||||
_, err = a.AccessAPI("ugc.reply", params)
|
||||
|
||||
Reference in New Issue
Block a user