160 lines
8.5 KiB
Go
160 lines
8.5 KiB
Go
package fnpsapi
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/platformapi"
|
||
"net/http"
|
||
"sync"
|
||
)
|
||
|
||
const (
|
||
ApiURL = "https://openic.sf-express.com" // 正式环境
|
||
RequestPost = "POST"
|
||
)
|
||
|
||
// 物品类型product_type枚举值:
|
||
const (
|
||
FastFood = 1 // 快餐
|
||
Drugs = 2 // 药品
|
||
DepartmentStore = 3 // 百货
|
||
OldClothes = 4 // 脏衣服收
|
||
NewClothes = 5 // 干净衣服派
|
||
Fresh = 6 // 生鲜
|
||
HighDrinks = 8 // 高端饮品
|
||
SiteInspection = 9 // 现场勘验
|
||
Express = 10 // 快递
|
||
File = 12 // 文件
|
||
Cake = 13 // 蛋糕
|
||
Flower = 14 // 鲜花
|
||
Digital = 15 // 数码
|
||
Clothing = 16 // 服装
|
||
Car = 17 // 汽配
|
||
Jewellery = 18 // 珠宝
|
||
Pizza = 20 // 披萨
|
||
ChineseFood = 21 // 中餐
|
||
FreshwaterFresh = 22 // 水产
|
||
DirectDelivery = 27 // 专人直送
|
||
MidRangeDrinks = 32 // 中端饮品
|
||
ConvenienceStore = 33 // 便利店
|
||
Bakeries = 34 // 面包糕点
|
||
HotPot = 35 // 火锅
|
||
licence = 36 // 证照
|
||
Crayfish = 40 // 烧烤小龙虾
|
||
OtherInfo = 41 // 外部落地配
|
||
AlcoholAndTobacco = 47 // 烟酒行
|
||
AdultEroticaProducts = 48 // 成人用品
|
||
Other = 99 // 其他
|
||
)
|
||
|
||
// 注册请求api
|
||
type API struct {
|
||
devId string `json:"dev_id"`
|
||
devKey string `json:"dev_key"`
|
||
signature string `json:"sign"`
|
||
pushTime int64 `json:"push_time"`
|
||
locker sync.RWMutex
|
||
client *http.Client
|
||
config *platformapi.APIConfig
|
||
}
|
||
|
||
/************************************************订单*****************************************************/
|
||
//#region 获取蜂鸟门店信息
|
||
|
||
// CreateOrder 创建订单(店铺)
|
||
type CreateOrder struct {
|
||
// 必填
|
||
DevId int64 `json:"dev_id"` // 同城开发者ID
|
||
ShopId string `json:"shop_id"` // 店铺ID
|
||
ShopOrderId string `json:"shop_order_id"` // 不允许重复(使用相同商家订单号会幂等返回)
|
||
OrderSource string `json:"order_source"` // 订单接入来源 1:美团;2:饿了么;3:百度;4:口碑;其他请直接填写中文字符串值
|
||
LbsType int `json:"lbs_type"` // 坐标类型 1:百度坐标,2:高德坐标
|
||
PayType int64 `json:"pay_type"` // 用户支付方式 1:已付款 0:货到付款
|
||
OrderTime int64 `json:"order_time"` // 用户下单时间 秒级时间戳
|
||
IsAppoint int `json:"is_appoint"` // 是否是预约单 0:非预约单;1:预约单
|
||
IsInsured int64 `json:"is_insured"` // 是否保价,0:非保价;1:保价
|
||
IsPriorityAssign int64 `json:"is_priority_assign"` // 是否优先派单,0:否 1:是
|
||
IsPersonDirect int64 `json:"is_person_direct"` // 是否是专人直送订单,0:否;1:是
|
||
PushTime int64 `json:"push_time"` // 推单时间 秒级时间戳
|
||
Version int64 `json:"version"` // 版本号 参照文档主版本号填写 如:文档版本号1.7,version=17
|
||
Receive *ReceiveAddress `json:"receive"` // 收货人信息
|
||
Shop *SfShopInfo `json:"shop"` // 发货店铺信息 Obj,详见shop结构, 平台级开发者(如饿了么)需传入如无特殊说明此字段可忽略
|
||
OrderDetail *OrderDetails `json:"order_detail"` // 订单详情
|
||
MultiPickupInfo []*MultiPickupDetails `json:"multi_pickup_info"` // 多点取货信息
|
||
// 非必填
|
||
ShopType int64 `json:"shop_type"` // 店铺ID类型 1:顺丰店铺ID ;2:接入方店铺ID
|
||
ShopPreparationTime int64 `json:"shop_preparation_time"` // 商家预计备餐时长(分10)
|
||
OrderSequence string `json:"order_sequence"` // 取货序号 与order_source配合使用 如:饿了么10号单,表示如下:order_source=2;order_sequence=10。用于骑士快速寻找配送物
|
||
AppointType int `json:"appoint_type"` // 预约单类型 预约单的时候传入,1:预约单送达单;2:预约单上门单
|
||
ExpectTime int64 `json:"expect_time"` // 用户期望送达时间 若传入自此段且时间大于配送时效,则按照预约送达单处理,时间小于配送时效按照立即单处理;appoint_type=1时需必传,秒级时间戳;
|
||
ExpectPickupTime int64 `json:"expect_pickup_time"` // 用户期望上门时间 appoint_type=2时需必传,秒级时间戳
|
||
ShopExpectTime int64 `json:"shop_expect_time"` // 商家期望送达时间 只展示给骑士,不参与时效考核;秒级时间戳
|
||
Vehicle int `json:"vehicle"` // 配送交通工具,0:否;1:电动车;2:小轿车
|
||
DeclaredValue int64 `json:"declared_value"` // 保价金额(单位:分)
|
||
GratuityFee int64 `json:"gratuity_fee"` // 订单小费,不传或者传0为不加小费 单位分,加小费最低不能少于100分
|
||
Remark string `json:"remark"` // 订单备注
|
||
RiderPickMethod int64 `json:"rider_pick_method"` // 物流流向 1:从门店取件送至用户; 2:从用户取件送至门店
|
||
ReturnFlag int `json:"return_flag"` // 返回字段控制标志位(二进制) 1:商品总价格,2:配送距离,4:物品重量,8:起送时间,16:期望送达时间,32:支付费用,64:实际支付金额,128:优惠券总金额,256:结算方式 例如全部返回为填入511
|
||
|
||
}
|
||
|
||
// 发货店铺信息,必填
|
||
type SfShopInfo struct {
|
||
ShopName string `json:"shop_name"` // 店铺名称
|
||
ShopPhone string `json:"shop_phone"` // 店铺电话
|
||
ShopAddress string `json:"shop_address"` // 店铺地址
|
||
ShopLng string `json:"shop_lng"` // 店铺经度
|
||
ShopLat string `json:"shop_lat"` // 店铺纬度
|
||
}
|
||
|
||
// 收货人信息
|
||
type ReceiveAddress struct {
|
||
// 必填
|
||
UserName string `json:"user_name"` // 用户姓名
|
||
UserPhone string `json:"user_phone"` // 用户电话
|
||
UserAddress string `json:"user_address"` // 用户地址
|
||
UserLng string `json:"user_lng"` // 用户经度
|
||
UserLat string `json:"user_lat"` // 用户纬度
|
||
// 非必填
|
||
CityName string `json:"city_name"` // 发单城市
|
||
}
|
||
|
||
// 订单详情
|
||
type OrderDetails struct {
|
||
// 必填
|
||
TotalPrice int64 `json:"total_price"` // 订单金额 分
|
||
ProductType int64 `json:"product_type"` // 物品类型 枚举值见下面定义
|
||
WeightGram int64 `json:"weight_gram"` // 物品重量(单位:克)
|
||
ProductNum int64 `json:"product_num"` // 物品个数
|
||
ProductTypeNum int64 `json:"product_type_num"` // 物品种类个数
|
||
ProductDetail []*ProductDetail `json:"product_detail"` // 物品详情;数组结构,详见product_detail结构
|
||
// 非必填
|
||
UserMoney int64 `json:"user_money"` // 用户实付商家金额(单位:分)
|
||
ShopMoney int `json:"shop_money"` // 商家实收用户金额(单位:分)
|
||
VolumeLitre int64 `json:"volume_litre"` // 物品体积(单位:升)
|
||
DeliveryMoney int64 `json:"delivery_money"` // 商家收取用户的配送费(单位:分)
|
||
}
|
||
|
||
// 购买物品详情清单
|
||
type ProductDetail struct {
|
||
// 必填
|
||
ProductName string `json:"product_name"` // 物品名称
|
||
ProductNum int64 `json:"product_num"` // 物品数量
|
||
// 非必填
|
||
ProductId int64 `json:"product_id"` // 物品ID
|
||
ProductPrice int64 `json:"product_price"` // 物品价格
|
||
ProductUnit string `json:"product_unit"` // 物品单位
|
||
ProductRemark string `json:"product_remark"` // 备注
|
||
ItemDetail string `json:"item_detail"` // 详情
|
||
}
|
||
|
||
// 取货地址详情
|
||
type MultiPickupDetails struct {
|
||
PickupShopAddress string `json:"pickup_shop_address"` // 取货点地址
|
||
PickupShopPhone string `json:"pickup_shop_phone"` // 取货点店铺手机号
|
||
PickupShopName string `json:"pickup_shop_name"` // 取货点店铺名称
|
||
PickupLng string `json:"pickup_lng"` // 取货点经度
|
||
PickupLat string `json:"pickup_lat"` // 取货点纬度
|
||
PickupProducts string `json:"pickup_products"` // 取货点店铺物品信息
|
||
}
|
||
|
||
//#endregion
|