• Java项目:工艺品商城系统(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/ 登录
     

     

     

     

     

     

    购物车管理控制层:

    1. @Controller
    2. public class ShoppingCartController {
    3. @Resource
    4. private NewBeeMallShoppingCartService newBeeMallShoppingCartService;
    5. @GetMapping("/shop-cart")
    6. public String cartListPage(HttpServletRequest request,
    7. HttpSession httpSession) {
    8. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    9. int itemsTotal = 0;
    10. int priceTotal = 0;
    11. List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());
    12. if (!CollectionUtils.isEmpty(myShoppingCartItems)) {
    13. //购物项总数
    14. itemsTotal = myShoppingCartItems.stream().mapToInt(NewBeeMallShoppingCartItemVO::getGoodsCount).sum();
    15. if (itemsTotal < 1) {
    16. return "error/error_5xx";
    17. }
    18. //总价
    19. for (NewBeeMallShoppingCartItemVO newBeeMallShoppingCartItemVO : myShoppingCartItems) {
    20. priceTotal += newBeeMallShoppingCartItemVO.getGoodsCount() * newBeeMallShoppingCartItemVO.getSellingPrice();
    21. }
    22. if (priceTotal < 1) {
    23. return "error/error_5xx";
    24. }
    25. }
    26. request.setAttribute("itemsTotal", itemsTotal);
    27. request.setAttribute("priceTotal", priceTotal);
    28. request.setAttribute("myShoppingCartItems", myShoppingCartItems);
    29. return "mall/cart";
    30. }
    31. @PostMapping("/shop-cart")
    32. @ResponseBody
    33. public Result saveNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,
    34. HttpSession httpSession) {
    35. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    36. newBeeMallShoppingCartItem.setUserId(user.getUserId());
    37. //todo 判断数量
    38. String saveResult = newBeeMallShoppingCartService.saveNewBeeMallCartItem(newBeeMallShoppingCartItem);
    39. //添加成功
    40. if (ServiceResultEnum.SUCCESS.getResult().equals(saveResult)) {
    41. return ResultGenerator.genSuccessResult();
    42. }
    43. //添加失败
    44. return ResultGenerator.genFailResult(saveResult);
    45. }
    46. @PutMapping("/shop-cart")
    47. @ResponseBody
    48. public Result updateNewBeeMallShoppingCartItem(@RequestBody NewBeeMallShoppingCartItem newBeeMallShoppingCartItem,
    49. HttpSession httpSession) {
    50. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    51. newBeeMallShoppingCartItem.setUserId(user.getUserId());
    52. //todo 判断数量
    53. String updateResult = newBeeMallShoppingCartService.updateNewBeeMallCartItem(newBeeMallShoppingCartItem);
    54. //修改成功
    55. if (ServiceResultEnum.SUCCESS.getResult().equals(updateResult)) {
    56. return ResultGenerator.genSuccessResult();
    57. }
    58. //修改失败
    59. return ResultGenerator.genFailResult(updateResult);
    60. }
    61. @DeleteMapping("/shop-cart/{newBeeMallShoppingCartItemId}")
    62. @ResponseBody
    63. public Result updateNewBeeMallShoppingCartItem(@PathVariable("newBeeMallShoppingCartItemId") Long newBeeMallShoppingCartItemId,
    64. HttpSession httpSession) {
    65. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    66. Boolean deleteResult = newBeeMallShoppingCartService.deleteById(newBeeMallShoppingCartItemId);
    67. //删除成功
    68. if (deleteResult) {
    69. return ResultGenerator.genSuccessResult();
    70. }
    71. //删除失败
    72. return ResultGenerator.genFailResult(ServiceResultEnum.OPERATE_ERROR.getResult());
    73. }
    74. @GetMapping("/shop-cart/settle")
    75. public String settlePage(HttpServletRequest request,
    76. HttpSession httpSession) {
    77. int priceTotal = 0;
    78. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    79. List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());
    80. if (CollectionUtils.isEmpty(myShoppingCartItems)) {
    81. //无数据则不跳转至结算页
    82. return "/shop-cart";
    83. } else {
    84. //总价
    85. for (NewBeeMallShoppingCartItemVO newBeeMallShoppingCartItemVO : myShoppingCartItems) {
    86. priceTotal += newBeeMallShoppingCartItemVO.getGoodsCount() * newBeeMallShoppingCartItemVO.getSellingPrice();
    87. }
    88. if (priceTotal < 1) {
    89. return "error/error_5xx";
    90. }
    91. }
    92. request.setAttribute("priceTotal", priceTotal);
    93. request.setAttribute("myShoppingCartItems", myShoppingCartItems);
    94. return "mall/order-settle";
    95. }
    96. }

    订单管理控制层:

    1. @Controller
    2. public class OrderController {
    3. @Resource
    4. private NewBeeMallShoppingCartService newBeeMallShoppingCartService;
    5. @Resource
    6. private NewBeeMallOrderService newBeeMallOrderService;
    7. @GetMapping("/orders/{orderNo}")
    8. public String orderDetailPage(HttpServletRequest request, @PathVariable("orderNo") String orderNo, HttpSession httpSession) {
    9. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    10. NewBeeMallOrderDetailVO orderDetailVO = newBeeMallOrderService.getOrderDetailByOrderNo(orderNo, user.getUserId());
    11. if (orderDetailVO == null) {
    12. return "error/error_5xx";
    13. }
    14. request.setAttribute("orderDetailVO", orderDetailVO);
    15. return "mall/order-detail";
    16. }
    17. @GetMapping("/orders")
    18. public String orderListPage(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpSession httpSession) {
    19. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    20. params.put("userId", user.getUserId());
    21. if (StringUtils.isEmpty(params.get("page"))) {
    22. params.put("page", 1);
    23. }
    24. params.put("limit", Constants.ORDER_SEARCH_PAGE_LIMIT);
    25. //封装我的订单数据
    26. PageQueryUtil pageUtil = new PageQueryUtil(params);
    27. request.setAttribute("orderPageResult", newBeeMallOrderService.getMyOrders(pageUtil));
    28. request.setAttribute("path", "orders");
    29. return "mall/my-orders";
    30. }
    31. @GetMapping("/saveOrder")
    32. public String saveOrder(HttpSession httpSession) {
    33. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    34. List<NewBeeMallShoppingCartItemVO> myShoppingCartItems = newBeeMallShoppingCartService.getMyShoppingCartItems(user.getUserId());
    35. if (StringUtils.isEmpty(user.getAddress().trim())) {
    36. //无收货地址
    37. NewBeeMallException.fail(ServiceResultEnum.NULL_ADDRESS_ERROR.getResult());
    38. }
    39. if (CollectionUtils.isEmpty(myShoppingCartItems)) {
    40. //购物车中无数据则跳转至错误页
    41. NewBeeMallException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());
    42. }
    43. //保存订单并返回订单号
    44. String saveOrderResult = newBeeMallOrderService.saveOrder(user, myShoppingCartItems);
    45. //跳转到订单详情页
    46. return "redirect:/orders/" + saveOrderResult;
    47. }
    48. @PutMapping("/orders/{orderNo}/cancel")
    49. @ResponseBody
    50. public Result cancelOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {
    51. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    52. String cancelOrderResult = newBeeMallOrderService.cancelOrder(orderNo, user.getUserId());
    53. if (ServiceResultEnum.SUCCESS.getResult().equals(cancelOrderResult)) {
    54. return ResultGenerator.genSuccessResult();
    55. } else {
    56. return ResultGenerator.genFailResult(cancelOrderResult);
    57. }
    58. }
    59. @PutMapping("/orders/{orderNo}/finish")
    60. @ResponseBody
    61. public Result finishOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {
    62. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    63. String finishOrderResult = newBeeMallOrderService.finishOrder(orderNo, user.getUserId());
    64. if (ServiceResultEnum.SUCCESS.getResult().equals(finishOrderResult)) {
    65. return ResultGenerator.genSuccessResult();
    66. } else {
    67. return ResultGenerator.genFailResult(finishOrderResult);
    68. }
    69. }
    70. @GetMapping("/selectPayType")
    71. public String selectPayType(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession) {
    72. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    73. NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
    74. //todo 判断订单userId
    75. //todo 判断订单状态
    76. request.setAttribute("orderNo", orderNo);
    77. request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
    78. return "mall/pay-select";
    79. }
    80. @GetMapping("/payPage")
    81. public String payOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession, @RequestParam("payType") int payType) {
    82. NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
    83. NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
    84. //todo 判断订单userId
    85. //todo 判断订单状态
    86. request.setAttribute("orderNo", orderNo);
    87. request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
    88. if (payType == 1) {
    89. return "mall/alipay";
    90. } else {
    91. return "mall/wxpay";
    92. }
    93. }
    94. @GetMapping("/paySuccess")
    95. @ResponseBody
    96. public Result paySuccess(@RequestParam("orderNo") String orderNo, @RequestParam("payType") int payType) {
    97. String payResult = newBeeMallOrderService.paySuccess(orderNo, payType);
    98. if (ServiceResultEnum.SUCCESS.getResult().equals(payResult)) {
    99. return ResultGenerator.genSuccessResult();
    100. } else {
    101. return ResultGenerator.genFailResult(payResult);
    102. }
    103. }
    104. }

    商品管理控制层:

    1. @Controller
    2. public class GoodsController {
    3. @Resource
    4. private NewBeeMallGoodsService newBeeMallGoodsService;
    5. @Resource
    6. private NewBeeMallCategoryService newBeeMallCategoryService;
    7. @GetMapping({"/search", "/search.html"})
    8. public String searchPage(@RequestParam Map<String, Object> params, HttpServletRequest request) {
    9. if (StringUtils.isEmpty(params.get("page"))) {
    10. params.put("page", 1);
    11. }
    12. params.put("limit", Constants.GOODS_SEARCH_PAGE_LIMIT);
    13. //封装分类数据
    14. if (params.containsKey("goodsCategoryId") && !StringUtils.isEmpty(params.get("goodsCategoryId") + "")) {
    15. Long categoryId = Long.valueOf(params.get("goodsCategoryId") + "");
    16. SearchPageCategoryVO searchPageCategoryVO = newBeeMallCategoryService.getCategoriesForSearch(categoryId);
    17. if (searchPageCategoryVO != null) {
    18. request.setAttribute("goodsCategoryId", categoryId);
    19. request.setAttribute("searchPageCategoryVO", searchPageCategoryVO);
    20. }
    21. }
    22. //封装参数供前端回显
    23. if (params.containsKey("orderBy") && !StringUtils.isEmpty(params.get("orderBy") + "")) {
    24. request.setAttribute("orderBy", params.get("orderBy") + "");
    25. }
    26. String keyword = "";
    27. //对keyword做过滤 去掉空格
    28. if (params.containsKey("keyword") && !StringUtils.isEmpty((params.get("keyword") + "").trim())) {
    29. keyword = params.get("keyword") + "";
    30. }
    31. request.setAttribute("keyword", keyword);
    32. params.put("keyword", keyword);
    33. //封装商品数据
    34. PageQueryUtil pageUtil = new PageQueryUtil(params);
    35. request.setAttribute("pageResult", newBeeMallGoodsService.searchNewBeeMallGoods(pageUtil));
    36. return "mall/search";
    37. }
    38. @GetMapping("/goods/detail/{goodsId}")
    39. public String detailPage(@PathVariable("goodsId") Long goodsId, HttpServletRequest request) {
    40. if (goodsId < 1) {
    41. return "error/error_5xx";
    42. }
    43. NewBeeMallGoods goods = newBeeMallGoodsService.getNewBeeMallGoodsById(goodsId);
    44. if (goods == null) {
    45. return "error/error_404";
    46. }
    47. NewBeeMallGoodsDetailVO goodsDetailVO = new NewBeeMallGoodsDetailVO();
    48. BeanUtil.copyProperties(goods, goodsDetailVO);
    49. goodsDetailVO.setGoodsCarouselList(goods.getGoodsCarousel().split(","));
    50. request.setAttribute("goodsDetail", goodsDetailVO);
    51. return "mall/detail";
    52. }
    53. }

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

  • 相关阅读:
    Milk Scheduling S——拓扑排序
    springboot基于java的校园二手书籍交易平台毕业设计源码131558
    字符串分割单词C++
    计算机视觉和机器学习 - 我所想知道的一切
    js 找出两个数组中的重复元素
    CentOS7中原生Python2.7.5和Python3共存
    3.2.5:VBA对单元格操作的引申
    冥想第五百五十九天
    计算机保研er历程分享(浙软、厦大、华师、东南网安、东北、西电、中南......)
    域名的命名规则有哪些?
  • 原文地址:https://blog.csdn.net/m0_66863468/article/details/125496033