赞
踩
基于javaweb+mysql的ssm+maven快递代拿系统(java+ssm+bootstrap+shiro+mysql+html)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven快递代拿系统(java+ssm+bootstrap+shiro+mysql+html)
使用技术
采用 Spring + SpringMVC + MyBatisPlus,连接池采用 Druid,安全框架使用 Shiro,前端采用 Bootstrap + layer 实现。
支付采用支付宝沙箱环境,支付APP下载链接,点击这里。
支付账号:uceskd4358 sandbox.com 登录密码、支付密码:111111
注意:
请务必使用以上链接下载沙箱支付宝
,也务必使用以上账号登录。不要使用真实支付宝APP和真实支付宝账号登录。
运行环境
集成开发环境:IntelliJ IDEA
项目构建工具:Maven - 数据库:MYSQL 5.7+ - JDK版本:1.8 - Tomcat版本:Tomcat8
(1)首先请创建数据库: shell CREATE DATABASE IF NOT EXISTS `express-ssm` /*!40100 DEFAULT CHARACTER SET utf8 */
(2)导入项目 sql 文件夹下的 express-ssm.sql
文件。 (3)编辑项目中 src/main/resources/cnf/mysql.properties
文件,修改数据库连接信息: jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/express-ssm?useUnicode=true&useSSL=false&characterEncoding=utf-8 jdbc.username=root # MYSQL 用户名 jdbc.password=root # MYSQL 密码
运行
项目运行时,在tomcat中配置项目运行路径为http://localhost:8080/ 注意:后面不要带项目名,否则会运行出错;
默认账户
注:以下为本项目默认存在的用户名密码,请将本仓库项目在本地运行后使用以下密码登录。
| 权限 | 用户名 | 密码 | | 管理员 | admin | 123 | | 配送员 | 李四 | 123 | | 用户名 | 小红 | 123 |
//商户订单号 String orderId = params.get("out_trade_no"); //支付宝交易号 String tradeNo = params.get("trade_no"); //交易状态 String tradeStatus = params.get("trade_status"); switch (tradeStatus) { case "WAIT_BUYER_PAY": expressPaymentService.updateStatus(orderId, PaymentStatusEnum.WAIT_BUYER_PAY.getIndex()); break; /* * 关闭订单 * (1)订单已创建,但用户未付款,调用关闭交易接口 * (2)付款成功后,订单金额已全部退款【如果没有全部退完,仍是TRADE_SUCCESS状态】 */ case "TRADE_CLOSED": expressPaymentService.updateStatus(orderId, PaymentStatusEnum.TRADE_CLOSED.getIndex()); break; /* * 订单完成 * (1)退款日期超过可退款期限后 */ case "TRADE_FINISHED" : expressPaymentService.updateStatus(orderId, PaymentStatusEnum.TRADE_FINISHED.getIndex()); break; /* * 订单Success * (1)用户付款成功 */ case "TRADE_SUCCESS" : expressPaymentService.updateStatus(orderId, PaymentStatusEnum.TRADE_SUCCESS.getIndex(), tradeNo); break; default:break; } response.getWriter().write("success"); }else { response.getWriter().write("fail"); } } catch (Exception e){ e.printStackTrace(); }
/** */ @RestController @RequestMapping("/staff/express") public class StaffExpressController { @Autowired private ExpressService expressService; @Autowired private ExpressPaymentService expressPaymentService; @Autowired private GlobalFunction globalFunction; /** * 获取订单的状态列表 */ @GetMapping("/status") public Msg listExpressStatus() { List<Map<String,Object>> result = new ArrayList<>(); for(ExpressStatusEnum enums :ExpressStatusEnum.values()) { Map<String,Object> map = new HashMap<>(); map.put("id",enums.getIndex()); map.put("name",enums.getName()); result.add(map);
try { usw.setName(globalFunction.iso8859ToUtf8(usw.getName())); usw.setAddress(globalFunction.iso8859ToUtf8(usw.getAddress())); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // 得到筛选条件 EntityWrapper<SysUser> userWrapper = globalFunction.getSysUserWrapper(usw); // 不显示admin角色 userWrapper.ne("role_id", RoleEnum.ADMIN.getIndex()); Page<SysUser> selectPage = userService.selectPage(new Page<>(page, rows), userWrapper); List<SysUserDto> list = globalFunction.sysUser2dto(selectPage.getRecords()); Map<String,Object> map = new HashMap<>(); map.put("total", selectPage.getTotal()); map.put("rows", list); return map; } /** * 更新用户信息 */ @PostMapping("") public Msg update(SysUser user) { userService.updateById(user); return Msg.ok(); } /** * 新增用户信息 */ @PostMapping("/insert") public Msg insert(SysUser user) { UUID uuid = UUID.randomUUID(); user.setId(uuid.toString()); user.setRoleId(1); user.setStatus(0); user.setPassword(PasswordUtils.entryptPassword("123456")); //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 user.setCreateDate(new Date());// new Date()为获取当前系统时间 user.setUpdateDate(new Date()); userService.insert(user); return Msg.ok(); } /**
* 彻底删除订单 */ @PostMapping("/clean") public Msg cleanById(String[] ids) { for(String id : ids) { expressService.deleteById(id); } return Msg.ok(); } } /** */ @RestController @RequestMapping("/staff/express") public class StaffExpressController { @Autowired private ExpressService expressService; @Autowired private ExpressPaymentService expressPaymentService; @Autowired private GlobalFunction globalFunction; /** * 获取订单的状态列表
@PostMapping("") public Msg search(String id) { // 订单号为纯数字,反馈号为数字+字母 if(StringUtils.isNumeric(id)) { Express express = expressService.selectById(id); if(express == null) { return Msg.error("没有查到相关信息"); } else { return Msg.ok("0", globalFunction.express2dto(express)); } } else { Feedback feedback = feedbackService.selectById(id); if(feedback == null) { return Msg.error("没有查到相关信息"); } else { return Msg.ok("1", globalFunction.feedback2dto(feedback)); } } } } /** * 密码Controller */ @RestController @RequestMapping("/password") public class PasswordController { @Autowired private SysUserService userService; @Autowired private GlobalFunction globalFunction; /** * 重置密码 */
// 订单号为纯数字,反馈号为数字+字母 if(StringUtils.isNumeric(id)) { Express express = expressService.selectById(id); if(express == null) { return Msg.error("没有查到相关信息"); } else { return Msg.ok("0", globalFunction.express2dto(express)); } } else { Feedback feedback = feedbackService.selectById(id); if(feedback == null) { return Msg.error("没有查到相关信息"); } else { return Msg.ok("1", globalFunction.feedback2dto(feedback)); } } } } /** * 密码Controller */ @RestController @RequestMapping("/password") public class PasswordController { @Autowired private SysUserService userService; @Autowired private GlobalFunction globalFunction; /** * 重置密码 */ @PostMapping("/reset") public Msg resetPassword(String oldPassword, String newPassword) { SysUser user = globalFunction.getUser();
String cookieValue, int cookieMaxage, boolean isEncode) { try { if (cookieValue == null) { cookieValue = ""; } else if (isEncode) { cookieValue = URLEncoder.encode(cookieValue, "utf-8"); } Cookie cookie = new Cookie(cookieName, cookieValue); if (cookieMaxage > 0) cookie.setMaxAge(cookieMaxage); if (null != request) {// 设置域名的cookie String domainName = getDomainName(request); System.out.println(domainName); if (!"localhost".equals(domainName)) { cookie.setDomain(domainName); } } cookie.setPath("/"); response.addCookie(cookie); } catch (Exception e) { e.printStackTrace(); } } private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) { try { if (cookieValue == null) { cookieValue = ""; } else { cookieValue = URLEncoder.encode(cookieValue, encodeString); } Cookie cookie = new Cookie(cookieName, cookieValue); if (cookieMaxage > 0) cookie.setMaxAge(cookieMaxage); if (null != request) {// 设置域名的cookie String domainName = getDomainName(request); // System.out.println(domainName); if (!"localhost".equals(domainName)) { cookie.setDomain(domainName);
for(SysUserStatusEnum enums :SysUserStatusEnum.values()) { Map<String,Object> map = new HashMap<>(); map.put("id",enums.getIndex()); map.put("name",enums.getName()); result.add(map); } return Msg.ok(null,result); } /** * 获取所有的职员名,用于分配订单 */ @GetMapping("/listName") public Msg listStaff() { // 获取所有在职的职员 List<SysUser> staffs = userService.selectList(new EntityWrapper<SysUser>() .eq("status", SysUserStatusEnum.ACTIVE.getIndex()) .eq("role_id", RoleEnum.STAFF.getIndex())); return Msg.ok(null,staffs); } /** * 获取所有职员 */ @GetMapping("/list") public Map listStaff(Integer rows, Integer page, SysUserSelectWrapper usw) { // Get请求中文编码 try { usw.setName(globalFunction.iso8859ToUtf8(usw.getName())); usw.setAddress(globalFunction.iso8859ToUtf8(usw.getAddress())); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // 得到筛选条件 EntityWrapper<SysUser> userWrapper = globalFunction.getSysUserWrapper(usw); // 不显示admin角色 userWrapper.ne("role_id", RoleEnum.ADMIN.getIndex()); Page<SysUser> selectPage = userService.selectPage(new Page<>(page, rows), userWrapper); List<SysUserDto> list = globalFunction.sysUser2dto(selectPage.getRecords()); Map<String,Object> map = new HashMap<>(); map.put("total", selectPage.getTotal()); map.put("rows", list); return map;
*/ @PostMapping("/clean") public Msg cleanById(String[] ids) { for(String id : ids) { expressService.deleteById(id); } return Msg.ok(); } } /** */ @RestController @RequestMapping("/staff/express") public class StaffExpressController { @Autowired private ExpressService expressService; @Autowired private ExpressPaymentService expressPaymentService; @Autowired private GlobalFunction globalFunction; /** * 获取订单的状态列表
try { fsw.setName(globalFunction.iso8859ToUtf8(fsw.getName())); fsw.setStaffName(globalFunction.iso8859ToUtf8(fsw.getStaffName())); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // 得到筛选条件 EntityWrapper<Feedback> feedbackWrapper = globalFunction.getFeedbackWrapper(fsw); Page<Feedback> selectPage = feedbackService.selectPage(new Page<>(page, rows,order,false), feedbackWrapper); List<FeedbackDto> list = globalFunction.feedback2dto(selectPage.getRecords()); Map<String,Object> map = new HashMap<>(); map.put("total", selectPage.getTotal()); map.put("rows", list); return map; } /** * 删除反馈 */ @PostMapping("/delete") public Msg deleteById(String[] ids) { for(String id : ids) { feedbackService.deleteById(id); } return Msg.ok(); } /** * 处理反馈 */ @PostMapping("") public Msg handleFeedback(String id, String content) { if(StringUtils.isBlank(id) || StringUtils.isBlank(content)) { return Msg.error("参数错误"); } Feedback feedback = feedbackService.selectById(id); // 设置处理人为当前用户 feedback.setStaffId(globalFunction.getUserId()); feedback.setResult(content); // 0代表未处理,1代表已处理;默认为0 feedback.setStatus(1); feedbackService.updateById(feedback); return Msg.ok(); }
*/ @PostMapping("") public Msg handleFeedback(String id, String content) { if(StringUtils.isBlank(id) || StringUtils.isBlank(content)) { return Msg.error("参数错误"); } Feedback feedback = feedbackService.selectById(id); // 设置处理人为当前用户 feedback.setStaffId(globalFunction.getUserId()); feedback.setResult(content); // 0代表未处理,1代表已处理;默认为0 feedback.setStatus(1); feedbackService.updateById(feedback); return Msg.ok(); } } /** * 页面跳转Controller */ @Controller public class PageController { @GetMapping("/") public String showIndex() { return "index"; } @GetMapping("/login") public String showLogin() { return "login"; } @GetMapping("/feedback") public String showFeedBack() { return "feedback"; }
/** * 订单列表 * @param esw 筛选条件 */ @GetMapping("/list") public Map listExpress(Integer rows, Integer page, ExpressSelectWrapper esw, @RequestParam(defaultValue = "createDate") String order) { // Get请求中文编码 try { esw.setName(globalFunction.iso8859ToUtf8(esw.getName())); esw.setStaffName(globalFunction.iso8859ToUtf8(esw.getStaffName())); esw.setAddress(globalFunction.iso8859ToUtf8(esw.getAddress())); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // 得到筛选条件 EntityWrapper<Express> expressWrapper = globalFunction.getExpressWrapper(esw); Page<Express> selectPage = expressService.selectPage(new Page<>(page, rows, order, false), expressWrapper); List<ExpressDto> list = globalFunction.express2dto(selectPage.getRecords()); Map<String,Object> map = new HashMap<>(16); map.put("total", selectPage.getTotal()); map.put("rows", list); return map; } /** * 获取单个订单详情 */ @GetMapping("/{id}") public Msg getById(@PathVariable String id) { Express express = expressService.selectById(id); ExpressDto expressDto = globalFunction.express2dto(express); return Msg.ok(null,expressDto); } /** * 分配订单 * @param ids 订单数组 * @param staffId 派送员id
* @param isDecoder 是否编码,编码格式为UTF-8 */ public static String getCookieValue(HttpServletRequest request, String cookieName, boolean isDecoder) { Cookie[] cookieList = request.getCookies(); if (cookieList == null || cookieName == null) { return null; } String retValue = null; try { for (int i = 0; i < cookieList.length; i++) { if (cookieList[i].getName().equals(cookieName)) { if (isDecoder) { retValue = URLDecoder.decode(cookieList[i].getValue(), "UTF-8"); } else { retValue = cookieList[i].getValue(); } break; } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return retValue; } /** * 得到Cookie的值 * @param encodeString 编码格式 */ public static String getCookieValue(HttpServletRequest request, String cookieName, String encodeString) { Cookie[] cookieList = request.getCookies(); if (cookieList == null || cookieName == null) { return null; } String retValue = null; try { for (int i = 0; i < cookieList.length; i++) { if (cookieList[i].getName().equals(cookieName)) { retValue = URLDecoder.decode(cookieList[i].getValue(), encodeString); break; } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return retValue; } /** * 设置Cookie的值 不设置生效时间默认浏览器关闭即失效,也不编码
String strRand = String.valueOf(codeSequence[random.nextInt(36)]); // 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。 red = random.nextInt(255); green = random.nextInt(255); blue = random.nextInt(255); // 用随机产生的颜色将验证码绘制到图像中。 //gd.setColor(new Color(red,green,blue)); gd.setColor(new Color(255,0,0)); gd.drawString(strRand, (i + 1) * codeX, codeY); // 将产生的四个随机数组合在一起。 randomCode.append(strRand); } // 将四位数字的验证码保存到Session中。 HttpSession session = request.getSession(); session.setAttribute("validateCode", randomCode.toString()); // 禁止图像缓存。 response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/jpeg"); // 将图像输出到Servlet输出流中。 ServletOutputStream sos = response.getOutputStream(); ImageIO.write(buffImg, "jpeg", sos); sos.close(); } } /** * 职员管理
/** * 支付Controller */ @Controller @RequestMapping("/payment") public class PaymentController { @Value("${session.latest_express}") private String SESSION_LATEST_EXPRESS; @Value("${session.latest_payment}") private String SESSION_LATEST_PAYMENT; @Autowired private ExpressService expressService; @Autowired private ExpressPaymentService expressPaymentService; @Autowired private AliPaySetting aliPaySetting; @Autowired private AlipayClient alipayClient; /** * 从客户Cookie中取出最新的一条订单信息 */ @GetMapping("/express") @ResponseBody public Msg getExpress(HttpSession session) { Express express = (Express)session.getAttribute(SESSION_LATEST_EXPRESS); if(express != null) { return Msg.ok(null,express); } else {
@GetMapping("/admin/expressRecycle") public String showExpressRecycle() { return "admin/expressRecycle"; } @GetMapping("/admin/staff") public String showStaff() { return "admin/staff"; } @GetMapping("/admin/feedback") public String showFeedback() { return "admin/feedback"; } @GetMapping("/admin/password") public String showPassword() { return "admin/password"; } @GetMapping("/staff/home") public String showStaffHome() { return "staff/home"; } @GetMapping("/staff/express") public String showStaffExpress() { return "staff/express"; } @GetMapping("/staff/password") public String showStaffPassword() { return "staff/password"; } } /** * 查询Controller */ @RestController
String domainName = getDomainName(request); // System.out.println(domainName); if (!"localhost".equals(domainName)) { cookie.setDomain(domainName); } } cookie.setPath("/"); response.addCookie(cookie); } catch (Exception e) { e.printStackTrace(); } } /** * 得到cookie的域名(跨域访问) */ private static final String getDomainName(HttpServletRequest request) { String domainName = null; String serverName = request.getRequestURL().toString(); if (serverName == null || serverName.equals("")) { domainName = ""; } else { serverName = serverName.toLowerCase(); serverName = serverName.substring(7); final int end = serverName.indexOf("/"); serverName = serverName.substring(0, end); final String[] domains = serverName.split("\\."); int len = domains.length; if (len > 3) { // www.xxx.com.cn domainName = "." + domains[len - 3] + "." + domains[len - 2] + "." + domains[len - 1]; } else if (len <= 3 && len > 1) { // xxx.com or xxx.cn domainName = "." + domains[len - 2] + "." + domains[len - 1]; } else { domainName = serverName; } } if (domainName != null && domainName.indexOf(":") > 0) { String[] ary = domainName.split("\\:"); domainName = ary[0]; } return domainName;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。