基于javaweb+mysql的ssm在线相机商城系统(java+ssm+jsp+jquery+mysql)

基于javaweb+mysql的ssm在线相机商城系统(java+ssm+jsp+jquery+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

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

功能说明

基于javaweb的SSM在线相机商城系统(java+ssm+jsp+jquery+mysql)

项目介绍

分为两个角色,一个管理员,一个普通用户 管理员角色包含以下功能: 管理员登录,相机品牌管理,相机库存管理,相机商品管理,相机订单管理,相机售后管理,新闻资讯管理,物流管理等功能。 用户角色包含以下功能: 商城首页,查看详情评论商品,用户注册后登录,查看购物车,按分类查看商品,提交订单,选择地址支付页面,查看订单,查看收藏,申请售后,留言等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7等版本均可;

技术栈

  1. 后端:Spring springmvc mybatis 2. 前端:JSP+css+javascript+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat
			ListSortUtil<Product> sortList = new ListSortUtil<Product>();  
	        sortList.sort(newslist, "salenum", "desc");
	        
	        
	        for(int i=0;i<newslist.size();i++){
	        	Product pro = newslist.get(i);
	        	if(i<5 && pro.getSalenum()>0){
	        		zphlist.add(pro);
	        	}else{
	        		break;
	        	}
	        }
	        //request.setAttribute("zphlist", zphlist);
		}
		return zphlist;
		
	}
	
	
	
}

 

/**
     *
     * @param request the request
     * @return the string
     */
//查询相机品牌
	@RequestMapping("/admin/categorySelect")
	public String categorySelect(HttpServletRequest request){
		HashMap map = new HashMap();
		List<Category> list = categoryDAO.selectFcategory(map);
		for(Category category:list){
			List<Category> scategorylist = categoryDAO.selectScategory(category.getId());
			category.setScategorylist(scategorylist);
		}
		request.setAttribute("list", list);
		return "admin/productadd";
	}

    /**
     * Product add string.
     *
     * @param product the product
     * @param request the request
     * @return the string
     */
//相机添加
	@RequestMapping("admin/productAdd")
	public String productAdd(Product product,HttpServletRequest request){
		User user = (User)request.getSession().getAttribute("admin");
		String productno = Info.getAutoId();
		product.setProductno(productno);
		product.setSaver(String.valueOf(user.getId()));
		product.setIssj("no");
		product.setIstj("no");
		product.setProductid("-1");
		product.setDelstatus("0");
		productDAO.add(product);
		return "redirect:productMsg.do";
	}

    /**
     * Show fubi string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
    @RequestMapping("admin/showFubi")
	public String showFubi(int id,HttpServletRequest request){
            }
            if (reflush) {
                str += "parent.location=parent.location;\n";
            }
            str += "</script>";

            PrintWriter wrt = null;
            try {
                wrt = response.getWriter();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            wrt.write(str);
        }

        return "";
    }

    /**
     * Delete.
     *
     * @param request   the request
     * @param tablename the tablename
     */
    public void delete(HttpServletRequest request, String tablename) {
        int i = 0;
        try {
            String did = request.getParameter("did");
            if (did == null) did = request.getParameter("scid");
            if (did != null) {
                if (did.length() > 0) {
                    Statement st = conn.createStatement();
                    st.execute("delete from " + tablename + " where id=" + did);
                    st.close();
                }
            }

        } catch (SQLException e) {
            // TODO Auto-generated catch block
					total += Double.parseDouble(String.valueOf(cart.getNum()))* sjprice;
					doublesubtotal = Double.parseDouble(String.valueOf(cart.getNum()))*sjprice;
				}
				cart.setSubtotal(String.format("%.2f", doublesubtotal));
			}
			totalstr = String.format("%.2f", total);
			request.setAttribute("totaldoubel", Double.parseDouble(totalstr));
			request.setAttribute("cartlist", cartlist);
			request.setAttribute("totalstr", totalstr);
		    saveobject.getCategoryObject(request);
		    String suc = request.getParameter("suc")==null?"":request.getParameter("suc");
		    if(!suc.equals("")){
		    	request.setAttribute("suc", "创建成功");
		    }
		    
		    HashMap mmm = new HashMap();
		    mmm.put("goodstype", "购买相机");
		    saveobject.hotSales("", request);
		    List<Product> zphlist = saveobject.hotSales("",request);
			request.setAttribute("zphlist", zphlist);
		return "cartlist";
	}

    /**
     * Add cart.
     *
     * @param request  the request
     * @param response the response
     */
