- serveral store apis for ebai.
This commit is contained in:
@@ -4,9 +4,54 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
SysStatusAll = -1
|
||||
SysStatusNew = 1
|
||||
SysStatusModifiedWait = 3
|
||||
SysStatusFailedVerify = 4
|
||||
SysStatusOpening = 6
|
||||
SysStatusNewWait = 7
|
||||
SysStatusOnlineRejected = 8
|
||||
SysStatusPassQC = 12
|
||||
)
|
||||
|
||||
const (
|
||||
ShopBusStatusOffline = 1
|
||||
ShopBusStatusCanBooking = 2
|
||||
ShopBusStatusOpening = 3
|
||||
ShopBusStatusSuspended = 4
|
||||
ShopBusStatusBookingNextDay = 5
|
||||
)
|
||||
|
||||
const (
|
||||
PlatformFlagElm = "1"
|
||||
PlatformFlagBaidu = "2"
|
||||
)
|
||||
|
||||
const (
|
||||
KeyShopID = "shop_id"
|
||||
KeyBaiduShopID = "baidu_shop_id"
|
||||
|
||||
KeyName = "name"
|
||||
KeyPhone = "phone"
|
||||
)
|
||||
|
||||
const (
|
||||
CoordTypeBaidu = "bdll"
|
||||
CoordTypeAutonavi = "amap"
|
||||
)
|
||||
|
||||
const (
|
||||
DeliveryTypeBaiduLogistics = 1
|
||||
DeliveryTypeBaiduDeliveryBySelf = 2
|
||||
DeliveryTypeBaiduCrowdSourcing = 3
|
||||
DeliveryTypeBaiduXiaofeixia = 7
|
||||
DeliveryTypeBaiduKuaidipeisong = 8
|
||||
)
|
||||
|
||||
type ShopInfo struct {
|
||||
ShopID int `json:"shop_id"`
|
||||
BaiduShopID int `json:"baidu_shop_id"`
|
||||
ShopID string `json:"shop_id"`
|
||||
BaiduShopID int64 `json:"baidu_shop_id"`
|
||||
Name string `json:"name"`
|
||||
Status int `json:"status"`
|
||||
SysStatus int `json:"sys_status"`
|
||||
@@ -14,17 +59,30 @@ type ShopInfo struct {
|
||||
OrderStatusPush int `json:"order_status_push"`
|
||||
}
|
||||
|
||||
func (a *API) ShopList(orderPush, orderStatusPush, status, sysStatus int) (shopList []*ShopInfo, err error) {
|
||||
func (a *API) genParams(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")
|
||||
}
|
||||
params := map[string]interface{}{}
|
||||
if shopID != "" {
|
||||
params[KeyShopID] = shopID
|
||||
} else {
|
||||
params[KeyBaiduShopID] = baiduShopID
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func (a *API) ShopList( /*orderPush, orderStatusPush, status, */ sysStatus int) (shopList []*ShopInfo, err error) {
|
||||
body := map[string]interface{}{}
|
||||
if orderPush >= 0 {
|
||||
body["order_push"] = orderPush
|
||||
}
|
||||
if orderStatusPush >= 0 {
|
||||
body["order_status_push"] = orderStatusPush
|
||||
}
|
||||
if status >= 0 {
|
||||
body["status"] = status
|
||||
}
|
||||
// if orderPush >= 0 {
|
||||
// body["order_push"] = orderPush
|
||||
// }
|
||||
// if orderStatusPush >= 0 {
|
||||
// body["order_status_push"] = orderStatusPush
|
||||
// }
|
||||
// if status >= 0 {
|
||||
// body["status"] = status
|
||||
// }
|
||||
if sysStatus >= 0 {
|
||||
body["sys_status"] = sysStatus
|
||||
}
|
||||
@@ -35,11 +93,38 @@ func (a *API) ShopList(orderPush, orderStatusPush, status, sysStatus int) (shopL
|
||||
for k, v := range list {
|
||||
mapData := v.(map[string]interface{})
|
||||
shopList[k] = &ShopInfo{
|
||||
ShopID: int(utils.MustInterface2Int64(mapData["shop_id"])),
|
||||
BaiduShopID: int(utils.MustInterface2Int64(mapData["baidu_shop_id"])),
|
||||
ShopID: utils.Interface2String(mapData[KeyShopID]),
|
||||
BaiduShopID: utils.Str2Int64(utils.Interface2String(mapData[KeyBaiduShopID])),
|
||||
}
|
||||
}
|
||||
return shopList, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) ShopGet(shopID string, baiduShopID int64) (shop map[string]interface{}, err error) {
|
||||
params := a.genParams(shopID, baiduShopID)
|
||||
result, err := a.AccessAPI("shop.get", params)
|
||||
if err == nil {
|
||||
return result.Data.(map[string]interface{}), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) ShopUpdate(params map[string]interface{}) (err error) {
|
||||
_, err = a.AccessAPI("shop.update", params)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) ShopBusStatusGet(shopID string, baiduShopID int64, platformFlag string) (busStatus int, err error) {
|
||||
params := a.genParams(shopID, baiduShopID)
|
||||
params["platformFlag"] = platformFlag
|
||||
result, err := a.AccessAPI("shop.busstatus.get", params)
|
||||
if err == nil {
|
||||
return int(utils.MustInterface2Int64(result.Data.(map[string]interface{})["shop_busstatus"])), nil
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user