99 lines
3.0 KiB
Go
99 lines
3.0 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
|
|
)
|
|
|
|
const (
|
|
ShopStatusOffline = 0 // -门店下线
|
|
ShopStatusOnline = 1 // -门店激活
|
|
)
|
|
|
|
type ShopInfo struct {
|
|
StationName string `json:"station_name,omitempty"`
|
|
Business int `json:"business,omitempty"`
|
|
CityName string `json:"city_name,omitempty"`
|
|
AreaName string `json:"area_name,omitempty"`
|
|
StationAddress string `json:"station_address,omitempty"`
|
|
Lng float64 `json:"lng,omitempty"`
|
|
Lat float64 `json:"lat,omitempty"`
|
|
ContactName string `json:"contact_name,omitempty"`
|
|
Phone string `json:"phone,omitempty"`
|
|
|
|
OriginShopID string `json:"origin_shop_id,omitempty"`
|
|
IDCard string `json:"id_card,omitempty"`
|
|
UserName string `json:"username,omitempty"`
|
|
Password string `json:"password,omitempty"`
|
|
|
|
NewShopID string `json:"new_shop_id,omitempty"` // 修改用
|
|
|
|
BDName string `json:"bd_name,omitempty"` // 查询用
|
|
BDPhone string `json:"bd_phone,omitempty"` // 查询用
|
|
Status int `json:"status,omitempty"` // 查询用
|
|
}
|
|
|
|
type AddShopFailInfo struct {
|
|
Code int `json:"code"`
|
|
ShopNo string `json:"shopNo"`
|
|
Msg string `json:"msg"`
|
|
ShopName string `json:"shopName"`
|
|
}
|
|
|
|
type AddShopResult struct {
|
|
Success int `json:"success"`
|
|
SuccessList []*ShopInfo `json:"successList"`
|
|
FailedList []*AddShopFailInfo `json:"failedList"`
|
|
}
|
|
|
|
func (a *API) ShopDetail(originShopID string) (shopDetail *ShopInfo, err error) {
|
|
params := map[string]interface{}{
|
|
"origin_shop_id": originShopID,
|
|
}
|
|
result, err := a.AccessAPI("api/shop/detail", params)
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result.Result, &shopDetail, false)
|
|
}
|
|
return shopDetail, err
|
|
}
|
|
|
|
func (a *API) ShopAdd(shopInfo *ShopInfo) (outOriginShopID string, err error) {
|
|
addResult, err := a.BatchShopAdd([]*ShopInfo{shopInfo})
|
|
if addResult != nil && len(addResult.FailedList) == 1 {
|
|
return "", utils.NewErrorIntCode(addResult.FailedList[0].Msg, int(utils.MustInterface2Int64(addResult.FailedList[0].Code)))
|
|
} else if err != nil {
|
|
return "", err
|
|
}
|
|
return addResult.SuccessList[0].OriginShopID, nil
|
|
}
|
|
|
|
func (a *API) BatchShopAdd(shopInfoList []*ShopInfo) (addResult *AddShopResult, err error) {
|
|
result, err := a.AccessAPI("api/shop/add", shopInfoList)
|
|
err2 := utils.Map2StructByJson(result.Result, &addResult, false)
|
|
if err == nil {
|
|
err = err2
|
|
}
|
|
return addResult, err
|
|
}
|
|
|
|
func (a *API) ShopUpdate(shopInfo *ShopInfo) (err error) {
|
|
_, err = a.AccessAPI("api/shop/update", shopInfo)
|
|
return err
|
|
}
|