当前位置:   article > 正文

基于javaweb+mysql的ssm校园外卖配送系统(java+ssm+jsp+js+jq+layui+mysql)_基于javaweb的配送系统

基于javaweb的配送系统

基于javaweb+mysql的ssm校园外卖配送系统(java+ssm+jsp+js+jq+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SSM校园外卖配送系统(java+ssm+jsp+js+jq+layui+mysql)

项目介绍

基于SSM的校园外卖配送系统

角色:管理员、用户、配送员

用户登录系统后,可以对个人中心,订单信息管理,订单取消管理,配送接单管理,取消配送管理,送达通知管理等功能

管理员登录系统后,可以对个人中心,用户管理,配送员管理,美食分类管理,特色美食管理,订单信息管理,订单取消管理,配送接单管理,取消配送管理,送达通知管理,系统管理等功能

配送员登录系统后,可以对个人中心,订单信息管理,配送接单管理,取消配送管理,送达通知管理等功能

环境需要

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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7/8.0等版本均可;

技术栈

后端:SSM(Spring+SpringMVC+Mybatis) 前端:JSP+CSS+JS+JQUERY+Layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目; 3. 将项目中db.xml配置文件中的数据库配置改为自己的配置,然后运行;

if(user.getMember()==1 && odTotal>200) {//当会员为1时,说明不是会员,并且支付的金额大于200

user.setMember(2);

System.out.println("进入方法后"+user.getMember());

user.setUMoney(user.getUMoney()+odTotal);

System.out.println(user.getMember());

tbUserService.updateUserByUser(user);

List<OrderDetail> details = orderDetailService.selectAllOrderByUId(orderDetail.getUId());

for (OrderDetail detail : details){

System.out.println("detail = " + detail.getOdCreateTime());

return "下单成功~";

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
TbUser tbUser = tbUserService.selectUserById(user.getUId());    //保存新数据,避免被原数据覆盖

System.out.println("tbUser = " + tbUser);

user.setUUsername(tbUser.getUUsername());

user.setUPassword(tbUser.getPassword());

user.setUMoney(tbUser.getUMoney());

tbUserService.updateUserByUser(user);

user = tbUserService.selectUserById(user.getUId());

UpdateSession.reloadUserAuthority(session,user);

return "redirect:/myInfo";

@RequestMapping("/shenqinghuiyuan")

public String shenqinghuiyuan(Integer uId, HttpSession session,Model model){

//更新操作

//保存新数据,避免被原数据覆盖
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

return "redirect:/myInfo";

@RequestMapping("/shenqinghuiyuan")

public String shenqinghuiyuan(Integer uId, HttpSession session,Model model){

//更新操作

//保存新数据,避免被原数据覆盖

TbUser tbUser = tbUserService.selectUserById(uId);

if(tbUser.getUMoney()>200){

tbUserService.updateMeber(uId);

model.addAttribute("Member",2);

model.addAttribute("error","申请成功,请重新登录后方可生效");

}else{

model.addAttribute("error","未满足条件");

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

//更新操作

TbUser user = tbUserService.selectUserById(uId);

user.setUUrl(imgPath);

tbUserService.updateUserByUser(user);

user = tbUserService.selectUserById(uId);

UpdateSession.reloadUserAuthority(session,user);

return "redirect:/myInfo";

/*更新我的信息*/

@RequestMapping("/updateMyInfo")

public String updateMyInfo(TbUser user, HttpSession session){

//更新操作

TbUser tbUser = tbUserService.selectUserById(user.getUId());    //保存新数据,避免被原数据覆盖

System.out.println("tbUser = " + tbUser);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

model.addAttribute("orders",orders);

model.addAttribute("allCount",allCount);

model.addAttribute("pendingCount",pendingCount);

model.addAttribute("receivedCount",receivedCount);

model.addAttribute("finishCount",finishCount);

return "menu/orderManage";

@RequestMapping("/myOrder")

public String myOrder(Model model,int uId){

List<OrderDetail> myOrders = orderDetailService.selectAllOrderByUId(uId);

TbUser user = tbUserService.selectUserById(uId);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
model.addAttribute("msg","刚刚:注册成功,赶快登录进行登录吧~");

return "user/login";

/*插入用户数据,返回字符串信息*/

@ResponseBody

@RequestMapping("/insertUserInfo")

public String insertUserInfo(String uUsername, String uPassword, String uRole){

//查询是否存在用户名了

String msg = "未知错误!";

List<TbUser> users = tbUserService.selectUserByName(uUsername);

if(users.size() == 0){

TbUser user = new TbUser();

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

TbUser adminUser = tbUserService.selectUserById(1);

model.addAttribute("total",adminUser.getUMoney());

model.addAttribute("page",page);

model.addAttribute("orders",orders);

model.addAttribute("allCount",allCount);

model.addAttribute("pendingCount",pendingCount);

model.addAttribute("receivedCount",receivedCount);

model.addAttribute("finishCount",finishCount);

return "menu/orderManage";

@RequestMapping("/myOrder")

public String myOrder(Model model,int uId){

List<OrderDetail> myOrders = orderDetailService.selectAllOrderByUId(uId);

TbUser user = tbUserService.selectUserById(uId);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

odDetail += "】";

//赋值

orderDetail.setOdDetail(odDetail);

if(user.getMember()==2){

orderDetail.setOdTotal((int)(odTotal * 0.88));

}else{

orderDetail.setOdTotal(odTotal);

orderDetail.setOdStatus(0);

orderDetail.setOdNo(RandomNo.getRandomNo());

//完成插入

orderDetailService.insertOrder(orderDetail);

//清空购物车 + 更新商品数据

for (ShoppingCart cart : carts){

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

@RequestMapping("/deleteUser/{uId}")

public String deleteUser(@PathVariable("uId")int uId, Model model){

tbUserService.deleteUserById(uId);

model.addAttribute("msg","删除成功!");

return "redirect:/userInfo";

@GetMapping("/myInfo")

public String myInfo(Principal principal,Model model){

String str = principal.getName();

List<TbUser> list = tbUserService.selectAllUser();

for(TbUser tbUser:list) {

if(tbUser.getUUsername().equals(str)){

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
List<TbUser> users = tbUserService.selectAllUser();

for (TbUser temp : users){  //验证成功,直接登录

if(uUsername.equals(temp.getUUsername())){

model.addAttribute("msg","刚刚:注册失败,该用户已存在!");

return "user/login";

TbUser user = new TbUser();

user.setUUsername(uUsername);

user.setUPassword(uPassword);

user.setURole(uRole);

tbUserService.insertUser(user);

model.addAttribute("msg","刚刚:注册成功,赶快登录进行登录吧~");

return "user/login";
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

/*去我的购物车页面*/

@RequestMapping("/shoppingCart")

public String shoppingCart(Model model,int uId){

//查询购物车的商品

List<ShoppingCart> products = shoppingCartService.selectAllByUId(uId);

int total = 0;

for (ShoppingCart cart : products){

total += cart.getScPrice()*cart.getScAmount();

model.addAttribute("products",products);

model.addAttribute("total",total);

TbUser tbUser = tbUserService.selectUserById(uId);

if(tbUser.getMember()==2){

int youhuitotal =(int) (total* 0.88);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

List<OrderDetail> myOrders = orderDetailService.selectAllOrderByUId(uId);

TbUser user = tbUserService.selectUserById(uId);

model.addAttribute("myOrders",myOrders);

model.addAttribute("total",user.getUMoney());

return "user/myOrder";

@ResponseBody

@PostMapping("/toOrder")

public String toOrder(OrderDetail orderDetail){

TbUser user = tbUserService.selectUserById(orderDetail.getUId());

//查询当前用户的所以购物车

List<ShoppingCart> carts = shoppingCartService.selectAllByUId(orderDetail.getUId());

//获取到具体商品
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

//        model.addAttribute("msg","刚刚:该用户不存在,请重新输入!");

//        return "user/login";

//    }

订单详情管理控制层:

@Controller

public class OrderDetailController {

@Resource

OrderDetailServiceImpl orderDetailService;

@Resource

ShoppingCartServiceImpl shoppingCartService;

@Resource

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

model.addAttribute("msg","刚刚:注册成功,赶快登录进行登录吧~");

return "user/login";

/*插入用户数据,返回字符串信息*/

@ResponseBody

@RequestMapping("/insertUserInfo")

public String insertUserInfo(String uUsername, String uPassword, String uRole){

//查询是否存在用户名了

String msg = "未知错误!";

List<TbUser> users = tbUserService.selectUserByName(uUsername);

if(users.size() == 0){

TbUser user = new TbUser();

user.setUUsername(uUsername);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
user.setUUsername(tbUser.getUUsername());

user.setUPassword(tbUser.getPassword());

user.setUMoney(tbUser.getUMoney());

tbUserService.updateUserByUser(user);

user = tbUserService.selectUserById(user.getUId());

UpdateSession.reloadUserAuthority(session,user);

return "redirect:/myInfo";

@RequestMapping("/shenqinghuiyuan")

public String shenqinghuiyuan(Integer uId, HttpSession session,Model model){

//更新操作

//保存新数据,避免被原数据覆盖

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

/*如果 数量== 1,直接删除*/

ShoppingCart one = shoppingCartService.selectOneByMdIdAndUId(mdId, uId);

if (one.getScAmount() == 1 ) {

//删除数据

shoppingCartService.deleteById(one.getScId());

return "redirect:/shoppingCart?uId="+uId;

}else{

//数量-1

one.setScAmount(one.getScAmount()-1);

shoppingCartService.updateProduct(one);

System.out.println("数量-1成功");

return "redirect:/shoppingCart?uId="+uId;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
one.setScAmount(one.getScAmount()+1);

shoppingCartService.updateProduct(one);

System.out.println("数量+1成功");

return "redirect:/shoppingCart?uId="+uId;

@RequestMapping("/shoppingCart-minus")

public String shoppingCartMinus(int uId,int mdId){

/*如果 数量== 1,直接删除*/

ShoppingCart one = shoppingCartService.selectOneByMdIdAndUId(mdId, uId);

if (one.getScAmount() == 1 ) {

//删除数据

shoppingCartService.deleteById(one.getScId());

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

return "user/login";

@PostMapping("/register")

public String register(String uUsername, String uPassword, String uRole,Model model){

List<TbUser> users = tbUserService.selectAllUser();

for (TbUser temp : users){  //验证成功,直接登录

if(uUsername.equals(temp.getUUsername())){

model.addAttribute("msg","刚刚:注册失败,该用户已存在!");

return "user/login";

TbUser user = new TbUser();

user.setUUsername(uUsername);

user.setUPassword(uPassword);

user.setURole(uRole);

tbUserService.insertUser(user);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

请添加图片描述

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/155556
推荐阅读
相关标签
  

闽ICP备14008679号