├── .gitattributes
├── .gitignore
├── README.md
├── TakeOutBusinessGUI
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── mp3
│ └── ts.mp3
└── src
│ └── cn
│ ├── elb
│ ├── entity
│ │ ├── BusinessInfo.java
│ │ ├── CommodityInfo.java
│ │ ├── DataPackage.java
│ │ ├── Order.java
│ │ └── Request.java
│ ├── socket
│ │ └── SendData.java
│ ├── test
│ │ └── test.java
│ └── window
│ │ └── MainWindow.java
│ └── hjj
│ └── funnction
│ ├── MyThread.java
│ └── PlayMp3.java
├── TakeOutSystem.sql
├── TakeOutSystemCustomer
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── img
│ ├── login®ister.png
│ └── welcome.png
└── src
│ └── cn
│ └── elb
│ ├── entity
│ ├── BusinessInfo.java
│ ├── CommodityInfo.java
│ ├── CustomerInfo.java
│ ├── DataPackage.java
│ ├── Goods.java
│ ├── OrderformInfo.java
│ └── Request.java
│ ├── main_window
│ └── MainWindow.java
│ ├── socket
│ └── SendData.java
│ └── swing
│ └── refit
│ ├── BusinessMenu.java
│ ├── ImageJpanel.java
│ └── TakeOutBar.java
├── TakeOutSystemServer
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── TestData.txt
├── bin
│ └── pres
│ │ └── mao
│ │ └── business
│ │ ├── addcommodity.txt
│ │ ├── business.txt
│ │ ├── commodity.txt
│ │ └── orderTest.txt
├── config.properties
├── jdbc.properties
└── src
│ ├── cn
│ └── elb
│ │ ├── dao
│ │ ├── BusinessInfoDao.java
│ │ ├── CustomerInfoDao.java
│ │ └── impl
│ │ │ ├── BusinessInfoDaoImpl.java
│ │ │ └── CustomerInfoDaoImp.java
│ │ ├── entity
│ │ ├── BandIP.java
│ │ ├── BusinessInfo.java
│ │ ├── BusinessList.java
│ │ ├── CommodityInfo.java
│ │ ├── CommodityList.java
│ │ ├── Company.java
│ │ ├── CustomerInfo.java
│ │ ├── DataPackage.java
│ │ ├── Goods.java
│ │ ├── Order.java
│ │ ├── Orderform.java
│ │ ├── OrderformInfo.java
│ │ └── Request.java
│ │ ├── response
│ │ ├── MySocket.java
│ │ ├── Response.java
│ │ └── Server.java
│ │ ├── test
│ │ └── Test.java
│ │ └── util
│ │ └── JDBCutil.java
│ └── pres
│ └── mao
│ └── business
│ ├── OrderList.java
│ ├── Test.java
│ ├── addcommodity.txt
│ ├── business.txt
│ ├── commodity.txt
│ └── orderTest.txt
└── img
├── 不辣.png
├── 中杯可乐.png
├── 午餐肉.png
├── 华莱士炸鸡汉堡.png
├── 吉味双拼饭.png
├── 吉野家.png
├── 培根.png
├── 培根炒双蛋堡.png
├── 大杯可乐.png
├── 奥尔良烤翅.png
├── 娃娃菜.png
├── 小杯可乐.png
├── 张亮麻辣烫.png
├── 微辣.png
├── 必胜客.png
├── 招牌牛肉饭.png
├── 撒尿牛丸.png
├── 方便面.png
├── 杨铭宇黄焖鸡米饭.png
├── 欧式培根炒饭.png
├── 海鲜至尊披萨.png
├── 猪柳蛋堡.png
├── 皮蛋鸡肉粥.png
├── 粉丝.png
├── 老成都酸辣粉.png
├── 脆香油条.png
├── 蓉城担担面.png
├── 蓉李记.png
├── 蟹排.png
├── 西兰花.png
├── 超级至尊披萨.png
├── 重庆小面.png
├── 金针菇.png
├── 钵钵鸡.png
├── 香辣鸡腿堡.png
├── 鱼豆腐.png
├── 鳕鱼堡.png
├── 鸡丝凉面.png
├── 鸡米花.png
├── 鸡肉卷.png
├── 麦当劳.png
├── 麻辣.png
├── 黄焖鱼豆腐.png
└── 黄焖鸡米饭.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Java SE 项目 饿了吧外卖系统
2 | #### SQL和图片测试文件我已经上传到项目中了,使用需要开启HTTP服务器(80端口),把IMG文件夹放在网站根目录下。
3 | #### Eclipse 可以直接导入项目运行,数据库名elb 用户民root 密码root(可以在配置文件中修改)
4 |
5 | ------------
6 |
7 | 这个项目属于练手项目,还有许多的问题,适合初学Java SE 的同学练练手
8 | 相关知识:Json 、socket编程 、数据库......
9 | 数据交换使用Json格式
10 | 数据库使用MySql5.5
11 |
12 | ------------
13 | 我的邮箱 gy1024@aliyun.com
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ELBBusiness
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.8
12 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/mp3/ts.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/TakeOutBusinessGUI/mp3/ts.mp3
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/entity/BusinessInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 商家信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class BusinessInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = 1259992436081004014L;
16 | private int business_id;// 商家id
17 | private String business_name;// 商家名称
18 | private String business_picture;// 商家图片
19 | private String business_username;// 商家账号名
20 | private String business_password;// 商家密码
21 | public int getBusiness_id() {
22 | return business_id;
23 | }
24 |
25 | public void setBusiness_id(int business_id) {
26 | this.business_id = business_id;
27 | }
28 |
29 | public String getBusiness_name() {
30 | return business_name;
31 | }
32 |
33 | public void setBusiness_name(String business_name) {
34 | this.business_name = business_name;
35 | }
36 |
37 | public String getBusiness_picture() {
38 | return business_picture;
39 | }
40 |
41 | public void setBusiness_picture(String business_picture) {
42 | this.business_picture = business_picture;
43 | }
44 |
45 | public String getBusiness_username() {
46 | return business_username;
47 | }
48 |
49 | public void setBusiness_username(String business_username) {
50 | this.business_username = business_username;
51 | }
52 |
53 | public String getBusiness_password() {
54 | return business_password;
55 | }
56 |
57 | public void setBusiness_password(String business_password) {
58 | this.business_password = business_password;
59 | }
60 |
61 | public BusinessInfo(String business_username, String business_password) {
62 | super();
63 | this.business_username = business_username;
64 | this.business_password = business_password;
65 | }
66 |
67 | public BusinessInfo(String business_name, String business_picture, String business_username,
68 | String business_password) {
69 | super();
70 | this.business_name = business_name;
71 | this.business_picture = business_picture;
72 | this.business_username = business_username;
73 | this.business_password = business_password;
74 | }
75 |
76 | public BusinessInfo(int business_id, String business_name, String business_picture, String business_username,
77 | String business_password) {
78 | super();
79 | this.business_id = business_id;
80 | this.business_name = business_name;
81 | this.business_picture = business_picture;
82 | this.business_username = business_username;
83 | this.business_password = business_password;
84 | }
85 |
86 | public BusinessInfo() {
87 | super();
88 | }
89 |
90 | public BusinessInfo(int business_id, String business_name, String business_picture) {
91 | super();
92 | this.business_id = business_id;
93 | this.business_name = business_name;
94 | this.business_picture = business_picture;
95 | }
96 |
97 | @Override
98 | public String toString() {
99 | return business_name;
100 | }
101 |
102 | @Override
103 | public int hashCode() {
104 | final int prime = 31;
105 | int result = 1;
106 | result = prime * result + business_id;
107 | return result;
108 | }
109 |
110 | @Override
111 | public boolean equals(Object obj) {
112 | if (this == obj)
113 | return true;
114 | if (obj == null)
115 | return false;
116 | if (getClass() != obj.getClass())
117 | return false;
118 | BusinessInfo other = (BusinessInfo) obj;
119 | if (business_id != other.business_id)
120 | return false;
121 | return true;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/entity/CommodityInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 商品信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class CommodityInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = -849655420418323846L;
16 | private int commodity_id;// 商品id
17 | private String commodity_name;// 商品名称
18 | private double commodity_price;// 商品价格
19 | private String commodity_picture;// 商品图片
20 | private int business_id;// 商家id
21 |
22 | public int getCommodity_id() {
23 | return commodity_id;
24 | }
25 |
26 | public void setCommodity_id(int commodity_id) {
27 | this.commodity_id = commodity_id;
28 | }
29 |
30 | public String getCommodity_name() {
31 | return commodity_name;
32 | }
33 |
34 | public void setCommodity_name(String commodity_name) {
35 | this.commodity_name = commodity_name;
36 | }
37 |
38 | public double getCommodity_price() {
39 | return commodity_price;
40 | }
41 |
42 | public void setCommodity_price(double commodity_price) {
43 | this.commodity_price = commodity_price;
44 | }
45 |
46 | public String getCommodity_picture() {
47 | return commodity_picture;
48 | }
49 |
50 | public void setCommodity_picture(String commodity_picture) {
51 | this.commodity_picture = commodity_picture;
52 | }
53 |
54 | public int getBusiness_id() {
55 | return business_id;
56 | }
57 |
58 | public void setBusiness_id(int business_id) {
59 | this.business_id = business_id;
60 | }
61 |
62 | public CommodityInfo(int commodity_id, String commodity_name, double commodity_price, String commodity_picture,
63 | int business_id) {
64 | super();
65 | this.commodity_id = commodity_id;
66 | this.commodity_name = commodity_name;
67 | this.commodity_price = commodity_price;
68 | this.commodity_picture = commodity_picture;
69 | this.business_id = business_id;
70 | }
71 |
72 | public CommodityInfo() {
73 | super();
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | return commodity_name;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/entity/DataPackage.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import com.alibaba.fastjson.JSON;
4 |
5 | /**
6 | * 传输的数据包定义
7 | *
8 | * @author Mao_TP
9 | * @param
10 | *
11 | */
12 | public class DataPackage {
13 | private Request request;
14 | private E o;
15 |
16 | public DataPackage(Request request, E o) {
17 | super();
18 | this.request = request;
19 | this.o = o;
20 | }
21 |
22 | public Request getRequest() {
23 | return request;
24 | }
25 |
26 | public void setRequest(Request request) {
27 | this.request = request;
28 | }
29 |
30 | public E getO() {
31 | return o;
32 | }
33 |
34 | public void setO(E o) {
35 | this.o = o;
36 | }
37 |
38 | public String toJson() {
39 | return JSON.toJSONString(this);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/entity/Order.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import com.alibaba.fastjson.JSON;
7 |
8 | public class Order {
9 | private HashMap order = new HashMap<>();
10 |
11 | public HashMap getOrder() {
12 | return order;
13 | }
14 |
15 | public void setOrder(HashMap order) {
16 | this.order = order;
17 | }
18 |
19 | public void putOrder(CommodityInfo commodityInfo, int count) {
20 | this.order.put(commodityInfo, new Integer(count));
21 | }
22 |
23 | public Order() {
24 | }
25 |
26 | public Order(HashMap order) {
27 | super();
28 | this.order = order;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | String key = null;
34 | String value = null;
35 | for (Map.Entry entry : order.entrySet()) {
36 | key = key + entry.getKey().toString();
37 | value = value + entry.getValue().toString();
38 | }
39 | return "Order [order_key=" + key + "order_value=" + value + "]";
40 | }
41 |
42 | public String toJson() {
43 | return JSON.toJSONString(this);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/entity/Request.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | /**
4 | * 请求枚举类
5 | *
6 | * @author Mao_TP
7 | *
8 | */
9 |
10 | public enum Request {
11 | 初始化请求, 商家登录, 用户登录,用户注册, 商家信息修改, 用户信息修改, 订单提交, 订单修改, 商家查询订单, 用户订单查询,心跳包;
12 | }
13 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/socket/SendData.java:
--------------------------------------------------------------------------------
1 | package cn.elb.socket;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.io.OutputStream;
8 | import java.net.Socket;
9 | import java.net.UnknownHostException;
10 |
11 |
12 | import com.alibaba.fastjson.JSON;
13 |
14 | import cn.elb.entity.DataPackage;
15 |
16 | public class SendData {
17 | private static final String HOST="192.168.57.154";
18 | private static final int POST=8888;
19 | private static Socket socket;
20 | public static String sendData(DataPackage> dp){
21 | StringBuffer sb = null;
22 | try {
23 | socket = new Socket(HOST, POST);
24 | String str = JSON.toJSONString(dp);
25 | OutputStream os = socket.getOutputStream();
26 | InputStream is =socket.getInputStream();
27 | os.write(str.getBytes());
28 | socket.shutdownOutput();
29 | sb = new StringBuffer();
30 | BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
31 | String s ="";
32 | while((s=br.readLine())!=null){
33 | sb.append(s);
34 | }
35 |
36 | } catch (UnknownHostException e) {
37 | e.printStackTrace();
38 | } catch (IOException e) {
39 | e.printStackTrace();
40 | }finally{
41 | try {
42 | socket.close();
43 | } catch (IOException e) {
44 | e.printStackTrace();
45 | }
46 | }
47 | return sb.toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/test/test.java:
--------------------------------------------------------------------------------
1 | package cn.elb.test;
2 |
3 |
4 | import cn.hjj.funnction.PlayMp3;
5 |
6 | public class test {
7 |
8 | public static void main(String[] args) {
9 | for(int i =0;i<4;i++){
10 | new Thread(new PlayMp3()).start();
11 | try {
12 | Thread.sleep(5000);
13 | } catch (InterruptedException e) {
14 | e.printStackTrace();
15 | }
16 | }
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/elb/window/MainWindow.java:
--------------------------------------------------------------------------------
1 | package cn.elb.window;
2 |
3 | import java.awt.EventQueue;
4 | import java.awt.Font;
5 |
6 | import javax.swing.JFrame;
7 | import javax.swing.JPanel;
8 | import javax.swing.UIManager;
9 |
10 | import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
11 |
12 | import com.alibaba.fastjson.JSON;
13 | import com.alibaba.fastjson.TypeReference;
14 |
15 | import cn.elb.entity.BusinessInfo;
16 | import cn.elb.entity.DataPackage;
17 | import cn.elb.entity.Request;
18 | import cn.elb.socket.SendData;
19 | import cn.hjj.funnction.MyThread;
20 |
21 | import javax.swing.JScrollPane;
22 | import javax.swing.JButton;
23 | import javax.swing.JTextArea;
24 | import javax.swing.ScrollPaneConstants;
25 | import javax.swing.JTextField;
26 | import javax.swing.JLabel;
27 | import javax.swing.JOptionPane;
28 | import javax.swing.JPasswordField;
29 |
30 | public class MainWindow {
31 |
32 | private JFrame frame;
33 | private JTextField businessName;
34 | private JPasswordField businesspassword;
35 | private BusinessInfo businessInfo;
36 | private JButton loginbtn;
37 |
38 | /**
39 | * Launch the application.
40 | */
41 | public static void main(String[] args) {
42 | EventQueue.invokeLater(new Runnable() {
43 | public void run() {
44 | try {
45 | System.setProperty("sun.java2d.noddraw", "true");
46 | BeautyEyeLNFHelper.launchBeautyEyeLNF(); //皮肤美化包
47 | UIManager.put("RootPane.setupButtonVisible", false);
48 | MainWindow window = new MainWindow();
49 | window.frame.setVisible(true);
50 | } catch (Exception e) {
51 | e.printStackTrace();
52 | }
53 | }
54 | });
55 | }
56 |
57 | /**
58 | * Create the application.
59 | */
60 | public MainWindow() {
61 | initialize();
62 | }
63 |
64 | /**
65 | * Initialize the contents of the frame.
66 | */
67 | private void initialize() {
68 | frame = new JFrame();
69 | frame.setSize(500, 660);
70 | frame.setTitle("饿了吧卖家接单系统");
71 | frame.setLocationRelativeTo(null);//窗体居中显示
72 | frame.setResizable(false);//禁止拉伸
73 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
74 | JPanel jp = new JPanel();
75 | frame.getContentPane().add(jp);
76 | jp.setLayout(null);
77 |
78 |
79 | JScrollPane scrollPane = new JScrollPane();
80 | scrollPane.setBounds(10, 10, 431, 538);
81 | scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);//取消水平(左右滚动条)
82 | jp.add(scrollPane);
83 |
84 | JTextArea textArea = new JTextArea();
85 | textArea.setLineWrap(true);
86 | textArea.setEditable(false);
87 | textArea.setFont(new Font("黑体", 0, 15));
88 | scrollPane.setViewportView(textArea);
89 |
90 | loginbtn = new JButton("登录");
91 | loginbtn.setBounds(348, 554, 93, 23);
92 | jp.add(loginbtn);
93 | loginbtn.addActionListener(event ->{
94 | if(businessName.getText().equals("")&&businesspassword.getText().equals("")){
95 | JOptionPane.showMessageDialog(null,"输入框不能为空!","提示框",JOptionPane.ERROR_MESSAGE);
96 | }else{
97 | String str =SendData.sendData(new DataPackage(Request.商家登录,new BusinessInfo(businessName.getText(),businesspassword.getText())));
98 | DataPackage dp = JSON.parseObject(str,new TypeReference>(){});
99 | if(dp==null){
100 | JOptionPane.showMessageDialog(null,"账号或密码输入错误!","提示框",JOptionPane.ERROR_MESSAGE);
101 | }else{
102 | businessInfo = dp.getO();
103 | JOptionPane.showMessageDialog(null,"登录成功!等待接单!","提示框",JOptionPane.PLAIN_MESSAGE);
104 | new Thread(new MyThread(textArea,businessInfo)).start();
105 | }
106 | }
107 | });
108 |
109 | businessName = new JTextField();
110 | businessName.setBounds(63, 554, 120, 22);
111 | jp.add(businessName);
112 |
113 | JLabel label = new JLabel("账号");
114 | label.setBounds(20, 557, 54, 15);
115 | jp.add(label);
116 |
117 | JLabel label_1 = new JLabel("密码");
118 | label_1.setBounds(186, 557, 54, 15);
119 | jp.add(label_1);
120 |
121 | businesspassword = new JPasswordField();
122 | businesspassword.setBounds(223, 554, 111, 22);
123 | jp.add(businesspassword);
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/hjj/funnction/MyThread.java:
--------------------------------------------------------------------------------
1 | package cn.hjj.funnction;
2 |
3 | import java.util.HashMap;
4 | import java.util.Iterator;
5 | import java.util.Set;
6 |
7 | import javax.swing.JTextArea;
8 |
9 | import com.alibaba.fastjson.JSON;
10 | import com.alibaba.fastjson.TypeReference;
11 |
12 | import cn.elb.entity.BusinessInfo;
13 | import cn.elb.entity.CommodityInfo;
14 | import cn.elb.entity.DataPackage;
15 | import cn.elb.entity.Order;
16 | import cn.elb.entity.Request;
17 | import cn.elb.socket.SendData;
18 |
19 | public class MyThread implements Runnable{
20 | private JTextArea textArea;
21 | private BusinessInfo businessInfo;
22 | public MyThread(JTextArea textArea,BusinessInfo businessInfo) {
23 | this.textArea = textArea;
24 | this.businessInfo = businessInfo;
25 | }
26 | @Override
27 | public void run() {
28 | DataPackage dp = new DataPackage(Request.心跳包,businessInfo);
29 |
30 | while(true){
31 | String str =SendData.sendData(dp);
32 | System.out.println(str);
33 | Order order = JSON.parseObject(str,new TypeReference(){});
34 | if(order!=null){
35 | // Order order = res.getO();
36 | HashMap map = order.getOrder();
37 | Set set = map.keySet();
38 | StringBuffer sb = new StringBuffer();
39 | sb.append("新的订单!\n");
40 | sb.append("商品/数量\n").append("-------------------------------\n");
41 | Iterator ite = set.iterator();
42 | while (ite.hasNext()) {
43 | CommodityInfo c = ite.next();
44 | sb.append(c.toString()).append("---->").append(map.get(c)).append("份\n");
45 | }
46 | sb.append("\n").append("-------------------------------\n");
47 | textArea.append(sb.toString());
48 | new Thread(new PlayMp3()).start();
49 | }
50 | try {
51 | Thread.sleep(5000);
52 | } catch (InterruptedException e) {
53 | e.printStackTrace();
54 | }
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/TakeOutBusinessGUI/src/cn/hjj/funnction/PlayMp3.java:
--------------------------------------------------------------------------------
1 | package cn.hjj.funnction;
2 |
3 |
4 | import java.io.FileInputStream;
5 | import java.io.FileNotFoundException;
6 |
7 | import javazoom.jl.decoder.JavaLayerException;
8 | import javazoom.jl.player.Player;
9 |
10 | public class PlayMp3 implements Runnable{
11 | private Player player;
12 | public PlayMp3() {
13 | try {
14 | player = new Player(new FileInputStream("mp3/ts.mp3"));
15 | } catch (FileNotFoundException e) {
16 | e.printStackTrace();
17 | } catch (JavaLayerException e) {
18 | e.printStackTrace();
19 | }
20 | }
21 | @Override
22 | public void run() {
23 | try {
24 | player.play();
25 | } catch (JavaLayerException e) {
26 | e.printStackTrace();
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/TakeOutSystem.sql:
--------------------------------------------------------------------------------
1 | /*
2 | Navicat MySQL Data Transfer
3 |
4 | Source Server : php
5 | Source Server Version : 50553
6 | Source Host : localhost:3306
7 | Source Database : elb
8 |
9 | Target Server Type : MYSQL
10 | Target Server Version : 50553
11 | File Encoding : 65001
12 |
13 | Date: 2018-07-13 17:34:25
14 | */
15 |
16 | SET FOREIGN_KEY_CHECKS=0;
17 |
18 | -- ----------------------------
19 | -- Table structure for `business`
20 | -- ----------------------------
21 | DROP TABLE IF EXISTS `business`;
22 | CREATE TABLE `business` (
23 | `business_id` int(5) NOT NULL AUTO_INCREMENT COMMENT '商家id',
24 | `business_name` varchar(20) NOT NULL COMMENT '商家名称',
25 | `business_picture` varchar(2000) DEFAULT NULL COMMENT '商家图片',
26 | `business_username` varchar(20) NOT NULL COMMENT '商家账户名',
27 | `business_password` varchar(20) NOT NULL COMMENT '商家密码',
28 | PRIMARY KEY (`business_id`)
29 | ) ENGINE=InnoDB AUTO_INCREMENT=10008 DEFAULT CHARSET=utf8;
30 |
31 | -- ----------------------------
32 | -- Records of business
33 | -- ----------------------------
34 | INSERT INTO `business` VALUES ('10001', '华莱士炸鸡汉堡', null, 'hls', '123123');
35 | INSERT INTO `business` VALUES ('10002', '张亮麻辣烫', null, 'zlmlt', '123123');
36 | INSERT INTO `business` VALUES ('10003', '蓉李记', null, 'rlj', '123123');
37 | INSERT INTO `business` VALUES ('10004', '杨铭宇黄焖鸡米饭', '', 'ymyhmjmf', '123123');
38 | INSERT INTO `business` VALUES ('10005', '麦当劳', null, 'mdl', '123123');
39 | INSERT INTO `business` VALUES ('10006', '必胜客', null, 'bsk', '123123');
40 | INSERT INTO `business` VALUES ('10007', '吉野家', null, 'jyj', '123123');
41 |
42 | -- ----------------------------
43 | -- Table structure for `commodity`
44 | -- ----------------------------
45 | DROP TABLE IF EXISTS `commodity`;
46 | CREATE TABLE `commodity` (
47 | `commodity_id` int(9) NOT NULL AUTO_INCREMENT COMMENT '商品id',
48 | `commodity_name` varchar(20) NOT NULL COMMENT '商品名称',
49 | `commodity_price` double(6,2) NOT NULL COMMENT '商品价格',
50 | `commodity_picture` varchar(2000) DEFAULT NULL COMMENT '商品图片',
51 | `business_id` int(6) NOT NULL COMMENT '商家id',
52 | PRIMARY KEY (`commodity_id`),
53 | KEY `buid` (`business_id`) USING BTREE,
54 | CONSTRAINT `commodity_ibfk_1` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`)
55 | ) ENGINE=InnoDB AUTO_INCREMENT=1000040 DEFAULT CHARSET=utf8;
56 |
57 | -- ----------------------------
58 | -- Records of commodity
59 | -- ----------------------------
60 | INSERT INTO `commodity` VALUES ('1000001', '香辣鸡腿堡', '10.00', null, '10001');
61 | INSERT INTO `commodity` VALUES ('1000002', '鳕鱼堡', '13.00', null, '10001');
62 | INSERT INTO `commodity` VALUES ('1000003', '鸡肉卷', '12.00', null, '10001');
63 | INSERT INTO `commodity` VALUES ('1000004', '奥尔良烤翅', '15.00', null, '10001');
64 | INSERT INTO `commodity` VALUES ('1000005', '鸡米花', '15.00', null, '10001');
65 | INSERT INTO `commodity` VALUES ('1000006', '小杯可乐', '5.00', null, '10001');
66 | INSERT INTO `commodity` VALUES ('1000007', '中杯可乐', '7.00', null, '10001');
67 | INSERT INTO `commodity` VALUES ('1000008', '大杯可乐', '9.00', null, '10001');
68 | INSERT INTO `commodity` VALUES ('1000009', '鱼豆腐', '2.00', null, '10002');
69 | INSERT INTO `commodity` VALUES ('1000010', '娃娃菜', '1.80', null, '10002');
70 | INSERT INTO `commodity` VALUES ('1000011', '西兰花', '1.80', null, '10002');
71 | INSERT INTO `commodity` VALUES ('1000012', '金针菇', '2.00', null, '10002');
72 | INSERT INTO `commodity` VALUES ('1000013', '撒尿牛丸', '2.00', null, '10002');
73 | INSERT INTO `commodity` VALUES ('1000014', '培根', '2.00', null, '10002');
74 | INSERT INTO `commodity` VALUES ('1000015', '午餐肉', '2.00', null, '10002');
75 | INSERT INTO `commodity` VALUES ('1000016', '蟹排', '2.00', null, '10002');
76 | INSERT INTO `commodity` VALUES ('1000017', '方便面', '2.00', null, '10002');
77 | INSERT INTO `commodity` VALUES ('1000018', '粉丝', '2.00', null, '10002');
78 | INSERT INTO `commodity` VALUES ('1000019', '麻辣', '0.50', null, '10002');
79 | INSERT INTO `commodity` VALUES ('1000020', '微辣', '0.50', null, '10002');
80 | INSERT INTO `commodity` VALUES ('1000021', '不辣', '0.50', null, '10002');
81 | INSERT INTO `commodity` VALUES ('1000022', '蓉城担担面', '15.00', null, '10003');
82 | INSERT INTO `commodity` VALUES ('1000023', '重庆小面', '15.00', null, '10003');
83 | INSERT INTO `commodity` VALUES ('1000024', '鸡丝凉面', '12.00', null, '10003');
84 | INSERT INTO `commodity` VALUES ('1000025', '老成都酸辣粉', '15.00', null, '10003');
85 | INSERT INTO `commodity` VALUES ('1000026', '钵钵鸡', '20.00', null, '10003');
86 | INSERT INTO `commodity` VALUES ('1000027', '黄焖鸡米饭', '21.00', '', '10004');
87 | INSERT INTO `commodity` VALUES ('1000028', '黄焖鱼豆腐', '15.00', '', '10004');
88 | INSERT INTO `commodity` VALUES ('1000029', '培根炒双蛋堡', '14.00', null, '10005');
89 | INSERT INTO `commodity` VALUES ('1000030', '皮蛋鸡肉粥', '8.00', null, '10005');
90 | INSERT INTO `commodity` VALUES ('1000031', '猪柳蛋堡', '15.00', null, '10005');
91 | INSERT INTO `commodity` VALUES ('1000032', '脆香油条', '6.00', null, '10005');
92 | INSERT INTO `commodity` VALUES ('1000033', '超级至尊披萨', '98.00', null, '10006');
93 | INSERT INTO `commodity` VALUES ('1000034', '海鲜至尊披萨', '128.00', null, '10006');
94 | INSERT INTO `commodity` VALUES ('1000035', '欧式培根炒饭', '30.00', null, '10006');
95 | INSERT INTO `commodity` VALUES ('1000036', '吉味双拼饭', '20.00', null, '10007');
96 | INSERT INTO `commodity` VALUES ('1000037', '招牌牛肉饭', '28.50', null, '10007');
97 | INSERT INTO `commodity` VALUES ('1000039', 'asdf', '8.00', null, '10002');
98 |
99 | -- ----------------------------
100 | -- Table structure for `customer`
101 | -- ----------------------------
102 | DROP TABLE IF EXISTS `customer`;
103 | CREATE TABLE `customer` (
104 | `customer_id` int(5) NOT NULL COMMENT '用户id',
105 | `customer_name` varchar(20) DEFAULT NULL COMMENT '用户昵称(姓名)',
106 | `customer_address` varchar(40) DEFAULT NULL COMMENT '收货地址',
107 | `customer_username` varchar(20) NOT NULL COMMENT '用户账号名',
108 | `customer_password` varchar(20) NOT NULL COMMENT '用户密码',
109 | PRIMARY KEY (`customer_id`),
110 | KEY `customer_address` (`customer_address`) USING BTREE
111 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
112 |
113 | -- ----------------------------
114 | -- Records of customer
115 | -- ----------------------------
116 | INSERT INTO `customer` VALUES ('100001', '小明', null, 'xiaoming', '123456');
117 | INSERT INTO `customer` VALUES ('100002', '古月', null, 'hujiajun', 'hujiajun');
118 | INSERT INTO `customer` VALUES ('100003', null, null, 'maomao', 'asd');
119 | INSERT INTO `customer` VALUES ('100004', null, null, 'xuyuan', '123');
120 | INSERT INTO `customer` VALUES ('100006', null, null, 'xyssb', '123');
121 | INSERT INTO `customer` VALUES ('100007', null, null, 'aaa', 'aaa');
122 | INSERT INTO `customer` VALUES ('100008', null, null, 'wanglei', '123123');
123 |
124 | -- ----------------------------
125 | -- Table structure for `orderform`
126 | -- ----------------------------
127 | DROP TABLE IF EXISTS `orderform`;
128 | CREATE TABLE `orderform` (
129 | `order_id` int(8) NOT NULL COMMENT '订单id',
130 | `business_id` int(10) NOT NULL COMMENT '商家id',
131 | `customer_id` int(10) NOT NULL COMMENT '用户id',
132 | `order` varchar(5000) NOT NULL COMMENT '订单详情',
133 | `customer_address` varchar(40) DEFAULT NULL COMMENT '收货地址',
134 | `start_time` bigint(32) NOT NULL COMMENT '订单开始时间',
135 | `end_time` bigint(32) DEFAULT NULL COMMENT '订单完成时间',
136 | `status` int(1) NOT NULL COMMENT '订单状态',
137 | PRIMARY KEY (`order_id`),
138 | KEY `business_id` (`business_id`) USING BTREE,
139 | KEY `customer_id` (`customer_id`) USING BTREE,
140 | KEY `customer_address` (`customer_address`) USING BTREE,
141 | CONSTRAINT `orderform_ibfk_1` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`),
142 | CONSTRAINT `orderform_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`),
143 | CONSTRAINT `orderform_ibfk_3` FOREIGN KEY (`customer_address`) REFERENCES `customer` (`customer_address`)
144 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
145 |
146 | -- ----------------------------
147 | -- Records of orderform
148 | -- ----------------------------
149 | INSERT INTO `orderform` VALUES ('10000005', '10003', '100001', '{\"order\":{{\"business_id\":10003,\"commodity_id\":1000022,\"commodity_name\":\"蓉城担担面\",\"commodity_price\":15.0}:3,{\"business_id\":10003,\"commodity_id\":1000024,\"commodity_name\":\"鸡丝凉面\",\"commodity_price\":12.0}:4,{\"business_id\":10003,\"commodity_id\":1000023,\"commodity_name\":\"重庆小面\",\"commodity_price\":15.0}:3}}', null, '1531393106187', '0', '0');
150 | INSERT INTO `orderform` VALUES ('10000006', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:3,{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:3}}', null, '1531393106230', '0', '0');
151 | INSERT INTO `orderform` VALUES ('10000007', '10004', '100001', '{\"order\":{{\"business_id\":10004,\"commodity_id\":1000028,\"commodity_name\":\"黄焖鱼豆腐\",\"commodity_picture\":\"\",\"commodity_price\":15.0}:4}}', null, '1531393106255', '0', '0');
152 | INSERT INTO `orderform` VALUES ('10000008', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:3,{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:1}}', null, '1531394674346', '0', '0');
153 | INSERT INTO `orderform` VALUES ('10000009', '10003', '100001', '{\"order\":{{\"business_id\":10003,\"commodity_id\":1000022,\"commodity_name\":\"蓉城担担面\",\"commodity_price\":15.0}:5}}', null, '1531394674378', '0', '0');
154 | INSERT INTO `orderform` VALUES ('10000010', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:8}}', null, '1531443874112', '0', '0');
155 | INSERT INTO `orderform` VALUES ('10000011', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1}}', null, '1531444064597', '0', '0');
156 | INSERT INTO `orderform` VALUES ('10000012', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1}}', null, '1531444253425', '0', '0');
157 | INSERT INTO `orderform` VALUES ('10000013', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:3,{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1,{\"business_id\":10001,\"commodity_id\":1000003,\"commodity_name\":\"鸡肉卷\",\"commodity_price\":12.0}:1}}', null, '1531444324955', '0', '0');
158 | INSERT INTO `orderform` VALUES ('10000014', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000007,\"commodity_name\":\"中杯可乐\",\"commodity_price\":7.0}:4,{\"business_id\":10001,\"commodity_id\":1000006,\"commodity_name\":\"小杯可乐\",\"commodity_price\":5.0}:4,{\"business_id\":10001,\"commodity_id\":1000004,\"commodity_name\":\"奥尔良烤翅\",\"commodity_price\":15.0}:2}}', null, '1531444357300', '0', '0');
159 | INSERT INTO `orderform` VALUES ('10000015', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000007,\"commodity_name\":\"中杯可乐\",\"commodity_price\":7.0}:4,{\"business_id\":10001,\"commodity_id\":1000005,\"commodity_name\":\"鸡米花\",\"commodity_price\":15.0}:5,{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:4,{\"business_id\":10001,\"commodity_id\":1000003,\"commodity_name\":\"鸡肉卷\",\"commodity_price\":12.0}:3,{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:17,{\"business_id\":10001,\"commodity_id\":1000008,\"commodity_name\":\"大杯可乐\",\"commodity_price\":9.0}:4,{\"business_id\":10001,\"commodity_id\":1000006,\"commodity_name\":\"小杯可乐\",\"commodity_price\":5.0}:6,{\"business_id\":10001,\"commodity_id\":1000004,\"commodity_name\":\"奥尔良烤翅\",\"commodity_price\":15.0}:3}}', null, '1531444389971', '0', '0');
160 | INSERT INTO `orderform` VALUES ('10000016', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000008,\"commodity_name\":\"大杯可乐\",\"commodity_price\":9.0}:10,{\"business_id\":10001,\"commodity_id\":1000006,\"commodity_name\":\"小杯可乐\",\"commodity_price\":5.0}:17,{\"business_id\":10001,\"commodity_id\":1000007,\"commodity_name\":\"中杯可乐\",\"commodity_price\":7.0}:9}}', null, '1531444411307', '0', '0');
161 | INSERT INTO `orderform` VALUES ('10000017', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:4,{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:4}}', null, '1531444568033', '0', '0');
162 | INSERT INTO `orderform` VALUES ('10000018', '10002', '100001', '{\"order\":{{\"business_id\":10002,\"commodity_id\":1000011,\"commodity_name\":\"西兰花\",\"commodity_price\":1.8}:3,{\"business_id\":10002,\"commodity_id\":1000009,\"commodity_name\":\"鱼豆腐\",\"commodity_price\":2.0}:3,{\"business_id\":10002,\"commodity_id\":1000010,\"commodity_name\":\"娃娃菜\",\"commodity_price\":1.8}:3,{\"business_id\":10002,\"commodity_id\":1000012,\"commodity_name\":\"金针菇\",\"commodity_price\":2.0}:3}}', null, '1531444568047', '0', '0');
163 | INSERT INTO `orderform` VALUES ('10000019', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000007,\"commodity_name\":\"中杯可乐\",\"commodity_price\":7.0}:3,{\"business_id\":10001,\"commodity_id\":1000004,\"commodity_name\":\"奥尔良烤翅\",\"commodity_price\":15.0}:4,{\"business_id\":10001,\"commodity_id\":1000003,\"commodity_name\":\"鸡肉卷\",\"commodity_price\":12.0}:11,{\"business_id\":10001,\"commodity_id\":1000008,\"commodity_name\":\"大杯可乐\",\"commodity_price\":9.0}:3,{\"business_id\":10001,\"commodity_id\":1000002,\"commodity_name\":\"鳕鱼堡\",\"commodity_price\":13.0}:7,{\"business_id\":10001,\"commodity_id\":1000006,\"commodity_name\":\"小杯可乐\",\"commodity_price\":5.0}:3,{\"business_id\":10001,\"commodity_id\":1000005,\"commodity_name\":\"鸡米花\",\"commodity_price\":15.0}:3}}', null, '1531444639719', '0', '0');
164 | INSERT INTO `orderform` VALUES ('10000020', '10002', '100001', '{\"order\":{{\"business_id\":10002,\"commodity_id\":1000013,\"commodity_name\":\"撒尿牛丸\",\"commodity_price\":2.0}:5,{\"business_id\":10002,\"commodity_id\":1000012,\"commodity_name\":\"金针菇\",\"commodity_price\":2.0}:5,{\"business_id\":10002,\"commodity_id\":1000011,\"commodity_name\":\"西兰花\",\"commodity_price\":1.8}:5,{\"business_id\":10002,\"commodity_id\":1000014,\"commodity_name\":\"培根\",\"commodity_price\":2.0}:3}}', null, '1531444639736', '0', '0');
165 | INSERT INTO `orderform` VALUES ('10000021', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000003,\"commodity_name\":\"鸡肉卷\",\"commodity_price\":12.0}:1,{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1}}', null, '1531444758273', '0', '0');
166 | INSERT INTO `orderform` VALUES ('10000022', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1}}', null, '1531444783821', '0', '0');
167 | INSERT INTO `orderform` VALUES ('10000023', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:1}}', null, '1531444823071', '0', '0');
168 | INSERT INTO `orderform` VALUES ('10000024', '10002', '100001', '{\"order\":{{\"business_id\":10002,\"commodity_id\":1000012,\"commodity_name\":\"金针菇\",\"commodity_price\":2.0}:3,{\"business_id\":10002,\"commodity_id\":1000010,\"commodity_name\":\"娃娃菜\",\"commodity_price\":1.8}:5,{\"business_id\":10002,\"commodity_id\":1000009,\"commodity_name\":\"鱼豆腐\",\"commodity_price\":2.0}:4,{\"business_id\":10002,\"commodity_id\":1000011,\"commodity_name\":\"西兰花\",\"commodity_price\":1.8}:4}}', null, '1531444937271', '0', '0');
169 | INSERT INTO `orderform` VALUES ('10000025', '10005', '100001', '{\"order\":{{\"business_id\":10005,\"commodity_id\":1000030,\"commodity_name\":\"皮蛋鸡肉粥\",\"commodity_price\":8.0}:4}}', null, '1531447623355', '0', '0');
170 | INSERT INTO `orderform` VALUES ('10000026', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:3}}', null, '1531470749406', '0', '0');
171 | INSERT INTO `orderform` VALUES ('10000027', '10001', '100001', '{\"order\":{{\"business_id\":10001,\"commodity_id\":1000001,\"commodity_name\":\"香辣鸡腿堡\",\"commodity_price\":10.0}:6}}', null, '1531470789137', '0', '0');
172 | INSERT INTO `orderform` VALUES ('10000028', '10002', '100001', '{\"order\":{{\"business_id\":10002,\"commodity_id\":1000010,\"commodity_name\":\"娃娃菜\",\"commodity_price\":1.8}:3,{\"business_id\":10002,\"commodity_id\":1000011,\"commodity_name\":\"西兰花\",\"commodity_price\":1.8}:3,{\"business_id\":10002,\"commodity_id\":1000009,\"commodity_name\":\"鱼豆腐\",\"commodity_price\":2.0}:3,{\"business_id\":10002,\"commodity_id\":1000012,\"commodity_name\":\"金针菇\",\"commodity_price\":2.0}:2}}', null, '1531470789158', '0', '0');
173 | INSERT INTO `orderform` VALUES ('10000029', '10007', '100001', '{\"order\":{{\"business_id\":10007,\"commodity_id\":1000036,\"commodity_name\":\"吉味双拼饭\",\"commodity_price\":20.0}:5}}', null, '1531470789175', '0', '0');
174 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ELBSystem
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.8
12 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/img/login®ister.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/TakeOutSystemCustomer/img/login®ister.png
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/img/welcome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/TakeOutSystemCustomer/img/welcome.png
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/BusinessInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 商家信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class BusinessInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = 1259992436081004014L;
16 | private int business_id;// 商家id
17 | private String business_name;// 商家名称
18 | private String business_picture;// 商家图片
19 | private String business_username;// 商家账号名
20 | private String business_password;// 商家密码
21 | public int getBusiness_id() {
22 | return business_id;
23 | }
24 |
25 | public void setBusiness_id(int business_id) {
26 | this.business_id = business_id;
27 | }
28 |
29 | public String getBusiness_name() {
30 | return business_name;
31 | }
32 |
33 | public void setBusiness_name(String business_name) {
34 | this.business_name = business_name;
35 | }
36 |
37 | public String getBusiness_picture() {
38 | return business_picture;
39 | }
40 |
41 | public void setBusiness_picture(String business_picture) {
42 | this.business_picture = business_picture;
43 | }
44 |
45 | public String getBusiness_username() {
46 | return business_username;
47 | }
48 |
49 | public void setBusiness_username(String business_username) {
50 | this.business_username = business_username;
51 | }
52 |
53 | public String getBusiness_password() {
54 | return business_password;
55 | }
56 |
57 | public void setBusiness_password(String business_password) {
58 | this.business_password = business_password;
59 | }
60 |
61 | public BusinessInfo(String business_username, String business_password) {
62 | super();
63 | this.business_username = business_username;
64 | this.business_password = business_password;
65 | }
66 |
67 | public BusinessInfo(String business_name, String business_picture, String business_username,
68 | String business_password) {
69 | super();
70 | this.business_name = business_name;
71 | this.business_picture = business_picture;
72 | this.business_username = business_username;
73 | this.business_password = business_password;
74 | }
75 |
76 | public BusinessInfo(int business_id, String business_name, String business_picture, String business_username,
77 | String business_password) {
78 | super();
79 | this.business_id = business_id;
80 | this.business_name = business_name;
81 | this.business_picture = business_picture;
82 | this.business_username = business_username;
83 | this.business_password = business_password;
84 | }
85 |
86 | public BusinessInfo() {
87 | super();
88 | }
89 |
90 | public BusinessInfo(int business_id, String business_name, String business_picture) {
91 | super();
92 | this.business_id = business_id;
93 | this.business_name = business_name;
94 | this.business_picture = business_picture;
95 | }
96 |
97 | @Override
98 | public String toString() {
99 | return business_name;
100 | }
101 |
102 | @Override
103 | public int hashCode() {
104 | final int prime = 31;
105 | int result = 1;
106 | result = prime * result + business_id;
107 | return result;
108 | }
109 |
110 | @Override
111 | public boolean equals(Object obj) {
112 | if (this == obj)
113 | return true;
114 | if (obj == null)
115 | return false;
116 | if (getClass() != obj.getClass())
117 | return false;
118 | BusinessInfo other = (BusinessInfo) obj;
119 | if (business_id != other.business_id)
120 | return false;
121 | return true;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/CommodityInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 商品信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class CommodityInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = -849655420418323846L;
16 | private int commodity_id;// 商品id
17 | private String commodity_name;// 商品名称
18 | private double commodity_price;// 商品价格
19 | private String commodity_picture;// 商品图片
20 | private int business_id;// 商家id
21 |
22 | public int getCommodity_id() {
23 | return commodity_id;
24 | }
25 |
26 | public void setCommodity_id(int commodity_id) {
27 | this.commodity_id = commodity_id;
28 | }
29 |
30 | public String getCommodity_name() {
31 | return commodity_name;
32 | }
33 |
34 | public void setCommodity_name(String commodity_name) {
35 | this.commodity_name = commodity_name;
36 | }
37 |
38 | public double getCommodity_price() {
39 | return commodity_price;
40 | }
41 |
42 | public void setCommodity_price(double commodity_price) {
43 | this.commodity_price = commodity_price;
44 | }
45 |
46 | public String getCommodity_picture() {
47 | return commodity_picture;
48 | }
49 |
50 | public void setCommodity_picture(String commodity_picture) {
51 | this.commodity_picture = commodity_picture;
52 | }
53 |
54 | public int getBusiness_id() {
55 | return business_id;
56 | }
57 |
58 | public void setBusiness_id(int business_id) {
59 | this.business_id = business_id;
60 | }
61 |
62 | public CommodityInfo(int commodity_id, String commodity_name, double commodity_price, String commodity_picture,
63 | int business_id) {
64 | super();
65 | this.commodity_id = commodity_id;
66 | this.commodity_name = commodity_name;
67 | this.commodity_price = commodity_price;
68 | this.commodity_picture = commodity_picture;
69 | this.business_id = business_id;
70 | }
71 |
72 | public CommodityInfo() {
73 | super();
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | return commodity_name;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/CustomerInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 用户信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class CustomerInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = -4423788838737484776L;
16 | private int customer_id;// 用户id
17 | private String customer_name;// 用户名称
18 | private String customer_username;// 用户账号名
19 | private String customer_password;// 用户密码
20 |
21 | public int getCustomer_id() {
22 | return customer_id;
23 | }
24 |
25 | public void setCustomer_id(int customer_id) {
26 | this.customer_id = customer_id;
27 | }
28 |
29 | public String getCustomer_name() {
30 | return customer_name;
31 | }
32 |
33 | public void setCustomer_name(String customer_name) {
34 | this.customer_name = customer_name;
35 | }
36 |
37 | public String getCustomer_username() {
38 | return customer_username;
39 | }
40 |
41 | public void setCustomer_username(String customer_username) {
42 | this.customer_username = customer_username;
43 | }
44 |
45 | public String getCustomer_password() {
46 | return customer_password;
47 | }
48 |
49 | public void setCustomer_password(String customer_password) {
50 | this.customer_password = customer_password;
51 | }
52 |
53 | public CustomerInfo(String customer_username, String customer_password) {
54 | super();
55 | this.customer_username = customer_username;
56 | this.customer_password = customer_password;
57 | }
58 |
59 | public CustomerInfo(String customer_name, String customer_username, String customer_password) {
60 | super();
61 | this.customer_name = customer_name;
62 | this.customer_username = customer_username;
63 | this.customer_password = customer_password;
64 | }
65 |
66 | public CustomerInfo(int customer_id, String customer_name, String customer_username, String customer_password) {
67 | super();
68 | this.customer_id = customer_id;
69 | this.customer_name = customer_name;
70 | this.customer_username = customer_username;
71 | this.customer_password = customer_password;
72 | }
73 |
74 | public CustomerInfo() {
75 | super();
76 | }
77 |
78 | @Override
79 | public String toString() {
80 | return "CustomerInfo [customer_id=" + customer_id + ", customer_name=" + customer_name + ", customer_username="
81 | + customer_username + ", customer_password=" + customer_password + "]";
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/DataPackage.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import com.alibaba.fastjson.JSON;
4 |
5 | /**
6 | * 传输的数据包定义
7 | *
8 | * @author Mao_TP
9 | * @param
10 | *
11 | */
12 | public class DataPackage {
13 | private Request request;
14 | private E e;
15 | private CustomerInfo customer;
16 | public DataPackage(Request request, E e) {
17 | super();
18 | this.request = request;
19 | this.e = e;
20 | }
21 |
22 | public Request getRequest() {
23 | return request;
24 | }
25 |
26 | public void setRequest(Request request) {
27 | this.request = request;
28 | }
29 |
30 | public Object getO() {
31 | return e;
32 | }
33 |
34 | public void setE(E e) {
35 | this.e = e;
36 | }
37 |
38 | public String toJson() {
39 | return JSON.toJSONString(this);
40 | }
41 |
42 | public CustomerInfo getCustomer() {
43 | return customer;
44 | }
45 |
46 | public void setCustomer(CustomerInfo customer) {
47 | this.customer = customer;
48 | }
49 |
50 | public E getE() {
51 | return e;
52 | }
53 |
54 | public DataPackage(Request request, E e, CustomerInfo customer) {
55 | super();
56 | this.request = request;
57 | this.e = e;
58 | this.customer = customer;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/Goods.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | public class Goods {
4 | private CommodityInfo commodityInfo;
5 | private int count;
6 | public CommodityInfo getCommodityInfo() {
7 | return commodityInfo;
8 | }
9 | public void setCommodityInfo(CommodityInfo commodityInfo) {
10 | this.commodityInfo = commodityInfo;
11 | }
12 | public int getCount() {
13 | return count;
14 | }
15 | public void setCount(int count) {
16 | this.count = count;
17 | }
18 | public Goods(CommodityInfo commodityInfo, int count) {
19 | super();
20 | this.commodityInfo = commodityInfo;
21 | this.count = count;
22 | }
23 | @Override
24 | public int hashCode() {
25 | final int prime = 31;
26 | int result = 1;
27 | result = prime * result + ((commodityInfo == null) ? 0 : commodityInfo.hashCode());
28 | return result;
29 | }
30 | @Override
31 | public boolean equals(Object obj) {
32 | if (this == obj)
33 | return true;
34 | if (obj == null)
35 | return false;
36 | if (getClass() != obj.getClass())
37 | return false;
38 | Goods other = (Goods) obj;
39 | if (commodityInfo == null) {
40 | if (other.commodityInfo != null)
41 | return false;
42 | } else if (!commodityInfo.equals(other.commodityInfo))
43 | return false;
44 | return true;
45 | }
46 | @Override
47 | public String toString() {
48 | return "Goods [commodityInfo=" + commodityInfo + ", count=" + count + "]";
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/OrderformInfo.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 订单信息表的实体类
7 | *
8 | * @author Administrator
9 | *
10 | */
11 | public class OrderformInfo implements Serializable {
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = 4631834927008599744L;
16 | private int order_id;// 订单id
17 | private int business_id;// 商家id
18 | private int customer_id;// 用户id
19 | private String order;// 订单详细信息
20 | private long start_time;// 订单开始时间
21 | private long end_time;// 订单结束时间
22 | private int status;// 订单状态
23 |
24 | public int getOrder_id() {
25 | return order_id;
26 | }
27 |
28 | public void setOrder_id(int order_id) {
29 | this.order_id = order_id;
30 | }
31 |
32 | public int getBusiness_id() {
33 | return business_id;
34 | }
35 |
36 | public void setBusiness_id(int business_id) {
37 | this.business_id = business_id;
38 | }
39 |
40 | public int getCustomer_id() {
41 | return customer_id;
42 | }
43 |
44 | public void setCustomer_id(int customer_id) {
45 | this.customer_id = customer_id;
46 | }
47 |
48 | public String getOrder() {
49 | return order;
50 | }
51 |
52 | public void setOrder(String order) {
53 | this.order = order;
54 | }
55 |
56 | public long getStart_time() {
57 | return start_time;
58 | }
59 |
60 | public void setStart_time(long start_time) {
61 | this.start_time = start_time;
62 | }
63 |
64 | public long getEnd_time() {
65 | return end_time;
66 | }
67 |
68 | public void setEnd_time(long end_time) {
69 | this.end_time = end_time;
70 | }
71 |
72 | public int getStatus() {
73 | return status;
74 | }
75 |
76 | public void setStatus(int status) {
77 | this.status = status;
78 | }
79 |
80 | public OrderformInfo(int order_id, int business_id, int customer_id, String order, long start_time, long end_time,
81 | int status) {
82 | super();
83 | this.order_id = order_id;
84 | this.business_id = business_id;
85 | this.customer_id = customer_id;
86 | this.order = order;
87 | this.start_time = start_time;
88 | this.end_time = end_time;
89 | this.status = status;
90 | }
91 |
92 | public OrderformInfo() {
93 | super();
94 | }
95 |
96 | @Override
97 | public String toString() {
98 | return "OrderformInfo [order_id=" + order_id + ", business_id=" + business_id + ", customer_id=" + customer_id
99 | + ", order=" + order + ", start_time=" + start_time + ", end_time=" + end_time + ", status=" + status
100 | + "]";
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/entity/Request.java:
--------------------------------------------------------------------------------
1 | package cn.elb.entity;
2 |
3 | /**
4 | * 请求枚举类
5 | *
6 | * @author Mao_TP
7 | *
8 | */
9 |
10 | public enum Request {
11 | 初始化请求, 商家登录, 用户登录,用户注册, 商家信息修改, 用户信息修改, 订单提交, 订单修改, 商家查询订单, 用户订单查询;
12 | }
13 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/main_window/MainWindow.java:
--------------------------------------------------------------------------------
1 | package cn.elb.main_window;
2 |
3 | import java.awt.Color;
4 | import java.awt.Dimension;
5 | import java.awt.EventQueue;
6 | import java.awt.Font;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.Iterator;
10 | import java.util.Set;
11 |
12 | import javax.swing.ImageIcon;
13 | import javax.swing.JButton;
14 | import javax.swing.JFrame;
15 | import javax.swing.JLabel;
16 | import javax.swing.JOptionPane;
17 | import javax.swing.JPanel;
18 | import javax.swing.JPasswordField;
19 | import javax.swing.JScrollPane;
20 | import javax.swing.JTextArea;
21 | import javax.swing.JTextField;
22 | import javax.swing.ScrollPaneConstants;
23 | import javax.swing.UIManager;
24 |
25 | import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
26 |
27 | import com.alibaba.fastjson.JSON;
28 | import com.alibaba.fastjson.TypeReference;
29 |
30 | import cn.elb.entity.BusinessInfo;
31 | import cn.elb.entity.CommodityInfo;
32 | import cn.elb.entity.CustomerInfo;
33 | import cn.elb.entity.DataPackage;
34 | import cn.elb.entity.Goods;
35 | import cn.elb.entity.Request;
36 | import cn.elb.socket.SendData;
37 | import cn.elb.swing.refit.BusinessMenu;
38 | import cn.elb.swing.refit.ImageJpanel;
39 | import cn.elb.swing.refit.TakeOutBar;
40 |
41 | public class MainWindow extends JFrame {
42 |
43 | private static final long serialVersionUID = 20180705L;
44 | /**
45 | * 登录界面和注册界面的字体
46 | */
47 | private final Font LOGIN_AND_REGISTER_FONT = new Font("黑体", 0, 20);
48 | private final Font APPLICATION_FONT = new Font("黑体", 0, 15);
49 | /**
50 | * 商家表
51 | */
52 | private HashMap businessTable;
53 | /**
54 | * 订单
55 | */
56 | private HashMap> orderForm;
57 | /**
58 | * 存储所有的店铺信息和商品信息
59 | */
60 | private HashMap> allData;
61 | /**
62 | * 承载页面的舞台
63 | */
64 | private JPanel stage;//舞台
65 | /**
66 | * 第一层界面有
67 | * 欢迎页:welcome------->0
68 | * 登录页:login--------->1
69 | * 注册页:register------>2
70 | * 应用页(第二层):application--->3
71 | */
72 | private JPanel[] firstPage;//第一层界面容器
73 | /**
74 | * 登录界面账号输入框
75 | */
76 | private JTextField loginUserNameField;
77 | /**
78 | * 登录界面密码输入框
79 | */
80 | private JPasswordField loginPasswordField;
81 | /**
82 | * 登录界面登录按钮
83 | */
84 | private JButton login_loginButton;
85 | /**
86 | * 登录界面注册按钮
87 | */
88 | private JButton login_registerButton;
89 | /**
90 | * 注册界面账号输入框
91 | */
92 | private JTextField registerUserNameField;
93 | /**
94 | * 注册界面密码输入框
95 | */
96 | private JPasswordField registerPasswordField;
97 | /**
98 | * 注册界面密码再次确认输入框
99 | */
100 | private JPasswordField registerPasswordField_re;
101 | /**
102 | * 注册界面返回按钮
103 | */
104 | private JButton register_backButton;
105 | /**
106 | * 注册界面注册按钮
107 | */
108 | private JButton register_registerButton;
109 | /**
110 | * 应用界面底层导航菜单层
111 | */
112 | private JPanel menuPane;
113 | /**
114 | * 应用界面内容层
115 | */
116 | private JPanel bodyPane;
117 | /**
118 | * 应用界面底层导航菜单层按钮容器
119 | * 0----->外卖
120 | * 1----->购物车
121 | * 2----->订单
122 | * 3----->我的
123 | */
124 | private JButton[] menuButton;
125 | /**
126 | * 应用界面内容层容器
127 | * 0----->外卖
128 | * 1----->购物车
129 | * 2----->订单
130 | * 3----->我的
131 | * 4----->可以动态改变的卖家菜单
132 | */
133 | private JPanel[] bodyPaneArray;
134 | /**
135 | * 外卖界面滚动栏
136 | */
137 | private JScrollPane takeOutScrollPane;
138 | /**
139 | * 购物车界面滚动栏
140 | */
141 | private JScrollPane shopCartScrollPane;
142 | /**
143 | * 订单界面滚动栏
144 | */
145 | private JScrollPane orderScrollPane;
146 | /**
147 | * 外卖界面滚动栏里的外卖界面
148 | */
149 | private JPanel takeOutPane;
150 | /**
151 | * 店铺栏
152 | */
153 | private TakeOutBar[] takeOutBar;
154 | /**
155 | * 动态改变的卖家菜单中返回按钮
156 | */
157 | private JButton backbtn;
158 | /**
159 | *动态改变的卖家菜单中滚动栏
160 | */
161 | private JScrollPane takeOutMenuScrollPane;
162 | /**
163 | * 动态改变的卖家菜单中滚动栏里的界面
164 | */
165 | private JPanel takeOutMenuPane;
166 | /**
167 | * 购物车
168 | */
169 | private HashMap shopcart;
170 | /**
171 | * 购物车界面提交按钮
172 | */
173 | private JButton putbtn;
174 | // /**
175 | // * 购物车界面滚动栏里的界面
176 | // */
177 | // private JPanel shopcartPane;
178 | /**
179 | * 购物车滚动栏里的内容
180 | */
181 | private JTextArea carttext;
182 | /**
183 | * 清空购物车按钮
184 | */
185 | private JButton clearCart;
186 | public static void main(String[] args) {
187 | EventQueue.invokeLater(() ->{
188 | try {
189 | //解决皮肤美化包切换输入法白屏BUG
190 | System.setProperty("sun.java2d.noddraw", "true");
191 | BeautyEyeLNFHelper.launchBeautyEyeLNF(); //皮肤美化包
192 | UIManager.put("RootPane.setupButtonVisible", false);
193 | MainWindow frame = new MainWindow();
194 | frame.setVisible(true);
195 | } catch (Exception e) {
196 | e.printStackTrace();
197 | }
198 | });
199 | }
200 |
201 | public MainWindow() {
202 | getData();
203 | /**
204 | * 这儿方法执行的顺序不可以改变!!!!!
205 | */
206 | initialize();//初始化
207 | setPage();//设置页面
208 | addEvent();//添加事件
209 | }
210 | /**
211 | * 从服务器获取商家数据的方法
212 | */
213 | private void getData(){
214 | allData = new HashMap<>();
215 | businessTable = new HashMap<>();
216 | orderForm = new HashMap<>();
217 | String str = SendData.sendData(new DataPackage<>(Request.初始化请求,null));
218 | allData = JSON.parseObject(str, new TypeReference>>() {});
219 | Set set = allData.keySet();
220 | Iterator ite = set.iterator();
221 | while(ite.hasNext()){
222 | BusinessInfo b = ite.next();
223 | businessTable.put(b.getBusiness_id(),b);
224 | }
225 | }
226 | /**
227 | * 初始化组件
228 | */
229 | private void initialize() {
230 | firstPage = new JPanel[4];//创建一个能存放四张界面的容器
231 | firstPage[0] = new ImageJpanel("welcome.png");
232 | firstPage[1] = new ImageJpanel("login®ister.png");
233 | firstPage[2] = new ImageJpanel("login®ister.png");
234 | firstPage[3] = new JPanel();
235 | stage = new JPanel();
236 |
237 | //登录界面组件初始化
238 | loginUserNameField = new JTextField();
239 | loginPasswordField = new JPasswordField();
240 | login_loginButton = new JButton("登录");
241 | login_registerButton = new JButton("注册");
242 | //注册界面组件初始化
243 | registerUserNameField = new JTextField();
244 | registerPasswordField = new JPasswordField();
245 | registerPasswordField_re = new JPasswordField();
246 | register_backButton = new JButton("返回");
247 | register_registerButton = new JButton("注册");
248 | //应用界面初始化
249 | menuPane = new JPanel();
250 | bodyPane = new JPanel();
251 | //初始化菜单按钮容器
252 | menuButton = new JButton[4];
253 | menuButton[0] = new JButton("外 卖",new ImageIcon("img/wk_c.png"));
254 | menuButton[1] = new JButton("购物车",new ImageIcon("img/gwc.png"));
255 | menuButton[2] = new JButton("订 单",new ImageIcon("img/dd.png"));
256 | menuButton[3] = new JButton("我 的",new ImageIcon("img/wd.png"));
257 | //初始化应用界面内容层容器
258 | bodyPaneArray = new JPanel[5];
259 | for (int i = 0; i < bodyPaneArray.length; i++) {
260 | bodyPaneArray[i] = new JPanel();
261 | }
262 | //初始化外卖界面滚动栏
263 | takeOutScrollPane = new JScrollPane();
264 | //初始化购物车界面滚动栏
265 | shopCartScrollPane = new JScrollPane();
266 | //初始化订单界面滚动栏
267 | orderScrollPane = new JScrollPane();
268 | //初始化外卖界面滚动栏中的外卖界面
269 | takeOutPane = new JPanel();
270 | //初始化动态改变的卖家菜单中返回按钮
271 | backbtn = new JButton("返回");
272 | //初始化动态改变的卖家菜单中滚动栏
273 | takeOutMenuScrollPane = new JScrollPane();
274 | //初始化动态改变的卖家菜单中滚动栏里的界面
275 | takeOutMenuPane = new JPanel();
276 | //初始化购物车
277 | shopcart = new HashMap<>();
278 | //初始化购物车界面提交按钮
279 | putbtn = new JButton("提交");
280 | //初始化购物车界面滚动栏里的界面
281 | // shopcartPane = new JPanel();
282 | //初始化购物车内容栏
283 | carttext = new JTextArea();
284 | //初始化清空购物车按钮
285 | clearCart = new JButton("清空购物车");
286 | }
287 | /**
288 | * 设置页面的方法
289 | */
290 | private void setPage(){
291 | //窗口设置
292 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
293 | setSize(450, 660);
294 | setTitle("饿了吧");
295 | setLocationRelativeTo(null);//窗体居中显示
296 | setResizable(false);//禁止拉伸
297 |
298 | //第一层组件设置
299 | firstPage[0].setSize(400,600);
300 | firstPage[1].setSize(400,600);
301 | firstPage[2].setSize(400,600);
302 | firstPage[3].setSize(400,600);
303 | firstPage[1].setLayout(null);
304 | firstPage[1].setVisible(false);
305 | firstPage[2].setLayout(null);
306 | firstPage[2].setVisible(false);
307 | firstPage[3].setLayout(null);
308 | firstPage[3].setVisible(false);
309 |
310 | JLabel loginUserName = new JLabel("账号:");
311 | JLabel loginPassword = new JLabel("密码:");
312 | loginUserName.setFont(LOGIN_AND_REGISTER_FONT);
313 | loginUserName.setBounds(30, 240, 80, 40);
314 | loginPassword.setFont(LOGIN_AND_REGISTER_FONT);
315 | loginPassword.setBounds(30, 290, 80, 40);
316 | loginUserNameField.setBounds(100, 240, 240, 35);
317 | loginPasswordField.setBounds(100, 290, 240, 35);
318 | login_loginButton.setBounds(100, 350, 115, 50);
319 | login_loginButton.setFont(LOGIN_AND_REGISTER_FONT);
320 | login_registerButton.setBounds(220, 350, 115, 50);
321 | login_registerButton.setFont(LOGIN_AND_REGISTER_FONT);
322 |
323 | JLabel registerUserName = new JLabel("账号:");
324 | JLabel registerPassword = new JLabel("密码:");
325 | JLabel registerPassword_re = new JLabel("确认密码:");
326 | registerUserName.setFont(LOGIN_AND_REGISTER_FONT);
327 | registerUserName.setBounds(30, 190, 80, 40);
328 | registerPassword.setFont(LOGIN_AND_REGISTER_FONT);
329 | registerPassword.setBounds(30, 240, 80, 40);
330 | registerPassword_re.setFont(LOGIN_AND_REGISTER_FONT);
331 | registerPassword_re.setBounds(10, 290, 110, 40);
332 | registerUserNameField.setBounds(100, 190, 240, 35);
333 | registerPasswordField.setBounds(100, 240, 240, 35);
334 | registerPasswordField_re.setBounds(100, 290, 240, 35);
335 | register_backButton.setBounds(100, 350, 115, 50);
336 | register_backButton.setFont(LOGIN_AND_REGISTER_FONT);
337 | register_registerButton.setBounds(220, 350, 115, 50);
338 | register_registerButton.setFont(LOGIN_AND_REGISTER_FONT);
339 |
340 | firstPage[1].add(loginUserNameField);
341 | firstPage[1].add(loginPasswordField);
342 | firstPage[1].add(login_loginButton);
343 | firstPage[1].add(login_registerButton);
344 | firstPage[1].add(loginUserName);
345 | firstPage[1].add(loginPassword);
346 |
347 | firstPage[2].add(registerUserNameField);
348 | firstPage[2].add(registerPasswordField);
349 | firstPage[2].add(registerPasswordField_re);
350 | firstPage[2].add(register_backButton);
351 | firstPage[2].add(register_registerButton);
352 | firstPage[2].add(registerUserName);
353 | firstPage[2].add(registerPassword);
354 | firstPage[2].add(registerPassword_re);
355 | //应用界面层设置
356 | menuPane.setLayout(null);
357 | menuPane.setBounds(0, 530, 400, 70);
358 | //添加并设置菜单层组件
359 | for(int i =0;i list = new ArrayList<>();
373 | // list.add(new BusinessInfo(0,"张亮麻辣烫","pd/0.png"));
374 | // list.add(new BusinessInfo(1,"周黑鸭","pd/1.png"));
375 | // list.add(new BusinessInfo(2,"肯德基","pd/2.png"));
376 | // list.add(new BusinessInfo(3,"德克士","pd/3.png"));
377 | // takeOutBar = new TakeOutBar[list.size()];
378 | // for (int i = 0; i < takeOutBar.length; i++) {
379 | // takeOutBar[i] = new TakeOutBar(list.get(i));
380 | // takeOutBar[i].setBounds(15, 0+i*120, 350, 120);
381 | // takeOutPane.add(takeOutBar[i]);
382 | // }
383 | Set set = allData.keySet();
384 | takeOutBar = new TakeOutBar[set.size()];
385 | Iterator ite =set.iterator();
386 | int index = 0;
387 | while (ite.hasNext()) {
388 | takeOutBar[index] = new TakeOutBar(ite.next());
389 | takeOutBar[index].setBounds(15, 0+index*120, 350, 120);
390 | takeOutPane.add(takeOutBar[index]);
391 | index++;
392 | }
393 | takeOutScrollPane.setViewportView(takeOutPane);
394 | takeOutScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);//取消水平(左右滚动条)
395 | bodyPaneArray[0].add(takeOutScrollPane);
396 | //设置购物车界面滚动栏
397 | putbtn.setBounds(0, 510, 198, 20);
398 | putbtn.setFont(APPLICATION_FONT);
399 | bodyPaneArray[1].add(putbtn);
400 | clearCart.setFont(APPLICATION_FONT);
401 | clearCart.setBounds(200, 510, 198, 20);
402 | bodyPaneArray[1].add(clearCart);
403 | shopCartScrollPane.setBounds(0, 0, 395, 515);
404 | // shopCartScrollPane.setLayout(null);不能设置布局
405 | shopCartScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);//取消水平(左右滚动条)
406 | // shopcartPane.setPreferredSize(new Dimension(380, 2500));
407 | // shopcartPane.setLayout(null);
408 | carttext.setLineWrap(true);
409 | carttext.setEditable(false);
410 | carttext.setFont(new Font("黑体", 0, 15));
411 | shopCartScrollPane.setViewportView(carttext);
412 | bodyPaneArray[1].add(shopCartScrollPane);
413 | //设置订单界面滚动栏
414 | orderScrollPane.setBounds(0, 0, 395, 530);
415 | orderScrollPane.setLayout(null);
416 | orderScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);//取消水平(左右滚动条)
417 | bodyPaneArray[2].add(orderScrollPane);
418 | //设置动态改变的卖家菜单
419 | backbtn.setBounds(0, 0, 395, 20);
420 | backbtn.setFont(APPLICATION_FONT);
421 | bodyPaneArray[4].add(backbtn);
422 | takeOutMenuScrollPane.setBounds(0, 20, 395, 515);
423 | takeOutMenuScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);//取消水平(左右滚动条)
424 | takeOutMenuPane.setPreferredSize(new Dimension(380, 2500));//设置滚动栏里的界面
425 | takeOutMenuPane.setLayout(null);
426 | takeOutMenuScrollPane.setViewportView(takeOutMenuPane);
427 | bodyPaneArray[4].add(takeOutMenuScrollPane);
428 | //内容层设置
429 | bodyPane.setLayout(null);
430 | bodyPane.setBounds(0, 0, 400, 530);
431 | bodyPane.setBackground(new Color(255, 193,193));
432 | for (int i = 0; i < bodyPaneArray.length; i++) {
433 | bodyPaneArray[i].setSize(400, 530);
434 | bodyPaneArray[i].setLayout(null);//清除布局
435 | if(i>0){
436 | bodyPaneArray[i].setVisible(false);
437 | }
438 | bodyPane.add(bodyPaneArray[i]);
439 | }
440 | //给应用界面添加菜单界面和内容界面
441 | firstPage[3].add(menuPane);
442 | firstPage[3].add(bodyPane);
443 | //舞台设置
444 | stage.setLayout(null); //清空舞台的布局
445 | //添加第一层组件
446 | for(int i=0;i{
457 | try {
458 | Thread.sleep(1000);
459 | } catch (InterruptedException e) {
460 | e.printStackTrace();
461 | }
462 | firstPage[0].setVisible(false);
463 | firstPage[1].setVisible(true);
464 | }).start();
465 | //登录界面点击注册按钮跳转注册界面
466 | login_registerButton.addActionListener(event ->{
467 | firstPage[1].setVisible(false);
468 | firstPage[2].setVisible(true);
469 | });
470 | //注册界面点击返回按钮跳转登录界面
471 | register_backButton.addActionListener(event ->{
472 | firstPage[1].setVisible(true);
473 | firstPage[2].setVisible(false);
474 | });
475 | register_registerButton.addActionListener(event ->{
476 | if(registerUserNameField.getText().equals("")||registerPasswordField.getText().equals("")||registerPasswordField_re.getText().equals("")){
477 | JOptionPane.showMessageDialog(null,"输入框不能为空!","提示框",JOptionPane.ERROR_MESSAGE);
478 | }else{
479 | if(!registerPasswordField.getText().equals(registerPasswordField_re.getText())){
480 | JOptionPane.showMessageDialog(null,"两次密码不一致!","提示框",JOptionPane.ERROR_MESSAGE);
481 | }else{
482 | //发送注册请求
483 | String request = SendData.sendData(new DataPackage(Request.用户注册,new CustomerInfo(registerUserNameField.getText(),registerPasswordField.getText())));
484 | if(request.equals("Success")){
485 | JOptionPane.showMessageDialog(null,"注册成功!","提示框",JOptionPane.PLAIN_MESSAGE);
486 | }else{
487 | JOptionPane.showMessageDialog(null,"用户已被注册!","提示框",JOptionPane.ERROR_MESSAGE);
488 | registerUserNameField.setText("");
489 | registerPasswordField.setText("");
490 | registerPasswordField_re.setText("");
491 | }
492 | }
493 | }
494 | });
495 | //登录界面点击登录按钮,登录成功,跳转操作界面
496 | login_loginButton.addActionListener(event ->{
497 | if(loginUserNameField.getText().equals("")||loginPasswordField.getText().equals("")){
498 | JOptionPane.showMessageDialog(null,"输入框不能为空!","提示框",JOptionPane.ERROR_MESSAGE);
499 | }else{
500 | String str = SendData.sendData(new DataPackage(Request.用户登录,new CustomerInfo(loginUserNameField.getText(), registerPasswordField.getText())));
501 | DataPackage dp = JSON.parseObject(str,new TypeReference>(){});
502 | if(dp!=null){
503 | firstPage[1].setVisible(false);
504 | firstPage[3].setVisible(true);
505 | }else{
506 | JOptionPane.showMessageDialog(null,"账号或密码输入错误!","提示框",JOptionPane.ERROR_MESSAGE);
507 | }
508 | }
509 |
510 | });
511 | //提交订单
512 | putbtn.addActionListener(event ->{
513 | // System.out.println(orderForm);
514 | DataPackage>> dp = new DataPackage<>(Request.订单提交,orderForm,new CustomerInfo("xiaoming","123456"));
515 | // try {
516 | // OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("TestData.txt"));
517 | // osw.write(JSON.toJSONString(dp));
518 | // osw.close();
519 | // } catch (IOException e) {
520 | // e.printStackTrace();
521 | // }
522 | String str =SendData.sendData(dp);
523 | if(str.equals("Success")){
524 | carttext.setText("");
525 | shopcart.clear();
526 | orderForm.clear();
527 | JOptionPane.showMessageDialog(null,"提交成功!等待配送!","提示框",JOptionPane.PLAIN_MESSAGE);
528 | }else{
529 | JOptionPane.showMessageDialog(null,"提交失败!请重新提交!","提示框",JOptionPane.ERROR_MESSAGE);
530 | }
531 | });
532 | //清空购物车
533 | clearCart.addActionListener(event ->{
534 | carttext.setText("");
535 | shopcart.clear();
536 | orderForm.clear();
537 | });
538 | //菜单按钮点击切换内容层界面
539 | menuButton[0].addActionListener(event ->{
540 | bodyPaneArray[0].setVisible(true);
541 | bodyPaneArray[1].setVisible(false);
542 | bodyPaneArray[2].setVisible(false);
543 | bodyPaneArray[3].setVisible(false);
544 | bodyPaneArray[4].setVisible(false);
545 | menuButton[0].setIcon(new ImageIcon("img/wk_c.png"));
546 | menuButton[1].setIcon(new ImageIcon("img/gwc.png"));
547 | menuButton[2].setIcon(new ImageIcon("img/dd.png"));
548 | menuButton[3].setIcon(new ImageIcon("img/wd.png"));
549 | });
550 | menuButton[1].addActionListener(event ->{
551 | bodyPaneArray[0].setVisible(false);
552 | bodyPaneArray[1].setVisible(true);
553 | bodyPaneArray[2].setVisible(false);
554 | bodyPaneArray[3].setVisible(false);
555 | bodyPaneArray[4].setVisible(false);
556 | menuButton[0].setIcon(new ImageIcon("img/wk.png"));
557 | menuButton[1].setIcon(new ImageIcon("img/gwc_c.png"));
558 | menuButton[2].setIcon(new ImageIcon("img/dd.png"));
559 | menuButton[3].setIcon(new ImageIcon("img/wd.png"));
560 | Set set = shopcart.keySet();
561 | Iterator ite = set.iterator();
562 | StringBuffer sb = new StringBuffer();
563 | sb.append("商品名称/").append("单价/").append("数量/").append("总价\n");
564 | sb.append("---------------------------------------\n");
565 | double price =0;
566 | while(ite.hasNext()){
567 | CommodityInfo c = ite.next();
568 | double money = c.getCommodity_price()*shopcart.get(c);
569 | price += money;
570 | sb.append(c.getCommodity_name()+" ").append(c.getCommodity_price()+"元 ");
571 | sb.append(shopcart.get(c)).append("份 ").append(money+"元\n");
572 | BusinessInfo bi = businessTable.get(c.getBusiness_id());
573 | if(orderForm.containsKey(bi)){
574 | Goods goods = new Goods(c,shopcart.get(c));
575 | ArrayList list =orderForm.get(bi);
576 | int index = -1;
577 | if((index=list.indexOf(goods))>=0){
578 | list.add(index,goods);
579 | }else{
580 | list.add(goods);
581 | }
582 | orderForm.put(bi,list);
583 | }else{
584 | ArrayList list = new ArrayList();
585 | list.add(new Goods(c,shopcart.get(c)));
586 | orderForm.put(bi,list);
587 | }
588 | }
589 | sb.append("---------------------------------------\n");
590 | sb.append("合计:").append(price).append("元");
591 | carttext.setText(sb.toString());
592 | });
593 | menuButton[2].addActionListener(event ->{
594 | bodyPaneArray[0].setVisible(false);
595 | bodyPaneArray[1].setVisible(false);
596 | bodyPaneArray[2].setVisible(true);
597 | bodyPaneArray[3].setVisible(false);
598 | bodyPaneArray[4].setVisible(false);
599 | menuButton[0].setIcon(new ImageIcon("img/wk.png"));
600 | menuButton[1].setIcon(new ImageIcon("img/gwc.png"));
601 | menuButton[2].setIcon(new ImageIcon("img/dd_c.png"));
602 | menuButton[3].setIcon(new ImageIcon("img/wd.png"));
603 | });
604 | menuButton[3].addActionListener(event ->{
605 | bodyPaneArray[0].setVisible(false);
606 | bodyPaneArray[1].setVisible(false);
607 | bodyPaneArray[2].setVisible(false);
608 | bodyPaneArray[3].setVisible(true);
609 | bodyPaneArray[4].setVisible(false);
610 | menuButton[0].setIcon(new ImageIcon("img/wk.png"));
611 | menuButton[1].setIcon(new ImageIcon("img/gwc.png"));
612 | menuButton[2].setIcon(new ImageIcon("img/dd.png"));
613 | menuButton[3].setIcon(new ImageIcon("img/wd_c.png"));
614 | });
615 | backbtn.addActionListener(event -> {
616 | bodyPaneArray[0].setVisible(true);
617 | bodyPaneArray[1].setVisible(false);
618 | bodyPaneArray[2].setVisible(false);
619 | bodyPaneArray[3].setVisible(false);
620 | bodyPaneArray[4].setVisible(false);
621 | });
622 | for (int i = 0; i < takeOutBar.length; i++) {
623 | takeOutBar[i].getIntoStore().addActionListener(event -> {
624 | JButton btn = (JButton)event.getSource();
625 | TakeOutBar t = (TakeOutBar)btn.getParent();
626 | System.out.println("用户进入了"+t.getId()+"号店铺:"+t);
627 | bodyPaneArray[0].setVisible(false);
628 | bodyPaneArray[1].setVisible(false);
629 | bodyPaneArray[2].setVisible(false);
630 | bodyPaneArray[3].setVisible(false);
631 | bodyPaneArray[4].setVisible(true);
632 | ArrayList InfoList = allData.get(t.getBusinessInfo());
633 | BusinessMenu[] bm = new BusinessMenu[InfoList.size()];
634 | takeOutMenuPane.removeAll();
635 | for (int j = 0; j < InfoList.size(); j++) {
636 | bm[j] = new BusinessMenu(InfoList.get(j));
637 | bm[j].setLayout(null);
638 | bm[j].setBounds(15,0+j*120, 350, 120);
639 | takeOutMenuPane.add(bm[j]);
640 | bm[j].getAddCartBtn().addActionListener(btnevent ->{
641 | JButton addbtn = (JButton)btnevent.getSource();
642 | BusinessMenu b = (BusinessMenu)addbtn.getParent();
643 | CommodityInfo ci = b.getCommodityInfo();
644 | System.out.println("用户点击了"+ci.getCommodity_name()+"商品!");
645 | if(shopcart.get(ci) != null){
646 | shopcart.put(ci,shopcart.get(ci).intValue()+1);
647 | }else{
648 | shopcart.put(ci,1);
649 | }
650 | System.out.println(shopcart);
651 | });
652 | }
653 | });
654 | }
655 | }
656 | }
657 |
--------------------------------------------------------------------------------
/TakeOutSystemCustomer/src/cn/elb/socket/SendData.java:
--------------------------------------------------------------------------------
1 | package cn.elb.socket;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.io.OutputStream;
8 | import java.net.Socket;
9 | import java.net.UnknownHostException;
10 | import java.util.ArrayList;
11 | import java.util.HashMap;
12 | import java.util.Iterator;
13 | import java.util.Set;
14 |
15 | import com.alibaba.fastjson.JSON;
16 | import com.alibaba.fastjson.TypeReference;
17 |
18 | import cn.elb.entity.BusinessInfo;
19 | import cn.elb.entity.CommodityInfo;
20 | import cn.elb.entity.DataPackage;
21 | import cn.elb.entity.Request;
22 |
23 | public class SendData {
24 | private static final String HOST="192.168.57.154";
25 | private static final int POST=8888;
26 | private static Socket socket;
27 | public static String sendData(DataPackage> dp){
28 | StringBuffer sb = null;
29 | try {
30 | socket = new Socket(HOST, POST);
31 | String str = JSON.toJSONString(dp);
32 | OutputStream os = socket.getOutputStream();
33 | InputStream is =socket.getInputStream();
34 | os.write(str.getBytes());
35 | socket.shutdownOutput();
36 | sb = new StringBuffer();
37 | BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
38 | String s ="";
39 | while((s=br.readLine())!=null){
40 | sb.append(s);
41 | }
42 |
43 | } catch (UnknownHostException e) {
44 | e.printStackTrace();
45 | } catch (IOException e) {
46 | e.printStackTrace();
47 | }finally{
48 | try {
49 | socket.close();
50 | } catch (IOException e) {
51 | e.printStackTrace();
52 | }
53 | }
54 | return sb.toString();
55 | }
56 | public static void main(String[] args) {
57 | DataPackage