订餐系统之同步饿了么商家订单

      随着阿里入主饿了么,我们一个配送口碑外卖订单的客户,正在步入正轨,人员齐整,训练有素... 但,突然一下子失去的所有订单来源,没有订单,也就没有了收入,线上7,8个客服,线下近100个配送员,只能开始寻找新的活计了...偶然想起,早年间公司给口碑外卖1.0做打印机时,刚基本完成时,口碑外卖没了,没想到几年后,口碑外卖2.0又深深的伤害了我们一次。。。陈年旧事,唏嘘两下,回归正文。

 

背景

   之前实时获取口碑外卖商家订单,及点点送订单,再使用的我们的调度系统统一调度各个来源的订单,再结合配送员自主抢单,加上配送员队长线上调度,最大限度的让配送员加”顺路单“,提高效率...这套班子不应该因为口碑没了,就变成破铜废铁。暮然回首,原来饿了么也有商户接口,虽然没有淘宝外卖开放平台那么强大,提供好几种语言的示例代码,没有怎么办?自己动手,丰衣足食!

  动手之前,还是偷懒的百度了下,以为能找到一些基础代码,或者借鉴之类的,也不知道是没人用呢,还是没人分享... 真没有,有的话,估计也没有这篇文章了。

  虽然,我们更想能有锋鸟配送的接口,现实总是那么实现,真没有,那权且用商户的接口了解这个流程吧,日后,如果他们能开放配送商接口,估计代码也能用上。

准备工作

  

  API 文档 http://merchant.openapi.eleme.io/

      估计大部分程序员,知道上面这个地址就可以了哈,最后有代码哦。

    文档中 有一个要注意的地方就是  consumer key,这个目前是通过发送邮件获取的,邮件里写上商家的访问地址就可以了,如下图(图一),另外,邮件中还提到接单方式的修改,操作如图二

      

                                                                        (图一)

 

     

 

  

   虽然,他们提供了一个 可以测试的商家,但是我好几个浏览器都测试了,下订单就提示让我加地址,如图3,我的内心几乎是崩溃,最后让一个客户给了我一个账号才勉强抚慰了一下受伤的心。如果你样要测试,还是用正式的商家吧,我敢保证你们奔溃。

     

      

 

你们熟悉的代码

   代码方面,目前实现了两个主要接口:获取新订单,订单详情两个接口。其他接口也都差不多了。代码写得不好,若蒙斧正,不胜感激。

   代码结构如下

   

 

  baseEleAPI.cs 实现签名,生成请求的url等功能。

  NewOrdersInfo.cs 获取新订单对应的实体

    eleOrder.cs  获取订单详情对应的实体

  EleUtil.cs 配置 consumer_key,consumer_secret 及一些 工具之类的方法。

      HttpHelper.cs  看名称就知道了,这是使用了别人的类,里面有原作者信息。

  

  代码里就一个地方要注意下,生成签名时,每个数据都是转成小写的。

  结尾部分有 demo 下载。  

 

成功获取数据

  当看日志输出下面的信息时,我知道已经已经胜利在望了,集成了这么多接口,流程基本都差不多,个把小时弄好了,当然,要实现所有接口,让订单跑起来,还有很多工作要做,等后面有空了,再完善下。当然,更多希望有人能用上这个。

  

