- 将飞鹅的一些信息转化得更易懂
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 (
|
const (
|
||||||
KeyShopID = "shop_id"
|
KeyShopID = "shop_id"
|
||||||
KeyBaiduShopID = "baidu_shop_id"
|
KeyBaiduShopID = "baidu_shop_id"
|
||||||
|
KeySupplierID = "supplier_id"
|
||||||
|
|
||||||
|
KeyActivityID = "activity_id"
|
||||||
|
|
||||||
KeyCustomSkuID = "custom_sku_id"
|
KeyCustomSkuID = "custom_sku_id"
|
||||||
KeySkuID = "sku_id"
|
KeySkuID = "sku_id"
|
||||||
@@ -72,15 +75,17 @@ type ShopInfo struct {
|
|||||||
OrderStatusPush int `json:"order_status_push"`
|
OrderStatusPush int `json:"order_status_push"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) genShopIDParams(shopID string, baiduShopID int64) map[string]interface{} {
|
func (a *API) genShopIDParams(shopID string, baiduShopID, supplierID int64) map[string]interface{} {
|
||||||
if shopID == "" && baiduShopID == 0 || shopID != "" && baiduShopID != 0 {
|
// if shopID == "" && baiduShopID == 0 || shopID != "" && baiduShopID != 0 {
|
||||||
panic("shopID and baiduShopID can not all be empty or all not be empty")
|
// panic("shopID and baiduShopID can not all be empty or all not be empty")
|
||||||
}
|
// }
|
||||||
params := map[string]interface{}{}
|
params := map[string]interface{}{}
|
||||||
if shopID != "" {
|
if shopID != "" {
|
||||||
params[KeyShopID] = shopID
|
params[KeyShopID] = shopID
|
||||||
} else {
|
} else if baiduShopID != 0 {
|
||||||
params[KeyBaiduShopID] = baiduShopID
|
params[KeyBaiduShopID] = baiduShopID
|
||||||
|
} else if supplierID != 0 {
|
||||||
|
params[KeySupplierID] = supplierID
|
||||||
}
|
}
|
||||||
return params
|
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) {
|
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)
|
result, err := a.AccessAPI("shop.get", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result.Data.(map[string]interface{}), 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) {
|
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
|
params["platformFlag"] = platformFlag
|
||||||
result, err := a.AccessAPI("shop.busstatus.get", params)
|
result, err := a.AccessAPI("shop.busstatus.get", params)
|
||||||
if err == nil {
|
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) {
|
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)
|
_, err = a.AccessAPI("shop.open", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return 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) {
|
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)
|
_, err = a.AccessAPI("shop.offline", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return 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) {
|
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)
|
_, err = a.AccessAPI("shop.close", params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return 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) {
|
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) {
|
if !utils.IsTimeZero(startTime) {
|
||||||
params["startTime"] = 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) {
|
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["comment_id"] = commentID
|
||||||
params["content"] = content
|
params["content"] = content
|
||||||
_, err = a.AccessAPI("ugc.reply", params)
|
_, err = a.AccessAPI("ugc.reply", params)
|
||||||
|
|||||||
@@ -24,9 +24,22 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PrinterStatusOffline = "离线。"
|
PrinterStatusStrOffline = "离线。"
|
||||||
PrinterStatusOnlineOK = "在线,工作状态正常。"
|
PrinterStatusStrOnlineOK = "在线,工作状态正常。"
|
||||||
PrinterStatusOnlineAbnormal = "在线,工作状态不正常。"
|
PrinterStatusStrOnlineAbnormal = "在线,工作状态不正常。"
|
||||||
|
|
||||||
|
PrinterStatusUnknown = 0
|
||||||
|
PrinterStatusOffline = 1
|
||||||
|
PrinterStatusOnlineOK = 2
|
||||||
|
PrinterStatusOnlineAbnormal = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
printStatusMap = map[string]int{
|
||||||
|
PrinterStatusStrOffline: PrinterStatusOffline,
|
||||||
|
PrinterStatusStrOnlineOK: PrinterStatusOnlineOK,
|
||||||
|
PrinterStatusStrOnlineAbnormal: PrinterStatusOnlineAbnormal,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -238,23 +251,24 @@ func (a *API) QueryOrderState(orderID string) (isFinished bool, err error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) QueryOrderInfoByDate(sn string, date time.Time) (data map[string]interface{}, err error) {
|
func (a *API) QueryOrderInfoByDate(sn string, date time.Time) (printed, waiting int, err error) {
|
||||||
result, err := a.AccessAPI("Open_queryOrderInfoByDate", map[string]interface{}{
|
result, err := a.AccessAPI("Open_queryOrderInfoByDate", map[string]interface{}{
|
||||||
"sn": sn,
|
"sn": sn,
|
||||||
"date": utils.Time2DateStr(date),
|
"date": utils.Time2DateStr(date),
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result.(map[string]interface{}), nil
|
resultMap := result.(map[string]interface{})
|
||||||
|
return int(utils.Interface2Int64WithDefault(resultMap["print"], 0)), int(utils.Interface2Int64WithDefault(resultMap["waiting"], 0)), nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) QueryPrinterStatus(sn string) (status string, err error) {
|
func (a *API) QueryPrinterStatus(sn string) (status int, err error) {
|
||||||
result, err := a.AccessAPI("Open_queryPrinterStatus", map[string]interface{}{
|
result, err := a.AccessAPI("Open_queryPrinterStatus", map[string]interface{}{
|
||||||
"sn": sn,
|
"sn": sn,
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result.(string), nil
|
return printStatusMap[result.(string)], nil
|
||||||
}
|
}
|
||||||
return "", err
|
return PrinterStatusUnknown, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ func TestPrinterDelList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryOrderInfoByDate(t *testing.T) {
|
func TestQueryOrderInfoByDate(t *testing.T) {
|
||||||
data, err := api.QueryOrderInfoByDate("218510310", time.Now())
|
printed, waiting, err := api.QueryOrderInfoByDate("218510310", time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("QueryOrderInfoByDate return error:%v", err)
|
t.Fatalf("QueryOrderInfoByDate return error:%v", err)
|
||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debug(utils.Format4Output(data, false))
|
baseapi.SugarLogger.Debugf("print:%d, waiting:%d", printed, waiting)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDelPrinterSqs(t *testing.T) {
|
func TestDelPrinterSqs(t *testing.T) {
|
||||||
@@ -80,3 +80,11 @@ func TestQueryPrinterStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debug(status)
|
baseapi.SugarLogger.Debug(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQueryOrderState(t *testing.T) {
|
||||||
|
status, err := api.QueryOrderState("218510310")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("QueryOrderState return error:%v", err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(status)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user