当前位置:网站首页>Based on the SSM to reach the phone sales mall system

Based on the SSM to reach the phone sales mall system

2022-08-10 23:54:00 qq_469603589

一,项目简介

 Online sales have become a mainstream trend in commodity sales now,The traditional agency model is no longer suitable for the ecological development of the current business.Online sales can be achievedF2CThis way of factory direct sales to customers,This reduces sales costs,can reduce intermediate procedures,Can provide convenience for customers.,And it can break the limitations of geographical and space-time,Make trading more free and flexible.

Developed through researchSSM手机商城系统,主要基于SSMFramework for the overall development and realization of the mall system.前端使用Bootstrap进行页面布局,并使用MySql5.7Relational database for storage of commodity and business data.系统整体功能完整,操作简洁方便.

This mall system mainly realizes the function of online sales of various brands of mobile phones,Include front-end commodity display and purchase and the background management functions.Mainly realize product browsing、Online order to buy mobile phone、The iphone to view、个人中心管理、后台的用户数据、订单数据、Product data management and other related functions.The launch of this mall will definitely provide better sales channels for merchants' product sales.

下面展示一下SSMThe functional structure of the mobile phone store

SSMThe users of the mobile phone mall system mainly include two user roles,One is the role of the store backend administrator,The second is the front-end user role of the mall,这两个角色的具体功能如下:

    管理员角色:The administrator logs in to the background management of the mobile mall system,Manage and operate relevant business data in the system,Including front end customer management、手机商品管理、手机订单管理、Mobile phone classification management, etc.;

前台用户角色:前台用户登录SSMAfter the mobile phone mall system, you can browse the mobile phone product information、Select phone to add to cart、在线下单购买、个人中心管理等操作.

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:SSM框架

前台开发技术:Bootstrap+Jquery+Ajax

三,系统展示

3.1 SSMDisplay of functional modules of mobile phone mall

3.1.1 前台首页展示

SSMThe front-end of the mobile mall is mainly to realize the information browsing of products and the operation of purchasing orders.,采用Bootstrap框架 ,主要基于 HTML、CSS、JAVASCRIPT、JSP,它简洁灵活,and easy to use,The front page mainly includes product browsing、在线下单、个人中心、我的订单等.具体操作界面展示如下图3-1所示.

图3-1 前台首页界面

.1.2前台用户购物车模块

  SSMAfter logging in the system at the front desk of the mobile shopping mall, users can enter the mobile phone details page to add the mobile phone to the shopping cart.Then you can place an online order in the shopping cart.The interface for adding a shopping cart and placing an order is as shown below3-2、3-3所示.

图3-2 前台用户添加购物车操作界面

图3-3 Front-end user submit order interface

3.1.3前台用户个人订单管理模块

  SSMAfter logging in to the system, the front-end user of the mobile mall system can manage personal order information in the personal order management module.Can display relevant information based on order status,And to pay the unpaid orders,前端用户个人订单管理操作界面如下图3-4所示.

图3-4前台用户个人订单管理操作界面

3.1.4Front-end user personal information management module

SSMThe front-end users of the mobile phone mall system can manage personal information in the personal information management module after logging in to the system.Front end users' personal information management interface below3-5所示.

图3-5Front-end user personal information management interface

3.1.5前台用户注册模块

  SSMUsers at the front desk of the mobile mall system can register their personal information and then log in.The front-end user personal account registration operation interface is as follows3-6所示.

图3-6Front-end user personal registration interface

User password and password are required fields,will be based onJSValidation of regular expressions,If the recorded data does not meet the requirements,Corresponding information will be prompted.

3.1.6Front-end user login module

  SSMUsers at the front desk of the mobile phone mall system can log in to the system after registering their personal information.,After logging in to the system, you can perform authorized purchases and other operations.The front-end user personal login interface is as follows3-7所示.

图3-7Front-end user personal login interface

3.2后台功能模块的展示

3.2.1Background user login function

  SSMMobile phone mall system background if you want to related information of mall management operations,首先要登录系统,才可展开相关的操作.输入手机号和密码后用户登陆界面如下图3-8所示.

图3-8后台用户登录操作界面

3.2.2客户管理功能

  SSMAfter the mobile phone mall system system administrator user logs in to the system,You can enter the customer management menu to manage the corresponding administrator customer information.用户管理操作界面如下图3-9、3-10所示:

图3-9Background user management function interface diagram

图3-10Back-end customer added interface diagram

