Java项目:水果店商城超市系统(java+SSM+JSP+Ajax+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.数据库:MySql 5.7版本;
6.是否Maven项目:否;

技术栈

1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+jQuery+Ajax

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录


 

 

 

 

 

 

 

订单管理控制层: 

@Controller
public class orderController {
	@Autowired
	private OrderService orderService;

	@RequestMapping("/toOrder")
	public String toOrder(HttpServletRequest request,Model model) throws Exception {
		Orders orders = new Orders();
		Cart cart = (Cart) request.getSession().getAttribute("cart");
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		if(loginUser==null){
			model.addAttribute("message", "对不起您还没有登录");
			return "msg";
		}
//		0表示没有付款、1表示已付款即将发货 2表示确认收货 3表示交易成功
		orders.setState(0);
		orders.setOrderTime(new Date());
		orders.setUid(loginUser.getUid());
		orders.setMoney(cart.getTotale());

		orderService.toOrder(orders);

		Map<Integer, CartItem> cartItems = cart.getCartItem();
		for (Entry<Integer, CartItem> entry : cartItems.entrySet()) {
			CartItem cartItem = entry.getValue();
			Orderitem orderitem = new Orderitem();
			orderitem.setProduct(cartItem.getProduct());
			orderitem.setCount(cartItem.getCount());
			orderitem.setPid(cartItem.getProduct().getPid());
			orderitem.setSubtotal(cartItem.getSubtotle());
			orderitem.setOid(orders.getOid());
			orders.getOiList().add(orderitem);
			orderService.toOrderItem(orderitem);
		}
		cart.clearCart();
		request.getSession().setAttribute("orders", orders);
		return "order";
	}

	// 为定单付款
	@RequestMapping("/payOrder")
	public String payOrder(Orders orders,@RequestParam String receiveInfo,@RequestParam String phoNum,@RequestParam String accepter) throws Exception {
		orders.setReceiveinfo(receiveInfo);
		orders.setPhonum(phoNum);
		orders.setAccepter(accepter);
		orderService.payOrder(orders);
		return "redirect:myOrder.action?page=1";
	}
   //payOrderAganin
	@RequestMapping("/payOrderAganin")
	public String payOrderAganin(@RequestParam int oid,HttpServletRequest request){
		Orders noPayOrder = orderService.findOrderByOid(oid);
		request.getSession().setAttribute("orders", noPayOrder);
		return "order";
	}
	// 查询myOrder
	@RequestMapping("/myOrder")
	public String myOrder(@RequestParam int page, Model model,
			HttpServletRequest request) throws Exception {
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		PageBean<Orders> pageBean = orderService.findOrderByUidAndPage(page,loginUser.getUid());
		model.addAttribute("pageBean", pageBean);
		return "orderList";
	}
	
	// 确认收货
		@RequestMapping("/updateState")
		public String updateState(@RequestParam int oid ) throws Exception {
			orderService.updateOrderStatus(oid, 3);
			return "redirect:myOrder.action?page=1";
		}
}

购物车管理控制层:

@Controller
public class cartController {
	@Autowired
	private ProductService productService;
//	添加到购物车
	@RequestMapping("/addCart")
	public String addCart(HttpServletRequest request,@RequestParam int pid,@RequestParam int count ,Model model){
		Product product = productService.finbProductByPid(pid);
//		存进一个购物项
		CartItem cartItem = new CartItem();
		cartItem.setCount(count);
		cartItem.setProduct(product);
		cartItem.setSubtotle(count*product.getShopPrice());
//		存进购物车
		Cart cart=getCart(request);
		cart.addCart(cartItem);
		return "cart";
	}
//	查看我的购物车
	@RequestMapping("/myCart")
	public String myCart(HttpServletRequest request,Model model){
		User loginUser = (User) request.getSession().getAttribute("loginUser");
		if (loginUser == null) {
			model.addAttribute("message","您还没有登录!");
			return "msg";
		}
		return "cart";
	}
	
//	清空购物车
	@RequestMapping("/clearCart")
	public String clearCart(HttpServletRequest request){
		Cart cart=getCart(request);
		cart.clearCart();
		return "redirect:myCart.action";
	}
//	删除某个购物项
	@RequestMapping("/delProFromCart")
	public String delProFromCart(@RequestParam int pid,HttpServletRequest request){
		Cart cart=getCart(request);
		cart.delProFromCart(pid);
		return "redirect:myCart.action";
	}
	public Cart getCart(HttpServletRequest request) {
		Cart cart = (Cart) request.getSession().getAttribute("cart");
		if (cart == null) {
			cart = new Cart();
			request.getSession().setAttribute("cart", cart);
		}
		return cart;
	}
}

管理员管理控制层:

@Controller
public class AdminController {
	@Autowired
	private UserService userService;
	@Autowired
	public CategoryService categoryService;
	@Autowired
	public CategorySecondService categorySecondService;
	@Autowired
	public ProductService productService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private MessageService messageService;

	@RequestMapping("/admin/admin_findAll")
	public String admin_findAll(Model model, HttpServletRequest request) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		List<User> userList = userService.admin_findAll();
		model.addAttribute("userList", userList);
		return "admin/user/list";
	}

	@RequestMapping("/admin/adminCategory_findAll")
	public String adminCategory_findAll(Model model, HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		List<Category> categoryList = categoryService.adminbFindCategory();
		/*for (Category category : categoryList) {
			System.out.println(category.getCname());
		}*/
		model.addAttribute("categoryList", categoryList);
		return "admin/category/list";
	}

	@RequestMapping("/admin/adminCategory_add")
	public String adminCategory_add(Model model,HttpServletRequest request) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
//		List<Category> categoryList = categoryService.adminbFindCategory();
//		model.addAttribute("categoryList", categoryList);
		return "admin/category/add";
	}

	@RequestMapping("/admin/adminCategory_save")
	public String adminCategory_save(@RequestParam String cname,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Category addCategory = new Category();
		addCategory.setCname(cname);
		categoryService.addCategory(addCategory);
		return "redirect:/admin/adminCategory_findAll.action";
	}

	@RequestMapping("/admin/adminCategory_edit")
	public String adminCategory_delete(@RequestParam int cid, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Category existCategory = categoryService.findCategory(cid);
		model.addAttribute("existCategory", existCategory);
		return "admin/category/edit";
	}

	@RequestMapping("/admin/adminCategory_update")
	public String adminCategory_update(@RequestParam int cid,
			@RequestParam String cname,HttpServletRequest request) {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Category category = new Category();
		category.setCid(cid);
		category.setCname(cname);
		categoryService.adminCategory_update(category);
		return "redirect:/admin/adminCategory_findAll.action";
	}

	@RequestMapping("/admin/adminCategory_delete")
	public String adminCategory_delete(@RequestParam int cid,HttpServletRequest request) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		categorySecondService.adminCategorySecond_deleteByCid(cid);
		categoryService.deleteCategoryByCid(cid);
		return "redirect:/admin/adminCategory_findAll.action";
	}

	// admin 的二级分类的管理
	@RequestMapping("/admin/adminCategorySecond_findAllByPage")
	public String adminCategorySecond_findAllByPage(@RequestParam int page,Model model,HttpServletRequest request) {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		PageBean<Categorysecond> csPageBean = categorySecondService
				.adminCategorySecond_findAllByPage(page);
		/*List<Categorysecond> list = csPageBean.getList();
		for (Categorysecond categorysecond : list) {
			System.out.println(categorysecond.getCsname());
		}*/
		model.addAttribute("csPageBean", csPageBean);
		return "admin/categorysecond/list";
	}
	@RequestMapping("admin/adminCategorySecond_addPage")
	public String adminCategorySecond_addPage(Model model,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		List<Category> categoryList = categoryService.adminbFindCategory();
		model.addAttribute("categoryList", categoryList);
		return "admin/categorysecond/add";
	}
	@RequestMapping("admin/adminCategorySecond_save")
	public String adminCategorySecond_save(@RequestParam String csname,@RequestParam int cid,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Categorysecond categorysecond = new Categorysecond();
		categorysecond.setCsname(csname);
		categorysecond.setCid(cid);
		categorySecondService.adminCategorySecond_save(categorysecond);
		return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";
	}
	@RequestMapping("admin/adminCategorySecond_edit")
	public String adminCategorySecond_edit(@RequestParam int csid,Model model,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Categorysecond findByCsid = categorySecondService.findByCsid(csid);
		model.addAttribute("findByCsid", findByCsid);
		return "admin/categorysecond/edit";
	}
	@RequestMapping("admin/adminCategorySecond_update")
	public String adminCategorySecond_update(@RequestParam String csname,@RequestParam int csid,HttpServletRequest request){
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Categorysecond categorysecond = new Categorysecond();
		categorysecond.setCsname(csname);
		categorysecond.setCsid(csid);
		categorySecondService.adminCategorySecond_update(categorysecond);
		return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";
	}
	@RequestMapping("admin/adminCategorySecond_delete")
	public String adminCategorySecond_delete(@RequestParam int csid,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		categorySecondService.adminCategorySecond_delete(csid);
		return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";
	}
	//admin的商品管理
	@RequestMapping("/admin/adminProduct_findAllByPage")
	public String adminProduct_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		PageBean<Product> allProPageBean = productService.findAllProduct(page);
		model.addAttribute("allProPageBean", allProPageBean);
		return "admin/product/list";
	}

	@RequestMapping("/admin/adminProduct_addPage")
	public String adminProduct_addPage(Model model,HttpServletRequest request) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		//查询出所有的二级分类
		List<Categorysecond> cslist = categorySecondService.findAll();
		/*for (Categorysecond categorysecond : cslist) {
			System.out.println(categorysecond.getCsname());
		}*/
		model.addAttribute("cslist", cslist);
		return "admin/product/add";
	}

	@RequestMapping("/admin/adminProduct_save")
	public String adminProduct_save(Product product,HttpServletRequest request,MultipartFile file) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		product.setPdate(new Date());