2016-05-14 17:43:28 returnmsg={"message":"ok","code":200,"data":{"original_price":58.0,"restaurant_name":"沈蔬果店 ","status_code":2,"restaurant_id":860035,"service_fee":7.5,"consignee":"张一平","invoice":"","description":"","user_id":24086157,"delivery_geo":"24.46839,118.09094","detail":{"abandoned_extra":[],"group":[[{"category_id":1,"name":"鲜切红心火龙果~1斤装","price":24.0,"sale_mode":0,"specs":[],"garnish":[],"id":82727401,"quantity":1},{"category_id":1,"name":"三拼果盘","price":12.0,"sale_mode":0,"specs":[],"garnish":[],"id":82727363,"quantity":1},{"category_id":1,"name":"云霄枇杷之乡","price":18.0,"sale_mode":0,"specs":[],"garnish":[],"id":82727558,"quantity":1}]],"extra":[{"description":"","quantity":1,"price":-10.0,"stats_quantity":1,"category_id":12,"type":102,"id":10087364,"name":"在线支付立减优惠"},{"description":"","price":4.0,"name":"配送费","category_id":2,"id":-10,"quantity":1},{"description":"","price":-7.0,"name":"使用红包","category_id":13,"type":0,"id":194098285927,"quantity":1}]},"active_at":"2016-05-13 22:54:30","invoiced":0,"user_name":"32b93b42c","deliver_fee":0,"is_book":0,"restaurant_part":4.0,"deliver_time":null,"order_id":"100646048067066976","eleme_part":6.0,"income":42.5,"restaurant_number":3,"address":"百脑汇科技大厦1906","hongbao":-7.0,"is_online_paid":1,"delivery_poi_address":"百脑汇科技大厦1906(福建省厦门市思明)","total_price":41.0,"created_at":"2016-05-13 22:53:48","service_rate":0.15,"package_fee":0,"activity_total":10.0,"phone_list":["1361092"]},"request_id":"b32835ae1f8040409624274d924860f0"}
2016-05-14 17:43:28 订单数据:百脑汇科技大厦1906 delivertime=

结语

  商家接口到这里就告一段落了,对于平台配送的,估计意见也不是很大,但对于单个商家,或者连锁商家还是非常有用的,如果他们在几个平台都开店了,订单能合在一起,不管是配送,还是统计就是非常有意义,也不用开着几个平台的商户端了。听着烦人的,您有新的饿了么订单,您有的百度订单,您有新的美团外卖订单...

  接下来,我会关注下其他平台的商户接口,有新的进展会,再分享给大家,我坚信:予人玫瑰 手有余香。

 

  demo 就在这里,扫码加好友,哈哈,主要为了交朋友哈.

  

  

     成为一名优秀的程序员!