3.2.3 Background mobile phone product management operationsUI

  SSMAfter the mobile phone mall system administrator user logs in to the system,You can enter the product management menu to manage the corresponding mobile product information.Which mainly includes the addition of mobile phone products、修改、查询、add banner、add new product、Join the hot sale and the corresponding removal operation, etc..商品信息管理操作界面如下图3-11、3-12所示.

图3-11后台商品管理功能UI界面

图3-12New features of commercial table foodUI界面

4.2.4 Background order management operationsUI

  SSMAfter the mobile phone mall system system administrator user logs in to the system,可以进入商品订单管理菜单进行相应的商品订单信息管理.Which mainly contains the query of the order、订单明细的查看等,You can check the line according to the different completion status of the order,And can according to user's payment,Receipt status, etc. to set different completion status of the order,订单信息管理操作界面如下图4-13所示.

图4-13后台订单管理功能UI界面

4.2.5 Background commodity category management operationsUI

  SSMAfter the mobile phone mall system administrator user logs in to the system,You can enter the product category management module to manage the classification information of meals.The product category management interface is as follows3-14所示.

图3-14Product category management functionUI界面

3.2.6 Background administrator personal password management operationUI

  SSMAfter the mobile phone mall system administrator user logs in to the system,In the background, you can modify and manage your own password..The personal password management interface is as follows4-15所示.

图3-15Personal password modification functionUI界面

四,核心代码展示

package com.controller;

import java.util.Objects;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.entity.Admins;
import com.entity.Goods;
import com.entity.Tops;
import com.entity.Types;
import com.entity.Users;
import com.service.AdminService;
import com.service.GoodService;
import com.service.OrderService;
import com.service.TopService;
import com.service.TypeService;
import com.service.UserService;
import com.util.PageUtil;
import com.util.SafeUtil;
import com.util.UploadUtil;