//		上传图片
		if (file != null) {
			String path = request.getServletContext().getRealPath(
					"/products");
			String uploadFileName = file.getOriginalFilename();
			String fileName = UUIDUtiils.getUUID()+uploadFileName;
			File diskFile = new File(path + "//" + fileName);
			file.transferTo(diskFile);
			product.setImage("products/" + fileName);
		}
		System.out.println(product.getImage());
		productService.adminProduct_save(product);
		return "redirect:/admin/adminProduct_findAllByPage.action?page=1";
	}
	
	@RequestMapping("admin/adminProduct_deletecs")
	public String adminProduct_deletecs(@RequestParam int pid,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		productService.adminProduct_deletecs(pid);
		return "redirect:/admin/adminProduct_findAllByPage.action?page=1";
	}
	/**
	 * 编辑商品
	 * 
	 * @param pid
	 * @param model
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("admin/adminProduct_edit")
	public String adminProduct_edit(@RequestParam int pid,Model model,HttpServletRequest request) throws Exception{
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		Product product = productService.finbProductByPid(pid);
		model.addAttribute("findByPid", product);
		//查询出所有的二级分类
		List<Categorysecond> cslist = categorySecondService.findAll();
		model.addAttribute("cslist", cslist);
		return "admin/product/edit";
	}
	
	@RequestMapping("/admin/adminProduct_update")
	public String adminProduct_update(Product product,HttpServletRequest request,MultipartFile file) throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		product.setPdate(new Date());
//		上传图片
		if (file != null) {
			String path = request.getServletContext().getRealPath(
					"/products");
			String uploadFileName = file.getOriginalFilename();
			String fileName = UUIDUtiils.getUUID()+uploadFileName;
			File diskFile = new File(path + "//" + fileName);
			file.transferTo(diskFile);
			product.setImage("products/" + fileName);
		}
		 
		productService.adminProduct_update(product);
		return "redirect:/admin/adminProduct_findAllByPage.action?page=1";
	}

	/** 订单管理模块  **/
	
	@RequestMapping("/admin/adminOrder_findAllByPage")
	public String adminOrder_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		PageBean<Orders> allProPageBean = orderService.findAllOrderByStateAndPage(page);
		model.addAttribute("pageBean", allProPageBean);
		return "admin/order/list";
	}
	
	//adminOrder_findByState
	@RequestMapping("/admin/adminOrder_findByState")
	public String adminOrder_findByState(@RequestParam int page,@RequestParam int state, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		PageBean<Orders> allProPageBean = orderService.findAllOrderByStateAndPage(state,page);
		model.addAttribute("pageBean", allProPageBean);
		return "admin/order/list";
	}
	
	//订单详情
	//adminOrder_findOrderItem
	@RequestMapping("/admin/adminOrder_findOrderItem")
	public String adminOrder_findOrderItem(@RequestParam int oid, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		Orders orderItems = orderService.findOrderByOid(oid);
		model.addAttribute("orderItems", orderItems);
		return "admin/order/list";
	}
	
	//更新订单状态
	@RequestMapping("/admin/adminOrder_updateState")
	public String adminOrder_updateState(@RequestParam int oid, @RequestParam int status, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		orderService.updateOrderStatus(oid, status);
		
		return "redirect:/admin/adminOrder_findAllByPage.action?page=1";
	}
	
	//后台留言管理 
	@RequestMapping("/admin/adminMessage_findAllByPage")
	public String adminMessage_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		PageBean<Message> pageBean = messageService.findAllMessageByPage(page);
		model.addAttribute("pageBean", pageBean);
		
		return "admin/message/list";
	}
	
	@RequestMapping("/admin/adminMessage_delete")
	public String adminOrder_updateState(@RequestParam int messageid, Model model,HttpServletRequest request)
			throws Exception {
		Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");
		if(adminuserLogin==null){
			request.getSession().setAttribute("message","对不起您还没有登录");
			return "admin/index";
		}
		
		messageService.deleteMessage(messageid);
		
		return "redirect:/admin/adminMessage_findAllByPage.action?page=1";
	}

}

