- dada shop api added.
This commit is contained in:
78
platformapi/dadaapi/shop.go
Normal file
78
platformapi/dadaapi/shop.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package dadaapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
const (
|
||||
BusinessTypeSnack = 1
|
||||
BusinessTypeDrink = 2
|
||||
BusinessTypeFlower = 3
|
||||
BusinessTypePrintTicket = 8
|
||||
BusinessTypeConvStore = 9
|
||||
BusinessTypeFruitVegetable = 13
|
||||
BusinessTypeCityEComm = 19
|
||||
BusinessTypeMedicine = 20
|
||||
BusinessTypeCake = 21
|
||||
BusinessTypeWine = 24
|
||||
BusinessTypeSmallware = 25
|
||||
BusinessTypeClothing = 26
|
||||
BusinessTypeCarPart = 27
|
||||
BusinessTypeDigital = 28
|
||||
BusinessTypeCray = 29
|
||||
BusinessTypeOther = -5
|
||||
)
|
||||
|
||||
func (a *API) ShopDetail(originShopID string) (shopDetail map[string]interface{}, err error) {
|
||||
params := map[string]interface{}{
|
||||
"origin_shop_id": originShopID,
|
||||
}
|
||||
result, err := a.AccessAPI("api/shop/detail", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Result.(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
func (a *API) ShopAdd(originShopID, stationName string, business int, cityName, areaName, stationAddress string, lng, lat float64, contactName, phone string, addParams map[string]interface{}) (outOriginShopID string, err error) {
|
||||
params := map[string]interface{}{
|
||||
"station_name": stationName,
|
||||
"business": business,
|
||||
"city_name": cityName,
|
||||
"area_name": areaName,
|
||||
"station_address": stationAddress,
|
||||
"lng": lng,
|
||||
"lat": lat,
|
||||
"contact_name": contactName,
|
||||
"phone": phone,
|
||||
}
|
||||
if originShopID != "" {
|
||||
params["origin_shop_id"] = originShopID
|
||||
}
|
||||
if addParams != nil {
|
||||
params = utils.MergeMaps(params, addParams)
|
||||
}
|
||||
successList, _, err := a.BatchShopAdd([]map[string]interface{}{params})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return utils.Interface2String(successList[0]["originShopId"]), nil
|
||||
}
|
||||
|
||||
func (a *API) BatchShopAdd(shopInfoList []map[string]interface{}) (successList, failedList []map[string]interface{}, err error) {
|
||||
result, err := a.AccessAPI("api/shop/add", shopInfoList)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
mapResult := result.Result.(map[string]interface{})
|
||||
if successList2 := mapResult["successList"]; successList2 != nil {
|
||||
successList = utils.Slice2MapSlice(successList2.([]interface{}))
|
||||
}
|
||||
if failedList2 := mapResult["failedList"]; failedList2 != nil {
|
||||
failedList = utils.Slice2MapSlice(failedList2.([]interface{}))
|
||||
}
|
||||
return successList, failedList, nil
|
||||
}
|
||||
|
||||
func (a *API) ShopUpdate(originShopID string, shopInfo map[string]interface{}) (err error) {
|
||||
_, err = a.AccessAPI("api/shop/update", utils.MergeMaps(utils.Params2Map("origin_shop_id", originShopID), shopInfo))
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user