/**
 * 后台相关接口
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

	private static final int rows = 10;

	@Autowired
	private AdminService adminService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private UserService userService;
	@Autowired
	private GoodService goodService;
	@Autowired
	private TopService topService;
	@Autowired
	private TypeService typeService;

	/**
	 * 管理员登录
	 * @return
	 */
	@RequestMapping("/login")
	public String login(Admins admin, HttpServletRequest request, HttpSession session) {
		if (adminService.checkUser(admin.getUsername(), admin.getPassword())) {
			session.setAttribute("username", admin.getUsername());
			return "redirect:index";
		}
		request.setAttribute("msg", "用户名或密码错误!");
		return "/admin/login.jsp";
	}

	/**
	 * 退出
	 * @return
	 */
	@RequestMapping("/logout")
	public String logout(HttpSession session) {
		session.removeAttribute("admin");
		return "/admin/login.jsp";
	}
	
	/**
	 * 后台首页
	 * @return
	 */
	@RequestMapping("/index")
	public String index(HttpServletRequest request) {
		request.setAttribute("msg", "恭喜你! 登录成功了");
		return "/admin/index.jsp";
	}

	/**
	 * 订单列表
	 * 
	 * @return
	 */
	@RequestMapping("/orderList")
	public String orderList(@RequestParam(required=false, defaultValue="0")byte status, HttpServletRequest request,
			@RequestParam(required=false, defaultValue="1") int page) {
		request.setAttribute("flag", 1);
		request.setAttribute("status", status);
		request.setAttribute("orderList", orderService.getList(status, page, rows));
		request.setAttribute("pageTool", PageUtil.getPageTool(request, orderService.getTotal(status), page, rows));
		return "/admin/order_list.jsp";
	}

	/**
	 * 订单发货
	 * 
	 * @return
	 */
	@RequestMapping("/orderDispose")
	public String orderDispose(int id, byte status,
			@RequestParam(required=false, defaultValue="1") int page) {
		orderService.dispose(id);
		return "redirect:orderList?flag=1&status="+status+"&page="+page;
	}
	
	/**
	 * 订单完成
	 * 
	 * @return
	 */
	@RequestMapping("/orderFinish")
	public String orderFinish(int id, byte status,
			@RequestParam(required=false, defaultValue="1") int page) {
		orderService.finish(id);
		return "redirect:orderList?flag=1&status="+status+"&page="+page;
	}

	/**
	 * 订单删除
	 * 
	 * @return
	 */
	@RequestMapping("/orderDelete")
	public String orderDelete(int id, byte status,
			@RequestParam(required=false, defaultValue="1") int page) {
		orderService.delete(id);
		return "redirect:orderList?flag=1&status="+status+"&page="+page;
	}

	/**
	 * 顾客管理
	 * 
	 * @return
	 */
	@RequestMapping("/userList")
	public String userList(HttpServletRequest request,
			@RequestParam(required=false, defaultValue="1") int page) {
		request.setAttribute("flag", 2);
		request.setAttribute("userList", userService.getList(page, rows));
		request.setAttribute("pageTool", PageUtil.getPageTool(request, userService.getTotal(), page, rows));
		return "/admin/user_list.jsp";
	}

	/**
	 * 顾客添加
	 * 
	 * @return
	 */
	@RequestMapping("/userAdd")
	public String userAdd(HttpServletRequest request) {
		request.setAttribute("flag", 2);
		return "/admin/user_add.jsp";
	}

	/**
	 * 顾客添加
	 * 
	 * @return
	 */
	@RequestMapping("/userSave")
	public String userSave(Users user, HttpServletRequest request, 
			@RequestParam(required=false, defaultValue="1") int page) {
		if (userService.isExist(user.getUsername())) {
			request.setAttribute("msg", "用户名已存在!");
			return "/admin/user_add.jsp";
		}
		userService.add(user);
		return "redirect:userList?flag=2&page="+page;
	}

	/**
	 * 顾客密码重置页面
	 * 
	 * @return
	 */
	@RequestMapping("/userRe")
	public String userRe(int id, HttpServletRequest request) {
		request.setAttribute("flag", 2);
		request.setAttribute("user", userService.get(id));
		return "/admin/user_reset.jsp";
	}

	/**
	 * 顾客密码重置
	 * 
	 * @return
	 */
	@RequestMapping("/userReset")
	public String userReset(Users user, 
			@RequestParam(required=false, defaultValue="1") int page) {
		String password = SafeUtil.encode(user.getPassword());
		user = userService.get(user.getId());
		user.setPassword(password);
		userService.update(user);
		return "redirect:userList?flag=2&page="+page;
	}

	/**
	 * 顾客更新
	 * 
	 * @return
	 */
	@RequestMapping("/userEdit")
	public String userEdit(int id, HttpServletRequest request) {
		request.setAttribute("flag", 2);
		request.setAttribute("user", userService.get(id));
		return "/admin/user_edit.jsp";
	}

	/**
	 * 顾客更新
	 * 
	 * @return
	 */
	@RequestMapping("/userUpdate")
	public String userUpdate(Users user, 
			@RequestParam(required=false, defaultValue="1") int page) {
		userService.update(user);
		return "redirect:userList?flag=2&page="+page;
	}

	/**
	 * 顾客删除
	 * 
	 * @return
	 */
	@RequestMapping("/userDelete")
	public String userDelete(Users user, 
			@RequestParam(required=false, defaultValue="1") int page) {
		userService.delete(user);
		return "redirect:userList?flag=2&page="+page;
	}

	/**
	 * 产品列表
	 * 
	 * @return
	 */
	@RequestMapping("/goodList")
	public String goodList(@RequestParam(required=false, defaultValue="0")byte status, HttpServletRequest request, 
			@RequestParam(required=false, defaultValue="1") int page) {
		request.setAttribute("flag", 3);
		request.setAttribute("page", page);
		request.setAttribute("status", status);
		request.setAttribute("goodList", goodService.getList(status, page, rows));
		request.setAttribute("pageTool", PageUtil.getPageTool(request, goodService.getTotal(status), page, rows));
		return "/admin/good_list.jsp";
	}

	/**
	 * 产品添加
	 * 
	 * @return
	 */
	@RequestMapping("/goodAdd")
	public String goodAdd(HttpServletRequest request) {
		request.setAttribute("flag", 3);
		request.setAttribute("typeList", typeService.getList());
		return "/admin/good_add.jsp";
	}

	/**
	 * 产品添加
	 * 
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/goodSave")
	public String goodSave(String name, int price, String intro, int stock, int typeId, 
			MultipartFile cover, MultipartFile image1, MultipartFile image2, 
			@RequestParam(required=false, defaultValue="1") int page) throws Exception {
		Goods good = new Goods();
		good.setName(name);
		good.setPrice(price);
		good.setIntro(intro);
		good.setStock(stock);
		good.setTypeId(typeId);
		good.setCover(UploadUtil.fileUpload(cover));
		good.setImage1(UploadUtil.fileUpload(image1));
		good.setImage2(UploadUtil.fileUpload(image2));
		goodService.add(good);
		return "redirect:goodList?flag=3&page="+page;
	}

	/**
	 * 产品更新
	 * 
	 * @return
	 */
	@RequestMapping("/goodEdit")
	public String goodEdit(int id, HttpServletRequest request) {
		request.setAttribute("flag", 3);
		request.setAttribute("typeList", typeService.getList());
		request.setAttribute("good", goodService.get(id));
		return "/admin/good_edit.jsp";
	}

	/**
	 * 产品更新
	 * 
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/goodUpdate")
	public String goodUpdate(int id, String name, int price, String intro, int stock, int typeId,  
			MultipartFile cover, MultipartFile image1, MultipartFile image2,
			@RequestParam(required=false, defaultValue="1") int page) throws Exception {
		Goods good = goodService.get(id);
		good.setName(name);
		good.setPrice(price);
		good.setIntro(intro);
		good.setStock(stock);
		good.setTypeId(typeId);
		if (Objects.nonNull(cover) && !cover.isEmpty()) {
			good.setCover(UploadUtil.fileUpload(cover));
		}
		if (Objects.nonNull(image1) && !image1.isEmpty()) {
			good.setImage1(UploadUtil.fileUpload(image1));
		}
		if (Objects.nonNull(image2) && !image2.isEmpty()) {
			good.setImage2(UploadUtil.fileUpload(image2));
		}
		goodService.update(good);
		return "redirect:goodList?flag=3&page="+page;
	}

	/**
	 * 产品删除
	 * 
	 * @return
	 */
	@RequestMapping("/goodDelete")
	public String goodDelete(int id, 
			@RequestParam(required=false, defaultValue="1") int page) {
		goodService.delete(id);
		return "redirect:goodList?flag=3&page="+page;
	}
	
	/**
	 * 添加推荐
	 * @return
	 */
	@RequestMapping("/topSave")
	public @ResponseBody String topSave(Tops tops, 
			@RequestParam(required=false, defaultValue="0")byte status,
			@RequestParam(required=false, defaultValue="1") int page) {
		int id = topService.add(tops);
		return id > 0 ? "ok" : null;
	}
	
	/**
	 * 删除推荐
	 * @return
	 */
	@RequestMapping("/topDelete")
	public @ResponseBody String topDelete(Tops tops, 
			@RequestParam(required=false, defaultValue="0")byte status,
			@RequestParam(required=false, defaultValue="1") int page) {
		boolean flag = topService.delete(tops);
		return flag ? "ok" : null;
	}

	/**
	 * 类目列表
	 * 
	 * @return
	 */
	@RequestMapping("/typeList")
	public String typeList(HttpServletRequest request) {
		request.setAttribute("flag", 4);
		request.setAttribute("typeList", typeService.getList());
		return "/admin/type_list.jsp";
	}

	/**
	 * 类目添加
	 * 
	 * @return
	 */
	@RequestMapping("/typeSave")
	public String typeSave(Types type, 
			@RequestParam(required=false, defaultValue="1") int page) {
		typeService.add(type);
		return "redirect:typeList?flag=4&page="+page;
	}

	/**
	 * 类目更新
	 * 
	 * @return
	 */
	@RequestMapping("/typeEdit")
	public String typeUp(int id, HttpServletRequest request) {
		request.setAttribute("flag", 4);
		request.setAttribute("type", typeService.get(id));
		return "/admin/type_edit.jsp";
	}

	/**
	 * 类目更新
	 * 
	 * @return
	 */
	@RequestMapping("/typeUpdate")
	public String typeUpdate(Types type, 
			@RequestParam(required=false, defaultValue="1") int page) {
		typeService.update(type);
		return "redirect:typeList?flag=4&page="+page;
	}

	/**
	 * 类目删除
	 * 
	 * @return
	 */
	@RequestMapping("/typeDelete")
	public String typeDelete(Types type, 
			@RequestParam(required=false, defaultValue="1") int page) {
		typeService.delete(type);
		return "redirect:typeList?flag=4&page="+page;
	}

	/**
	 * 管理员列表
	 * 
	 * @return
	 */
	@RequestMapping("/adminList")
	public String adminList(HttpServletRequest request, 
			@RequestParam(required=false, defaultValue="1") int page) {
		request.setAttribute("flag", 5);
		request.setAttribute("adminList", adminService.getList(page, rows));
		request.setAttribute("pageTool", PageUtil.getPageTool(request, adminService.getTotal(), page, rows));
		return "/admin/admin_list.jsp";
	}

	/**
	 * 管理员修改自己密码
	 * 
	 * @return
	 */
	@RequestMapping("/adminRe")
	public String adminRe(HttpServletRequest request, HttpSession session) {
		request.setAttribute("flag", 5);
		request.setAttribute("admin", adminService.getByUsername(String.valueOf(session.getAttribute("username"))));
		return "/admin/admin_reset.jsp";
	}

	/**
	 * 管理员修改自己密码
	 * 
	 * @return
	 */
	@RequestMapping("/adminReset")
	public String adminReset(Admins admin, HttpServletRequest request) {
		request.setAttribute("flag", 5);
		if (adminService.get(admin.getId()).getPassword().equals(SafeUtil.encode(admin.getPassword()))) {
			admin.setPassword(SafeUtil.encode(admin.getPasswordNew()));
			adminService.update(admin);
			request.setAttribute("admin", admin);
			request.setAttribute("msg", "修改成功!");
		}else {
			request.setAttribute("msg", "原密码错误!");
		}
		return "/admin/admin_reset.jsp";
	}

	/**
	 * 管理员添加
	 * 
	 * @return
	 */
	@RequestMapping("/adminSave")
	public String adminSave(Admins admin, HttpServletRequest request, 
			@RequestParam(required=false, defaultValue="1") int page) {
		if (adminService.isExist(admin.getUsername())) {
			request.setAttribute("msg", "用户名已存在!");
			return "/admin/admin_add.jsp";
		}
		adminService.add(admin);
		return "redirect:adminList?flag=5&page="+page;
	}

	/**
	 * 管理员修改
	 * 
	 * @return
	 */
	@RequestMapping("/adminEdit")
	public String adminEdit(int id, HttpServletRequest request) {
		request.setAttribute("flag", 5);
		request.setAttribute("admin", adminService.get(id));
		return "/admin/admin_edit.jsp";
	}

	/**
	 * 管理员更新
	 * 
	 * @return
	 */
	@RequestMapping("/adminUpdate")
	public String adminUpdate(Admins admin, 
			@RequestParam(required=false, defaultValue="1") int page) {
		admin.setPassword(SafeUtil.encode(admin.getPassword()));
		adminService.update(admin);
		return "redirect:adminList?flag=5&page="+page;
	}

	/**
	 * 管理员删除
	 * 
	 * @return
	 */
	@RequestMapping("/adminDelete")
	public String adminDelete(Admins admin, 
			@RequestParam(required=false, defaultValue="1") int page) {
		adminService.delete(admin);
		return "redirect:adminList?flag=5&page="+page;
	}

}
package com.controller;