转载于:https://my.oschina.net/jijunjian/blog/675782

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class system extends JFrame { JDesktopPane deskpane = new JDesktopPane();//在窗体里建立虚拟桌 JPanel p = new JPanel();//创建一个面板并实例化 public system(){//构造函数 setTitle("订单管理系统");//设置窗体标题 Container con = getContentPane(); con.setLayout(new BorderLayout());//创建一个布局 con.add(deskpane,BorderLayout.CENTER);//实例虚拟桌面的布局 Font f =new Font("新宋体",Font.PLAIN,12); JMenuBar mb = new JMenuBar();//实例化菜单栏 mb.setOpaque(true); setJMenuBar(mb); mb.setOpaque(true); setJMenuBar(mb); JMenu systemM = new JMenu("系统管理"); systemM.setFont(f); mb.add(systemM); JMenuItem land = new JMenuItem("重新登陆"); land.setFont(f); JMenuItem exit = new JMenuItem("退出系统"); exit.setFont(f); systemM.add(land); systemM.add(exit); JMenu userM = new JMenu("用户管理"); userM.setFont(f); mb.add(userM); JMenuItem password = new JMenuItem("密码修改"); password.setFont(f); JMenuItem addDelete = new JMenuItem("添加/删除用户"); addDelete.setFont(f); userM.add(password); userM.add(addDelete); JMenu mesM = new JMenu("信息管理"); mesM .setFont(f); mb.add(mesM ); JMenu addM= new JMenu("添加信息"); addM.setFont(f); JMenu viewM = new JMenu("查看信息"); viewM.setFont(f); JMenu modifM = new JMenu("修改信息"); modifM.setFont(f); JMenu deleteM = new JMenu("删除信息"); deleteM.setFont(f); mesM.add(addM); mesM.add(viewM); mesM.add(modifM); mesM.add(deleteM); JMenuItem addgoods = new JMenuItem("添加商品信息"); addgoods.setFont(f); addM.add(addgoods); JMenuItem addclient = new JMenuItem("添加客户信息"); addclient.setFont(f); addM.add(addclient); JMenuItem viewgoods= new JMenuItem("查看商品信息"); viewgoods.setFont(f); viewM.add(viewgoods); JMenuItem viewclient = new JMenuItem("查看客户信息"); viewclient.setFont(f); viewM.add(viewclient); JMenuItem modifgoods = new JMenuItem("修改商品信息"); modifgoods.setFont(f); modifM.add(modifgoods); JMenuItem modifclient = new JMenuItem("修改用户信息"); modifclient.setFont(f); modifM.add(modifclient); JMenuItem deletegoods = new JMenuItem("删除商品信息"); deletegoods.setFont(f); deleteM.add(deletegoods); JMenuItem deleteclient = new JMenuItem("删除用户信息"); deleteclient.setFont(f); deleteM.add(deleteclient); JMenu orderM = new JMenu("订单管理"); orderM.setFont(f); mb.add(orderM); JMenuItem addO= new JMenuItem("添加订单"); addO.setFont(f); JMenuItem viewO = new JMenuItem("查看订单"); viewO.setFont(f); JMenuItem modifO = new JMenuItem("修改订单"); modifO.setFont(f); JMenuItem deleteO = new JMenuItem("删除订单"); deleteO.setFont(f); orderM.add(addO); orderM.add(viewO); orderM.add(modifO); orderM.add(deleteO); //主界面上标出学号、姓名、及所作系统名 JLabel jlabel1=new JLabel(); jlabel1.setFont(new Font("宋体",Font.BOLD,15)); //设置字体 jlabel1.setHorizontalAlignment(SwingConstants.CENTER); //设置位置 jlabel1.setText("简易订单管理系统学号:070810228" + " 姓名:廖太春指导老师:周老师"); jlabel1.setBounds(450,350, 200, 200); deskpane.add(jlabel1); password.addActionListener(new ActionListener(){//密码修改监听 public void actionPerformed(ActionEvent e){ System.out.println("修改密码"); deskpane.add(new modifpsw()); } }); land.addActionListener(new ActionListener(){//重新登陆监听 public void actionPerformed(ActionEvent e){ System.out.println("登录"); setVisible(false); new Land(); } }); addDelete.addActionListener(new ActionListener(){//添加/删除用户监听 public void actionPerformed(ActionEvent e){ deskpane.add(new AddDeleteUser()); } }); addgoods.addActionListener(new ActionListener(){//添加商品信息 public void actionPerformed(ActionEvent e){ deskpane.add(new addgoods()); } }); addclient.addActionListener(new ActionListener(){//添加用户信息 public void actionPerformed(ActionEvent e){ deskpane.add(new addclient()); } }); viewgoods.addActionListener(new ActionListener(){//查看商品信息 public void actionPerformed(ActionEvent e){ System.out.println("查看商品信息"); deskpane.add(new viewgoods()); } }); viewclient.addActionListener(new ActionListener(){//查看客户信息 public void actionPerformed(ActionEvent e){ System.out.println("查看客户信息"); deskpane.add(new viewclient()); } }); modifgoods.addActionListener(new ActionListener(){//修改商品信息 public void actionPerformed(ActionEvent e){ System.out.println("修改商品信息"); deskpane.add(new modifgoods()); } }); modifclient.addActionListener(new ActionListener(){//修改用户信息 public void actionPerformed(ActionEvent e){ System.out.println("修改用户信息"); deskpane.add(new modifclient()); } }); deletegoods.addActionListener(new ActionListener(){//删除商品信息 public void actionPerformed(ActionEvent e){ System.out.println("删除商品信息"); deskpane.add(new deletegoods()); } }); deleteclient.addActionListener(new ActionListener(){//删除用户信息 public void actionPerformed(ActionEvent e){ System.out.println("删除用户信息"); deskpane.add(new deleteclient()); } }); addO.addActionListener(new ActionListener(){//添加订单 public void actionPerformed(ActionEvent e){ deskpane.add(new addO()); } }); viewO.addActionListener(new ActionListener(){//查看订单 public void actionPerformed(ActionEvent e){ deskpane.add(new viewO()); } }); modifO.addActionListener(new ActionListener(){//修改订单 public void actionPerformed(ActionEvent e){ System.out.println("修改订单"); deskpane.add(new modifO()); } }); deleteO.addActionListener(new ActionListener(){//删除订单 public void actionPerformed(ActionEvent e){ System.out.println("/删除订单"); deskpane.add(new deleteO()); } }); exit.addActionListener(new ActionListener(){//退出系统监听 public void actionPerformed(ActionEvent e){ setVisible(false); } }); this.setBounds(200,200,700,600); setVisible(true); } public static void main(String[] args){ new Land(); } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值