├── .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 dp = new DataPackage(Request.初始化请求, null); 58 | String str = SendData.sendData(dp); 59 | System.out.println(str); 60 | HashMap> map =JSON.parseObject(str, new TypeReference>>() {}); 61 | Set set =map.keySet(); 62 | Iterator ite = set.iterator(); 63 | while(ite.hasNext()){ 64 | BusinessInfo b = ite.next(); 65 | System.out.println(b.getBusiness_name()); 66 | System.out.println("=================================="); 67 | ArrayList list = map.get(b); 68 | for (int i = 0; i < list.size(); i++) { 69 | System.out.println(list.get(i).getCommodity_name()); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /TakeOutSystemCustomer/src/cn/elb/swing/refit/BusinessMenu.java: -------------------------------------------------------------------------------- 1 | package cn.elb.swing.refit; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Graphics; 6 | import java.awt.Image; 7 | import java.net.MalformedURLException; 8 | import java.net.URL; 9 | 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JLabel; 13 | import javax.swing.JPanel; 14 | 15 | import cn.elb.entity.CommodityInfo; 16 | 17 | public class BusinessMenu extends JPanel{ 18 | 19 | private static final long serialVersionUID = -6861429303145378865L; 20 | private Image img; 21 | private JLabel title; 22 | private CommodityInfo commodityInfo; 23 | private JButton addCartBtn; 24 | public BusinessMenu(CommodityInfo commodityInfo) { 25 | this.commodityInfo = commodityInfo; 26 | try { 27 | img = new ImageIcon(new URL("http://127.0.0.1/img/"+commodityInfo.getCommodity_name()+".png")).getImage(); 28 | } catch (MalformedURLException e) { 29 | e.printStackTrace(); 30 | } 31 | title = new JLabel(commodityInfo.getCommodity_name()); 32 | title.setBounds(120, 10, 200, 30); 33 | title.setFont(new Font("黑体", 0, 25)); 34 | add(title); 35 | JLabel price = new JLabel("售价:"+commodityInfo.getCommodity_price()+"元"); 36 | price.setFont(new Font("黑体", 0, 20)); 37 | price.setForeground(Color.RED); 38 | price.setBounds(120,40, 200, 30); 39 | add(price); 40 | addCartBtn = new JButton("加入购物车"); 41 | addCartBtn.setBounds(200, 65, 130, 45); 42 | addCartBtn.setFont(new Font("楷体", 0, 18)); 43 | add(addCartBtn); 44 | } 45 | @Override 46 | protected void paintComponent(Graphics g) { 47 | super.paintComponent(g); 48 | g.drawImage(img, 10, 10, 100, 100, this); 49 | g.setColor(new Color(220, 220, 220)); 50 | g.drawLine(5, 5, 340, 5); 51 | g.drawLine(5, 5, 5, 115); 52 | g.drawLine(5, 115, 340, 115); 53 | g.drawLine(340, 5, 340, 115); 54 | } 55 | public CommodityInfo getCommodityInfo() { 56 | return commodityInfo; 57 | } 58 | public JButton getAddCartBtn() { 59 | return addCartBtn; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /TakeOutSystemCustomer/src/cn/elb/swing/refit/ImageJpanel.java: -------------------------------------------------------------------------------- 1 | package cn.elb.swing.refit; 2 | 3 | import java.awt.Graphics; 4 | import java.awt.Image; 5 | 6 | import javax.swing.ImageIcon; 7 | import javax.swing.JPanel; 8 | 9 | public class ImageJpanel extends JPanel { 10 | 11 | private static final long serialVersionUID = 20180705L; 12 | private Image img; 13 | /** 14 | * 可以添加背景图片的Jpanel 15 | * @param fileName 16 | * img文件夹下图片的地址 17 | */ 18 | public ImageJpanel(String fileName) { 19 | fileName="img/"+fileName; 20 | img = new ImageIcon(fileName).getImage(); 21 | } 22 | @Override 23 | protected void paintComponent(Graphics g) { 24 | super.paintComponent(g); 25 | g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /TakeOutSystemCustomer/src/cn/elb/swing/refit/TakeOutBar.java: -------------------------------------------------------------------------------- 1 | package cn.elb.swing.refit; 2 | 3 | import java.awt.Color; 4 | import java.awt.Font; 5 | import java.awt.Graphics; 6 | import java.awt.Image; 7 | import java.net.MalformedURLException; 8 | import java.net.URL; 9 | 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JLabel; 13 | import javax.swing.JPanel; 14 | 15 | import cn.elb.entity.BusinessInfo; 16 | 17 | public class TakeOutBar extends JPanel{ 18 | 19 | private static final long serialVersionUID = 20180705L; 20 | private Image img; 21 | private JButton intoStore;//进入店铺按钮 22 | private JLabel title; 23 | private BusinessInfo businessInfo; 24 | /** 25 | * 外卖菜单栏 26 | * @param fileName 27 | */ 28 | public TakeOutBar(BusinessInfo businessInfo) { 29 | this.businessInfo = businessInfo; 30 | setLayout(null); 31 | try { 32 | img = new ImageIcon(new URL("http://127.0.0.1/img/"+businessInfo.getBusiness_name()+".png")).getImage(); 33 | } catch (MalformedURLException e) { 34 | e.printStackTrace(); 35 | } 36 | title = new JLabel(businessInfo.getBusiness_name()); 37 | title.setBounds(120, 10, 200, 30); 38 | title.setFont(new Font("黑体", 0, 20)); 39 | title.setForeground(Color.RED); 40 | add(title); 41 | intoStore = new JButton("进入店铺"); 42 | intoStore.setBounds(120, 45, 200, 60); 43 | intoStore.setFont(new Font("楷体", 0, 25)); 44 | add(intoStore); 45 | setSize(385,150); 46 | } 47 | @Override 48 | public String toString() { 49 | return title.getText(); 50 | } 51 | @Override 52 | protected void paintComponent(Graphics g) { 53 | super.paintComponent(g); 54 | g.drawImage(img, 10, 10, 100, 100, this); 55 | g.setColor(new Color(220, 220, 220)); 56 | g.drawLine(5, 5, 340, 5); 57 | g.drawLine(5, 5, 5, 115); 58 | g.drawLine(5, 115, 340, 115); 59 | g.drawLine(340, 5, 340, 115); 60 | } 61 | /** 62 | * 63 | * @return 64 | * 获取外卖栏中进入店铺的按钮 65 | */ 66 | public JButton getIntoStore() { 67 | return intoStore; 68 | } 69 | public int getId(){ 70 | return businessInfo.getBusiness_id(); 71 | } 72 | public BusinessInfo getBusinessInfo() { 73 | return businessInfo; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /TakeOutSystemServer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TakeOutSystemServer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Business 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 | -------------------------------------------------------------------------------- /TakeOutSystemServer/.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 | -------------------------------------------------------------------------------- /TakeOutSystemServer/TestData.txt: -------------------------------------------------------------------------------- 1 | {"customer":{"customer_id":0,"customer_password":"123456","customer_username":"xiaoming"},"e":{{"business_id":10001,"business_name":"华莱士炸鸡汉堡","business_password":"123123","business_username":"hls"}:[{"commodityInfo":{"business_id":10001,"commodity_id":1000002,"commodity_name":"鳕鱼堡","commodity_price":13.0},"count":3},{"commodityInfo":{"business_id":10001,"commodity_id":1000001,"commodity_name":"香辣鸡腿堡","commodity_price":10.0},"count":3}],{"business_id":10003,"business_name":"蓉李记","business_password":"123123","business_username":"rlj"}:[{"commodityInfo":{"business_id":10003,"commodity_id":1000024,"commodity_name":"鸡丝凉面","commodity_price":12.0},"count":4},{"commodityInfo":{"business_id":10003,"commodity_id":1000023,"commodity_name":"重庆小面","commodity_price":15.0},"count":3},{"commodityInfo":{"business_id":10003,"commodity_id":1000022,"commodity_name":"蓉城担担面","commodity_price":15.0},"count":3}],{"business_id":10004,"business_name":"杨铭宇黄焖鸡米饭","business_password":"123123","business_picture":"","business_username":"cjhmjmf"}:[{"commodityInfo":{"business_id":10004,"commodity_id":1000028,"commodity_name":"黄焖鱼豆腐","commodity_picture":"","commodity_price":15.0},"count":4}]},"o":{"$ref":"$.e"},"request":"订单提交"} -------------------------------------------------------------------------------- /TakeOutSystemServer/bin/pres/mao/business/addcommodity.txt: -------------------------------------------------------------------------------- 1 | commodity_id=10002 2 | commodity_name=薯条 3 | commodit_price=12.00 4 | business_id=0001 -------------------------------------------------------------------------------- /TakeOutSystemServer/bin/pres/mao/business/business.txt: -------------------------------------------------------------------------------- 1 | business_id=0001 2 | business_name=华莱士炸鸡汉堡 3 | business_picture=null 4 | business_username=hualaishi 5 | business_password=123123asd -------------------------------------------------------------------------------- /TakeOutSystemServer/bin/pres/mao/business/commodity.txt: -------------------------------------------------------------------------------- 1 | commodity_id=10001 2 | commodity_name=炸鸡汉堡 3 | commodit_price=24.00 4 | business_id=0001 5 | commodity_id=10001 6 | commodity_name=炸鸡汉堡 7 | commodit_price=24.00 8 | business_id=0001 9 | commodity_id=10002 10 | commodity_name=薯条 11 | commodit_price=12.00 12 | business_id=0001 -------------------------------------------------------------------------------- /TakeOutSystemServer/bin/pres/mao/business/orderTest.txt: -------------------------------------------------------------------------------- 1 | orderID=0001 2 | businessID=0002 3 | customerID=0003 4 | order=order 5 | startTime=2018-07-03 6 | endTime=2018-07-04 7 | status=01 -------------------------------------------------------------------------------- /TakeOutSystemServer/config.properties: -------------------------------------------------------------------------------- 1 | PORT=8888 -------------------------------------------------------------------------------- /TakeOutSystemServer/jdbc.properties: -------------------------------------------------------------------------------- 1 | #jdbc 2 | #Mon Jun 04 15:12:07 CST 2018 3 | datatype=mysql 4 | oracleuser=scott 5 | oraclepassword=1596357hu 6 | oracleurl=jdbc:oracle:thin:@localhost:1521:XE 7 | oracledriver=oracle.jdbc.driver.OracleDriver 8 | 9 | mysqldriver=com.mysql.jdbc.Driver 10 | mysqluser=root 11 | mysqlpassword=root 12 | #mysqlurl=jdbc:mysql://106.12.13.224:3306/elb?useUnicode=true&characterEncoding=utf8 13 | mysqlurl=jdbc:mysql://192.168.57.199:3306/elb?useUnicode=true&characterEncoding=utf8 -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/dao/BusinessInfoDao.java: -------------------------------------------------------------------------------- 1 | package cn.elb.dao; 2 | 3 | import java.util.ArrayList; 4 | import cn.elb.entity.BusinessInfo; 5 | import cn.elb.entity.CommodityInfo; 6 | import cn.elb.entity.Orderform; 7 | 8 | public interface BusinessInfoDao { 9 | // -----------增--------- 10 | /** 11 | * 增加商户信息(商家注册:用户名,图片,账号,密码) 12 | * 13 | * @param business 14 | * 商家对象 15 | * @return 16 | */ 17 | public int insert(BusinessInfo business); 18 | 19 | /** 20 | * 增加商品 21 | * 22 | * @param commodity 23 | * @return 24 | */ 25 | public int insert(CommodityInfo commodity); 26 | 27 | // -----------删--------- 28 | /** 29 | * 删除商品 30 | * 31 | * @param commodity_id 32 | * 商品ID 33 | * @return 34 | */ 35 | public int delete(int commodity_id); 36 | 37 | // -----------改--------- 38 | /** 39 | * 修改商家信息(密码、图片) 40 | * 41 | * @param business_id 42 | * @param business_name 43 | * @param business_picture 44 | * @param business_username 45 | * @param business_password 46 | * @return 47 | */ 48 | public int update(int business_id, String business_name, String business_picture, String business_username, 49 | String business_password); 50 | 51 | /** 52 | * 修改商品表 53 | * 54 | * @param commodity_id 55 | * @param commodity_name 56 | * @param commodity_price 57 | * @param commodity_picture 58 | * @param business_id 59 | * @return 60 | */ 61 | public int update(int commodity_id, String commodity_name, double commodity_price, String commodity_picture, 62 | int business_id); 63 | 64 | /** 65 | * 修改订单状态 66 | * 67 | * @param order_id 68 | * 订单编号 69 | * @param status 70 | * 订单状态 71 | * @return 72 | */ 73 | public int update(int order_id, int status); 74 | 75 | // -----------查--------- 76 | /** 77 | * 根据商家username查询商家所有信息 78 | * 79 | * @param business 80 | * @return 81 | */ 82 | public BusinessInfo selectBusinessInfo(String business_username); 83 | 84 | /** 85 | * 根据商家id查询商家所有商品 86 | * 87 | * @param business_id 88 | * @return 89 | */ 90 | public ArrayList selectCommodityInfo(int business_id); 91 | 92 | /** 93 | * 根据商家id查询所有订单 94 | * 95 | * @param business_id 96 | * @return 97 | */ 98 | public ArrayList selectOrderformInfo(int business_id); 99 | 100 | /** 101 | * 根据商家id查询所有订单,有时间限制 102 | * 103 | * @param business_id 104 | * @return 105 | */ 106 | public ArrayList selectOrderformInfoTime(int business_id); 107 | 108 | } 109 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/dao/CustomerInfoDao.java: -------------------------------------------------------------------------------- 1 | package cn.elb.dao; 2 | 3 | import java.util.ArrayList; 4 | 5 | import cn.elb.entity.BusinessInfo; 6 | import cn.elb.entity.CustomerInfo; 7 | import cn.elb.entity.Orderform; 8 | import cn.elb.entity.OrderformInfo; 9 | 10 | public interface CustomerInfoDao { 11 | // -----------增--------- 12 | /** 13 | * 增加用户信息(用户注册:用户名,账号,密码,用户地址) 14 | * 15 | * @param customer 16 | * @return 17 | */ 18 | public int insert(CustomerInfo customer); 19 | 20 | /** 21 | * 增加订单 22 | * 23 | * @param orderform 24 | * @return 25 | */ 26 | public int insert(OrderformInfo orderform); 27 | 28 | // -----------改--------- 29 | /** 30 | * 修改用户信息(用户名,密码,用户地址) 31 | * 32 | * @param customer_id 33 | * @param customer_name 34 | * @param customer_username 35 | * @param customer_password 36 | * @return 37 | */ 38 | public int update(int customer_id, String customer_name, String customer_username, String customer_password, 39 | String customer_address); 40 | 41 | // /** 42 | // * 修改订单状态 43 | // * 44 | // * @param orderform 45 | // * @return 46 | // */ 47 | // public int update(OrderformInfo orderform); 48 | 49 | // -----------查--------- 50 | /** 51 | * 查询所有商家 52 | * 53 | * @return 54 | */ 55 | public ArrayList selectAllBusinessInfo(); 56 | 57 | // /** 58 | // * 根据商家id查询商家所有商品 59 | // * 60 | // * @param business_id 61 | // * @return 62 | // */ 63 | // public ArrayList selectCommodityInfo(int business_id); 64 | 65 | /** 66 | * 根据用户id查询所有订单 67 | * 68 | * @param customer_id 69 | * @return 70 | */ 71 | public ArrayList selectOrderformInfo(int customer_id); 72 | 73 | /** 74 | * 根据用户username查询用户所有信息 75 | * 76 | * @param customer_username 77 | * @return 78 | */ 79 | public CustomerInfo selectCustomerInfo(String customer_username); 80 | 81 | // /** 82 | // * 根据用户name查重 83 | // * 84 | // * @param customer_name 85 | // * @return 86 | // */ 87 | // public int selectCustomerName(String customer_name); 88 | } 89 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/dao/impl/BusinessInfoDaoImpl.java: -------------------------------------------------------------------------------- 1 | package cn.elb.dao.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | import java.util.ArrayList; 8 | 9 | import com.alibaba.fastjson.JSON; 10 | 11 | import cn.elb.dao.BusinessInfoDao; 12 | import cn.elb.entity.BusinessInfo; 13 | import cn.elb.entity.CommodityInfo; 14 | import cn.elb.entity.Order; 15 | import cn.elb.entity.Orderform; 16 | import cn.elb.util.JDBCutil; 17 | 18 | public class BusinessInfoDaoImpl implements BusinessInfoDao { 19 | /** 20 | * 增加商户信息(商家注册:用户名,图片,账号,密码) 21 | */ 22 | @Override 23 | public int insert(BusinessInfo business) { 24 | String sql = "insert into business values ((select * from((select MAX(business_id)+1 from business)a)),?,?,?,?)"; 25 | int result = JDBCutil.update(sql, business.getBusiness_name(), business.getBusiness_picture(), 26 | business.getBusiness_username(), business.getBusiness_password()); 27 | if (result > 0) { 28 | return 1; 29 | } else { 30 | return -1; 31 | } 32 | } 33 | 34 | /** 35 | * 增加商品(商品id,商品名称,商品价格,商品图片,商家id) 36 | */ 37 | @Override 38 | public int insert(CommodityInfo commodity) { 39 | String sql = "insert into commodity values ((select * from((select MAX(commodity_id)+1 from commodity)a)),?,?,?,?)"; 40 | int result = JDBCutil.update(sql, commodity.getCommodity_name(), commodity.getCommodity_price(), 41 | commodity.getCommodity_picture(), commodity.getBusiness_id()); 42 | if (result > 0) { 43 | return 1; 44 | } else { 45 | return -1; 46 | } 47 | } 48 | 49 | /** 50 | * 删除商品 51 | */ 52 | @Override 53 | public int delete(int commodity_id) { 54 | String sql = "delete from commodity where commodity_id=?"; 55 | int result = JDBCutil.update(sql, commodity_id); 56 | if (result > 0) { 57 | return 1; 58 | } else { 59 | return -1; 60 | } 61 | } 62 | 63 | /** 64 | * 修改商家信息(密码、图片) 65 | */ 66 | @Override 67 | public int update(int business_id, String business_name, String business_picture, String business_username, 68 | String business_password) { 69 | String sql = "update business set business_name=?, business_picture=?, business_username=? , business_password=? where business_id=?"; 70 | Object[] obj = { business_name, business_picture, business_username, business_password, business_id }; 71 | int result = JDBCutil.update(sql, obj); 72 | if (result > 0) { 73 | return 1; 74 | } else { 75 | return -1; 76 | } 77 | } 78 | 79 | /** 80 | * 修改商品表 81 | */ 82 | @Override 83 | public int update(int commodity_id, String commodity_name, double commodity_price, String commodity_picture, 84 | int business_id) { 85 | String sql = "update commodity set commodity_name=?,commodity_price=?,commodity_picture=?,business_id=? where commodity_id=?"; 86 | Object[] obj = { commodity_name, commodity_price, commodity_picture, business_id, commodity_id }; 87 | int result = JDBCutil.update(sql, obj); 88 | if (result > 0) { 89 | return 1; 90 | } else { 91 | return -1; 92 | } 93 | } 94 | 95 | /** 96 | * 修改订单状态 97 | */ 98 | @Override 99 | public int update(int order_id, int status) { 100 | String sql = "update userinfo set status=? where order_id=?"; 101 | Object[] obj = { status, order_id }; 102 | int result = JDBCutil.update(sql, obj); 103 | if (result > 0) { 104 | return 1; 105 | } else { 106 | return -1; 107 | } 108 | } 109 | 110 | /** 111 | * 根据商家username查询商家所有的信息 112 | */ 113 | @Override 114 | public BusinessInfo selectBusinessInfo(String business_username) { 115 | Connection conn = JDBCutil.getConn();// 获取连接 116 | Statement stmt = null; // PreparedStatement是Statement的子接口 117 | ResultSet rs = null; 118 | BusinessInfo u = null; 119 | try { 120 | String sql = "select * from business where business_username='" + business_username + "'"; 121 | stmt = conn.createStatement(); 122 | rs = stmt.executeQuery(sql); 123 | while (rs.next()) { 124 | int business_id = rs.getInt("business_id"); 125 | String business_name = rs.getString("business_name"); 126 | String business_picture = rs.getString("business_picture"); 127 | String business_password = rs.getString("business_password"); 128 | u = new BusinessInfo(business_id, business_name, business_picture, business_username, 129 | business_password); 130 | } 131 | } catch (SQLException e) { 132 | e.printStackTrace(); 133 | } finally { 134 | JDBCutil.closeAll(stmt, rs, conn); 135 | } 136 | return u; 137 | } 138 | 139 | /** 140 | * 根据商家id查询商家所有商品 141 | */ 142 | @Override 143 | public ArrayList selectCommodityInfo(int business_id) { 144 | Connection conn = JDBCutil.getConn();// 获取连接 145 | Statement stmt = null; // PreparedStatement是Statement的子接口 146 | ResultSet rs = null; 147 | CommodityInfo u = null; 148 | ArrayList list = new ArrayList<>(); 149 | try { 150 | String sql = "select * from commodity where business_id=" + business_id; 151 | stmt = conn.createStatement(); 152 | rs = stmt.executeQuery(sql); 153 | while (rs.next()) { 154 | int commodity_id = rs.getInt("commodity_id"); 155 | String commodity_name = rs.getString("commodity_name"); 156 | double commodity_price = rs.getDouble("commodity_price"); 157 | String commodity_picture = rs.getString("commodity_picture"); 158 | u = new CommodityInfo(commodity_id, commodity_name, commodity_price, commodity_picture, business_id); 159 | list.add(u); 160 | } 161 | } catch (SQLException e) { 162 | e.printStackTrace(); 163 | } finally { 164 | JDBCutil.closeAll(stmt, rs, conn); 165 | } 166 | return list; 167 | } 168 | 169 | /** 170 | * 根据商家id查询所有订单 171 | */ 172 | @Override 173 | public ArrayList selectOrderformInfo(int business_id) { 174 | Connection conn = JDBCutil.getConn();// 获取连接 175 | Statement stmt = null; // PreparedStatement是Statement的子接口 176 | ResultSet rs = null; 177 | Orderform u = null; 178 | ArrayList list = new ArrayList<>(); 179 | try { 180 | String sql = "SELECT o.order_id, b.business_name, c.customer_name, o.order, o.start_time, o.end_time, o.status FROM orderform o JOIN business b ON o.business_id = b.business_id JOIN customer c ON o.customer_id = c.customer_id WHERE b.business_id =" 181 | + business_id; 182 | stmt = conn.createStatement(); 183 | rs = stmt.executeQuery(sql); 184 | while (rs.next()) { 185 | int order_id = rs.getInt("order_id"); 186 | int customer_id = rs.getInt("customer_id"); 187 | String business_name = rs.getString("business_name"); 188 | String customer_name = rs.getString("customer_name"); 189 | String str = rs.getString("order"); 190 | Long start_time = (Long) rs.getObject("start_time"); 191 | Long end_time = (Long) rs.getObject("end_time"); 192 | int status = rs.getInt("status"); 193 | String customer_address = rs.getString("customer_address"); 194 | Order order = JSON.parseObject(str, Order.class); 195 | u = new Orderform(order_id, business_id, customer_id, order, start_time, end_time, status, 196 | customer_address, business_name, customer_name); 197 | list.add(u); 198 | } 199 | } catch (SQLException e) { 200 | e.printStackTrace(); 201 | } finally { 202 | JDBCutil.closeAll(stmt, rs, conn); 203 | } 204 | return list; 205 | } 206 | 207 | /** 208 | * 根据商家id查询所有订单,有时间限制 209 | */ 210 | @Override 211 | public ArrayList selectOrderformInfoTime(int business_id) { 212 | Connection conn = JDBCutil.getConn();// 获取连接 213 | Statement stmt = null; // PreparedStatement是Statement的子接口 214 | ResultSet rs = null; 215 | Orderform u = null; 216 | ArrayList list = new ArrayList<>(); 217 | Long time = System.currentTimeMillis(); 218 | try { 219 | String sql = "SELECT o.order_id,o.customer_id, b.business_name, c.customer_name, o.order, o.start_time, o.end_time, o.status FROM orderform o JOIN business b ON o.business_id = b.business_id JOIN customer c ON o.customer_id = c.customer_id WHERE b.business_id =" 220 | + business_id + " and start_time >" + (time - 5000); 221 | stmt = conn.createStatement(); 222 | rs = stmt.executeQuery(sql); 223 | while (rs.next()) { 224 | int order_id = rs.getInt("order_id"); 225 | int customer_id = rs.getInt("customer_id"); 226 | String business_name = rs.getString("business_name"); 227 | String customer_name = rs.getString("customer_name"); 228 | String str = rs.getString("order"); 229 | Long start_time = (Long) rs.getObject("start_time"); 230 | Long end_time = (Long) rs.getObject("end_time"); 231 | int status = rs.getInt("status"); 232 | // String customer_address = rs.getString("customer_address"); 233 | Order order = null; 234 | if (str != null) { 235 | order = JSON.parseObject(str, Order.class); 236 | } 237 | u = new Orderform(order_id, business_id, customer_id, order, start_time, end_time, status, 238 | business_name, customer_name); 239 | list.add(u); 240 | } 241 | } catch (SQLException e) { 242 | e.printStackTrace(); 243 | } finally { 244 | JDBCutil.closeAll(stmt, rs, conn); 245 | } 246 | return list; 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/dao/impl/CustomerInfoDaoImp.java: -------------------------------------------------------------------------------- 1 | package cn.elb.dao.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | import java.util.ArrayList; 8 | 9 | import com.alibaba.fastjson.JSON; 10 | 11 | import cn.elb.dao.CustomerInfoDao; 12 | import cn.elb.entity.BusinessInfo; 13 | import cn.elb.entity.CustomerInfo; 14 | import cn.elb.entity.Order; 15 | import cn.elb.entity.Orderform; 16 | import cn.elb.entity.OrderformInfo; 17 | import cn.elb.util.JDBCutil; 18 | 19 | public class CustomerInfoDaoImp implements CustomerInfoDao { 20 | /** 21 | * 增加用户信息(用户注册:用户名,账号,密码,用户地址) 22 | * 23 | * @param customer 24 | * @return 25 | */ 26 | // @Override 27 | // public int insert(CustomerInfo customer) { 28 | // String sql = "insert into customer values ((select * from((select 29 | // MAX(customer_id)+1 from customer)a)),?,?,?,?)"; 30 | // int result = JDBCutil.update(sql, customer.getCustomer_name(), 31 | // customer.getCustomer_username(), 32 | // customer.getCustomer_password(), customer.getCustomer_address()); 33 | // if (result > 0) { 34 | // return 1; 35 | // } else { 36 | // return -1; 37 | // } 38 | // } 39 | @Override 40 | public int insert(CustomerInfo customer) { 41 | String sql = "insert into customer(customer_id,customer_username,customer_password) values ((select * from((select MAX(customer_id)+1 from customer)a)),?,?)"; 42 | int result = JDBCutil.update(sql, customer.getCustomer_username(), customer.getCustomer_password()); 43 | if (result > 0) { 44 | return 1; 45 | } else { 46 | return -1; 47 | } 48 | } 49 | 50 | /** 51 | * 增加订单 52 | * 53 | * @param orderform 54 | * @return 55 | */ 56 | @Override 57 | public int insert(OrderformInfo orderform) { 58 | String sql = "insert into orderform values ((select * from((select MAX(order_id)+1 from orderform)a)),?,?,?,?,?,?,?)"; 59 | int result = JDBCutil.update(sql, orderform.getBusiness_id(), orderform.getCustomer_id(), 60 | orderform.getOrder().toJson(), orderform.getCustomer_address(), orderform.getStart_time(), 61 | orderform.getEnd_time(), orderform.getStatus()); 62 | if (result > 0) { 63 | return 1; 64 | } else { 65 | return -1; 66 | } 67 | } 68 | 69 | /** 70 | * 修改用户信息(用户名,密码,用户地址) 71 | * 72 | * @param customer_id 73 | * @param customer_name 74 | * @param customer_username 75 | * @param customer_password 76 | * @return 77 | */ 78 | @Override 79 | public int update(int customer_id, String customer_name, String customer_username, String customer_password, 80 | String customer_address) { 81 | String sql = "update customer set customer_name=?, customer_username=? , customer_password=?,customer_address=? where customer_id=?"; 82 | Object[] obj = { customer_name, customer_username, customer_password, customer_address, customer_id }; 83 | int result = JDBCutil.update(sql, obj); 84 | if (result > 0) { 85 | return 1; 86 | } else { 87 | return -1; 88 | } 89 | } 90 | 91 | // @Override 92 | // public int update(OrderformInfo orderform) { 93 | // return 0; 94 | // } 95 | /** 96 | * 查询所有商家 97 | * 98 | * @return 99 | */ 100 | @Override 101 | public ArrayList selectAllBusinessInfo() { 102 | Connection conn = JDBCutil.getConn();// 获取连接 103 | Statement stmt = null; // PreparedStatement是Statement的子接口 104 | ResultSet rs = null; 105 | BusinessInfo u = null; 106 | ArrayList list = new ArrayList<>(); 107 | try { 108 | String sql = "select * from business"; 109 | stmt = conn.createStatement(); 110 | rs = stmt.executeQuery(sql); 111 | while (rs.next()) { 112 | int business_id = rs.getInt("business_id"); 113 | String business_name = rs.getString("business_name"); 114 | String business_picture = rs.getString("business_picture"); 115 | String business_username = rs.getString("business_username"); 116 | String business_password = rs.getString("business_password"); 117 | u = new BusinessInfo(business_id, business_name, business_picture, business_username, 118 | business_password); 119 | list.add(u); 120 | } 121 | } catch (SQLException e) { 122 | e.printStackTrace(); 123 | } finally { 124 | JDBCutil.closeAll(stmt, rs, conn); 125 | } 126 | return list; 127 | } 128 | 129 | // @Override 130 | // public ArrayList selectCommodityInfo(int business_id) { 131 | // 132 | // return null; 133 | // } 134 | /** 135 | * 根据用户id查询所有订单 136 | * 137 | * @param customer_id 138 | * @return 139 | */ 140 | @Override 141 | public ArrayList selectOrderformInfo(int customer_id) { 142 | Connection conn = JDBCutil.getConn();// 获取连接 143 | Statement stmt = null; // PreparedStatement是Statement的子接口 144 | ResultSet rs = null; 145 | Orderform u = null; 146 | ArrayList list = new ArrayList<>(); 147 | try { 148 | String sql = "SELECT o.order_id, b.business_name, c.customer_name, o.order, o.start_time, o.end_time, o.status FROM orderform o JOIN business b ON o.business_id = b.business_id JOIN customer c ON o.customer_id = c.customer_id WHERE c.customer_id =" 149 | + customer_id; 150 | stmt = conn.createStatement(); 151 | rs = stmt.executeQuery(sql); 152 | while (rs.next()) { 153 | int order_id = rs.getInt("order_id"); 154 | int business_id = rs.getInt("business_id"); 155 | String business_name = rs.getString("business_name"); 156 | String customer_name = rs.getString("customer_name"); 157 | String str = rs.getString("order"); 158 | Long start_time = (Long) rs.getObject("start_time"); 159 | Long end_time = (Long) rs.getObject("end_time"); 160 | int status = rs.getInt("status"); 161 | String customer_address = rs.getString("customer_address"); 162 | Order order = JSON.parseObject(str, Order.class); 163 | u = new Orderform(order_id, business_id, customer_id, order, start_time, end_time, status, 164 | customer_address, business_name, customer_name); 165 | list.add(u); 166 | } 167 | } catch (SQLException e) { 168 | e.printStackTrace(); 169 | } finally { 170 | JDBCutil.closeAll(stmt, rs, conn); 171 | } 172 | return list; 173 | } 174 | 175 | /** 176 | * 根据用户username查询用户所有信息 177 | * 178 | * @param customer_username 179 | * @return 180 | */ 181 | @Override 182 | public CustomerInfo selectCustomerInfo(String customer_username) { 183 | Connection conn = JDBCutil.getConn();// 获取连接 184 | Statement stmt = null; // PreparedStatement是Statement的子接口 185 | ResultSet rs = null; 186 | CustomerInfo u = null; 187 | try { 188 | String sql = "select * from customer where customer_username='" + customer_username + "'"; 189 | stmt = conn.createStatement(); 190 | rs = stmt.executeQuery(sql); 191 | while (rs.next()) { 192 | int customer_id = rs.getInt("customer_id"); 193 | String customer_name = rs.getString("customer_name"); 194 | String customer_password = rs.getString("customer_password"); 195 | String customer_address = rs.getString("customer_address"); 196 | u = new CustomerInfo(customer_id, customer_name, customer_username, customer_password, 197 | customer_address); 198 | } 199 | } catch (SQLException e) { 200 | e.printStackTrace(); 201 | } finally { 202 | JDBCutil.closeAll(stmt, rs, conn); 203 | } 204 | return u; 205 | } 206 | 207 | // /** 208 | // * 根据用户username查重 209 | // * 210 | // * @param customer_name 211 | // * @return 212 | // */ 213 | // @Override 214 | // public int selectCustomerName(String customer_username) { 215 | // String sql = "select * FROM customer WHERE customer_username ='" + 216 | // customer_username + "'"; 217 | // Connection conn = JDBCutil.getConn();// 获取连接 218 | // Statement stmt = null; // PreparedStatement是Statement的子接口 219 | // ResultSet rs = null; 220 | // CustomerInfo ci = null; 221 | // try { 222 | // stmt = conn.createStatement(); 223 | // rs = stmt.executeQuery(sql); 224 | // while (rs.next()) { 225 | // String username = rs.getString("customer_username"); 226 | // String password = rs.getString("customer_password"); 227 | // ci = new CustomerInfo(username, password); 228 | // } 229 | // } catch (SQLException e) { 230 | // e.printStackTrace(); 231 | // } 232 | // if (ci != null) { 233 | // return 1; 234 | // } else { 235 | // return -1; 236 | // } 237 | // } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/BandIP.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | /** 3 | * 绑定IP与ID 4 | * 5 | * @author Mao_TP 6 | * 7 | */ 8 | 9 | import java.net.InetAddress; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import com.alibaba.fastjson.JSON; 14 | 15 | public class BandIP { 16 | private Map map = new HashMap<>(); 17 | 18 | public BandIP(Map map) { 19 | super(); 20 | this.map = map; 21 | } 22 | 23 | public Map getMap() { 24 | return map; 25 | } 26 | 27 | public void setMap(Map map) { 28 | this.map = map; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "CustomerIP [map=" + map + "]"; 34 | } 35 | 36 | public String toJson() { 37 | return JSON.toJSONString(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/BusinessInfo.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 商家信息表的实体类 5 | * 6 | * @author Administrator 7 | * 8 | */ 9 | public class BusinessInfo { 10 | private int business_id;// 商家id 11 | private String business_name;// 商家名称 12 | private String business_picture;// 商家图片 13 | private String business_username;// 商家账号名 14 | private String business_password;// 商家密码 15 | 16 | public int getBusiness_id() { 17 | return business_id; 18 | } 19 | 20 | public void setBusiness_id(int business_id) { 21 | this.business_id = business_id; 22 | } 23 | 24 | public String getBusiness_name() { 25 | return business_name; 26 | } 27 | 28 | public void setBusiness_name(String business_name) { 29 | this.business_name = business_name; 30 | } 31 | 32 | public String getBusiness_picture() { 33 | return business_picture; 34 | } 35 | 36 | public void setBusiness_picture(String business_picture) { 37 | this.business_picture = business_picture; 38 | } 39 | 40 | public String getBusiness_username() { 41 | return business_username; 42 | } 43 | 44 | public void setBusiness_username(String business_username) { 45 | this.business_username = business_username; 46 | } 47 | 48 | public String getBusiness_password() { 49 | return business_password; 50 | } 51 | 52 | public void setBusiness_password(String business_password) { 53 | this.business_password = business_password; 54 | } 55 | 56 | public BusinessInfo(String business_username, String business_password) { 57 | super(); 58 | this.business_username = business_username; 59 | this.business_password = business_password; 60 | } 61 | 62 | public BusinessInfo(String business_name, String business_picture, String business_username, 63 | String business_password) { 64 | super(); 65 | this.business_name = business_name; 66 | this.business_picture = business_picture; 67 | this.business_username = business_username; 68 | this.business_password = business_password; 69 | } 70 | 71 | public BusinessInfo(int business_id, String business_name, String business_picture, String business_username, 72 | String business_password) { 73 | super(); 74 | this.business_id = business_id; 75 | this.business_name = business_name; 76 | this.business_picture = business_picture; 77 | this.business_username = business_username; 78 | this.business_password = business_password; 79 | } 80 | 81 | public BusinessInfo() { 82 | super(); 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "BusinessInfo [business_name=" + business_name + "]"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/BusinessList.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | 7 | /** 8 | * business表对应的实体类,BusinessInfo为business表中的一条记录 9 | * 10 | * @author Administrator 11 | * 12 | */ 13 | public class BusinessList { 14 | 15 | private ArrayList list; 16 | 17 | public BusinessList(ArrayList list) { 18 | super(); 19 | this.list = list; 20 | } 21 | 22 | public ArrayList getList() { 23 | return list; 24 | } 25 | 26 | public void setList(ArrayList list) { 27 | this.list = list; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | String str = null; 33 | for (BusinessInfo temp : list) { 34 | str = str + temp.toString(); 35 | } 36 | return str; 37 | } 38 | 39 | public String toJson() { 40 | return JSON.toJSONString(this); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/CommodityInfo.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 商品信息表的实体类 5 | * 6 | * @author Administrator 7 | * 8 | */ 9 | public class CommodityInfo { 10 | private int commodity_id;// 商品id 11 | private String commodity_name;// 商品名称 12 | private double commodity_price;// 商品价格 13 | private String commodity_picture;// 商品图片 14 | private int business_id;// 商家id 15 | 16 | public int getCommodity_id() { 17 | return commodity_id; 18 | } 19 | 20 | public void setCommodity_id(int commodity_id) { 21 | this.commodity_id = commodity_id; 22 | } 23 | 24 | public String getCommodity_name() { 25 | return commodity_name; 26 | } 27 | 28 | public void setCommodity_name(String commodity_name) { 29 | this.commodity_name = commodity_name; 30 | } 31 | 32 | public double getCommodity_price() { 33 | return commodity_price; 34 | } 35 | 36 | public void setCommodity_price(double commodity_price) { 37 | this.commodity_price = commodity_price; 38 | } 39 | 40 | public String getCommodity_picture() { 41 | return commodity_picture; 42 | } 43 | 44 | public void setCommodity_picture(String commodity_picture) { 45 | this.commodity_picture = commodity_picture; 46 | } 47 | 48 | public int getBusiness_id() { 49 | return business_id; 50 | } 51 | 52 | public void setBusiness_id(int business_id) { 53 | this.business_id = business_id; 54 | } 55 | 56 | public CommodityInfo(String commodity_name, double commodity_price, String commodity_picture, int business_id) { 57 | super(); 58 | this.commodity_name = commodity_name; 59 | this.commodity_price = commodity_price; 60 | this.commodity_picture = commodity_picture; 61 | this.business_id = business_id; 62 | } 63 | 64 | public CommodityInfo(int commodity_id, String commodity_name, double commodity_price, String commodity_picture, 65 | int business_id) { 66 | super(); 67 | this.commodity_id = commodity_id; 68 | this.commodity_name = commodity_name; 69 | this.commodity_price = commodity_price; 70 | this.commodity_picture = commodity_picture; 71 | this.business_id = business_id; 72 | } 73 | 74 | public CommodityInfo() { 75 | super(); 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "CommodityInfo [commodity_name=" + commodity_name + "]"; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/CommodityList.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | 7 | /** 8 | * commodity表对应的实体类,CommodityInfo为commodity表中的一条信息 9 | * 10 | * @author Mao_TP 11 | * 12 | */ 13 | public class CommodityList { 14 | private ArrayList list; 15 | 16 | public CommodityList(ArrayList list) { 17 | super(); 18 | this.list = list; 19 | } 20 | 21 | public ArrayList getList() { 22 | return list; 23 | } 24 | 25 | public void setList(ArrayList list) { 26 | this.list = list; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | String str = null; 32 | for (CommodityInfo temp : list) { 33 | str = str + temp.toString(); 34 | } 35 | return str; 36 | } 37 | 38 | public String toJson() { 39 | return JSON.toJSONString(this); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/Company.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Company { 6 | private BusinessInfo bi; 7 | private ArrayList list; 8 | 9 | public BusinessInfo getBi() { 10 | return bi; 11 | } 12 | 13 | public void setBi(BusinessInfo bi) { 14 | this.bi = bi; 15 | } 16 | 17 | public ArrayList getList() { 18 | return list; 19 | } 20 | 21 | public void setList(ArrayList list) { 22 | this.list = list; 23 | } 24 | 25 | public Company(BusinessInfo bi, ArrayList list) { 26 | super(); 27 | this.bi = bi; 28 | this.list = list; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/CustomerInfo.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 用户信息表的实体类 5 | * 6 | * @author Administrator 7 | * 8 | */ 9 | public class CustomerInfo { 10 | private int customer_id;// 用户id 11 | private String customer_name;// 用户名称 12 | private String customer_username;// 用户账号名 13 | private String customer_password;// 用户密码 14 | private String customer_address;// 用户地址 15 | 16 | public CustomerInfo(String customer_username, String customer_password) { 17 | super(); 18 | this.customer_username = customer_username; 19 | this.customer_password = customer_password; 20 | } 21 | 22 | public CustomerInfo(String customer_name, String customer_username, String customer_password) { 23 | super(); 24 | this.customer_name = customer_name; 25 | this.customer_username = customer_username; 26 | this.customer_password = customer_password; 27 | } 28 | 29 | public CustomerInfo(int customer_id, String customer_name, String customer_username, String customer_password) { 30 | super(); 31 | this.customer_id = customer_id; 32 | this.customer_name = customer_name; 33 | this.customer_username = customer_username; 34 | this.customer_password = customer_password; 35 | } 36 | 37 | public CustomerInfo(int customer_id, String customer_name, String customer_username, String customer_password, 38 | String customer_address) { 39 | super(); 40 | this.customer_id = customer_id; 41 | this.customer_name = customer_name; 42 | this.customer_username = customer_username; 43 | this.customer_password = customer_password; 44 | this.customer_address = customer_address; 45 | } 46 | 47 | public CustomerInfo() { 48 | super(); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "CustomerInfo [customer_id=" + customer_id + ", customer_name=" + customer_name + ", customer_username=" 54 | + customer_username + ", customer_password=" + customer_password + ", customer_address=" 55 | + customer_address + "]"; 56 | } 57 | 58 | public int getCustomer_id() { 59 | return customer_id; 60 | } 61 | 62 | public void setCustomer_id(int customer_id) { 63 | this.customer_id = customer_id; 64 | } 65 | 66 | public String getCustomer_name() { 67 | return customer_name; 68 | } 69 | 70 | public void setCustomer_name(String customer_name) { 71 | this.customer_name = customer_name; 72 | } 73 | 74 | public String getCustomer_username() { 75 | return customer_username; 76 | } 77 | 78 | public void setCustomer_username(String customer_username) { 79 | this.customer_username = customer_username; 80 | } 81 | 82 | public String getCustomer_password() { 83 | return customer_password; 84 | } 85 | 86 | public void setCustomer_password(String customer_password) { 87 | this.customer_password = customer_password; 88 | } 89 | 90 | public String getCustomer_address() { 91 | return customer_address; 92 | } 93 | 94 | public void setCustomer_address(String customer_address) { 95 | this.customer_address = customer_address; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /TakeOutSystemServer/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 Object o; 15 | private CustomerInfo customer; 16 | 17 | public DataPackage(Request request, Object o) { 18 | super(); 19 | this.request = request; 20 | this.o = o; 21 | } 22 | 23 | public DataPackage(Request request, Object o, CustomerInfo customer) { 24 | super(); 25 | this.request = request; 26 | this.o = o; 27 | this.customer = customer; 28 | } 29 | 30 | public Request getRequest() { 31 | return request; 32 | } 33 | 34 | public void setRequest(Request request) { 35 | this.request = request; 36 | } 37 | 38 | public Object getO() { 39 | return o; 40 | } 41 | 42 | public void setO(Object o) { 43 | this.o = o; 44 | } 45 | 46 | public CustomerInfo getCustomer() { 47 | return customer; 48 | } 49 | 50 | public void setCustomer(CustomerInfo customer) { 51 | this.customer = customer; 52 | } 53 | 54 | public String toJson() { 55 | return JSON.toJSONString(this); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/Goods.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 单个订单 5 | * 6 | * @author hu 7 | * 8 | */ 9 | public class Goods { 10 | private CommodityInfo commodityInfo; 11 | private int count; 12 | 13 | public CommodityInfo getCommodityInfo() { 14 | return commodityInfo; 15 | } 16 | 17 | public void setCommodityInfo(CommodityInfo commodityInfo) { 18 | this.commodityInfo = commodityInfo; 19 | } 20 | 21 | public int getCount() { 22 | return count; 23 | } 24 | 25 | public void setCount(int count) { 26 | this.count = count; 27 | } 28 | 29 | public Goods(CommodityInfo commodityInfo, int count) { 30 | super(); 31 | this.commodityInfo = commodityInfo; 32 | this.count = count; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/Order.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | 7 | public class Order { 8 | private HashMap order = new HashMap<>(); 9 | 10 | public HashMap getOrder() { 11 | return order; 12 | } 13 | 14 | public void setOrder(HashMap order) { 15 | this.order = order; 16 | } 17 | 18 | public void putOrder(CommodityInfo commodityInfo, int count) { 19 | this.order.put(commodityInfo, new Integer(count)); 20 | } 21 | 22 | public Order() { 23 | } 24 | 25 | public Order(HashMap order) { 26 | super(); 27 | this.order = order; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | String key = null; 33 | String value = null; 34 | for (HashMap.Entry entry : order.entrySet()) { 35 | key = key + entry.getKey().toString(); 36 | value = value + entry.getValue().toString(); 37 | } 38 | return "Order [order_key=" + key + "order_value=" + value + "]"; 39 | } 40 | 41 | public String toJson() { 42 | return JSON.toJSONString(this); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/Orderform.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 订单信息表的实体类 5 | * 6 | * @author Administrator 7 | * 8 | */ 9 | public class Orderform extends OrderformInfo { 10 | private String business_name;// 商家名称 11 | private String customer_name;// 用户名称 12 | 13 | public Orderform(int order_id, int business_id, int customer_id, Order order, long start_time, long end_time, 14 | int status, String business_name, String customer_name) { 15 | super(order_id, business_id, customer_id, order, start_time, end_time, status); 16 | this.business_name = business_name; 17 | this.customer_name = customer_name; 18 | } 19 | 20 | public Orderform(int order_id, int business_id, int customer_id, Order order, long start_time, long end_time, 21 | int status, String customer_address, String business_name, String customer_name) { 22 | super(order_id, business_id, customer_id, order, start_time, end_time, status, customer_address); 23 | this.business_name = business_name; 24 | this.customer_name = customer_name; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "Orderform [order_id=" + super.getOrder_id() + ", business_id=" + super.getBusiness_id() 30 | + ", customer_id=" + super.getCustomer_id() + ", business_name=" + business_name + ", customer_name=" 31 | + customer_name + ", order=" + super.getOrder() + ", start_time=" + super.getStart_time() 32 | + ", end_time=" + super.getEnd_time() + ", status=" + super.getStatus() + ", customer_address=" 33 | + super.getCustomer_address() + "]"; 34 | } 35 | 36 | public String getBusiness_name() { 37 | return business_name; 38 | } 39 | 40 | public void setBusiness_name(String business_name) { 41 | this.business_name = business_name; 42 | } 43 | 44 | public String getCustomer_name() { 45 | return customer_name; 46 | } 47 | 48 | public void setCustomer_name(String customer_name) { 49 | this.customer_name = customer_name; 50 | } 51 | 52 | public Orderform() { 53 | super(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/entity/OrderformInfo.java: -------------------------------------------------------------------------------- 1 | package cn.elb.entity; 2 | 3 | /** 4 | * 订单信息表的实体类 5 | * 6 | * @author Administrator 7 | * 8 | */ 9 | public class OrderformInfo { 10 | private int order_id;// 订单id 11 | private int business_id;// 商家id 12 | private int customer_id;// 用户id 13 | private Order order;// 订单详细信息 14 | private long start_time;// 订单开始时间 15 | private long end_time;// 订单结束时间 16 | private int status;// 订单状态 17 | private String customer_address;// 用户地址 18 | 19 | public String getCustomer_address() { 20 | return customer_address; 21 | } 22 | 23 | public void setCustomer_address(String customer_address) { 24 | this.customer_address = customer_address; 25 | } 26 | 27 | public int getOrder_id() { 28 | return order_id; 29 | } 30 | 31 | public void setOrder_id(int order_id) { 32 | this.order_id = order_id; 33 | } 34 | 35 | public int getBusiness_id() { 36 | return business_id; 37 | } 38 | 39 | public void setBusiness_id(int business_id) { 40 | this.business_id = business_id; 41 | } 42 | 43 | public int getCustomer_id() { 44 | return customer_id; 45 | } 46 | 47 | public void setCustomer_id(int customer_id) { 48 | this.customer_id = customer_id; 49 | } 50 | 51 | public Order getOrder() { 52 | return order; 53 | } 54 | 55 | public void setOrder(Order order) { 56 | this.order = order; 57 | } 58 | 59 | public long getStart_time() { 60 | return start_time; 61 | } 62 | 63 | public void setStart_time(long start_time) { 64 | this.start_time = start_time; 65 | } 66 | 67 | public long getEnd_time() { 68 | return end_time; 69 | } 70 | 71 | public void setEnd_time(long end_time) { 72 | this.end_time = end_time; 73 | } 74 | 75 | public int getStatus() { 76 | return status; 77 | } 78 | 79 | public void setStatus(int status) { 80 | this.status = status; 81 | } 82 | 83 | public OrderformInfo(int order_id, int business_id, int customer_id, Order order, long start_time, long end_time, 84 | int status) { 85 | super(); 86 | this.order_id = order_id; 87 | this.business_id = business_id; 88 | this.order = order; 89 | this.start_time = start_time; 90 | this.end_time = end_time; 91 | this.status = status; 92 | } 93 | 94 | public OrderformInfo(int business_id, int customer_id, Order order, long start_time, long end_time, int status, 95 | String customer_address) { 96 | super(); 97 | this.business_id = business_id; 98 | this.customer_id = customer_id; 99 | this.order = order; 100 | this.start_time = start_time; 101 | this.end_time = end_time; 102 | this.status = status; 103 | this.customer_address = customer_address; 104 | } 105 | 106 | public OrderformInfo(int order_id, int business_id, int customer_id, Order order, long start_time, long end_time, 107 | int status, String customer_address) { 108 | super(); 109 | this.order_id = order_id; 110 | this.business_id = business_id; 111 | this.customer_id = customer_id; 112 | this.order = order; 113 | this.start_time = start_time; 114 | this.end_time = end_time; 115 | this.status = status; 116 | this.customer_address = customer_address; 117 | } 118 | 119 | public OrderformInfo() { 120 | super(); 121 | } 122 | 123 | @Override 124 | public String toString() { 125 | return "OrderformInfo [order_id=" + order_id + ", business_id=" + business_id + ", customer_id=" + customer_id 126 | + ", order=" + order.toString() + ", start_time=" + start_time + ", end_time=" + end_time + ", status=" 127 | + status + ", customer_address=" + customer_address + "]"; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /TakeOutSystemServer/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 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/response/MySocket.java: -------------------------------------------------------------------------------- 1 | package cn.elb.response; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.io.OutputStreamWriter; 8 | import java.net.Socket; 9 | 10 | public class MySocket implements Runnable { 11 | private Socket socket; 12 | private BufferedReader reader; 13 | private BufferedWriter writer; 14 | 15 | public MySocket(Socket socket) { 16 | this.socket = socket; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | try { 22 | reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); 23 | writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); 24 | String str = ""; 25 | str = reader.readLine(); 26 | System.out.print("服务端收到" + socket.getInetAddress().getHostAddress() + "发来的请求!\n"); 27 | /** 28 | * 在此对传入内容进行处理
29 | * 1、对传入的JSON字符串进行解包
30 | * 2、对请求进行分派
31 | */ 32 | // 分派 33 | String response = Response.responseQuest(str); 34 | if (response == null) { 35 | response = ""; 36 | } 37 | writer.write(response); 38 | writer.flush(); 39 | System.out.print("服务端将" + socket.getInetAddress().getHostAddress() + "的请求处理完毕\n"); 40 | } catch ( 41 | 42 | IOException e) { 43 | e.printStackTrace(); 44 | } finally { 45 | try { 46 | System.out.println(socket.getInetAddress().getHostAddress() + "断开连接!"); 47 | socket.close(); 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/response/Response.java: -------------------------------------------------------------------------------- 1 | package cn.elb.response; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.Map.Entry; 6 | 7 | import com.alibaba.fastjson.JSON; 8 | import com.alibaba.fastjson.JSONObject; 9 | import com.alibaba.fastjson.TypeReference; 10 | 11 | import cn.elb.dao.impl.BusinessInfoDaoImpl; 12 | import cn.elb.dao.impl.CustomerInfoDaoImp; 13 | import cn.elb.entity.BusinessInfo; 14 | import cn.elb.entity.CommodityInfo; 15 | import cn.elb.entity.CustomerInfo; 16 | import cn.elb.entity.DataPackage; 17 | import cn.elb.entity.Goods; 18 | import cn.elb.entity.Order; 19 | import cn.elb.entity.Orderform; 20 | import cn.elb.entity.OrderformInfo; 21 | 22 | /** 23 | * 请求响应 请求类型 请求代码 涉及数据表
24 | * 初始化请求 00 BusinessList,CommodityList——商家对象,包含商家对应的商品链表
25 | * 商家登录 01 BusinessInfo
26 | * 用户登录 02 CustomerInfo
27 | * 商家信息修改 03 BusinessInfo
28 | * 用户信息修改 04 CustomerInfo
29 | * 订单提交 05 OrderformInfo
30 | * 订单修改 06 OrderformInfo
31 | * 商家查询订单 07 OrderformInfoList
32 | * 用户查询订单 08 OrderformInfoList
33 | * 商家,用户注册
34 | * 35 | * @author Mao_TP 36 | * 37 | */ 38 | // TODO 改英文 39 | public class Response { 40 | private static CustomerInfoDaoImp cimp = new CustomerInfoDaoImp(); 41 | private static BusinessInfoDaoImpl bimp = new BusinessInfoDaoImpl(); 42 | 43 | /** 44 | * 45 | * @param request 46 | * @param o 47 | * @return 48 | */ 49 | public static String responseQuest(String json) { 50 | String str = null; 51 | // 解包 52 | DataPackage data = JSON.parseObject(json, DataPackage.class); 53 | DataPackage data2 = null; 54 | JSONObject jo = null; 55 | JSONObject jsonObj = null; 56 | switch (data.getRequest()) { 57 | case 初始化请求: 58 | ArrayList list = cimp.selectAllBusinessInfo(); 59 | HashMap> map = new HashMap<>(); 60 | for (BusinessInfo temp : list) { 61 | int business_id = temp.getBusiness_id(); 62 | map.put(temp, bimp.selectCommodityInfo(business_id)); 63 | } 64 | str = JSON.toJSONString(map); 65 | map = JSON.parseObject(str, new TypeReference>>() { 66 | }); 67 | break; 68 | case 用户注册: 69 | jsonObj = JSONObject.parseObject(json); 70 | jo = jsonObj.getJSONObject("o"); 71 | CustomerInfo c = JSONObject.parseObject(jo.toJSONString(), CustomerInfo.class); 72 | CustomerInfo flag = cimp.selectCustomerInfo(c.getCustomer_username()); 73 | if (flag != null) { 74 | str = "Haved";// 用户已存在 75 | } else { 76 | if (cimp.insert(c) == 1) { 77 | str = "Success";// 注册成功 78 | } else { 79 | str = "Failed";// 注册失败 80 | } 81 | } 82 | break; 83 | case 商家登录: 84 | jsonObj = null; 85 | jsonObj = JSONObject.parseObject(json); 86 | JSONObject json_BusinessInfo = jsonObj.getJSONObject("o"); 87 | BusinessInfo bi_log = JSON.parseObject(json_BusinessInfo.toJSONString(), BusinessInfo.class); 88 | // BusinessInfo bi_log = JSONObject 89 | bi_log = bimp.selectBusinessInfo(bi_log.getBusiness_username()); 90 | if (bi_log == null) { 91 | data2 = new DataPackage(null, null); 92 | } else { 93 | data2 = new DataPackage(null, bi_log); 94 | } 95 | str = JSON.toJSONString(data2); 96 | break; 97 | case 用户登录: 98 | // 绑定IP与ID 99 | // BandIP ip = new BandIP(); 100 | jsonObj = null; 101 | jsonObj = JSONObject.parseObject(json); 102 | JSONObject json_CustomerInfo = jsonObj.getJSONObject("o"); 103 | CustomerInfo ci_log = JSON.parseObject(json_CustomerInfo.toJSONString(), CustomerInfo.class); 104 | 105 | // BusinessInfo bi_log = JSONObject 106 | ci_log = cimp.selectCustomerInfo(ci_log.getCustomer_username()); 107 | data2 = null; 108 | if (ci_log == null) { 109 | data2 = new DataPackage(null, null); 110 | } else { 111 | data2 = new DataPackage(null, ci_log); 112 | } 113 | str = JSON.toJSONString(data2); 114 | break; 115 | case 商家信息修改: 116 | 117 | break; 118 | case 用户信息修改: 119 | 120 | break; 121 | case 订单提交: 122 | // HashMap 123 | // HashMap> 124 | int i = -1; 125 | // 拆包 126 | jsonObj = JSONObject.parseObject(json); 127 | jo = jsonObj.getJSONObject("o"); 128 | JSONObject json_customer = jsonObj.getJSONObject("customer"); 129 | CustomerInfo customerInfo = JSONObject.parseObject(json_customer.toJSONString(), CustomerInfo.class); 130 | String customer_username = customerInfo.getCustomer_username(); 131 | customerInfo = cimp.selectCustomerInfo(customer_username); 132 | int customer_id = customerInfo.getCustomer_id(); 133 | String customer_address = customerInfo.getCustomer_address(); 134 | HashMap> orderMap = JSONObject.parseObject(jo.toJSONString(), 135 | new TypeReference>>() { 136 | }); 137 | for (Entry> entry : orderMap.entrySet()) { 138 | BusinessInfo bi = entry.getKey(); 139 | int business_id = bi.getBusiness_id(); 140 | long start_time = System.currentTimeMillis(); 141 | Long end_time = 0L; 142 | int status = 0; 143 | ArrayList glist = entry.getValue(); 144 | Order order = new Order(); 145 | for (Goods temp : glist) { 146 | order.putOrder(temp.getCommodityInfo(), temp.getCount()); 147 | } 148 | OrderformInfo orderform = new OrderformInfo(business_id, customer_id, order, start_time, end_time, 149 | status, customer_address); 150 | i = cimp.insert(orderform); 151 | } 152 | if (i == 1) { 153 | str = "Success"; 154 | } else { 155 | str = "Failed"; 156 | } 157 | 158 | break; 159 | case 订单修改: 160 | 161 | break; 162 | case 商家查询订单: 163 | 164 | break; 165 | case 心跳包: 166 | // 拆包 167 | jsonObj = JSONObject.parseObject(json); 168 | jo = jsonObj.getJSONObject("o"); 169 | BusinessInfo bi = JSON.parseObject(jo.toJSONString(), BusinessInfo.class); 170 | // 获取商家信息8 171 | bi = bimp.selectBusinessInfo(bi.getBusiness_username()); 172 | // 根据商家id查询订单 173 | ArrayList list1 = bimp.selectOrderformInfoTime(bi.getBusiness_id()); 174 | Order order = new Order(); 175 | // 查询最近五秒的订单orderform.getOrder().getOrder() 176 | if (list1.size() != 0) { 177 | order.setOrder(list1.get(0).getOrder().getOrder()); 178 | str = JSON.toJSONString(order); 179 | } 180 | break; 181 | 182 | case 用户订单查询: 183 | 184 | break; 185 | default: 186 | break; 187 | } 188 | return str; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/response/Server.java: -------------------------------------------------------------------------------- 1 | package cn.elb.response; 2 | 3 | import java.io.FileNotFoundException; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | import java.net.ServerSocket; 7 | import java.net.Socket; 8 | import java.util.Properties; 9 | 10 | public class Server { 11 | private final int PORT; 12 | private ServerSocket serverSocket; 13 | 14 | public Server() { 15 | Properties p = new Properties(); 16 | try { 17 | p.load(new FileReader("config.properties")); 18 | } catch (FileNotFoundException e) { 19 | e.printStackTrace(); 20 | } catch (IOException e) { 21 | e.printStackTrace(); 22 | } 23 | PORT = Integer.parseInt(p.getProperty("PORT")); 24 | } 25 | 26 | public void start() { 27 | try { 28 | serverSocket = new ServerSocket(PORT); 29 | System.out.println("服务器已启动!正在监听" + PORT + "端口...."); 30 | while (true) { 31 | Socket socket = serverSocket.accept(); 32 | // 线程启动 33 | new Thread(new MySocket(socket)).start(); 34 | 35 | System.out.println(socket.getInetAddress().getHostAddress() + "连接到服务器!"); 36 | } 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } finally { 40 | try { 41 | if (serverSocket != null) { 42 | serverSocket.close(); 43 | } 44 | } catch (IOException e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | } 49 | 50 | public static void main(String[] args) { 51 | new Server().start(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/test/Test.java: -------------------------------------------------------------------------------- 1 | package cn.elb.test; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedReader; 5 | import java.io.FileInputStream; 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.Map.Entry; 12 | 13 | import com.alibaba.fastjson.JSONObject; 14 | import com.alibaba.fastjson.TypeReference; 15 | 16 | import cn.elb.dao.impl.CustomerInfoDaoImp; 17 | import cn.elb.entity.BusinessInfo; 18 | import cn.elb.entity.CustomerInfo; 19 | import cn.elb.entity.Goods; 20 | import cn.elb.entity.Order; 21 | import cn.elb.entity.OrderformInfo; 22 | import cn.elb.entity.Request; 23 | import cn.elb.response.Response; 24 | 25 | /** 26 | * 测试json 27 | * 28 | * @author Mao_TP8745 29 | * 30 | */ 31 | public class Test { 32 | public static void main(String[] args) throws IOException { 33 | // CustomerInfo ci = new CustomerInfo("maomao", "asd"); 34 | long start = System.currentTimeMillis(); 35 | BufferedReader bi = new BufferedReader(new FileReader("TestData.txt")); 36 | StringBuffer sb = new StringBuffer(); 37 | String str = bi.readLine(); 38 | while (str != null) { 39 | sb.append(str); 40 | str = bi.readLine(); 41 | } 42 | 43 | insert(sb.toString()); 44 | long end = System.currentTimeMillis(); 45 | System.out.println(end - start); 46 | } 47 | 48 | public static void insert(String json) { 49 | // HashMap 50 | // HashMap> 51 | CustomerInfoDaoImp cimp = new CustomerInfoDaoImp(); 52 | JSONObject jsonObj1 = JSONObject.parseObject(json); 53 | JSONObject json_o = jsonObj1.getJSONObject("o"); 54 | JSONObject json_customer = jsonObj1.getJSONObject("customer"); 55 | CustomerInfo customerInfo = JSONObject.parseObject(json_customer.toJSONString(), CustomerInfo.class); 56 | String customer_username = customerInfo.getCustomer_username(); 57 | customerInfo = cimp.selectCustomerInfo(customer_username); 58 | int customer_id = customerInfo.getCustomer_id(); 59 | String customer_address = customerInfo.getCustomer_address(); 60 | HashMap> orderMap = JSONObject.parseObject(json_o.toJSONString(), 61 | new TypeReference>>() { 62 | }); 63 | for (Entry> entry : orderMap.entrySet()) { 64 | BusinessInfo bi = entry.getKey(); 65 | int business_id = bi.getBusiness_id(); 66 | long start_time = System.currentTimeMillis(); 67 | Long end_time = 0L; 68 | int status = 0; 69 | ArrayList glist = entry.getValue(); 70 | Order order = new Order(); 71 | for (Goods temp : glist) { 72 | order.putOrder(temp.getCommodityInfo(), temp.getCount()); 73 | } 74 | OrderformInfo orderform = new OrderformInfo(business_id, customer_id, order, start_time, end_time, status, 75 | customer_address); 76 | cimp.insert(orderform); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/cn/elb/util/JDBCutil.java: -------------------------------------------------------------------------------- 1 | package cn.elb.util; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.FileReader; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | import java.sql.Connection; 9 | import java.sql.DriverManager; 10 | import java.sql.PreparedStatement; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.sql.Statement; 14 | import java.util.Properties; 15 | 16 | public class JDBCutil { 17 | private static String DRIVER; 18 | private static String URL; 19 | private static String USER; 20 | private static String PASSWORD; 21 | private static File file = new File("jdbc.properties"); 22 | static { 23 | Properties p = new Properties(); 24 | if (!file.exists()) { 25 | p.setProperty("oracledriver", "oracle.jdbc.driver.OracleDriver"); 26 | p.setProperty("oracleurl", "jdbc:oracle:thin:@localhost:1521:XE"); 27 | p.setProperty("oracleuser", "scott"); 28 | p.setProperty("oraclepassword", "1596357hu"); 29 | p.setProperty("datatype", "oracle"); 30 | try { 31 | p.store(new FileWriter(file), "jdbc"); 32 | } catch (IOException e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | try { 37 | p.load(new FileReader(file)); 38 | String dataType = p.getProperty("datatype"); 39 | System.out.println("---------" + dataType); 40 | DRIVER = p.getProperty(dataType + "driver"); 41 | URL = p.getProperty(dataType + "url"); 42 | USER = p.getProperty(dataType + "user"); 43 | PASSWORD = p.getProperty(dataType + "password"); 44 | } catch (FileNotFoundException e) { 45 | e.printStackTrace(); 46 | } catch (IOException e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | public static Connection getConn() { 52 | Connection conn = null; 53 | try { 54 | Class.forName(DRIVER); 55 | conn = DriverManager.getConnection(URL, USER, PASSWORD); 56 | } catch (ClassNotFoundException e) { 57 | e.printStackTrace(); 58 | } catch (SQLException e) { 59 | e.printStackTrace(); 60 | } 61 | return conn; 62 | } 63 | 64 | public static int update(String sql, Object... obj) { 65 | Connection conn = null; 66 | PreparedStatement stmt = null; 67 | int result = 0; 68 | conn = getConn(); 69 | try { 70 | stmt = conn.prepareStatement(sql); 71 | for (int i = 0; i < obj.length; i++) { 72 | stmt.setObject(i + 1, obj[i]); 73 | } 74 | result = stmt.executeUpdate(); 75 | } catch (SQLException e) { 76 | e.printStackTrace(); 77 | } 78 | return result; 79 | } 80 | 81 | public static void closeAll(Statement stmt, ResultSet rs, Connection conn) { 82 | if (stmt != null) { 83 | try { 84 | stmt.close(); 85 | } catch (SQLException e) { 86 | e.printStackTrace(); 87 | } 88 | } 89 | if (rs != null) { 90 | try { 91 | rs.close(); 92 | } catch (SQLException e) { 93 | e.printStackTrace(); 94 | } 95 | } 96 | if (conn != null) { 97 | try { 98 | conn.close(); 99 | } catch (SQLException e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | } 104 | 105 | public static void main(String[] args) { 106 | System.out.println(getConn()); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/OrderList.java: -------------------------------------------------------------------------------- 1 | package pres.mao.business; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | 7 | import cn.elb.entity.Order; 8 | 9 | /** 10 | * 订单的列表 11 | * 12 | * @author Mao_TP 13 | * 14 | */ 15 | public class OrderList { 16 | ArrayList list = new ArrayList<>(); 17 | 18 | public OrderList(ArrayList list) { 19 | super(); 20 | this.list = list; 21 | } 22 | 23 | public ArrayList getList() { 24 | return list; 25 | } 26 | 27 | public void setList(ArrayList list) { 28 | this.list = list; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | String str = null; 34 | for (Order temp : list) { 35 | str = str + temp.toString(); 36 | } 37 | return str; 38 | } 39 | 40 | public String toJson() { 41 | String str = JSON.toJSONString(this); 42 | return str; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/Test.java: -------------------------------------------------------------------------------- 1 | package pres.mao.business; 2 | 3 | import java.awt.List; 4 | import java.io.BufferedInputStream; 5 | import java.io.BufferedOutputStream; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.util.ArrayList; 11 | 12 | import com.alibaba.fastjson.JSON; 13 | 14 | import cn.elb.dao.BusinessInfoDao; 15 | import cn.elb.dao.impl.BusinessInfoDaoImpl; 16 | import cn.elb.entity.CommodityList; 17 | import cn.elb.entity.CustomerInfo; 18 | 19 | /** 20 | * 外卖订餐系统
21 | * 商家部分
22 | * 23 | * @author Mao_TP 24 | * 25 | */ 26 | class Te { 27 | private Color color; 28 | private Object o; 29 | private ArrayList list; 30 | 31 | public ArrayList getList() { 32 | return list; 33 | } 34 | 35 | public void setList(ArrayList list) { 36 | this.list = list; 37 | } 38 | 39 | public Object getO() { 40 | return o; 41 | } 42 | 43 | public void setO(Object o) { 44 | this.o = o; 45 | } 46 | 47 | public Color getColor() { 48 | return color; 49 | } 50 | 51 | public void setColor(Color color) { 52 | this.color = color; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "Te [color=" + color + ", o=" + o + ", list=" + list + "]"; 58 | } 59 | 60 | } 61 | 62 | enum Color { 63 | red, blue, green; 64 | 65 | } 66 | 67 | public class Test { 68 | 69 | public static void main(String[] args) throws FileNotFoundException, IOException { 70 | 71 | // Test t = new Test(); 72 | // t.addCommodity("addcommodity.txt", "commodity.txt"); // 添加商品 73 | // t.queryStatus("orderTest.txt"); // 查询订单状态 74 | // t.modifyStatus("orderTest.txt"); // 修改订单状态 75 | // t.showCommodity(10001); 76 | Te t = new Te(); 77 | t.setColor(Color.red); 78 | 79 | t.setList(new ArrayList()); 80 | t.getList().add("asd"); 81 | t.getList().add("zXC"); 82 | t.getList().add("xfg"); 83 | t.getList().add("qqq"); 84 | t.setO(new CustomerInfo("mao", "123")); 85 | String str = JSON.toJSONString(t); 86 | System.out.println(str); 87 | System.out.println(JSON.parseObject(str, Te.class)); 88 | 89 | } 90 | 91 | /** 92 | * 读取订单
93 | * 94 | * @param path 95 | * 序列化内容 96 | * @return b 订单信息 97 | * @throws IOException 98 | */ 99 | public byte[] readOrder(String path) throws IOException { 100 | 101 | BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path)); 102 | // BufferedInputStream bos2 = new BufferedInputStream(new ObjectInputStream(new 103 | // FileInputStream("orderTest.txt")));————之后要修改成序列化 104 | byte[] b = new byte[bis.available()]; 105 | bis.read(b); 106 | bis.close(); 107 | return b; 108 | } 109 | 110 | /** 111 | * 写入订单
112 | * 113 | * @param b 114 | * 订单信息数据 115 | * @param path 116 | * 序列化内容 117 | * @throws IOException 118 | */ 119 | public void writeOrder(byte[] b, String path) throws IOException { 120 | 121 | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(path)); 122 | // BufferedOutputStream bos2 = new BufferedOutputStream(new 123 | // ObjectOutputStream(new 124 | // FileOutputStream("orderTest.txt")));————之后要修改成序列化 125 | bos.write(b); 126 | bos.flush(); 127 | bos.close(); 128 | } 129 | 130 | /** 131 | * 查询订单状态
132 | * 133 | * @param orderPath 134 | * 订单表 135 | * @throws IOException 136 | */ 137 | public void queryStatus(String orderPath) throws IOException { 138 | 139 | // 读取订单 140 | byte[] orderTest = readOrder(orderPath); 141 | 142 | // 显示订单 143 | String str = new String(orderTest); 144 | System.out.println(str); 145 | } 146 | 147 | /** 148 | * 修改订单状态
149 | * 150 | * 状态:
151 | * 00 保存订单,状态为(未接单)
152 | * 01 修改订单状态为(已接单)
153 | * 02  修改订单状态为(配送中)
154 | * 03 修改订单状态为(已完成)
155 | * 156 | * @param orderPath 157 | * 订单表 158 | * @throws FileNotFoundException 159 | * @throws IOException 160 | */ 161 | public void modifyStatus(String orderPath) throws FileNotFoundException, IOException { 162 | 163 | // 读取订单 164 | byte[] orderTest = readOrder(orderPath); 165 | 166 | // 显示订单 167 | String str = new String(orderTest); 168 | System.out.println(str); 169 | 170 | // 修改订单(主要是修改订单状态) 171 | str = str.replaceAll("status=00", "status=01");// 这里可以换成一个enum 172 | 173 | // 保存订单 174 | byte[] temp = str.getBytes(); 175 | System.out.println("============"); 176 | writeOrder(temp, orderPath); 177 | System.out.println(new String(readOrder(orderPath))); 178 | 179 | } 180 | 181 | /** 182 | * 增加商品
183 | * 184 | * @param addCommoditypath 185 | * 增加的商品表 186 | * @param commoditypath 187 | * 商品表 188 | * @throws IOException 189 | */ 190 | public void addCommodity(String addCommoditypath, String commoditypath) throws IOException { 191 | 192 | // 读取要增加的商品列表 193 | // 通过填表的方式完成新增商品 194 | byte[] commodity = readOrder(addCommoditypath); 195 | String str = new String(commodity); 196 | // System.out.println(str);// 显示订单 197 | 198 | // 读取现有商品列表 199 | byte[] commoditys = readOrder(commoditypath); 200 | 201 | // 增加商品——在sql中采用增加,在txt测试中暂时采用string字符串添加 202 | str = (new String(commoditys)) + System.getProperty("line.separator") + str; 203 | writeOrder(str.getBytes(), commoditypath); 204 | System.out.println(str); 205 | } 206 | 207 | /** 208 | * 删除商品 209 | * 210 | * @throws IOException 211 | */ 212 | public void deleteCommodity(int commodity_id) throws IOException { 213 | 214 | // 读取当前商品列表,Test使用 215 | byte[] commoditys = readOrder("commodity.txt"); 216 | 217 | // 根据发送过来的商品ID删除商品 218 | 219 | } 220 | 221 | /** 222 | * 展示商品 223 | */ 224 | public void showCommodity(int business_id) { 225 | BusinessInfoDao bid = new BusinessInfoDaoImpl(); 226 | bid.selectCommodityInfo(business_id); 227 | // iTODO 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/addcommodity.txt: -------------------------------------------------------------------------------- 1 | commodity_id=10002 2 | commodity_name=薯条 3 | commodit_price=12.00 4 | business_id=0001 -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/business.txt: -------------------------------------------------------------------------------- 1 | business_id=0001 2 | business_name=华莱士炸鸡汉堡 3 | business_picture=null 4 | business_username=hualaishi 5 | business_password=123123asd -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/commodity.txt: -------------------------------------------------------------------------------- 1 | commodity_id=10001 2 | commodity_name=炸鸡汉堡 3 | commodit_price=24.00 4 | business_id=0001 5 | commodity_id=10001 6 | commodity_name=炸鸡汉堡 7 | commodit_price=24.00 8 | business_id=0001 9 | commodity_id=10002 10 | commodity_name=薯条 11 | commodit_price=12.00 12 | business_id=0001 -------------------------------------------------------------------------------- /TakeOutSystemServer/src/pres/mao/business/orderTest.txt: -------------------------------------------------------------------------------- 1 | orderID=0001 2 | businessID=0002 3 | customerID=0003 4 | order=order 5 | startTime=2018-07-03 6 | endTime=2018-07-04 7 | status=01 -------------------------------------------------------------------------------- /img/不辣.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/不辣.png -------------------------------------------------------------------------------- /img/中杯可乐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/中杯可乐.png -------------------------------------------------------------------------------- /img/午餐肉.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/午餐肉.png -------------------------------------------------------------------------------- /img/华莱士炸鸡汉堡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/华莱士炸鸡汉堡.png -------------------------------------------------------------------------------- /img/吉味双拼饭.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/吉味双拼饭.png -------------------------------------------------------------------------------- /img/吉野家.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/吉野家.png -------------------------------------------------------------------------------- /img/培根.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/培根.png -------------------------------------------------------------------------------- /img/培根炒双蛋堡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/培根炒双蛋堡.png -------------------------------------------------------------------------------- /img/大杯可乐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/大杯可乐.png -------------------------------------------------------------------------------- /img/奥尔良烤翅.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/奥尔良烤翅.png -------------------------------------------------------------------------------- /img/娃娃菜.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/娃娃菜.png -------------------------------------------------------------------------------- /img/小杯可乐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/小杯可乐.png -------------------------------------------------------------------------------- /img/张亮麻辣烫.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/张亮麻辣烫.png -------------------------------------------------------------------------------- /img/微辣.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/微辣.png -------------------------------------------------------------------------------- /img/必胜客.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/必胜客.png -------------------------------------------------------------------------------- /img/招牌牛肉饭.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/招牌牛肉饭.png -------------------------------------------------------------------------------- /img/撒尿牛丸.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/撒尿牛丸.png -------------------------------------------------------------------------------- /img/方便面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/方便面.png -------------------------------------------------------------------------------- /img/杨铭宇黄焖鸡米饭.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/杨铭宇黄焖鸡米饭.png -------------------------------------------------------------------------------- /img/欧式培根炒饭.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/欧式培根炒饭.png -------------------------------------------------------------------------------- /img/海鲜至尊披萨.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/海鲜至尊披萨.png -------------------------------------------------------------------------------- /img/猪柳蛋堡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/猪柳蛋堡.png -------------------------------------------------------------------------------- /img/皮蛋鸡肉粥.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/皮蛋鸡肉粥.png -------------------------------------------------------------------------------- /img/粉丝.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/粉丝.png -------------------------------------------------------------------------------- /img/老成都酸辣粉.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/老成都酸辣粉.png -------------------------------------------------------------------------------- /img/脆香油条.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/脆香油条.png -------------------------------------------------------------------------------- /img/蓉城担担面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/蓉城担担面.png -------------------------------------------------------------------------------- /img/蓉李记.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/蓉李记.png -------------------------------------------------------------------------------- /img/蟹排.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/蟹排.png -------------------------------------------------------------------------------- /img/西兰花.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/西兰花.png -------------------------------------------------------------------------------- /img/超级至尊披萨.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/超级至尊披萨.png -------------------------------------------------------------------------------- /img/重庆小面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/重庆小面.png -------------------------------------------------------------------------------- /img/金针菇.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/金针菇.png -------------------------------------------------------------------------------- /img/钵钵鸡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/钵钵鸡.png -------------------------------------------------------------------------------- /img/香辣鸡腿堡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/香辣鸡腿堡.png -------------------------------------------------------------------------------- /img/鱼豆腐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/鱼豆腐.png -------------------------------------------------------------------------------- /img/鳕鱼堡.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/鳕鱼堡.png -------------------------------------------------------------------------------- /img/鸡丝凉面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/鸡丝凉面.png -------------------------------------------------------------------------------- /img/鸡米花.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/鸡米花.png -------------------------------------------------------------------------------- /img/鸡肉卷.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/鸡肉卷.png -------------------------------------------------------------------------------- /img/麦当劳.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/麦当劳.png -------------------------------------------------------------------------------- /img/麻辣.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/麻辣.png -------------------------------------------------------------------------------- /img/黄焖鱼豆腐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/黄焖鱼豆腐.png -------------------------------------------------------------------------------- /img/黄焖鸡米饭.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gy1024/GyTakeOutSystem/43228c88e6ae26098a8948914162b8a9abfb8ab4/img/黄焖鸡米饭.png --------------------------------------------------------------------------------