79 lines
2.7 KiB
Go
79 lines
2.7 KiB
Go
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, failedList, err := a.BatchShopAdd([]map[string]interface{}{params})
|
|
if err != nil {
|
|
if len(failedList) == 1 {
|
|
return "", utils.NewErrorIntCode(failedList[0]["msg"].(string), int(utils.MustInterface2Int64(failedList[0]["code"])))
|
|
}
|
|
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)
|
|
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, err
|
|
}
|
|
|
|
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
|
|
}
|