import java.util.Objects;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * 后台登录验证拦截器
 */
public class AdminInterceptor extends HandlerInterceptorAdapter{

	/**
	 * 检测登录状态
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, 
			HttpServletResponse response, Object handler) throws Exception {
		String uri = request.getRequestURI();
		if(uri.contains("css/") || uri.contains("js/") || uri.contains("img/") 
				|| uri.contains("login") || uri.contains("logout")) {
			return true; // 不拦截路径
		}
		Object username = request.getSession().getAttribute("username");
		if (Objects.nonNull(username) && !username.toString().trim().isEmpty()) {
			return true; // 登录验证通过
		}
		response.sendRedirect("login.jsp");
		return false; // 其他情况一律拦截
	}

}

五,项目总结

The shopping mall system designed and implemented in this paper,Realize the emerging industry of electronic mall through the Internet,Electronic malls mainly rely on computer Internet technology.If this technology is missing,There is no way to realize the electronic mall,If you want to achieve perfect,Internet technology will have great development.这样,The electronic mall has driven the great progress of science and technology.Users can search for products anytime, anywhere、挑选商品、The entire process of purchasing an item.对于商家而言,Buying goods online has the following advantages:不受场地限制、购买成本低、降低了风险、It is beneficial to better stimulate users to consume and buy.对于消费者来说,Buying goods online has the following advantages:Inexpensive and convenient、You can buy satisfactory products without leaving home.对商家而言,Selling goods online has the following advantages:It can save the rent of the store for the merchant、人力成本,The most important thing is that the price of goods will also be greatly reduced.

原网站

版权声明
本文为[qq_469603589]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208102322073776.html