叮点跑腿系统第三方接入教程

3,008 阅读2分钟

开源项目地址:gitee.com/yaozy717/dd…

一、第三方接入介绍

  • 本系统支持第三方系统发单到本系统。如某餐饮系统,订餐服务需要大量的派送服务,即可将派送服务接入本系统。

二、接入流程

1.添加第三方应用

  • 应用名称:用于识别接入的应用
  • api_key:系统自动生成-将作为第三方应用唯一识别
  • 设置ip白名单:只有白名单内的ip可以访问此接口,设置为“*”,表示所有ip均可访问
  • 回调地址:订单状态改变时会将,会将状态信息发送到第三方应用

2.查询配送价格

# x.x.x.x 表示你服务器的域名
# 请求方式POST 
https://x.x.x.x/opentp/v1/cost/calculation
请求参数
参数属性 类型 必填 说明
app_key string 应用的密钥
startAddress string 起点地址,是一个object,请求时,将它转成string类型
endAddress string 终点地址,是一个object,请求时,将它转成string类型
service_type string 服务类型,仅支持“帮我送”,“帮我去”,“代驾”
weight int 产品的重量(单位:g)
startAddress与endAddress参数表
属性 类型 必填 说明
formatted_addresse string 经格式化后的地址
province string 省份
city string 城市
district string 区/县
latitude float 纬度(gcj02 )
longitude float 经度(gcj02 )
name string 联系人姓名
phone string 手机号
street_number string 街区号
address_detail string 详细地址
返回值说明
属性 类型 说明
errno int 等于0说明请求成功,大于1000,请查看请求失败原因
totalPrice string 服务总费用
weightPrice float 重量产生的费用
start.startDistance int 起送价距离
start.startPrice float 起送价格
excced.exccedDistance int 超出起送距离部分的距离
excced.exccedPrice float 超出起送距离部分的价格
请求示例
$.ajax({
    url: 'https://x.x.x.x/opentp/v1/cost/calculation',
    type: 'POST',
    data:{
        app_key: '61e080ab-3830-4316-955c-dd7eec82b1',
        startAddress: '{"street_number":"千秋东街1号","formatted_addresse":"德清县人民政府(云岫北路西)","province":"浙江省","city":"湖州市","district":"德清县","phone":"18858589595","latitude":30.54269,"longitude":119.97754}',
        endAddress: '{"formatted_addresse":"D Iinx酒吧","province":"浙江省","city":"湖州市","district":"德清县","latitude":30.539268,"longitude":119.967952,"phone":"17758585959","name":"qwe","street_number":"余英坊7幢1-10号1楼","address_detail":""}',
        service_type: '帮我送',
        weight: 500
    },
    success(res){
        console.log(res)
    },
    fail(res){
        console.log(res)
    }
})

3.发布一个服务订单

# 请求方式POST 
https://x.x.x.x/opentp/v1/order/place
请求参数与上面一模一样
返回值说明
属性 类型 说明
errno int 等于0说明请求成功,大于1000,请查看请求失败原因
data.order_id int 本系统订单的ID
data.out_trade_no string 通用订单编号
data.totalFee float 服务价格