基于javaweb的SSM+Maven快递代拿系统(java+ssm+bootstrap+shiro+mysql+html)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

230023522402

240023522402

260023522402

270023522402

280023522402

290023522402

基于javaweb的SSM+Maven快递代拿系统(java+ssm+bootstrap+shiro+mysql+html)

1 用户填写快递单
2 管理员分配配送员
3 配送员确认

*支付宝支付功能可以不使用,非必须(使用[线下支付]选项即可)

使用技术

采用 Spring + SpringMVC + MyBatisPlus,连接池采用 Druid,安全框架使用 Shiro,前端采用 Bootstrap + layer 实现。

运行环境

  • 集成开发环境:IntelliJ IDEA

  • 项目构建工具:Maven - 数据库:MYSQL 5.7+ - JDK版本:1.8 - Tomcat版本:Tomcat8

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
28
29
30
31
32
33
34
35
36
37
38
 */
@PostMapping("/offline")
@ResponseBody
public Msg paymentOffline(Double money, HttpSession session) {
Express express = (Express)session.getAttribute(SESSION_LATEST_EXPRESS);

if(express == null || money == null) {
return Msg.error("参数错误");
}

// 创建订单
String expressId = expressService.createExpress(express);
// 创建订单支付信息
ExpressPayment payment = expressPaymentService.createOfflinePayment(expressId, money);

// 将支付信息写入session
session.setAttribute(SESSION_LATEST_PAYMENT, payment);
// 支付成功后删除Express的session
session.removeAttribute(SESSION_LATEST_EXPRESS);

return Msg.ok(null,"/payment/result");
}

/**
* 支付宝支付方式
* @param money 支付金额
*/
@PostMapping("/alipay")
public void paymentAlipay(Double money, HttpSession session, HttpServletResponse response) throws IOException {
Express express = (Express)session.getAttribute(SESSION_LATEST_EXPRESS);

if(express == null || money == null) {
response.getWriter().write("参数错误,请重新下单");
}

// 金额保留两位
money = (double) (Math.round(money * 100)) / 100;

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
// 定义图像buffer
BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D gd = buffImg.createGraphics();
// 创建一个随机数生成器类
Random random = new Random();
// 将图像填充为白色
gd.setColor(Color.LIGHT_GRAY);
gd.fillRect(0, 0, width, height);
// 创建字体,字体的大小应该根据图片的高度来定。
Font font = new Font("Times New Roman", Font.PLAIN, fontHeight);
// 设置字体。
gd.setFont(font);
// 画边框。
gd.setColor(Color.BLACK);
gd.drawRect(0, 0, width - 1, height - 1);
// 随机产生16条干扰线,使图象中的认证码不易被其它程序探测到。
gd.setColor(Color.gray);
for (int i = 0; i < interLine; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
gd.drawLine(x, y, x + xl, y + yl);
}
// randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
StringBuffer randomCode = new StringBuffer();
int red = 0, green = 0, blue = 0;
// 随机产生codeCount数字的验证码。
for (int i = 0; i < codeCount; i++) {
// 得到随机产生的验证码数字。
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());
// 禁止图像缓存。
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
28
29
30
31
32
33
34
35
36
37
38
39
40
   public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, boolean isEncode) {
setCookie(request, response, cookieName, cookieValue, -1, isEncode);
}

/**
* 设置Cookie的值 在指定时间内生效,编码
* @version 创建时间:2018年4月16日 下午7:09:52
* @param cookieMaxage 过期时间
* @param isEncode 是否编码,编码格式为UTF-8
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode);
}

/**
* 设置Cookie的值 在指定时间内生效, 编码
* @version 创建时间:2018年4月16日 下午7:10:26
* @param cookieMaxage 过期时间
* @param encodeString 编码格式
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, String encodeString) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString);
}

/**
* 删除Cookie
* @version 创建时间:2018年4月16日 下午7:10:48
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName) {
doSetCookie(request, response, cookieName, "", -1, false);
}

private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
try {
if (cookieValue == null) {
cookieValue = "";
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
        result.add(map);
}
return Msg.ok(null,result);
}

/**
* 获取所有等待接单的订单
*/
@RequestMapping("/list")
public Map listExpress(Integer rows, Integer page, ExpressSelectWrapper esw, @RequestParam(defaultValue = "createDate") String order) {
// Get请求中文编码
try {
esw.setName(globalFunction.iso8859ToUtf8(esw.getName()));
esw.setAddress(globalFunction.iso8859ToUtf8(esw.getAddress()));
esw.setStaffName(globalFunction.iso8859ToUtf8(esw.getStaffName()));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 得到筛选条件
EntityWrapper<Express> expressWrapper = globalFunction.getExpressWrapper(esw);
// 设置仅查找等待接单的订单
expressWrapper.eq("status", ExpressStatusEnum.WAIT_DIST.getIndex());
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<>();
map.put("total", selectPage.getTotal());
map.put("rows", list);
return map;
}

/**
* 获取所有个人的订单
*/
@RequestMapping("/selfList")
public Map listSelfExpress(Integer rows, Integer page, ExpressSelectWrapper esw, @RequestParam(defaultValue = "createDate") String order) {
// Get请求中文编码
try {
esw.setName(globalFunction.iso8859ToUtf8(esw.getName()));
esw.setAddress(globalFunction.iso8859ToUtf8(esw.getAddress()));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 得到筛选条件
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
28
29
30
31
32
33
34
35
36
    List<ExpressDto> list = globalFunction.express2dto(selectPage.getRecords());

Map<String,Object> map = new HashMap<>();
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);
}

/**
* 接单
*/
@PostMapping("")
public Msg acceptExpress(String[] ids) {
for(String id : ids) {
Express express = expressService.selectById(id);

express.setStaff(globalFunction.getUserId());
express.setStatus(ExpressStatusEnum.TRANSPORT.getIndex());
expressService.updateById(express);
}
return Msg.ok();
}

/**
* 确认订单
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
28
29
30
31
32
33
34
35
36
37
38
39
40
		}
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);
}
}
cookie.setPath("/");
response.addCookie(cookie);
} catch (Exception e) {
e.printStackTrace();


项目链接:
https://javayms.github.io?id=431422312105200iu
https://javayms.pages.dev?id=431422312105200iu