Java项目:ssm开发的Java快递代拿系统

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

使用技术

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

支付采用支付宝沙箱环境,支付APP下载链接,[点击这里](https://sandbox.alipaydev.com/user/downloadApp.htm)。

支付账号: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  |

运行截图

相关代码 

管理员订单Controller

package jit.wxs.express.controller.admin;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import jit.wxs.express.controller.GlobalFunction;
import jit.wxs.express.dto.ExpressDto;
import jit.wxs.express.enums.ExpressStatusEnum;
import jit.wxs.express.interactive.ExpressSelectWrapper;
import jit.wxs.express.interactive.Msg;
import jit.wxs.express.pojo.Express;
import jit.wxs.express.pojo.ExpressPayment;
import jit.wxs.express.service.ExpressPaymentService;
import jit.wxs.express.service.ExpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 管理员订单Controller
 * @author jitwxs
 * @date 2018/5/2 0:21
 */
@RestController
@RequestMapping("/admin/express")
public class ExpressController {
    @Autowired
    private ExpressService expressService;
    @Autowired
    private GlobalFunction globalFunction;
    @Autowired
    private ExpressPaymentService expressPaymentService;

    /**
     * 获取订单的状态列表
     * @author jitwxs
     * @since 2018/5/2 9:58
     */
    @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);
        }
        return Msg.ok(null,result);
    }

    /**
     * 订单列表
     * @param esw 筛选条件
     * @author jitwxs
     * @since 2018/5/2 0:33
     */
    @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;
    }

    /**
     * 获取单个订单详情
     * @author jitwxs
     * @since 2018/5/2 14:04
     */
    @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
     * @author jitwxs
     * @since 2018/5/2 16:37
     */
    @PostMapping("/assign")
    public Msg assignExpress(String[] ids,String staffId) {
        for(String id : ids) {
            Express express = expressService.selectById(id);
            // 只有订单状态为WAIT_DIST时才要分配订单
            if(ExpressStatusEnum.WAIT_DIST.getName().equals(ExpressStatusEnum.getName(express.getStatus()))) {
                express.setStaff(staffId);
                express.setStatus(ExpressStatusEnum.TRANSPORT.getIndex());
                expressService.updateById(express);
            }
        }
        return Msg.ok();
    }

    /**
     * 确认订单
     * @author jitwxs
     * @since 2018/5/13 17:51
     */
    @PostMapping("/confirm")
    public Msg confirmExpress(ExpressPayment payment) {
        String id = payment.getExpressId();

        Express express = expressService.selectById(id);
        express.setStatus(ExpressStatusEnum.COMPLTE.getIndex());
        expressService.updateById(express);

        expressPaymentService.updateById(payment);

        return Msg.ok();
    }

    /**
     * 异常订单
     * @author jitwxs
     * @since 2018/5/13 17:51
     */
    @PostMapping("/error")
    public Msg errorExpress(String[] ids, String text) {
        for(String id : ids) {
            Express express = expressService.selectById(id);
            // 只有订单状态为TRANSPORT时才要确认
            if(ExpressStatusEnum.TRANSPORT.getName().equals(ExpressStatusEnum.getName(express.getStatus()))) {
                express.setStatus(ExpressStatusEnum.ERROR.getIndex());
                express.setStaffRemark(text);
                expressService.updateById(express);
            }
        }
        return Msg.ok();
    }

    /**
     * 删除订单
     * @author jitwxs
     * @since 2018/5/2 14:05
     */
    @PostMapping("/delete")
    public Msg deleteById(String[] ids) {
        for(String id : ids) {
            Express express = expressService.selectById(id);
            if(express != null) {
                // 设置删除标记为true
                express.setHasDelete(true);
                expressService.updateById(express);
            }
        }
        return Msg.ok();
    }

    /**
     * 恢复订单
     * @author jitwxs
     * @since 2018/5/2 14:05
     */
    @PostMapping("/recycle")
    public Msg recycleById(String[] ids) {
        for(String id : ids) {
            Express express = expressService.selectById(id);
            if(express != null) {
                // 设置删除标记为false
                express.setHasDelete(false);
                expressService.updateById(express);
            }
        }
        return Msg.ok();
    }

    /**
     * 彻底删除订单
     * @author jitwxs
     * @since 2018/5/2 14:05
     */
    @PostMapping("/clean")
    public Msg cleanById(String[] ids) {
        for(String id : ids) {
            expressService.deleteById(id);
        }
        return Msg.ok();
    }
}

用户反馈Controller

