作者主页:夜未央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/ 登录
用户角色
- package com.carSystem.action.user;
-
- import java.util.List;
- import java.util.Map;
-
- 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 com.carSystem.entity.Brand;
- import com.carSystem.entity.Car;
- import com.carSystem.entity.Login;
- import com.carSystem.entity.Order;
- import com.carSystem.entity.Person;
- import com.carSystem.entity.ShopCart;
- import com.carSystem.service.BrandService;
- import com.carSystem.service.CarService;
- import com.carSystem.service.OrderService;
- import com.carSystem.service.PersonService;
- import com.carSystem.service.ShopCartService;
-
- @Controller
- @RequestMapping("/orderManage")
- public class OrderManageAction {
-
-
- @Autowired
- private OrderService orderService;
-
- @Autowired
- private PersonService personService;
-
- @Autowired
- private CarService carService;
-
- @Autowired
- private ShopCartService shopCartService;
-
- @Autowired
- private BrandService brandService;
-
- //提交订单页面
- @RequestMapping("/addOrderInit")
- public String addOrderInit(ShopCart shopCart, Map
map,HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
-
- Car car = carService.queryOnlineCarById(shopCart.getShopCart_car_id()).get(0);
- Person preson = personService.queryPersonById(shopCart.getShopCart_person_id());
- map.put("personInfo", preson);
- map.put("carInfo", car);
-
- //从购物车付款,成功后删除购物车中的记录!!!
- if(shopCart.getShopCart_id() != null){
- shopCartService.deleteById(shopCart.getShopCart_id());
- }
-
- return "user/order/order_add";
- }
-
- //下单(生成订单,未支付,跳转到支付页面)
- @RequestMapping("/addOrder")
- public String addOrder(Order order, Map
map) { - String id = orderService.addOrder(order);
- map.put("order_id", id);
- return "user/order/order_pay";
- }
-
- //跳转到支付页面(用于待付款列表的使用)
- @RequestMapping("/orderToPay")
- public String orderToPay(String order_id, Map
map) { - map.put("order_id", order_id);
- return "user/order/order_pay";
- }
-
- //用户取消订单(删除!)
- @RequestMapping("/deleteOrder")
- public String deleteOrder(String order_id){
- orderService.orderDeleteById(order_id);
- return "redirect:/orderManage/notPayOrder";
- }
-
-
- //支付操作,成功后跳转到代发货页面
- @RequestMapping("/payOrder")
- public String payOrder(String order_id){
- orderService.payOrder(order_id);
- return "redirect:/orderManage/notSendOrder";
- }
-
- //待付款页面
- @RequestMapping("/notPayOrder")
- public String notPayOrder(Map
map, HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
- List
orderList = orderService.userQueryAllNotPayOrder( login.getLogin_id() ); - map.put("notPayOrder", orderList);
- System.out.println("=================代付款长度:" + orderList.size());
- return "user/order/order_notPay";
- }
-
- //已经付款未发货订单
- @RequestMapping("/notSendOrder")
- public String notSendOrder(Map
map, HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
- List
orderList = orderService.userQueryAllPayOrder(login.getLogin_id()); - map.put("notSendOrder", orderList);
- return "user/order/order_notSend";
- }
-
- //已经发货未收货订单
- @RequestMapping("/notReceiveOrder")
- public String notReceiveOrder(Map
map, HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
- List
orderList = orderService.userQueryAllSendOrder(login.getLogin_id()); - map.put("notReceiveOrder", orderList);
- return "user/order/order_notReceive";
- }
-
- //历史订单
- @RequestMapping("/historyOrder")
- public String historyOrder(Map
map, HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
- List
orderList = orderService.userQueryAllReceiveOrder(login.getLogin_id()); - map.put("historyOrder", orderList);
- return "user/order/order_history";
- }
-
- //订单详情
- @RequestMapping("/orderDetails")
- public String orderDetails(Map
map, String order_id) { - Order order = orderService.queryOrderById(order_id).get(0);
- map.put("detailsOrder", order);
- return "user/order/order_details";
- }
-
- //将已发货订单 收货(并且在brand表中,品牌对应的销售量+1,价钱也+)
- @RequestMapping("/orderToReceive")
- public String orderToReceive(String order_id){
- orderService.orderToReceive(order_id);
-
- Order order = orderService.queryOrderById(order_id).get(0);
- Car car = carService.queryOnlineCarById(order.getOrder_car_id()).get(0);
- Brand brand = brandService.queryBrandById(car.getCar_brand_id());
- brandService.addBrandSaleNum(brand, car.getCar_price_new());
-
- return "redirect:/orderManage/notReceiveOrder";
- }
-
- //用户根据id删除历史订单
- @RequestMapping("/orderDeleteHistory")
- public String orderDelete(String order_id){
- orderService.orderDeleteHistory(order_id);
- return "redirect:/orderManage/historyOrder";
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- package com.carSystem.action.user;
-
- import java.util.List;
- import java.util.Map;
-
- 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 com.carSystem.entity.Car;
- import com.carSystem.entity.Page;
- import com.carSystem.entity.ShopCart;
- import com.carSystem.entity.ShopQuery;
- import com.carSystem.service.BrandService;
- import com.carSystem.service.CarService;
- import com.carSystem.service.PageService;
- import com.carSystem.service.PriceService;
- import com.carSystem.service.ShopCartService;
-
- @Controller
- @RequestMapping("/userShop")
- public class ShopAction {
-
- @Autowired
- private CarService carService;
-
- @Autowired
- private BrandService brandService;
-
- @Autowired
- private PriceService priceService;
-
- @Autowired
- private ShopCartService shopCartService;
-
- @Autowired
- private PageService pageService;
-
- //导航栏的搜索框
- @RequestMapping("/navQueryIdOrName")
- public String navQueryIdOrName(Map
map, String car_name) { - List
onlineCarList = carService.queryOnlineCarByIdOrName(car_name); - map.put("onlineCarList", onlineCarList);
- map.put("brandList", brandService.queryBeQueryBrand());
- map.put("priceList",priceService.getAllPrice());
- map.put("recommandList", carService.queryAllRecommandCar());
- return "user/shop/shopIndex";
- }
-
- //初始化商店界面
- @RequestMapping("/shopInit")
- public String shopInit(Map
map, String currentpage) { - List
onlineCarList = carService.queryAllOnlineCar(); -
- Page page = pageService.pageToCar(onlineCarList.size(), currentpage);
- int subEnd = (page.getCurrentpage()-1)*page.getSize() + page.getSize() > onlineCarList.size() ? onlineCarList.size() : (page.getCurrentpage()-1)*page.getSize() + page.getSize();
- onlineCarList = onlineCarList.subList( (page.getCurrentpage()-1)*page.getSize() , subEnd);
-
- map.put("page", page);
- map.put("onlineCarList", onlineCarList);
- map.put("brandList", brandService.queryBeQueryBrand());
- map.put("priceList",priceService.getAllPrice());
- map.put("recommandList", carService.queryAllRecommandCar());
-
- return "user/shop/shopIndex";
- }
-
- //多添加查询商品
- @RequestMapping("/queryCarByClassifys")
- public String queryCarByClassifys(String brand_id, String price_low, String price_high, String time_start, String time_end, Map
map) { - if(time_start == null || time_start.equals("不限制")) time_start = "1000-01-01 00:00:01";
- if(time_end == null || time_end.equals("不限制")) time_end = "5000-01-01 00:00:01";
-
- ShopQuery shopQuery = new ShopQuery(Integer.parseInt(price_low), Integer.parseInt(price_high), brand_id, time_start, time_end);
- List
onlineCarList = carService.queryCarByClassifys(shopQuery); -
- map.put("onlineCarList", onlineCarList);
- map.put("brandList", brandService.queryBeQueryBrand());
- map.put("priceList",priceService.getAllPrice());
- map.put("recommandList", carService.queryAllRecommandCar());
-
- if(!brand_id.equals("all")){
- String name = brandService.queryBrandById(brand_id).getBrand_name();
- map.put("queryBrand_name", name);
- map.put("queryBrand_id", brand_id);
- }
- if( !price_low.equals("-100000")){
- map.put("queryPrice_low", price_low);
- }
- if( !price_high.equals("1000000000")){
- map.put("queryPrice_high", price_high);
- }
- if( ! time_start.equals("1000-01-01 00:00:01")){
- map.put("queryTimeStart", time_start);
- }
- if( ! time_end.equals("5000-01-01 00:00:01")){
- map.put("queryTimeEnd", time_end);
- }
-
- return "user/shop/shopIndex";
- }
-
- //添加购物车信息
- @RequestMapping("/addShopCart")
- public String addShopCart(ShopCart shopCart, HttpSession session){
- if(session.getAttribute("loginSession") == null){
- return "redirect:/loginInitAction";
- }
- shopCartService.addShopCart(shopCart);
- return "redirect:/userShop/shopInit";
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- package com.carSystem.action.user;
-
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.util.Map;
-
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- 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 com.carSystem.entity.Login;
- import com.carSystem.entity.Person;
- import com.carSystem.service.LoginService;
- import com.carSystem.service.PersonService;
- import com.google.gson.Gson;
-
- @Controller
- @RequestMapping("/user")
- public class UserInfoAction {
-
- @Autowired
- private PersonService personService;
-
- @Autowired
- private LoginService loginSevice;
-
-
- //初始化用户更新页面
- @RequestMapping("/updateInfoInit")
- public String updateInfoInit(HttpSession session, Map
map) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
- Person person = personService.queryPersonById(login.getLogin_id());
- map.put("updatePersonInfo", person);
- return "user/userInfo/updateInfo";
- }
-
- //保存用户修改后的个人信息
- @RequestMapping("/saveUpdatePersonInfo")
- public String saveUpdatePersonInfo(Person person, Map
map) { - personService.saveUpdatePersonInfo(person);
- return "redirect:/user/updateInfoInit";
- }
-
- //利用ajax确定修改后的电话号码没有被注册
- @RequestMapping("/ajaxTextTelExist")
- public void ajaxGetStu_name(HttpServletRequest request, HttpServletResponse response, String person_tel) throws UnsupportedEncodingException{
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
-
- boolean boolTel = personService.textTelExist(person_tel);
- String json = new Gson().toJson(boolTel);
- try {
- response.getWriter().print(json);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- //修改用户的密码
- @RequestMapping("/changePassword")
- public String changePassword(String oldPwd, String newPwd, Map
map, HttpSession session) { - Login login = (Login) session.getAttribute("loginSession");
- if(login == null){
- return "redirect:/loginInitAction";
- }else if( !login.getLogin_permission().equals("user")){
- return "redirect:/loginInitAction";
- }
-
- if( ! login.getLogin_password().equals(oldPwd)){ //输入密码错误
- map.put("changePwdError", "您输入的原密码错误");
- return "user/userInfo/changePassword";
- }
-
- login.setLogin_password(newPwd);
- loginSevice.saveLogin(login);
- map.put("changePwdSuccess", "恭喜您,修改密码成功");
- return "user/userInfo/changePassword";
- }
- }
如果也想学习本系统,下面领取。关注并回复:152ssm