Files
baseapi/platformapi/sfps/sf_base.go
2025-11-21 09:09:09 +08:00

160 lines
8.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"` // 是否是专人直送订单01
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"` // 配送交通工具01电动车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