源码获取:俺的博客首页 "资源" 里下载!

实现功能:(1)客户端开机自动琐定,输入帐号、密码后进行验证登陆并开始计费。或控制端远程解锁上机。 (2).控制端能够对上网的客户端进行远程控制,比如:远程关机、注销、锁定、远程结帐后又自动锁定计算机等功能。 (3)能对客户端发送消息。 (4)客户端在上机过程中能够随时查看消费状态,比如:预缴金额、上机时间、上机金额等。 MySql表结构: desc user; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | uid | varchar(30) | NO | PRI | 0 | | | password | varchar(30) | NO | | 0 | | | balance | double | NO | | 0 | | | isvip | int(2) | NO | | 0 | | +----------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) desc userhistory; +-----------+-------------+------+-----+-------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+-------------------+-------+ | cid | varchar(30) | NO | | 0 | | | uid | varchar(30) | NO | MUL | 0 | | | isvip | int(2) | NO | | 0 | | | logintime | timestamp | NO | | CURRENT_TIMESTAMP | | | usetime | varchar(30) | NO | | 00:00:00 | | | cost | double | NO | | 0 | | +-----------+-------------+------+-----+-------------------+-------+ 6 rows in set (0.00 sec) 涉及知识点:swing,socket和serverSocket,jdbc,多线程,心跳包建立长连接,通信消息封装为xml。。。。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyondwild

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值