159 lines
7.5 KiB
Go
159 lines
7.5 KiB
Go
package fnpsapi
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/platformapi"
|
||
"net/http"
|
||
"sync"
|
||
)
|
||
|
||
const (
|
||
sigKey = "signature"
|
||
|
||
TokenURL = "https://open-anubis.ele.me/anubis-webapi/openapi/token"
|
||
ApiURL = "https://open-anubis.ele.me/anubis-webapi/v3/invoke/"
|
||
RequestPost = "POST"
|
||
RequestGet = "GET"
|
||
)
|
||
|
||
//todo 返回参数没做玩
|
||
//type TokenInfo struct {
|
||
// AccessToken string `json:"access_token"`
|
||
// AppID string `json:"app_id"`
|
||
// ExpireTime int64 `json:"expire_time"`
|
||
//}
|
||
|
||
// 获取token
|
||
type TokenInfo struct {
|
||
Sign string `json:"sign"` //返回值签名,详见开放平台侧返回值签名算法
|
||
Code string `json:"code"` //错误码,详见开放平台侧错误码映射表
|
||
Msg string `json:"msg"` //错误信息
|
||
BusinessData string `json:"business_data"` // string
|
||
}
|
||
|
||
type BusinessData struct {
|
||
AppID string `json:"app_id"` //应用id
|
||
MerchantID string `json:"merchant_id"` //商户id
|
||
AccessToken string `json:"access_token"` //凭证token
|
||
RefreshToken string `json:"refresh_token"` //刷新token
|
||
ExpireIn string `json:"expire_in"` //access_token剩余有效时间,单位:秒,默认有效期是一年
|
||
ReExpireIn string `json:"re_expire_in"` //refresh_token剩余有效时间
|
||
}
|
||
|
||
// 注册请求api
|
||
type API struct {
|
||
grantType string `json:"grant_type"`
|
||
code string `json:"code"`
|
||
appID string `json:"app_id"`
|
||
merchantId string `json:"merchant_id"`
|
||
signature string `json:"signature"`
|
||
timestamp int64 `json:"timestamp"`
|
||
accessToken string `json:"access_token"`
|
||
appSecret string `json:"app_secret"`
|
||
version string `json:"version"`
|
||
locker sync.RWMutex
|
||
client *http.Client
|
||
config *platformapi.APIConfig
|
||
}
|
||
|
||
//<------------------------------------------------------------->
|
||
// 请求基础结构体
|
||
type BaseInfo struct {
|
||
AccessToken string `json:"access_token"` //凭证token
|
||
Signature string `json:"signature"`
|
||
MerchantID string `json:"merchant_id"` //商户id
|
||
Version string `json:"version"` // 版本固定1.0
|
||
AppID string `json:"app_id"` //应用id
|
||
Timestamp int64 `json:"timestamp"` // 当前时间戳
|
||
}
|
||
|
||
//#region 获取蜂鸟门店信息
|
||
|
||
// 获取单个门店查询
|
||
type GetOneStoreParam struct {
|
||
BaseInfo
|
||
BusinessData string `json:"business_data"` // 门店基础数据
|
||
}
|
||
|
||
// 获取单个门店基础参数
|
||
type GetOneStore struct {
|
||
MerchantID string `json:"merchant_id"` // 商户id
|
||
OutShopCode string `json:"out_shop_code"` // 外部门店编码
|
||
}
|
||
|
||
// 获取门店返回值信息
|
||
type GetStoreResp struct {
|
||
TokenInfo
|
||
}
|
||
|
||
type GetOneStoreRespData struct {
|
||
Address string `json:"address"` // 门店地址
|
||
BranchName string `json:"branch_name"` // 门店分店名
|
||
CategoryID int `json:"category_id"` // 门店类目
|
||
ChainStoreID int `json:"chain_store_id"` // 蜂鸟门店id,创建接口返回的id
|
||
ChainstoreType int `json:"chainstore_type"` // 门店类型 1-正式门店;2-测试门店
|
||
ChainstoreTypeDesc string `json:"chainstore_type_desc"` // 门店类型描述
|
||
ContactPhone string `json:"contact_phone"` // 门店联系方式
|
||
CreditCode string `json:"credit_code"` // 统一社会信用代码
|
||
Latitude float64 `json:"latitude"` // 门店纬度[0,90]
|
||
Longitude float64 `json:"longitude"` // 门店经度[0,180]
|
||
MerchantID int `json:"merchant_id"` // 所属商户id
|
||
ModifyStatus int `json:"modify_status"` // 0-无修改,10-资料修改审核中,20-审核通过,30-a审核驳回
|
||
ModifyStatusDesc string `json:"modify_status_desc"` // 门店修改状态描述
|
||
Name string `json:"name"` // 门店主店名
|
||
OutShopCode string `json:"out_shop_code"` // 外部门店编码
|
||
OwnerIDNum string `json:"owner_id_num"` // 门店拥有人身份证号
|
||
OwnerName string `json:"owner_name"` // 门店拥有人姓名
|
||
PositionSource int `json:"position_source"` // 经纬度来源 坐标属性(1:腾讯地图, 2:百度地图, 3:高德地图),蜂鸟建议使用高德地图
|
||
PositionSourceDesc string `json:"position_source_desc"` // 经纬度来源说明
|
||
SettlementAccountID int `json:"settlement_account_id"` // 门店结算账号id
|
||
SettlementMode int `json:"settlement_mode"` // 门店结算方式 1:实时结算; 2:账期结算;
|
||
SettlementModeDesc string `json:"settlement_mode_desc"` // 结算说明?
|
||
Status int `json:"status"` // 0-上架审核中,20-正常(已上架),30-上架审核失败,40-已冻结,50-已下架
|
||
StatusDesc string `json:"status_desc"` // 门店认证状态描述
|
||
}
|
||
|
||
//#endregion
|
||
|
||
// CreateStoreParam 创建门店请求参数
|
||
type CreateStoreParam struct {
|
||
BaseInfo
|
||
BusinessData string `json:"business_data"` // 门店基础数据
|
||
}
|
||
|
||
// 创建门店基础数据
|
||
type CreateStoreBaseInfo struct {
|
||
BranchShopName string `json:"branch_shop_name"` // 门店主店名 必填
|
||
ContactPhone string `json:"contact_phone"` // 门店联系方式
|
||
OwnerIDPicFrontHash string `json:"owner_id_pic_front_hash"` // 身份证正面
|
||
BusinessLicencePicHash string `json:"business_licence_pic_hash"` // 营业执照图片
|
||
Longitude float64 `json:"longitude"` // 门店经度(0-18)
|
||
Latitude float64 `json:"latitude"` // 门店纬度(0-90)
|
||
OutShopCode string `json:"out_shop_code"` // 外部门店编码
|
||
CategoryID string `json:"category_id"` // 门店类目
|
||
HandheldLicencePicHash string `json:"handheld_licence_pic_hash"` // 门店拥有人手持身份证、营业执照图片
|
||
CreditCode string `json:"credit_code"` // 统一社会信用代码
|
||
SettlementModel string `json:"settlement_model"` // 1:实时结算; 2:账期结算;默认为1,若为账期结算,需额外传入结算账号id
|
||
SettlementAccountID string `json:"settlement_account_id"` // 门店结算账号id
|
||
OwnerIDNum string `json:"owner_id_num"` // 门店拥有人身份证号
|
||
FoodLicensePicHash string `json:"food_license_pic_hash"` // 食品安全执照图片(食品经营必传)
|
||
HeadShopName string `json:"head_shop_name"` // 门店主店名
|
||
Address string `json:"address"` // 门店地址
|
||
OwnerName string `json:"owner_name"` // 门店拥有人姓名
|
||
ChainstoreType int `json:"chainstore_type"` // 门店类型 1:正式门店;2:测试门店;默认为1
|
||
OwnerIDPicBackHash string `json:"owner_id_pic_back_hash"` // 身份证反面
|
||
PositionSource int `json:"position_source"` // 经纬度来源只支持高德(默认值3)
|
||
}
|
||
|
||
type GetStoreResult struct {
|
||
ChainStoreCode string `json:"chain_store_code"`
|
||
ChainStoreName string `json:"chain_store_name"`
|
||
Address string `json:"address"`
|
||
Latitude string `json:"latitude"`
|
||
Longitude string `json:"longitude"`
|
||
PositionSource int `json:"position_source"`
|
||
City string `json:"city"`
|
||
ContactPhone string `json:"contact_phone"`
|
||
ServiceCode string `json:"service_code"`
|
||
Status int `json:"status"` //1关店,2开店
|
||
}
|