基于javaweb的家居购物商城系统

基于javaweb的家居购物商城系统,第1张

一、项目简述
功能: Java Web精品项目源码,家居商城分类展示,商品展示, 商品下单,购物车,个人中心,后台管理,用户管理,商品管理,分类管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: Jdbc+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload




适用

课程设计,大作业,毕业设计,项目练习,学习演示等

                //我的订单中心进入,无需添加商品
                CategoryService service1 = new CategoryServiceImpl();
                List<Category> flist = service1.findCategoryListByName("father");
                List<Category> clist = service1.findCategoryListByName("child");
                request.setAttribute("flist",flist);
                request.setAttribute("clist",clist);
                AddressService service = new AddressServiceImpl();
                List<Address> addresses = service.findAddressByUserId(user.getUser_id());
                request.setAttribute("address",addresses);
                //计算商品价格
                String pid = request.getParameter("pid");
                String oid = request.getParameter("oid");
                String count = request.getParameter("count");
                ProductService service2 = new ProductServiceImpl();
                Product p = service2.findProductById(Integer.valueOf(pid));
                int price = p.getProduct_price();
                int totalPrice = price*Integer.valueOf(count);
                request.setAttribute("price",price);
                request.setAttribute("clist",clist);
                AddressService service = new AddressServiceImpl();
                List<Address> addresses = service.findAddressByUserId(user.getUser_id());
                request.setAttribute("address",addresses);
                //计算商品价格
                String pid = request.getParameter("pid");
                String oid = request.getParameter("oid");
                String count = request.getParameter("count");
                ProductService service2 = new ProductServiceImpl();
                Product p = service2.findProductById(Integer.valueOf(pid));
                int price = p.getProduct_price();
                int totalPrice = price*Integer.valueOf(count);
                request.setAttribute("price",price);
                request.setAttribute("count",count);
                request.setAttribute("product",p);
                request.setAttribute("totalPrice",totalPrice);
                //计算商品价格
                String pid = request.getParameter("pid");
                String oid = request.getParameter("oid");
                String count = request.getParameter("count");
                ProductService service2 = new ProductServiceImpl();
                Product p = service2.findProductById(Integer.valueOf(pid));
                int price = p.getProduct_price();
                int totalPrice = price*Integer.valueOf(count);
                request.setAttribute("price",price);
                request.setAttribute("count",count);
                request.setAttribute("product",p);
                request.setAttribute("totalPrice",totalPrice);
                //查询购物车数量
                String cartCount = "0";
                CartService service3 = new CartServiceImpl();
                if (user != null) {
                    cartCount = String.valueOf(service3.findCartCountByUserId(user.getUser_id()));
                }else {
                    cartCount = "?";
                }
                request.setAttribute("cartCount",cartCount);
                OrderService service4 = new OrderServiceImpl();
                Order o = service4.findOrderById(oid);
                request.setAttribute("order",o);
			//在base字符串中获取下标为index的字符
			char c = base.charAt(index);
			//将c放入到StringBuffer中去
			sb.append(c);
		}
		return sb.toString();
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request,response);
	}
}
用户信息服务:
@WebServlet("/toUserInfoServlet")
public class ToUserInfoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("name");
        if (user != null) {
            UserService service = new UserServiceImpl();
            User newUser = service.findUserByUserId(user.getUser_id());
            CategoryService service1 = new CategoryServiceImpl();
            List<Category> flist = service1.findCategoryListByName("father");
            List<Category> clist = service1.findCategoryListByName("child");
            request.setAttribute("flist",flist);
            request.setAttribute("clist",clist);
public class SelectProductList extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //查询购物车数量
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("name");
        String cartCount = "0";
        CartService service1 = new CartServiceImpl();
        if (user != null) {
            cartCount = String.valueOf(service1.findCartCountByUserId(user.getUser_id()));
        }else {
            cartCount = "?";
        }
        request.setAttribute("cartCount",cartCount);
        String cid = request.getParameter("cid");
        if (cid != null && !cid.trim().equals("")) {
            ProductService service = new ProductServiceImpl();
                Product product = service5.findProductById(product_id);
                order.setProduct_name(product.getProduct_name());
                order.setProduct_photo(product.getProduct_photo());
                order.setProduct_price(product.getProduct_price());
                request.setAttribute("order",order);
                OrderService service4 = new OrderServiceImpl();
                service4.addOrder(order);
            }
//            String product_quantity = count;
//            String order_id = order.getOrder_id();
//            int product_id = p.getProduct_id();
//
//            OrderList orderList = new OrderList(order_id,product_id,product_quantity);
//
//            OrderListService service5 = new OrderListServiceImpl();
//            service5.addOrderList(orderList);
            request.getRequestDispatcher("order.jsp").forward(request, response);
        }else {
            response.sendRedirect("login.jsp");
        }
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		StringBuffer sb = new StringBuffer();
		for(int i=1;i<=4;i++){
			//产生0到size-1的随机值
			int index = r.nextInt(size);
			//在base字符串中获取下标为index的字符
			char c = base.charAt(index);
			//将c放入到StringBuffer中去
			sb.append(c);
		}
		return sb.toString();
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request,response);
	}
}
用户信息服务:
@WebServlet("/toUserInfoServlet")
public class ToUserInfoServlet extends HttpServlet {
            Category f = service2.findCategoryByCid(c.getCategory_parentid());
            System.out.println(f.getCategory_name());
            request.setAttribute("fatherC",f);
            List<Category> flist =  service2.findCategoryListByName("father");
            request.setAttribute("flist", flist);
            List<Category> clist =  service2.findCategoryListByName("child");
            request.setAttribute("clist", clist);
            //没实现分类添加图片
            if (f.getCategory_id() == 1) {
                request.setAttribute("link", "images/temp/banner1.jpg");
            }else if (f.getCategory_id() == 2){
                request.setAttribute("link", "images/temp/bzbig.jpg");
            }else if (f.getCategory_id() == 3){
                request.setAttribute("link", "images/temp/banner2.jpg");
            }else if (f.getCategory_id() == 4){
            }
            request.getRequestDispatcher("productlist.jsp").forward(request, response);
        }else {
            //有fid
            String fid = request.getParameter("fid");
            CategoryService service2 = new CategoryServiceImpl();
            Category f = service2.findCategoryByCid(Integer.valueOf(fid));
            request.setAttribute("fatherC",f);
            List<Category> flist =  service2.findCategoryListByName("father");
            request.setAttribute("flist", flist);
            List<Category> clist =  service2.findCategoryListByName("child");
            request.setAttribute("clist", clist);
            //没实现分类添加图片
            if (f.getCategory_id() == 1) {
                request.setAttribute("link", "images/temp/banner1.jpg");
            }else if (f.getCategory_id() == 2){
                request.setAttribute("link", "images/temp/perfume_Banner.jpg");
            }else if (f.getCategory_id() == 5){
                request.setAttribute("link", "img/idea1.jpg");
            }else {
                request.setAttribute("link", "img/banner1.jpg");
            }
            request.getRequestDispatcher("productlist.jsp").forward(request, response);
        }else {
            //有fid
            String fid = request.getParameter("fid");
            CategoryService service2 = new CategoryServiceImpl();
            Category f = service2.findCategoryByCid(Integer.valueOf(fid));
            request.setAttribute("fatherC",f);
            List<Category> flist =  service2.findCategoryListByName("father");
            List<Category> flist = service1.findCategoryListByName("father");
            List<Category> clist = service1.findCategoryListByName("child");
            request.setAttribute("flist",flist);
            request.setAttribute("clist",clist);
            request.setAttribute("user",newUser);
            //查看该用户的各种订单数量
            OrderService service2 = new OrderServiceImpl();
            List<Order> orders = service2.findOrderByUserId(user.getUser_id());
            int a1 = 0;
            int a2 = 0;
            int a3 = 0;
            int a4 = 0;
            for (Order o:orders) {
                if ("0".equals(o.getIs_pay()) && "0".equals(o.getIs_ship()) && "0".equals(o.getIs_receipt())) {
                    a1++;
                }
                if ("1".equals(o.getIs_pay()) && "0".equals(o.getIs_ship()) && "0".equals(o.getIs_receipt())) {
                    a2++;
                }
                if ("1".equals(o.getIs_pay()) && "1".equals(o.getIs_ship()) && "0".equals(o.getIs_receipt())) {
                    a3++;
                }
                if ("1".equals(o.getIs_pay()) && "1".equals(o.getIs_ship()) && "1".equals(o.getIs_receipt())) {
                    a4++;
                }
            }

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/944337.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-18
下一篇 2022-05-18

发表评论

登录后才能评论

评论列表(0条)

保存