博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
废品回收系统是由SpringBoot+Mybatis开发的,分为前台和后台,前台进行下单,后台处理。
后台功能如下:
前台功能如下:
注册登录
上门回收预约
回收订单
环保商城
我的订单
购物车
个人中心
下单
付款
确认收货
用idea打开项目
在idea中配置jdk环境
配置maven环境并下载依赖
新建数据库,导入数据库文件
在application.yml文件中将数据库账号密码改成自己本地的
启动运行
OrderManager
package com.soft.action.business;
import com.soft.model.*;
import com.soft.service.*;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
/**
* @program: garbgeSpringboot
* @description: 商户订单管理
**/
@Controller
@RequestMapping("business/orderManager")
public class OrderManager {
@Autowired
private GarbageOrderService garbageOrderService;
@Autowired
private AddressService addressService;
@Autowired
private GarbageTypeService garbageTypeService;
@Autowired
private SalesService salesService;
@Autowired
private UserService userService;
// 跳转到废品回收订单管理界面
@RequestMapping("/toOrderManager")
public String toGarbageOrderManager(Map<String, Object> map) {
List<GarbageOrder> garbageOrderList = garbageOrderService.getAllWaitGet();
map.put("garbageOrderList", garbageOrderList);
List<GarbageType> garbageTypeList = garbageTypeService.getAll();
List<Address> addresses = addressService.getAll();
map.put("garbageOrderList", garbageOrderList);
map.put("addresses", addresses);
map.put("garbageTypeList", garbageTypeList);
return "business/garbageOrderManager";
}
// 跳转到废品回收订单管理界面
@RequestMapping("/toAssigenSaler")
public String toAssigenSaler(Map<String, Object> map, HttpSession session,@RequestParam("orderId")Integer orderId) {
Business business = (Business) session.getAttribute("admin");
Integer businessId = business.getId();
List<Sales> salesList = salesService.getAll(businessId);
map.put("salesList", salesList);
map.put("orderId", orderId);
return "business/saleList";
}
@RequestMapping(value = "/getGarbageOrder", method = RequestMethod.GET)
public void getGarbageOrder(Map<String, Object> map, HttpSession session, HttpServletResponse response, @RequestParam("id") Integer id) throws IOException {
PrintWriter out = response.getWriter();
List<GarbageOrder> garbageOrderList = garbageOrderService.getAllWaitGet();
Business business = (Business) session.getAttribute("admin");
GarbageOrder garbageOrder = new GarbageOrder();
garbageOrder.setId(id);
garbageOrder.setStatus(2);
garbageOrder.setBusinessId(business.getId());
int result = garbageOrderService.updateSelective(garbageOrder);
map.put("garbageOrderList", garbageOrderList);
List<GarbageType> garbageTypeList = garbageTypeService.getAll();
List<Address> addresses = addressService.getAll();
map.put("garbageOrderList", garbageOrderList);
map.put("addresses", addresses);
map.put("garbageTypeList", garbageTypeList);
// 添加废品上门回收订单
if (result == 1) {
System.out.println("抢单成功!");
out.write("");
} else {
System.out.println("抢约失败!");
out.write("");
}
}
/**
* 委派回收员
*/
@RequestMapping(value = "/assigneSaler/{orderId}", method = RequestMethod.GET)
public void assigneSaler(Map<String, Object> map, HttpSession session, HttpServletResponse response,
@PathVariable("orderId") Integer orderId,
@RequestParam("userId") Integer userId) throws IOException {
PrintWriter out = response.getWriter();
Business business = (Business) session.getAttribute("admin");
GarbageOrder garbageOrder = new GarbageOrder();
garbageOrder.setId(orderId);
garbageOrder.setSaleId(userId);
garbageOrder.setStatus(3);
int result = garbageOrderService.updateSelective(garbageOrder);
List<Sales> salesList = salesService.getAll(orderId);
map.put("salesList", salesList);
// 添加废品上门回收订单
if (result == 1) {
System.out.println("委派收货员成功!");
out.write("");
} else {
System.out.println("委派收货员失败!");
out.write("");
}
}
}
SalesManagerAction
package com.soft.action.business;
import com.soft.model.Business;
import com.soft.model.Sales;
import com.soft.model.User;
import com.soft.service.AddressService;
import com.soft.service.GarbageTypeService;
import com.soft.service.SalesService;
import com.soft.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description: 商户管理回收员控制器
*/
@Controller
@RequestMapping("/business/salesManager")
public class SalesManagerAction {
@Autowired
private SalesService userService;
// 跳转到会员管理界面
@RequestMapping("/toUserManager")
public String toUserManager(Map<String, Object> map, HttpSession session) {
Business business = (Business)session.getAttribute("admin");
List<Sales> users = userService.getAll(business.getId());
map.put("users", users);
return "business/salePersonManager";
}
// 查询
@RequestMapping("/search")
public String search(String username, Map<String, Object> map, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
if (username != null && !"".equals(username)) {
Sales user = userService.getByUserName(username);
if (user == null) {
System.out.println("用户不存在!");
out.write(
"");
} else {
List<Sales> users = new ArrayList<Sales>();
users.add(user);
map.put("users", users);
return "business/salePersonManager";
}
} else {
return "redirect:toUserManager";
}
return "redirect:toUserManager";
}
// 修改
@RequestMapping("/update")
public String update(User user) {
if (user != null) {
// 这个是更新入库的user
Sales newUser = userService.getById(user.getId());
if (user.getUsername() != null && !"".equals(user.getUsername())) {
newUser.setUsername(user.getUsername());
System.out.println("修改了用户名");
}
if (user.getPassword() != null && !"".equals(user.getPassword())) {
newUser.setPassword(user.getPassword());
System.out.println("修改了密码");
}
if (user.getMoney() != null) {
//newUser.setMoney(user.getMoney());
System.out.println("修改了积分");
}
userService.update(newUser);
}
return "redirect:toUserManager";
}
@RequestMapping("/delete")
public String delete(Integer id) {
userService.delete(id);
return "redirect:toUserManager";
}
}
大家点赞、收藏、关注、评论啦 、点开下方卡片关注后回复 104