// 添加购物车
	@RequestMapping("addCart")
	public void addCart(HttpServletRequest request, HttpServletResponse response) {
		PrintWriter out;
		try {
			out = response.getWriter();
			Member member = (Member) request.getSession().getAttribute(
					"sessionmember");
			if (member != null) {
				String productid = request.getParameter("productid");
				String num = request.getParameter("num");
				//判断是否是购买自己的相机
				Product product = (Product)productDAO.findById(Integer.parseInt(productid));
				HashMap map = new HashMap();
				map.put("memberid", member.getId());
				map.put("productid", productid);
				List<Cart> list = cartDAO.selectAll(map);
				if (list.size() == 0) {
					Cart cart = new Cart();
					cart.setMemberid(member.getId());
					cart.setProductid(Integer.parseInt(productid));
					cart.setNum(Integer.parseInt(num));
					cart.setShopid(Integer.valueOf(product.getSaver()));
					cartDAO.add(cart);
    {
        //boolean flag = false;
        //String s = "";
        //String s = new String();
        int i = m_currentIndex;
        int j = 0;
        int k = m_boundary.length();
        m_startData = m_currentIndex;
        m_endData = 0;
        while(i < m_totalBytes)
        {
            if(m_binArray[i] == (byte)m_boundary.charAt(j))
            {
                if(j == k - 1)
                {
                    m_endData = ((i - k) + 1) - 3;
                    break;
                }
                i++;
                j++;
            }
            else
            {
                i++;
                j = 0;
            }
        }
        m_currentIndex = m_endData + k + 3;
    }

    private String getDataHeader()
    {
        //boolean flag = false;
        int i = m_currentIndex;
        int j = 0;
        for(boolean flag1 = false;!flag1;)
        {
            if(m_binArray[m_currentIndex] == 13 && m_binArray[m_currentIndex + 2] == 13)
            {
                flag1 = true;
                j = m_currentIndex - 1;
                m_currentIndex = m_currentIndex + 2;
            }

/**
 * The type Product controller.
 */
@Controller
public class ProductController extends BaseController {
    /**
     * The Product dao.
     */
    @Resource
	ProductDAO productDAO;
    /**
     * The Category dao.
     */
    @Resource
	CategoryDAO categoryDAO;
    /**
     * The Member dao.
     */
    @Resource
	MemberDAO memberDAO;
    /**
     * The Comment dao.
     */
    @Resource
	CommentDAO commentDAO;
    /**
     * The Ordermsg dao.
     */
    @Resource
	OrdermsgDAO ordermsgDAO;
    /**
     * The Saveobject.
     */
    @Resource
   	    map.put("fid", fid);
   	    map.put("sid", sid);
	    map.put("issj", "yes");
	    map.put("ph", ph);
	    map.put("saver", saver);
	    List<Product> nlist = productDAO.selectAll(map);
	    PageHelper.startPage(pageNum,10);
		List<Product> list = productDAO.selectAll(map);
		PageInfo<Product> pageInfo =  new PageInfo<Product>(list);
		request.setAttribute("pageInfo", pageInfo);
		request.setAttribute("nlist", nlist);
		request.setAttribute("sid", sid);
		request.setAttribute("fid", fid);
		request.setAttribute("saver", saver);
		request.setAttribute("shop", shop);
		request.setAttribute("shopid", saver);
		
		
		String categroystr = "";
		if(sid!=null && !sid.equals("")){
			Category scategory = categoryDAO.findById(Integer.parseInt(sid));
			categroystr=scategory.getName();
			request.setAttribute("categroystr", categroystr);
		}
		if(fid!=null && !fid.equals("")){
			Category fcategory = categoryDAO.findById(Integer.parseInt(fid));
			categroystr=fcategory.getName();
			request.setAttribute("categroystr", categroystr);
		}
		saveobject.getCart(request);
		saveobject.getCategoryObject(request);
		return "shop";
	}

    /**
     * Fubi lb string.
     *
     * @param pageNum the page num
     * @param request the request
     * @return the string
     */
    @RequestMapping("fubiLb")
	public String fubiLb(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletRequest request){
		//显示相机列表
   	    HashMap map = new HashMap();
	    map.put("issj", "yes");
	    map.put("leibie", "积分相机");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

    /**
     * Show user string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
    @RequestMapping("/admin/showUser")
	public String showUser(int id, HttpServletRequest request){
		User user = userDAO.findById(id);
		request.setAttribute("user", user);
		return "admin/useredit";
	}

    /**
     * User edit string.
     *
     * @param u       the u
     * @param request the request
     * @return the string
     */
    @RequestMapping("/admin/userEdit")
	public String userEdit(User u, HttpServletRequest request){
		userDAO.update(u);
		return "redirect:userList.do";
	}

    /**
     * User del string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
    @RequestMapping("/admin/userDel")
	public String userDel(int id,HttpServletRequest request){
		User user = userDAO.findById(id);
		user.setDelstatus("1");
     * @param request the request
     * @return the string
     */
//搜索相机
	@RequestMapping("Search")
	public String Search(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletRequest request){
		String key = request.getParameter("key");
		String ph = request.getParameter("ph");
		//显示相机列表
   	    HashMap map = new HashMap();
   	    map.put("key", key);
	    map.put("issj", "yes");
	    map.put("ph", ph);
	    List<Product> nlist = productDAO.selectAll(map);
	    PageHelper.startPage(pageNum,8);
		List<Product> list = productDAO.selectAll(map);
		PageInfo<Product> pageInfo =  new PageInfo<Product>(list);
		request.setAttribute("pageInfo", pageInfo);
		request.setAttribute("nlist", nlist);
		request.setAttribute("key", key);
		request.setAttribute("ph", ph);
		saveobject.getCart(request);
		saveobject.getCategoryObject(request);
		return "search";
	}

    /**
     * Skip reg string.
     *
     * @param request the request
     * @return the string
     */
//注册页面
	@RequestMapping("skipReg")
	public  String skipReg(HttpServletRequest request) {
		String suc = request.getParameter("suc")==null?"":request.getParameter("suc");
		saveobject.getCategoryObject(request);
		if(!suc.equals("")){
			request.setAttribute("suc", "注册成功");
		}
		return "redirect:orderLb.do";
	}

    /**
     * Qs string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
    @RequestMapping("fubiqianshou")
	public String qs(int id,HttpServletRequest request){
		Ordermsg ordermsg = ordermsgDAO.findById(id);
		ordermsg.setFkstatus("交易完成");
		ordermsgDAO.update(ordermsg);
		return "redirect:fubiOrder.do";
	}

    /**
     * Fubiorder sc string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
    @RequestMapping("fubiorderSc")
	public String fubiorderSc(int id,HttpServletRequest request){
		Ordermsg ordermsg = ordermsgDAO.findById(id);
		ordermsg.setDelstatus("1");
		ordermsgDAO.update(ordermsg);
		return "redirect:fubiOrder.do";
	}

    /**
     * Order sc string.
     *
     * @param id      the id
     * @param request the request
     * @return the string
     */
//删除订单
		@RequestMapping("orderSc")
		public String orderSc(int id,HttpServletRequest request){
			Ordermsg ordermsg = ordermsgDAO.findById(id);
			ordermsg.setDelstatus("1");
			ordermsgDAO.update(ordermsg);
			return "redirect:orderLb.do";
				int intotal = new Double(total).intValue();
				if(intotal<=mmm.getJf()){
				int yjf = mmm.getJf()-intotal;
				CheckCode cc = new CheckCode();
				String ddno = cc.getCheckCode();
				Ordermsg ordermsg = new Ordermsg();
				ordermsg.setDdno(ddno);
				ordermsg.setMemberid(String.valueOf(member.getId()));
				ordermsg.setProductid(productid);
				ordermsg.setNum(Integer.parseInt(num));
				ordermsg.setTotal(intotal);
				ordermsg.setFkstatus("已付款");
				ordermsg.setSavetime(Info.getDateStr());
				ordermsg.setDelstatus("0");
				ordermsg.setShfs("到店自取");
				ordermsg.setSaver(product.getSaver());
				ordermsg.setGoodstype("积分相机");
				ordermsgDAO.add(ordermsg);
				
				mmm.setJf(yjf);
				memberDAO.updateJf(mmm);
				out.print("1");
				}else{
				out.print("2");//积分不足
				}
			} else {
				out.println("0");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	
}

		    HashMap mmm = new HashMap();
		    mmm.put("goodstype", "购买相机");
		    saveobject.hotSales("", request);
		    List<Product> zphlist = saveobject.hotSales("",request);
			request.setAttribute("zphlist", zphlist);
		return "cartlist";
	}

    /**
     * Add cart.
     *
     * @param request  the request
     * @param response the response
     */
// 添加购物车
	@RequestMapping("addCart")
	public void addCart(HttpServletRequest request, HttpServletResponse response) {
		PrintWriter out;
		try {
			out = response.getWriter();
			Member member = (Member) request.getSession().getAttribute(
					"sessionmember");
			if (member != null) {
				String productid = request.getParameter("productid");
				String num = request.getParameter("num");
				//判断是否是购买自己的相机
				Product product = (Product)productDAO.findById(Integer.parseInt(productid));
				HashMap map = new HashMap();
				map.put("memberid", member.getId());
				map.put("productid", productid);
				List<Cart> list = cartDAO.selectAll(map);
				if (list.size() == 0) {
					Cart cart = new Cart();
					cart.setMemberid(member.getId());
					cart.setProductid(Integer.parseInt(productid));
					cart.setNum(Integer.parseInt(num));
					cart.setShopid(Integer.valueOf(product.getSaver()));
					cartDAO.add(cart);
				} else {
					Cart ct = new Cart();
					ct.setId(list.get(0).getId());
					ct.setNum(list.get(0).getNum() + Integer.parseInt(num));
					cartDAO.update(ct);
				}
	@RequestMapping("shopRegister")
	public String shopRegister(User user,HttpServletRequest request){
		user.setUserpassword(MD5.getDigest(user.getUserpassword()));
		user.setDelstatus("0");
		user.setShstatus("待审核");
		user.setUsertype("商家");
		userDAO.add(user);
		return "redirect:skipshopRetist.do?suc=suc";
	}

}

 

/**
 * The type Shapply controller.
 */
@Controller
                                String dknamevalue = request.getParameter("dk-" + rsmd.getColumnName(j) + "-value");
                                vstr += " - " + dknamevalue + ":" + dkv;
                            }

                            value += vstr + " ~ ";
                        }
                        if (value == null) value = "";
                        if (value.equals("null")) value = "";
                        if (value.length() > 0) value = value.substring(0, value.length() - 3);

                        if (rsmd.getColumnTypeName(j).equals("int")) {
                            sql += rsmd.getColumnName(j) + "=" + value + ",";
                        } else {
                            sql += rsmd.getColumnName(j) + "='" + value + "',";
                        }
                    } else {
                        if (extmap.get(rsmd.getColumnName(j)) != null) {
                            if (rsmd.getColumnTypeName(j).equals("int")) {
                                sql += rsmd.getColumnName(j) + "=" + extmap.get(rsmd.getColumnName(j)) + ",";
                            } else {
                                sql += rsmd.getColumnName(j) + "='" + extmap.get(rsmd.getColumnName(j)) + "',";
                            }
                        }
                    }
                }
                sql = sql.substring(0, sql.length() - 1);
                sql += " where id=" + request.getParameter("id");
                System.out.println(sql);
                Statement st1 = conn.createStatement();
                st1.execute(sql);
                st1.close();
                rs.close();
                st.close();

            } catch (SQLException e) {
                e.printStackTrace();
            }
            String str = "";
            if (!reflush)
                str += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
            str += "<script language=javascript>\n";
            if (alert) {
                str += "alert('操作成功');\n";
            }
            if (reflush) {
                str += "parent.location=parent.location;\n";
            }

            str += "</script>\n";
			out = response.getWriter();
			Member member = (Member)request.getSession().getAttribute("sessionmember");
			if(member!=null){
				HashMap map = new HashMap();
				map.put("memberid", member.getId());
				List<Cart> list =  cartDAO.selectAll(map);
				for(Cart cart:list){
					cartDAO.delCart(cart.getId());
				}
				out.println("1");
			}else{
				out.println("0");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

 

		}
		return "admin/updatepwd";
	}

    /**
     * Select all string.
     *
     * @param pageNum the page num
     * @param request the request
     * @return the string
     */
    @RequestMapping("/admin/userList")
	public String selectAll(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletRequest request){
		String key = request.getParameter("key");
		HashMap map = new HashMap();
		map.put("key", key);
		map.put("usertype", "商家");
		map.put("shstatus", "通过审核");
		PageHelper.startPage(pageNum, 10);
		List<User> list = userDAO.selectAll(map);
		PageInfo<User> pageInfo =  new PageInfo<User>(list);
		request.setAttribute("key",key);
		request.setAttribute("pageInfo",pageInfo);
		return "admin/userlist";
	}

    /**
     * User add string.
     *
     * @param user    the user
     * @param request the request
     * @return the string
     */
    @RequestMapping("admin/userAdd")
	public String userAdd(User user, HttpServletRequest request){
		userDAO.add(user);
		return "redirect:userList.do";
	}

    /**
     * Check username.
     *
     * @param username the username
     * @param request  the request
     * @param response the response
     */
//检查用户名的唯一性
	@RequestMapping("admin/checkUsername")

/**
 * The type News controller.
 */
@Controller
public class NewsController extends BaseController {
    /**
     * The News dao.
     */
    @Resource
	NewsDAO newsDAO;
    /**
     * The Category dao.
     */
    @Resource
	CategoryDAO categoryDAO;
    /**
     * The Member dao.
     */
    @Resource
	MemberDAO memberDAO;
    /**
     * The Product dao.
     */
    @Resource
	ProductDAO productDAO;
    /**
     * The Saveobject.
     */
    @Resource
	Saveobject saveobject;
    /**
     * The Ordermsg dao.
     */
     * @param bbs     the bbs
     * @param request the request
     * @return the string
     */
//编辑帖子提交
		@RequestMapping("bbsEdit")
		public String bbsEdit(Bbs bbs,HttpServletRequest request){
			bbsDAO.update(bbs);
			return "redirect:mybbsList.do";
		}

    /**
     * Bbs del string.
     *
     * @param id       the id
     * @param request  the request
     * @param response the response
     * @return the string
     */
//删除帖子
	@RequestMapping("bbsDel")
	public String bbsDel(int id, HttpServletRequest request,HttpServletResponse response){
		Bbs bbs = bbsDAO.findById(id);
		HashMap map = new HashMap();
		map.put("fid",id);
		List<Bbs> list = bbsDAO.selectAll(map);
		for(Bbs b:list){
			bbsDAO.delete(b.getId());
		}
		bbsDAO.delete(id);
		return "redirect:mybbsList.do";
	}

    /**
     * Bbs show string.
     *
     * @param pageNum the page num
     * @param id      the id
     * @param request the request
     * @return the string
     */
//帖子详情
	@RequestMapping("bbsShow")
	public String bbsShow(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,int id,HttpServletRequest request){
		Bbs bbs = bbsDAO.findById(id);
		Member author = memberDAO.findById(bbs.getMid());
		bbs.setMember(author);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值