• 酒水商城|基于Springboot实现酒水商城系统


    项目编号:BS-SC-036

    一,项目简介

    系统整体介绍:

    本系统主要基于Springboot框架开发实现,实现了一个以茶叶为主题的商城系统。在本商城系统中,可以实现在线购买酒水,在线支付,管理个人订单,管理个人收货地址,确认收货等功能。用户浏览商城的茶叶产品后可以将茶叶商品添加到购物车中,然后下单支付购买。用户登陆后可以在个人中心中管理自己的购物车信息、订单信息、收货地址信息等。同样在商城前端页面中提供了全文搜索功能,用户可以根据酒水的相关功效或禁忌来查询符合自己要的酒水商品。

    系统同样提供了强大的后台管理系统,在后台管理模块中可以实现能前台注册用户的管理操作,可以管理所有用户的订单信息,根据订单支付情况进行发货等操作。同样可以管理产品的分类,可以管理商品的信息,以图文的形式来添加商品信息。为了更好了了解商品的销售情况,在后台使用echart实现了商品销售的图形报表和订单的统计报表功能。

          系统使用了SpringSecurity框架来管理系统的用户登陆和权限认证操作,以保证系统的安全性。本系统功能完整,页面简洁大方,运行无误,适合做毕业设计使用。

          相似性推荐:根据用户的浏览商品的相似性做协同过滤运算,从而给用户进行商品的推荐。

          浏览记录查询:用户的浏览和搜索记录后台会进行记录,在用户进行搜索时会根据搜索关键词的总量进行排行,从而实现推荐的效果

     

    二,环境介绍

    语言环境:Java:  jdk1.8

    数据库:Mysql: mysql5.7

    应用服务器:Tomcat:  tomcat8.5.31

    开发工具:IDEA或eclipse

    后台开发技术:springboot+springmvc+mybatis+ Springsecurity

    前台开发技术:jsp+jquery+ajax+bootstrap

    三,系统展示

    系统首页

    分类展示

    商品详情

    全文检索:记录用户检索历史记录并可以根据历史记录来进行快速搜索

    根据品牌进行搜索

    相似性推荐:根据用户的浏览商品的相似性做协同过滤运算,从而给用户进行商品的推荐

    用户注册

    用户登陆

    登陆后可以进行商品购买

    下单后可个人中心可以查看我的订单,并可以取消订单

    个人中心管理个人收货地址

    后台管理员登陆

    用户管理

    轮播图管理

    商品分类动态维护

    商品品牌管理

    商品管理

    订单管理

    图形统计报表

    四,核心代码展示

    1. package com.yw.eshop.controller.front;
    2. import com.yw.eshop.domain.Carousel;
    3. import com.yw.eshop.domain.Product;
    4. import com.yw.eshop.domain.ProductType;
    5. import com.yw.eshop.domain.SearchHistory;
    6. import com.yw.eshop.service.CarouselService;
    7. import com.yw.eshop.service.ProductService;
    8. import com.yw.eshop.service.ProductTypeService;
    9. import com.yw.eshop.service.SearchHistoryService;
    10. import com.yw.eshop.service.CarouselService;
    11. import com.yw.eshop.service.ProductService;
    12. import com.yw.eshop.service.ProductTypeService;
    13. import com.yw.eshop.service.SearchHistoryService;
    14. import org.springframework.beans.factory.annotation.Autowired;
    15. import org.springframework.stereotype.Controller;
    16. import org.springframework.ui.Model;
    17. import org.springframework.web.bind.annotation.RequestMapping;
    18. import java.util.List;
    19. /**
    20. * 前端首页控制接口
    21. */
    22. @Controller
    23. @RequestMapping("/front")
    24. public class FrontIndexController {
    25. @Autowired//轮播图
    26. private CarouselService carouselService ;
    27. @Autowired//商品类型
    28. private ProductTypeService productTypeService ;
    29. @Autowired//商品
    30. private ProductService productService ;
    31. @Autowired
    32. private SearchHistoryService searchHistoryService;
    33. @RequestMapping("/index")
    34. public String index(Model model){
    35. //轮播图
    36. List carousels = carouselService.queryCarouselAll();
    37. model.addAttribute("allcarouselFigures",carousels);
    38. //分类
    39. List productTypes = productTypeService.queryProductTypeAll();
    40. model.addAttribute("allProductTypes",productTypes);
    41. //新品
    42. List newProducts = productService.queryNewProduct(6);
    43. model.addAttribute("newProducts", newProducts);
    44. //查询热搜词
    45. List searchHistorys = searchHistoryService.querySearchHistoryPages(10);
    46. model.addAttribute("searchHistorys",searchHistorys);
    47. //排行榜
    48. List rankings = productService.queryProductRankings();
    49. model.addAttribute("rankings", rankings);
    50. //白酒
    51. ProductType productType = new ProductType();
    52. productType.setProductTypeName("白酒");
    53. Product product = new Product();
    54. product.setProductType(productType);
    55. List list = productService.queryProductsByType(product, 5);
    56. model.addAttribute("list", list);
    57. //红酒
    58. productType.setProductTypeName("红酒");
    59. product.setProductType(productType);
    60. product.getProductType().setProductTypeName("红酒");
    61. List list2 = productService.queryProductsByType(product, 12);
    62. model.addAttribute("list2", list2);
    63. //洋酒
    64. productType.setProductTypeName("洋酒");
    65. product.setProductType(productType);
    66. List list3 = productService.queryProductsByType(product, 5);
    67. model.addAttribute("list3", list3);
    68. //养生酒
    69. productType.setProductTypeName("养生酒");
    70. product.setProductType(productType);
    71. List list4 = productService.queryProductsByType(product, 12);
    72. model.addAttribute("list4", list4);
    73. return "front/index/index";
    74. }
    75. }

    1. package com.yw.eshop.controller.front;
    2. import com.yw.eshop.domain.User;
    3. import com.yw.eshop.service.UserService;
    4. import com.yw.eshop.utils.EncryptionUtils;
    5. import com.yw.eshop.service.UserService;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.util.StringUtils;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.ResponseBody;
    11. import javax.servlet.http.Cookie;
    12. import javax.servlet.http.HttpServletRequest;
    13. import javax.servlet.http.HttpServletResponse;
    14. import javax.servlet.http.HttpSession;
    15. import java.io.IOException;
    16. /**
    17. * 前端用户登陆退出
    18. */
    19. @Controller
    20. @RequestMapping("/front/login")
    21. public class FrontLoginController {
    22. @Autowired
    23. private UserService userService;
    24. @RequestMapping("/loginPage")
    25. public String loginPage(){
    26. return "front/login";
    27. }
    28. @RequestMapping("/login")
    29. @ResponseBody
    30. public String login(String username, String password, String code, String autoLogin,
    31. HttpServletRequest request, HttpSession session, HttpServletResponse response){
    32. String code1 = (String) session.getAttribute("code");
    33. if(StringUtils.isEmpty(code)||!code.equalsIgnoreCase(code1)){
    34. return "验证码错误";
    35. }
    36. if(!StringUtils.isEmpty(username)){
    37. User user = userService.queryUserByName(username, 1);
    38. if(user==null){
    39. return "用户名不存在";
    40. }else {
    41. String psw1 = user.getPassword();
    42. if(psw1.equals(EncryptionUtils.encryptMD5(password))){
    43. System.out.println("登录成功");
    44. session.setAttribute("user",user);
    45. if(!StringUtils.isEmpty(autoLogin)&&autoLogin.equals("1")){
    46. Cookie username_cookie = new Cookie("username", username);
    47. username_cookie.setMaxAge(3600*24*7);
    48. username_cookie.setPath(request.getContextPath());
    49. response.addCookie(username_cookie);
    50. }else {
    51. Cookie username_cookie = new Cookie("username", username);
    52. username_cookie.setMaxAge(0);
    53. username_cookie.setPath(request.getContextPath());
    54. response.addCookie(username_cookie);
    55. }
    56. return "登录成功";
    57. }else {
    58. return "密码错误";
    59. }
    60. }
    61. }else {
    62. return "用户名为空";
    63. }
    64. }
    65. @RequestMapping("/logout")
    66. public void logout(HttpSession session,HttpServletRequest request,HttpServletResponse response) throws IOException {
    67. session.removeAttribute("user");
    68. Cookie[] cookies = request.getCookies();
    69. if(cookies!=null){
    70. for (Cookie cookie : cookies) {
    71. if ("username".equals(cookie.getName())) {
    72. cookie.setMaxAge(0);
    73. cookie.setPath(request.getContextPath());
    74. response.addCookie(cookie);
    75. }
    76. }
    77. }
    78. response.sendRedirect(request.getContextPath()+"/front/login/loginPage");
    79. }
    80. }

    1. package com.yw.eshop.controller.front;
    2. import com.yw.eshop.domain.Order;
    3. import com.yw.eshop.domain.OrderProduct;
    4. import com.yw.eshop.domain.User;
    5. import com.yw.eshop.service.OrderProductService;
    6. import com.yw.eshop.service.OrderService;
    7. import com.yw.eshop.service.OrderProductService;
    8. import com.yw.eshop.service.OrderService;
    9. import org.springframework.beans.factory.annotation.Autowired;
    10. import org.springframework.stereotype.Controller;
    11. import org.springframework.ui.Model;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.ResponseBody;
    14. import javax.servlet.http.HttpSession;
    15. import java.util.List;
    16. /**
    17. * 前台订单控制器
    18. */
    19. @Controller
    20. @RequestMapping("front/order")
    21. public class FrontOrderController {
    22. @Autowired
    23. private OrderService orderService;
    24. @Autowired
    25. private OrderProductService orderProductService;
    26. /**
    27. * 前台个人中心订单查询
    28. * @param session
    29. * @param model
    30. * @return
    31. */
    32. @RequestMapping("index")
    33. private String index(HttpSession session, Model model){
    34. try {
    35. User user = (User) session.getAttribute("user");
    36. if (user == null) {
    37. return "redirect:/front/login/loginPage";
    38. } else {
    39. List list = orderService.queryAllOrder(user.getId());
    40. for (Order order : list) {
    41. List orderProducts = orderProductService.queryOrderProByOrderId(order.getId());
    42. order.setList(orderProducts);
    43. }
    44. model.addAttribute("list", list);
    45. return "front/order/order";
    46. }
    47. }catch (Exception e){
    48. e.printStackTrace();
    49. model.addAttribute("errMessage","服务器繁忙"+e.getMessage());
    50. return "500";
    51. }
    52. }
    53. /**
    54. * 前台用户取消订单:条件是未发货状态
    55. * @param id
    56. * @param model
    57. * @return
    58. */
    59. @RequestMapping("/delete")
    60. @ResponseBody
    61. public String delete(String id, Model model){
    62. model.addAttribute("id", id);
    63. try {
    64. int i = orderService.delete(id);
    65. if (i==0){
    66. model.addAttribute("errMessage","服务器繁忙操作失败");
    67. return "500";
    68. }
    69. }catch (Exception e){
    70. model.addAttribute("errMessage",e.getMessage());
    71. return "500";
    72. }
    73. //return "forward:/front/order/index";
    74. model.addAttribute("url", "/front/order/index");
    75. return "success";
    76. }
    77. /**
    78. * 前台用户确认收货:条件是己发货状态
    79. * @param id
    80. * @param model
    81. * @return
    82. */
    83. @RequestMapping("/update")
    84. @ResponseBody
    85. public String update(String id,Integer status, Model model){
    86. model.addAttribute("id", id);
    87. try {
    88. int i = orderService.updateStatus(id,status);
    89. if (i==0){
    90. model.addAttribute("errMessage","服务器繁忙操作失败");
    91. return "500";
    92. }
    93. }catch (Exception e){
    94. model.addAttribute("errMessage",e.getMessage());
    95. return "500";
    96. }
    97. //return "forward:/front/order/index";
    98. model.addAttribute("url", "/front/order/index");
    99. return "success";
    100. }
    101. }
    1. package com.yw.eshop.controller.front;
    2. import com.alibaba.fastjson.JSON;
    3. import com.yw.eshop.domain.*;
    4. import com.yw.eshop.service.*;
    5. import com.yw.eshop.domain.*;
    6. import com.yw.eshop.utils.UUIDUtils;
    7. import com.fasterxml.jackson.core.JsonProcessingException;
    8. import com.fasterxml.jackson.databind.ObjectMapper;
    9. import com.yw.eshop.service.*;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.ui.Model;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import javax.servlet.http.HttpSession;
    16. import java.util.Date;
    17. import java.util.HashMap;
    18. import java.util.List;
    19. import java.util.Map;
    20. /**
    21. * 购物车处理控制品接口
    22. */
    23. @Controller
    24. @RequestMapping("front/shop_cart")
    25. public class ShopCartController {
    26. @Autowired
    27. private ReceiveAddressService receiveAddressService;
    28. @Autowired
    29. private ShopCartProductService shopCartProductService;
    30. @Autowired
    31. private ShopCartService shopCartService;
    32. @Autowired
    33. private OrderService orderService;
    34. @Autowired
    35. private OrderProductService orderProductService;
    36. @RequestMapping("/shopCart")
    37. public String index(HttpSession session, Model model){
    38. try{
    39. User user =(User) session.getAttribute("user");
    40. if (user ==null){
    41. return "redirect:/front/login/loginPage";
    42. }else {
    43. ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
    44. List receiveAddresses=receiveAddressService.queryAddressByUserID(user.getId());
    45. model.addAttribute("address",receiveAddresses);
    46. List list=shopCartProductService.queryCartProductAll(shopCart.getId());
    47. model.addAttribute("list",list);
    48. }
    49. return "front/shop_cart/shop_cart";
    50. }catch (Exception e){
    51. e.printStackTrace();
    52. model.addAttribute("errMessage","服务器繁忙"+e.getMessage());
    53. return "500";
    54. }
    55. }
    56. @RequestMapping("addProductToCart")
    57. @ResponseBody
    58. public String addProductToCart(HttpSession session, String product_id,Integer product_num) throws JsonProcessingException {
    59. Map map =new HashMap();
    60. try{
    61. User user =(User) session.getAttribute("user");
    62. if (user ==null){
    63. map.put("message","请登录后再操作");
    64. map.put("url","/front/login/loginPage");
    65. }else {
    66. ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
    67. ShopCartProduct shopCartProduct=new ShopCartProduct();
    68. Product product=new Product();
    69. product.setId(product_id);
    70. shopCartProduct.setProduct(product);
    71. shopCartProduct.setShopCart(shopCart);
    72. shopCartProduct.setProductNum(product_num);
    73. shopCartProductService.addShop(shopCartProduct);
    74. map.put("result",true);
    75. }
    76. }catch (Exception e){
    77. e.printStackTrace();
    78. map.put("message","添加失败"+e.getMessage());
    79. }
    80. ObjectMapper objectMapper = new ObjectMapper();
    81. String val = objectMapper.writeValueAsString(map);
    82. return val;
    83. }
    84. @RequestMapping("/deleteProduct")
    85. @ResponseBody
    86. public String delete(String id) throws JsonProcessingException {
    87. Map map =new HashMap();
    88. try {
    89. int i = shopCartProductService.deleteById(id);
    90. if (i==0){
    91. map.put("message","删除失败");
    92. }else {
    93. map.put("message","删除成功");
    94. map.put("result",true);
    95. }
    96. }catch (Exception e){
    97. e.printStackTrace();;
    98. map.put("message","删除失败:"+e.getMessage());
    99. }
    100. ObjectMapper objectMapper = new ObjectMapper();
    101. String val = objectMapper.writeValueAsString(map);
    102. System.out.println(val);
    103. return val;
    104. }
    105. @RequestMapping("/batchDel")
    106. @ResponseBody
    107. public String batchDel(String[] ids) throws JsonProcessingException {
    108. Map map =new HashMap();
    109. try {
    110. shopCartProductService.deleteAll(ids);
    111. map.put("message","删除成功");
    112. map.put("result",true);
    113. }catch (Exception e){
    114. e.printStackTrace();;
    115. map.put("message","删除失败:"+e.getMessage());
    116. }
    117. ObjectMapper objectMapper = new ObjectMapper();
    118. String val = objectMapper.writeValueAsString(map);
    119. System.out.println(val);
    120. return val;
    121. }
    122. @RequestMapping("compute")
    123. @ResponseBody
    124. public String compute(String products,String address_id,HttpSession session) throws JsonProcessingException {
    125. Map map =new HashMap();
    126. User user =(User) session.getAttribute("user");
    127. try {
    128. if (user ==null){
    129. map.put("message","请登录后再操作");
    130. map.put("url","/front/login/loginPage");
    131. }else {
    132. List proIdAndNums= JSON.parseArray(products,ProIdAndNum.class);
    133. Order order=new Order();
    134. String OrderProId=UUIDUtils.getId();
    135. order.setId(OrderProId);
    136. order.setCreateTime(new Date());
    137. order.setUserId(user.getId());
    138. ReceiveAddress receiveAddress = new ReceiveAddress();
    139. receiveAddress.setId(address_id);
    140. order.setReceiveAddress(receiveAddress);
    141. orderService.addOrderOne(order);
    142. ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
    143. for (ProIdAndNum proIdAndNum : proIdAndNums) {
    144. OrderProduct orderProduct=new OrderProduct();
    145. orderProduct.setId(UUIDUtils.getId());
    146. orderProduct.setOrder(order);
    147. Product product=new Product();
    148. product.setId(proIdAndNum.getId());
    149. orderProduct.setProduct(product);
    150. orderProduct.setProductNum(proIdAndNum.getNum());
    151. orderProductService.addOrdProOne(orderProduct);
    152. shopCartProductService.deleteShopCartBy(shopCart.getId(),proIdAndNum.getId());
    153. }
    154. map.put("message","结算成功");
    155. map.put("result",true);
    156. }
    157. }catch (Exception e){
    158. map.put("message","服务器繁忙:"+e.getMessage());
    159. }
    160. ObjectMapper objectMapper = new ObjectMapper();
    161. String val = objectMapper.writeValueAsString(map);
    162. System.out.println(val);
    163. return val;
    164. }
    165. }

    五,项目总结

    在目前电商为王的中国社会上,种类繁多的电子商务网站如雨后春笋般纷纷建立,百花齐鸣的发展态势可以在很大程度上,十分有效的解决原来时代的信息资源闭塞和地域上的限制[1]。网上交易代替了很多传统的线下消费,这种势头发展的越来越火热,而这一却都是伴随着用户的购买能力的提高,和IT信息化产业的发展以及新型互联网技术的应用[2]。

    互联网以及移动互联网的普及应用,也使得消费者的消费路径更加快捷短暂,足不出户可一缆天下,一机在手可买遍全球。所以消费者基本上已经被新的消费模式所吸引,也具备了网络消费的应用水平。而对于广大的电商平台来讲,大而全的电商有之,小而美的电商也有自己的存活空间[3]。而最近这些年比较流行的垂直电商平台的崛起和应用,也让我们的用户可以直接找到自己所喜欢酒水的平台,进行点对点的消费,这就是我们进行酒水电商研究的一个基础背景[6]。

  • 相关阅读:
    Vue项目中组件相互引用,组件不能正常注册,控制台警告处理
    ERP生产管理系统,如何解决机械制造企业生产管理难题?
    java---贪心/Huffman树---合并果子(每日一道算法2022.11.2)
    机器学习笔记 - 图解对象检测任务(1)
    通配符SSL证书价格贵吗
    web大作业 静态网页(地下城与勇士 10页 带视频)
    leetcode363周赛
    Mybatis中传递多个参数的4种方法
    C语言第四章第5节条件运算符和条件表达式学习导案
    wxFormBuilder + Python 工具开发第二章-日记本工具数据连接与展示
  • 原文地址:https://blog.csdn.net/znzbs/article/details/127948165