├── web ├── images │ ├── s1.jpg │ ├── s2.jpg │ ├── s3.jpg │ ├── s4.jpg │ ├── left.png │ ├── right.png │ ├── 1482219425879.jpg │ ├── 1482219447332.jpg │ ├── 1482219468785.jpg │ ├── 1482219490238.jpg │ └── 1482219511691.jpg ├── todo.html ├── WEB-INF │ └── web.xml ├── my_order.jsp ├── css │ ├── page.css │ ├── cart.css │ ├── good.css │ ├── good_index.css │ ├── user_comm.css │ ├── header.css │ └── scroll.css ├── js │ ├── user_comm.js │ └── scroll.js ├── user_error.html ├── login.html ├── register.html ├── good.html ├── index.jsp ├── good.jsp ├── user_center.jsp ├── all_goods.jsp └── my_cart.jsp ├── README.md ├── src ├── db │ ├── FunDelete.java │ ├── PoolConn.java │ └── ConnectionPool.java └── servlet │ ├── Delete.java │ ├── Register.java │ ├── Ad_cart.java │ ├── Login.java │ └── Buy.java └── SQL.sql /web/images/s1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/s1.jpg -------------------------------------------------------------------------------- /web/images/s2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/s2.jpg -------------------------------------------------------------------------------- /web/images/s3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/s3.jpg -------------------------------------------------------------------------------- /web/images/s4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/s4.jpg -------------------------------------------------------------------------------- /web/images/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/left.png -------------------------------------------------------------------------------- /web/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/right.png -------------------------------------------------------------------------------- /web/images/1482219425879.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/1482219425879.jpg -------------------------------------------------------------------------------- /web/images/1482219447332.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/1482219447332.jpg -------------------------------------------------------------------------------- /web/images/1482219468785.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/1482219468785.jpg -------------------------------------------------------------------------------- /web/images/1482219490238.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/1482219490238.jpg -------------------------------------------------------------------------------- /web/images/1482219511691.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changqing18/Shopping/HEAD/web/images/1482219511691.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shopping 2 |
登录
19 | 41 | 60 | 61 | -------------------------------------------------------------------------------- /src/servlet/Ad_cart.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import db.PoolConn; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.annotation.WebServlet; 7 | import javax.servlet.http.*; 8 | import java.io.IOException; 9 | import java.sql.CallableStatement; 10 | import java.sql.Connection; 11 | import java.sql.SQLException; 12 | 13 | /** 14 | * Created by 28713 on 2016/12/26. 15 | */ 16 | @WebServlet(value = "/servlet/Ad_cart", name = "Ad_cart") 17 | public class Ad_cart extends HttpServlet { 18 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 19 | HttpSession session = request.getSession(); 20 | String Email = (String) session.getAttribute("Email"); 21 | if (Email == null) { 22 | response.sendRedirect("/user_error.html?Email=&name=&error=21"); 23 | } else { 24 | long gid = Long.parseLong(request.getParameter("gid")); 25 | int number = Integer.parseInt(request.getParameter("number")); 26 | PoolConn poolConn = PoolConn.getPoolConn(); 27 | try (Connection con = poolConn.getConnection(); 28 | CallableStatement cs = con.prepareCall("CALL cart_merge(?,?,?,?)")) { 29 | cs.setLong(1, System.currentTimeMillis()); 30 | cs.setString(2, Email); 31 | cs.setLong(3, gid); 32 | cs.setInt(4, number); 33 | int i = cs.executeUpdate(); 34 | poolConn.returnConnection(con); 35 | if (i == 1) 36 | response.sendRedirect("/user_error.html?Email=&name=&error=30"); 37 | else { 38 | response.sendRedirect("/user_error.html?Email=&name=&error=32"); 39 | } 40 | } catch (SQLException e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SQL.sql: -------------------------------------------------------------------------------- 1 | create table border 2 | ( 3 | orderid bigint not null, 4 | email varchar(30) not null, 5 | gid bigint not null, 6 | number int not null, 7 | buytime datetime default CURRENT_TIMESTAMP not null, 8 | constraint `PRIMARY` 9 | primary key (orderid) 10 | ) 11 | ; 12 | 13 | create index gid 14 | on border (gid) 15 | ; 16 | 17 | create table cart 18 | ( 19 | orderid bigint not null, 20 | email varchar(30) not null, 21 | gid bigint not null, 22 | number int not null, 23 | constraint `PRIMARY` 24 | primary key (orderid) 25 | ) 26 | ; 27 | 28 | create index gid 29 | on cart (gid) 30 | ; 31 | 32 | create table good 33 | ( 34 | gid bigint not null, 35 | gname varchar(100) not null, 36 | brand varchar(10) null, 37 | price float(6,2) not null, 38 | number int not null, 39 | constraint `PRIMARY` 40 | primary key (gid) 41 | ) 42 | ; 43 | 44 | alter table border 45 | add constraint border_ibfk_1 46 | foreign key (gid) references web.good (gid) 47 | ; 48 | 49 | alter table cart 50 | add constraint cart_ibfk_1 51 | foreign key (gid) references web.good (gid) 52 | ; 53 | 54 | create table user 55 | ( 56 | username varchar(20) null, 57 | email varchar(30) not null, 58 | password varchar(20) not null, 59 | constraint `PRIMARY` 60 | primary key (email) 61 | ) 62 | ; 63 | 64 | create procedure buy (IN pid bigint, IN pe varchar(30), IN pgid bigint, IN num int) 65 | CREATE PROCEDURE `buy`(`pid` BIGINT(20), `pe` VARCHAR(30), `pgid` BIGINT(20), `num` INT(11)) 66 | BEGIN 67 | INSERT INTO border (orderid, email, gid, number) 68 | VALUES (pid, pe, pgid, num); 69 | DELETE FROM cart 70 | WHERE orderid = pid; 71 | UPDATE good 72 | SET number = number - num 73 | WHERE gid = pgid; 74 | END; 75 | 76 | create procedure cart_merge (IN pid bigint, IN pemail varchar(30), IN pgid bigint, IN num int) 77 | CREATE PROCEDURE `cart_merge`(`pid` BIGINT(20), `pemail` VARCHAR(30), `pgid` BIGINT(20), `num` INT(11)) 78 | BEGIN 79 | DECLARE temp INT; 80 | SELECT number 81 | INTO temp 82 | FROM cart 83 | WHERE gid = pgid && email = pemail; 84 | IF temp IS NULL 85 | THEN INSERT INTO cart VALUES (pid, pemail, pgid, num); 86 | ELSE UPDATE cart 87 | SET orderid = pid, number = num + temp 88 | WHERE gid = pgid && email = pemail; 89 | END IF; 90 | END; 91 | 92 | -------------------------------------------------------------------------------- /web/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |注册账号
18 | 51 | 66 | 67 | -------------------------------------------------------------------------------- /web/good.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
25 | 中兴(ZTE) A2 Plus 4GB+32GB高配 流光金 全网通4G双卡双待
28 |¥949.00
29 | 58 |




¥<%=resultSet.getFloat(3)%>
89 |
57 | <%=resultSet.getString(1)%>
60 |¥<%=resultSet.getFloat(2)%>
61 | 95 |¥<%=resultSet1.getFloat(3)%> 91 |
92 |