The article "Oto Catering app real-time order tracking System Architecture Design" article.
After the user generates a takeaway order, you can send a text message to inform the store to have an order, but the shortcomings of the SMS method is very obvious, if you want to let users and websites know that the store to accept orders and other operations need site human intervention, which is not available before the smartphone, those takeout sites such operations are understandable, But the smartphone has been out for so many years, and now some of the takeout sites are still operating so I am difficult to understand. The last time I used "hungry" the next takeaway orders, after the order, hungry customer service immediately call to confirm the order, I do not know whether the customer service after confirmation call to the store to notify the order. I am also very dissatisfied with this experience, not satisfied with the process, not the service.
It's a little far away.
5.2.1 User app submits order business logic layer:
Order.sethowmuch (total);
Order.setmenu (menulist);
Order.setordertype (0x001); The representative is the takeaway order
Order.setpaytype (0x002); Alipay Online Payment
order.setuser_id (1/*integer.parseint (Mapplication.getmuser () getId ()) */);
Send the order out
orderserver orderserver = new Orderserver ();
Orderserver.dealorder (order,new Asynchttpresponsehandler () {
@Override public
void Onsuccess (String Response) {
if (!response.equals ("0"))
{
log.i ("takeawaycommitactivity", "Submit order succeeded" + response);
StartActivity (New Intent (Takeawaycommitactivity.this,paysuccessactivity.class));
Finish ();
}
}
@Override public
void OnFailure (throwable error, String content) {
}
});
Network communication layer
Package com.cmyy.httpServer;
Import Com.cmyy.model.Order;
Import Com.cmyy.util.HttpUtil;
Import Com.google.gson.Gson;
Import com.loopj.android.http.AsyncHttpClient;
Import Com.loopj.android.http.AsyncHttpResponseHandler;
Import Com.loopj.android.http.RequestParams;
Import Com.loopj.android.http.ResponseHandlerInterface;
Order Form Operation Public
class Orderserver {
//Generate order public
void Dealorder (Order Order,asynchttpresponsehandler ResponseHandler)
{
Gson Gson = new Gson ();
String JSON = Gson.tojson (order);
String posturl=httputil.order_action;
Asynchttpclient orderrequest = new Asynchttpclient ();
Orderrequest.post (Posturl,responsehandler);
Requestparams prarms = new Requestparams ();
Prarms.put ("req", JSON);
Orderrequest.post (PostURL, prarms, ResponseHandler);
}
}
Communication Protocol Model
Order
Package Com.cmyy.model;
Import java.util.ArrayList; Order list public class Order {private Double howmuch; Consumption amount private arraylist<commitmenu> menu; Consumption of the dishes private bussiness bussiness;//merchant private String Checkcode; Verification code private int ordertype; Order type orders are divided into 3 types: 1. Take out 2. Reservation 3. private int paytype; Payment type Payment type is divided into: 1. Alipay 2. NET Silver 3. Meal to payment private int user_id;
User ID public int getuser_id () {return user_id;
} public void setuser_id (int user_id) {this.user_id = user_id;
} public int Getordertype () {return ordertype;
} public void Setordertype (int ordertype) {this.ordertype = OrderType;
} public int Getpaytype () {return paytype;
} public void Setpaytype (int paytype) {this.paytype = PayType;
} public bussiness getbussiness () {return bussiness;
} public void Setbussiness (bussiness bussiness) {this.bussiness = bussiness;
} public String Getcheckcode () {return checkcode; } public void Setcheckcode (String checkcode) {this.checkcode = Checkcode;
} public double Gethowmuch () {return howmuch;
} public void Sethowmuch (double howmuch) {This.howmuch = Howmuch;
} public arraylist<commitmenu> GetMenu () {return menu;
} public void SetMenu (arraylist<commitmenu> menu) {this.menu = menu;
}
}
Menu
Package Com.cmyy.model;
Import java.io.Serializable;
Meal list public class Menu implements serializable{private static final long serialversionuid = 1L;
fields private Integer ID;
Private String Cainame;
Private String decsrible;
Private String Imagespath;
Private Integer Commentcount;
Private Integer Bussinessid;
Private Integer count;
Private Integer Categorizeid;
Private Integer Price;
Private String ImagesPath3;
Private String ImagesPath5;
Private String ImagesPath4;
Private String imagesPath2;
Private String imagesPath1;
Private String categorize;
Constructors public String Getcategorize () {return categorize;
} public void Setcategorize (String categorize) {this.categorize = categorize; }/** default Constructor */Public menu () {}/** minimal constructor * * Public menu (Integer ID) {this.id
= ID; /** Full Constructor */public Menu (Integer ID, string cainame, String decsrible, StrinG Imagespath, Integer commentcount, Integer bussinessid, integer count, integer categorizeid, integer price, Strin
G ImagesPath3, String ImagesPath5, String ImagesPath4, String imagesPath2, String imagesPath1) {this.id = ID;
This.cainame = Cainame;
this.decsrible = decsrible;
This.imagespath = Imagespath;
This.commentcount = Commentcount;
This.bussinessid = Bussinessid;
This.count = count;
This.categorizeid = Categorizeid;
This.price = Price;
This.imagespath3 = ImagesPath3;
This.imagespath5 = ImagesPath5;
This.imagespath4 = ImagesPath4;
This.imagespath2 = ImagesPath2;
This.imagespath1 = imagesPath1;
}//Property accessors Public Integer getId () {return this.id;
} public void SetId (Integer id) {this.id = ID;
} public String Getcainame () {return this.cainame;
} public void Setcainame (String cainame) {this.cainame = Cainame;
} public String getdecsrible () {return this.decsrible; } public void setdecsrible (String decsrible) {this.decsrible = decsrible;
} public String Getimagespath () {return this.imagespath;
} public void Setimagespath (String imagespath) {this.imagespath = Imagespath;
} public Integer Getcommentcount () {return this.commentcount;
} public void Setcommentcount (Integer commentcount) {this.commentcount = Commentcount;
} public Integer Getbussinessid () {return this.bussinessid;
} public void Setbussinessid (Integer bussinessid) {this.bussinessid = Bussinessid;
} public Integer GetCount () {return this.count;
} public void SetCount (Integer count) {this.count = count;
} public Integer Getcategorizeid () {return this.categorizeid;
} public void Setcategorizeid (Integer categorizeid) {This.categorizeid = Categorizeid;
} public Integer GetPrice () {return this.price;
The public void Setprice (Integer price) {this.price = Price; } public String GetimaGesPath3 () {return this.imagespath3;
} public void SetImagesPath3 (String imagesPath3) {this.imagespath3 = ImagesPath3;
} public String GetImagesPath5 () {return this.imagespath5;
} public void SetImagesPath5 (String imagesPath5) {this.imagespath5 = ImagesPath5;
} public String GetImagesPath4 () {return this.imagespath4;
} public void SetImagesPath4 (String imagesPath4) {this.imagespath4 = ImagesPath4;
} public String GetImagesPath2 () {return this.imagespath2;
} public void SetImagesPath2 (String imagesPath2) {this.imagespath2 = ImagesPath2;
} public String GetImagesPath1 () {return this.imagespath1;
} public void SetImagesPath1 (String imagesPath1) {this.imagespath1 = imagesPath1;
}
}
5.2.2 Web server receive orders
The Web server receives the order, generates the order sequence number, writes to the database, and forwards the necessary information for the order to the store app.
The Web server uses the Java EE SSH framework. Originally e-Commerce Web site with PHP should be better.
Package cmyy.web.action.user;
Import java.io.IOException;
Import Org.apache.struts2.ServletActionContext;
Import Org.ddpush.im.util.StringUtil;
Import Org.ddpush.im.v1.client.appserver.Pusher;
Import Com.google.gson.Gson;
Import Com.google.gson.reflect.TypeToken;
Import Cmyy.domain.bussiness.BussinessOrder;
Import Cmyy.domain.bussiness.Order;
Import Cmyy.utils.MD5Utils;
Import cmyy.web.action.base.BaseAction;
Import Javax.servlet.http.HttpServletRequest;
Order submission public class Orderaction extends baseaction{private httpservletrequest req;
public void Ordersubmit () {req = Servletactioncontext.getrequest ();
Gson Gson = new Gson ();
Order order = Gson.fromjson (Req.getparameter ("req"), new Typetoken<order> () {}.gettype ());
Forward to the tracking server to push to the corresponding store byte[] bussinessid = null;
try {bussinessid = Stringutil.md5byte (string.valueof (Order.getbussiness (). GetId ())); } catch (Exception E1) {//TODO auto-generated catch block E1.printstacktrace ();
}//Store id pusher pusher = null;
Bussinessorder Bussinessorder = new Bussinessorder ();
Bussinessorder.setorder_uuid ("Dajldahgiahlajl");
The try {//push server IP address can be placed in the configuration file, where the value is temporarily written pusher = new Pusher ("127.0.0.1", 9999, 1000*5);
Boolean result = Pusher.push0x20message (Bussinessid,gson.tojson (Bussinessorder). GetBytes ());
if (result) {System.out.println ("Common Information sent successfully"); }else{System.out.println ("Send failed.
Format is incorrect ");
}} catch (Exception e) {//TODO auto-generated catch block E.printstacktrace ();
}//Generate order number information try {outprint (Req.getparameter ("req"));
} catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
}
}
}
5.2.3 Push server to receive orders and forward
5.2.4 Store app receiving orders