基于javaweb和mysql的ssm工艺品商城系统(java+ssm+jsp+bootstrap+mysql)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb的SSM工艺品商城系统(java+ssm+jsp+bootstrap+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+CSS+JavaScript+jQuery+Bootstrap

使用说明

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

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (!CollectionUtils.isEmpty(myShoppingCartItems)) {

//购物项总数

itemsTotal = myShoppingCartItems.stream().mapToInt(NewBeeMallShoppingCartItemVO::getGoodsCount).sum();

if (itemsTotal < 1) {

return "error/error_5xx";

//总价

for (NewBeeMallShoppingCartItemVO newBeeMallShoppingCartItemVO : myShoppingCartItems) {

priceTotal += newBeeMallShoppingCartItemVO.getGoodsCount() * newBeeMallShoppingCartItemVO.getSellingPrice();

if (priceTotal < 1) {


NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (StringUtils.isEmpty(user.getAddress().trim())) {

//无收货地址

NewBeeMallException.fail(ServiceResultEnum.NULL_ADDRESS_ERROR.getResult());

if (CollectionUtils.isEmpty(myShoppingCartItems)) {

//购物车中无数据则跳转至错误页

NewBeeMallException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());

//保存订单并返回订单号

String saveOrderResult = newBeeMallOrderService.saveOrder(user, myShoppingCartItems);


SearchPageCategoryVO searchPageCategoryVO = newBeeMallCategoryService.getCategoriesForSearch(categoryId);

if (searchPageCategoryVO != null) {

request.setAttribute("goodsCategoryId", categoryId);

request.setAttribute("searchPageCategoryVO", searchPageCategoryVO);

//封装参数供前端回显

if (params.containsKey("orderBy") && !StringUtils.isEmpty(params.get("orderBy") + "")) {

request.setAttribute("orderBy", params.get("orderBy") + "");

String keyword = "";

//对keyword做过滤 去掉空格

if (params.containsKey("keyword") && !StringUtils.isEmpty((params.get("keyword") + "").trim())) {

keyword = params.get("keyword") + "";


if (StringUtils.isEmpty(user.getAddress().trim())) {

//无收货地址

NewBeeMallException.fail(ServiceResultEnum.NULL_ADDRESS_ERROR.getResult());

if (CollectionUtils.isEmpty(myShoppingCartItems)) {

//购物车中无数据则跳转至错误页

NewBeeMallException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());

//保存订单并返回订单号

String saveOrderResult = newBeeMallOrderService.saveOrder(user, myShoppingCartItems);

//跳转到订单详情页

return "redirect:/orders/" + saveOrderResult;

@PutMapping("/orders/{orderNo}/cancel")


params.put("page", 1);

params.put("limit", Constants.ORDER_SEARCH_PAGE_LIMIT);

//封装我的订单数据

PageQueryUtil pageUtil = new PageQueryUtil(params);

request.setAttribute("orderPageResult", newBeeMallOrderService.getMyOrders(pageUtil));

request.setAttribute("path", "orders");

return "mall/my-orders";

@GetMapping("/saveOrder")

public String saveOrder(HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (StringUtils.isEmpty(user.getAddress().trim())) {

//无收货地址


return ResultGenerator.genSuccessResult();

} else {

return ResultGenerator.genFailResult(finishOrderResult);

@GetMapping("/selectPayType")

public String selectPayType(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);

//todo 判断订单userId

//todo 判断订单状态

request.setAttribute("orderNo", orderNo);

request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());

for (NewBeeMallShoppingCartItemVO newBeeMallShoppingCartItemVO : myShoppingCartItems) {

priceTotal += newBeeMallShoppingCartItemVO.getGoodsCount() * newBeeMallShoppingCartItemVO.getSellingPrice();

if (priceTotal < 1) {

return "error/error_5xx";

request.setAttribute("itemsTotal", itemsTotal);

request.setAttribute("priceTotal", priceTotal);

request.setAttribute("myShoppingCartItems", myShoppingCartItems);

return "mall/cart";

@PostMapping("/shop-cart")

@ResponseBody

public Result saveNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,

HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (CollectionUtils.isEmpty(myShoppingCartItems)) {

//无数据则不跳转至结算页

return "/shop-cart";

} else {

//总价

for (NewBeeMallShoppingCartItemVO newBeeMallShoppingCartItemVO : myShoppingCartItems) {

priceTotal += newBeeMallShoppingCartItemVO.getGoodsCount() * newBeeMallShoppingCartItemVO.getSellingPrice();

if (priceTotal < 1) {

return "error/error_5xx";

request.setAttribute("priceTotal", priceTotal);

request.setAttribute("myShoppingCartItems", myShoppingCartItems);

public Result saveNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,

HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

newBeeMallShoppingCartItem.setUserId(user.getUserId());

//todo 判断数量

String saveResult = newBeeMallShoppingCartService.saveNewBeeMallCartItem(newBeeMallShoppingCartItem);

//添加成功

if (ServiceResultEnum.SUCCESS.getResult().equals(saveResult)) {

return ResultGenerator.genSuccessResult();

//添加失败

return ResultGenerator.genFailResult(saveResult);

@PutMapping("/shop-cart")

@ResponseBody


//添加成功

if (ServiceResultEnum.SUCCESS.getResult().equals(saveResult)) {

return ResultGenerator.genSuccessResult();

//添加失败

return ResultGenerator.genFailResult(saveResult);

@PutMapping("/shop-cart")

@ResponseBody

public Result updateNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,

HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);


public String payOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession, @RequestParam("payType") int payType) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);

//todo 判断订单userId

//todo 判断订单状态

request.setAttribute("orderNo", orderNo);

request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());

if (payType == 1) {

return "mall/alipay";

} else {

return "mall/wxpay";

@GetMapping("/paySuccess")

@ResponseBody


//删除失败

return ResultGenerator.genFailResult(ServiceResultEnum.OPERATE_ERROR.getResult());

@GetMapping("/shop-cart/settle")

public String settlePage(HttpServletRequest request,

HttpSession httpSession) {

int priceTotal = 0;

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (CollectionUtils.isEmpty(myShoppingCartItems)) {

//无数据则不跳转至结算页

return "/shop-cart";
newBeeMallShoppingCartItem.setUserId(user.getUserId());

//todo 判断数量

String saveResult = newBeeMallShoppingCartService.saveNewBeeMallCartItem(newBeeMallShoppingCartItem);

//添加成功

if (ServiceResultEnum.SUCCESS.getResult().equals(saveResult)) {

return ResultGenerator.genSuccessResult();

//添加失败

return ResultGenerator.genFailResult(saveResult);

@PutMapping("/shop-cart")

@ResponseBody

public Result updateNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,

HttpSession httpSession) {


Boolean deleteResult = newBeeMallShoppingCartService.deleteById(newBeeMallShoppingCartItemId);

//删除成功

if (deleteResult) {

return ResultGenerator.genSuccessResult();

//删除失败

return ResultGenerator.genFailResult(ServiceResultEnum.OPERATE_ERROR.getResult());

@GetMapping("/shop-cart/settle")

public String settlePage(HttpServletRequest request,

HttpSession httpSession) {

int priceTotal = 0;

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

NewBeeMallOrderDetailVO orderDetailVO = newBeeMallOrderService.getOrderDetailByOrderNo(orderNo, user.getUserId());

if (orderDetailVO == null) {

return "error/error_5xx";

request.setAttribute("orderDetailVO", orderDetailVO);

return "mall/order-detail";

@GetMapping("/orders")

public String orderListPage(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

params.put("userId", user.getUserId());

if (StringUtils.isEmpty(params.get("page"))) {
//封装我的订单数据

PageQueryUtil pageUtil = new PageQueryUtil(params);

request.setAttribute("orderPageResult", newBeeMallOrderService.getMyOrders(pageUtil));

request.setAttribute("path", "orders");

return "mall/my-orders";

@GetMapping("/saveOrder")

public String saveOrder(HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());

if (StringUtils.isEmpty(user.getAddress().trim())) {

//无收货地址

NewBeeMallException.fail(ServiceResultEnum.NULL_ADDRESS_ERROR.getResult());

if (CollectionUtils.isEmpty(myShoppingCartItems)) {
return "mall/alipay";

} else {

return "mall/wxpay";

@GetMapping("/paySuccess")

@ResponseBody

public Result paySuccess(@RequestParam("orderNo") String orderNo, @RequestParam("payType") int payType) {

String payResult = newBeeMallOrderService.paySuccess(orderNo, payType);

if (ServiceResultEnum.SUCCESS.getResult().equals(payResult)) {

return ResultGenerator.genSuccessResult();

} else {

return ResultGenerator.genFailResult(payResult);

商品管理控制层:

@Controller

public class GoodsController {

@PutMapping("/orders/{orderNo}/cancel")

@ResponseBody

public Result cancelOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {

NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);

String cancelOrderResult = newBeeMallOrderService.cancelOrder(orderNo, user.getUserId());

if (ServiceResultEnum.SUCCESS.getResult().equals(cancelOrderResult)) {

return ResultGenerator.genSuccessResult();

} else {

return ResultGenerator.genFailResult(cancelOrderResult);

@PutMapping("/orders/{orderNo}/finish")

@ResponseBody

public Result finishOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {

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

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