• Java项目:SSM二手汽车交易商城网站管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    本项目共分为管理员、用户、店员三种角色:
    管理员角色包含以下功能:
    管理员登录,在售车辆管理,品牌管理,品牌分类管理,推荐车辆,订单管理,销量统计等功能。

    用户角色包含以下功能:
    用户登录,用户角色首页,购物商城,查看购物车,订单管理,个人信息修改,关于我们等功能。

    店员角色包含以下功能:

    添加删除修改二手车,订单管理,销量统计,个人信息修改等功能。

    环境需要

    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/8.0版本均可;

    6.是否Maven项目:否;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+JavaScript+jQuery+BootStrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

    3. 将项目中DB.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入localhost:8080/ 登录

    运行截图

    用户角色

     

     

     

     

     

    管理员角色

     

     

     

     

     

     

     

     相关代码

    订单管理

    1. package com.carSystem.action.user;
    2. import java.util.List;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpSession;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import com.carSystem.entity.Brand;
    9. import com.carSystem.entity.Car;
    10. import com.carSystem.entity.Login;
    11. import com.carSystem.entity.Order;
    12. import com.carSystem.entity.Person;
    13. import com.carSystem.entity.ShopCart;
    14. import com.carSystem.service.BrandService;
    15. import com.carSystem.service.CarService;
    16. import com.carSystem.service.OrderService;
    17. import com.carSystem.service.PersonService;
    18. import com.carSystem.service.ShopCartService;
    19. @Controller
    20. @RequestMapping("/orderManage")
    21. public class OrderManageAction {
    22. @Autowired
    23. private OrderService orderService;
    24. @Autowired
    25. private PersonService personService;
    26. @Autowired
    27. private CarService carService;
    28. @Autowired
    29. private ShopCartService shopCartService;
    30. @Autowired
    31. private BrandService brandService;
    32. //提交订单页面
    33. @RequestMapping("/addOrderInit")
    34. public String addOrderInit(ShopCart shopCart, Map map,HttpSession session){
    35. Login login = (Login) session.getAttribute("loginSession");
    36. if(login == null){
    37. return "redirect:/loginInitAction";
    38. }else if( !login.getLogin_permission().equals("user")){
    39. return "redirect:/loginInitAction";
    40. }
    41. Car car = carService.queryOnlineCarById(shopCart.getShopCart_car_id()).get(0);
    42. Person preson = personService.queryPersonById(shopCart.getShopCart_person_id());
    43. map.put("personInfo", preson);
    44. map.put("carInfo", car);
    45. //从购物车付款,成功后删除购物车中的记录!!!
    46. if(shopCart.getShopCart_id() != null){
    47. shopCartService.deleteById(shopCart.getShopCart_id());
    48. }
    49. return "user/order/order_add";
    50. }
    51. //下单(生成订单,未支付,跳转到支付页面)
    52. @RequestMapping("/addOrder")
    53. public String addOrder(Order order, Map map){
    54. String id = orderService.addOrder(order);
    55. map.put("order_id", id);
    56. return "user/order/order_pay";
    57. }
    58. //跳转到支付页面(用于待付款列表的使用)
    59. @RequestMapping("/orderToPay")
    60. public String orderToPay(String order_id, Map map){
    61. map.put("order_id", order_id);
    62. return "user/order/order_pay";
    63. }
    64. //用户取消订单(删除!)
    65. @RequestMapping("/deleteOrder")
    66. public String deleteOrder(String order_id){
    67. orderService.orderDeleteById(order_id);
    68. return "redirect:/orderManage/notPayOrder";
    69. }
    70. //支付操作,成功后跳转到代发货页面
    71. @RequestMapping("/payOrder")
    72. public String payOrder(String order_id){
    73. orderService.payOrder(order_id);
    74. return "redirect:/orderManage/notSendOrder";
    75. }
    76. //待付款页面
    77. @RequestMapping("/notPayOrder")
    78. public String notPayOrder(Map map, HttpSession session){
    79. Login login = (Login) session.getAttribute("loginSession");
    80. if(login == null){
    81. return "redirect:/loginInitAction";
    82. }else if( !login.getLogin_permission().equals("user")){
    83. return "redirect:/loginInitAction";
    84. }
    85. List orderList = orderService.userQueryAllNotPayOrder( login.getLogin_id() );
    86. map.put("notPayOrder", orderList);
    87. System.out.println("=================代付款长度:" + orderList.size());
    88. return "user/order/order_notPay";
    89. }
    90. //已经付款未发货订单
    91. @RequestMapping("/notSendOrder")
    92. public String notSendOrder(Map map, HttpSession session){
    93. Login login = (Login) session.getAttribute("loginSession");
    94. if(login == null){
    95. return "redirect:/loginInitAction";
    96. }else if( !login.getLogin_permission().equals("user")){
    97. return "redirect:/loginInitAction";
    98. }
    99. List orderList = orderService.userQueryAllPayOrder(login.getLogin_id());
    100. map.put("notSendOrder", orderList);
    101. return "user/order/order_notSend";
    102. }
    103. //已经发货未收货订单
    104. @RequestMapping("/notReceiveOrder")
    105. public String notReceiveOrder(Map map, HttpSession session){
    106. Login login = (Login) session.getAttribute("loginSession");
    107. if(login == null){
    108. return "redirect:/loginInitAction";
    109. }else if( !login.getLogin_permission().equals("user")){
    110. return "redirect:/loginInitAction";
    111. }
    112. List orderList = orderService.userQueryAllSendOrder(login.getLogin_id());
    113. map.put("notReceiveOrder", orderList);
    114. return "user/order/order_notReceive";
    115. }
    116. //历史订单
    117. @RequestMapping("/historyOrder")
    118. public String historyOrder(Map map, HttpSession session){
    119. Login login = (Login) session.getAttribute("loginSession");
    120. if(login == null){
    121. return "redirect:/loginInitAction";
    122. }else if( !login.getLogin_permission().equals("user")){
    123. return "redirect:/loginInitAction";
    124. }
    125. List orderList = orderService.userQueryAllReceiveOrder(login.getLogin_id());
    126. map.put("historyOrder", orderList);
    127. return "user/order/order_history";
    128. }
    129. //订单详情
    130. @RequestMapping("/orderDetails")
    131. public String orderDetails(Map map, String order_id){
    132. Order order = orderService.queryOrderById(order_id).get(0);
    133. map.put("detailsOrder", order);
    134. return "user/order/order_details";
    135. }
    136. //将已发货订单 收货(并且在brand表中,品牌对应的销售量+1,价钱也+)
    137. @RequestMapping("/orderToReceive")
    138. public String orderToReceive(String order_id){
    139. orderService.orderToReceive(order_id);
    140. Order order = orderService.queryOrderById(order_id).get(0);
    141. Car car = carService.queryOnlineCarById(order.getOrder_car_id()).get(0);
    142. Brand brand = brandService.queryBrandById(car.getCar_brand_id());
    143. brandService.addBrandSaleNum(brand, car.getCar_price_new());
    144. return "redirect:/orderManage/notReceiveOrder";
    145. }
    146. //用户根据id删除历史订单
    147. @RequestMapping("/orderDeleteHistory")
    148. public String orderDelete(String order_id){
    149. orderService.orderDeleteHistory(order_id);
    150. return "redirect:/orderManage/historyOrder";
    151. }
    152. }

    商店模块

    1. package com.carSystem.action.user;
    2. import java.util.List;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpSession;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import com.carSystem.entity.Car;
    9. import com.carSystem.entity.Page;
    10. import com.carSystem.entity.ShopCart;
    11. import com.carSystem.entity.ShopQuery;
    12. import com.carSystem.service.BrandService;
    13. import com.carSystem.service.CarService;
    14. import com.carSystem.service.PageService;
    15. import com.carSystem.service.PriceService;
    16. import com.carSystem.service.ShopCartService;
    17. @Controller
    18. @RequestMapping("/userShop")
    19. public class ShopAction {
    20. @Autowired
    21. private CarService carService;
    22. @Autowired
    23. private BrandService brandService;
    24. @Autowired
    25. private PriceService priceService;
    26. @Autowired
    27. private ShopCartService shopCartService;
    28. @Autowired
    29. private PageService pageService;
    30. //导航栏的搜索框
    31. @RequestMapping("/navQueryIdOrName")
    32. public String navQueryIdOrName(Map map, String car_name){
    33. List onlineCarList = carService.queryOnlineCarByIdOrName(car_name);
    34. map.put("onlineCarList", onlineCarList);
    35. map.put("brandList", brandService.queryBeQueryBrand());
    36. map.put("priceList",priceService.getAllPrice());
    37. map.put("recommandList", carService.queryAllRecommandCar());
    38. return "user/shop/shopIndex";
    39. }
    40. //初始化商店界面
    41. @RequestMapping("/shopInit")
    42. public String shopInit(Map map, String currentpage){
    43. List onlineCarList = carService.queryAllOnlineCar();
    44. Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
    45. int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
    46. onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
    47. map.put("page", page);
    48. map.put("onlineCarList", onlineCarList);
    49. map.put("brandList", brandService.queryBeQueryBrand());
    50. map.put("priceList",priceService.getAllPrice());
    51. map.put("recommandList", carService.queryAllRecommandCar());
    52. return "user/shop/shopIndex";
    53. }
    54. //多添加查询商品
    55. @RequestMapping("/queryCarByClassifys")
    56. public String queryCarByClassifys(String brand_id, String price_low, String price_high, String time_start, String time_end, Map map){
    57. if(time_start == null || time_start.equals("不限制")) time_start = "1000-01-01 00:00:01";
    58. if(time_end == null || time_end.equals("不限制")) time_end = "5000-01-01 00:00:01";
    59. ShopQuery shopQuery = new ShopQuery(Integer.parseInt(price_low), Integer.parseInt(price_high), brand_id, time_start, time_end);
    60. List onlineCarList = carService.queryCarByClassifys(shopQuery);
    61. map.put("onlineCarList", onlineCarList);
    62. map.put("brandList", brandService.queryBeQueryBrand());
    63. map.put("priceList",priceService.getAllPrice());
    64. map.put("recommandList", carService.queryAllRecommandCar());
    65. if(!brand_id.equals("all")){
    66. String name = brandService.queryBrandById(brand_id).getBrand_name();
    67. map.put("queryBrand_name", name);
    68. map.put("queryBrand_id", brand_id);
    69. }
    70. if( !price_low.equals("-100000")){
    71. map.put("queryPrice_low", price_low);
    72. }
    73. if( !price_high.equals("1000000000")){
    74. map.put("queryPrice_high", price_high);
    75. }
    76. if( ! time_start.equals("1000-01-01 00:00:01")){
    77. map.put("queryTimeStart", time_start);
    78. }
    79. if( ! time_end.equals("5000-01-01 00:00:01")){
    80. map.put("queryTimeEnd", time_end);
    81. }
    82. return "user/shop/shopIndex";
    83. }
    84. //添加购物车信息
    85. @RequestMapping("/addShopCart")
    86. public String addShopCart(ShopCart shopCart, HttpSession session){
    87. if(session.getAttribute("loginSession") == null){
    88. return "redirect:/loginInitAction";
    89. }
    90. shopCartService.addShopCart(shopCart);
    91. return "redirect:/userShop/shopInit";
    92. }
    93. }

    用户页面

    1. package com.carSystem.action.user;
    2. import java.io.IOException;
    3. import java.io.UnsupportedEncodingException;
    4. import java.util.Map;
    5. import javax.servlet.http.HttpServletRequest;
    6. import javax.servlet.http.HttpServletResponse;
    7. import javax.servlet.http.HttpSession;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.web.bind.annotation.RequestMapping;
    11. import com.carSystem.entity.Login;
    12. import com.carSystem.entity.Person;
    13. import com.carSystem.service.LoginService;
    14. import com.carSystem.service.PersonService;
    15. import com.google.gson.Gson;
    16. @Controller
    17. @RequestMapping("/user")
    18. public class UserInfoAction {
    19. @Autowired
    20. private PersonService personService;
    21. @Autowired
    22. private LoginService loginSevice;
    23. //初始化用户更新页面
    24. @RequestMapping("/updateInfoInit")
    25. public String updateInfoInit(HttpSession session, Map map){
    26. Login login = (Login) session.getAttribute("loginSession");
    27. if(login == null){
    28. return "redirect:/loginInitAction";
    29. }else if( !login.getLogin_permission().equals("user")){
    30. return "redirect:/loginInitAction";
    31. }
    32. Person person = personService.queryPersonById(login.getLogin_id());
    33. map.put("updatePersonInfo", person);
    34. return "user/userInfo/updateInfo";
    35. }
    36. //保存用户修改后的个人信息
    37. @RequestMapping("/saveUpdatePersonInfo")
    38. public String saveUpdatePersonInfo(Person person, Map map){
    39. personService.saveUpdatePersonInfo(person);
    40. return "redirect:/user/updateInfoInit";
    41. }
    42. //利用ajax确定修改后的电话号码没有被注册
    43. @RequestMapping("/ajaxTextTelExist")
    44. public void ajaxGetStu_name(HttpServletRequest request, HttpServletResponse response, String person_tel) throws UnsupportedEncodingException{
    45. response.setCharacterEncoding("UTF-8");
    46. request.setCharacterEncoding("UTF-8");
    47. boolean boolTel = personService.textTelExist(person_tel);
    48. String json = new Gson().toJson(boolTel);
    49. try {
    50. response.getWriter().print(json);
    51. } catch (IOException e) {
    52. e.printStackTrace();
    53. }
    54. }
    55. //修改用户的密码
    56. @RequestMapping("/changePassword")
    57. public String changePassword(String oldPwd, String newPwd, Map map, HttpSession session){
    58. Login login = (Login) session.getAttribute("loginSession");
    59. if(login == null){
    60. return "redirect:/loginInitAction";
    61. }else if( !login.getLogin_permission().equals("user")){
    62. return "redirect:/loginInitAction";
    63. }
    64. if( ! login.getLogin_password().equals(oldPwd)){ //输入密码错误
    65. map.put("changePwdError", "您输入的原密码错误");
    66. return "user/userInfo/changePassword";
    67. }
    68. login.setLogin_password(newPwd);
    69. loginSevice.saveLogin(login);
    70. map.put("changePwdSuccess", "恭喜您,修改密码成功");
    71. return "user/userInfo/changePassword";
    72. }
    73. }

    如果也想学习本系统,下面领取。关注并回复:152ssm 

  • 相关阅读:
    【数据密集型系统设计】软件系统的可靠性、可伸缩性、可维护性
    【小型网站测试】使用python脚本来控制docker容器的编排
    Java学习笔记4.1.2 字符串 - StringBuffer类与StringBuilder类
    JVM性能监控和调优
    1668、最大重复子字符串(暴力+KMP+strstr)
    spfa判断负环的应用
    【JVM】创建对象的流程详解
    qsort函数使用方法总结
    CSS jQuery 自动充满剩余高度
    springboot 自动注入servlet原理
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126474888