package jit.wxs.express.controller.admin;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import jit.wxs.express.controller.GlobalFunction;
import jit.wxs.express.dto.FeedbackDto;
import jit.wxs.express.enums.FeedbackTypeEnum;
import jit.wxs.express.interactive.FeedbackSelectWrapper;
import jit.wxs.express.interactive.Msg;
import jit.wxs.express.pojo.Feedback;
import jit.wxs.express.service.FeedbackService;
import jit.wxs.express.service.SysUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户反馈Controller
 * @author jitwxs
 * @since 2018/5/14 14:35
 */
@RestController
@RequestMapping("/admin/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    @Autowired
    private SysUserService userService;
    @Autowired
    private GlobalFunction globalFunction;

    /**
     * 获取所有反馈类型
     * @author jitwxs
     * @since 2018/5/14 14:46
     */
    @GetMapping("/type/list")
    public Msg listFeedbackType() {
        List<Map<String,Object>> result = new ArrayList<>();
        for(FeedbackTypeEnum enums :FeedbackTypeEnum.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);
    }

    /**
     * 获取所有反馈
     * @author jitwxs
     * @since 2018/5/14 14:35
     */
    @GetMapping("/list")
    public Map listFeedback(Integer rows, Integer page, FeedbackSelectWrapper fsw, @RequestParam(defaultValue = "createDate") String order) {
        // Get请求中文编码
        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;
    }

    /**
     * 删除反馈
     * @author jitwxs
     * @since 2018/5/2 14:05
     */
    @PostMapping("/delete")
    public Msg deleteById(String[] ids) {
        for(String id : ids) {
            feedbackService.deleteById(id);
        }
        return Msg.ok();
    }

    /**
     * 处理反馈
     * @author jitwxs
     * @since 2018/5/14 15:06
     */
    @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();
    }
}

职员管理

package jit.wxs.express.controller.admin;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import jit.wxs.express.controller.GlobalFunction;
import jit.wxs.express.dto.SysUserDto;
import jit.wxs.express.enums.RoleEnum;
import jit.wxs.express.enums.SysUserStatusEnum;
import jit.wxs.express.interactive.Msg;
import jit.wxs.express.interactive.SysUserSelectWrapper;
import jit.wxs.express.pojo.SysUser;
import jit.wxs.express.service.SysUserService;
import jit.wxs.express.utils.PasswordUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.util.*;

/**
 * 职员管理
 * @author jitwxs
 * @date 2018/5/2 16:49
 */
@RestController
@RequestMapping("/admin/staff")
public class StaffController {
    @Autowired
    private SysUserService userService;
    @Autowired
    private GlobalFunction globalFunction;

    private void changeUserStatus(String[] ids, Integer status) {
        for(String id : ids) {
            SysUser user = userService.selectById(id);
            user.setStatus(status);
            userService.updateById(user);
        }
    }

    /**
     * 获取用户的状态列表
     * @author jitwxs
     * @since 2018/5/2 9:58
     */
    @GetMapping("/status")
    public Msg listStaffStatus() {
        List<Map<String,Object>> result = new ArrayList<>();
        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);
    }

    /**
     * 获取所有的职员名,用于分配订单
     * @author jitwxs
     * @since 2018/5/14 13:38
     */
    @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);
    }

    /**
     * 获取所有职员
     * @author jitwxs
     * @since 2018/5/2 16:50
     */
    @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("")
    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("123"));
        //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();
    }

    /**
     * 获取用户信息
     * @author jitwxs
     * @since 2018/5/14 16:15
     */
    @GetMapping("/{id}")
    public Msg getById(@PathVariable String id) {
        SysUser user = userService.selectById(id);
        return Msg.ok(null,user);
    }

    /**
     * 修改员工为在职
     * @author jitwxs
     * @since 2018/5/13 20:42
     */
    @PostMapping("/active")
    public Msg changeActive(String[] ids) {
        changeUserStatus(ids, SysUserStatusEnum.ACTIVE.getIndex());
        return Msg.ok();
    }

    /**
     * 修改员工为冻结
     * @author jitwxs
     * @since 2018/5/13 20:42
     */
    @PostMapping("/freeze")
    public Msg changeFreeze(String[] ids) {
        changeUserStatus(ids, SysUserStatusEnum.FREEZE.getIndex());
        return Msg.ok();
    }

    /**
     * 修改员工为离职
     * @author jitwxs
     * @since 2018/5/13 20:42
     */
    @PostMapping("/leave")
    public Msg changeLeave(String[] ids) {
        changeUserStatus(ids, SysUserStatusEnum.LEAVE.getIndex());
        return Msg.ok();
    }

}

如果也想学习本系统,下面领取。关注并回复:044ssm 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值