作者主页:Java毕设网
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
一、项目介绍
CRM客户关系管理系统。本系统共分为三种角色:超级管理员、经理、销售人员;
超级管理员的功能主要有:
公司资料:部门结构、销售目录;
人员资料:销售人员、账号权限;
客户资料:客户列表;
销售跟踪:订单列表、报表统计;
图表分析:销售与客户分析、销售失败分析;
二、环境需要
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版本;
三、技术栈
1. 后端:SpringBoot;
2. 前端:layui+html
四、使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.yml配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入localhost:8080 登录
五、运行截图
六、相关代码
销售管理控制器
@RestController
@RequestMapping("/copClient")
public class CopClientController {
@Autowired
private CopClientService copClientService;
@Autowired
private AuthUserService authUserService;
@PostMapping
@ApiOperation(value = "插入")
public ResultDTO insertOne(Authentication authentication,@RequestBody CopClient copClient) throws Exception {
AuthUser userDetails = authUserService.getUserDetails(authentication);
copClient.setClientPrincipal(userDetails.getUserId());
copClientService.save(copClient);
return ResultUtil.Success(copClient);
}
@PutMapping
@ApiOperation(value = "按ID修改")
public ResultDTO updateById(@RequestBody CopClient copClient) throws Exception {
copClientService.updateById(copClient);
return ResultUtil.Success();
}
@DeleteMapping("/{id:\\d+}")
@ApiOperation("按ID删除")
public ResultDTO deleteById(@PathVariable Long id) throws Exception {
copClientService.removeById((long) id);
return ResultUtil.Success();
}
@GetMapping("/list")
@ApiOperation("查询全部")
public ResultDTO selectEntityPage(Authentication authentication)throws Exception{
/*
查询下属销售人员的编号
*/
List<AuthUser> userAndChild = authUserService.getUserAndChildId(authentication);
Set<Long> userId = userAndChild.stream().map(AuthUser::getUserId).collect(Collectors.toSet());
/*
查询自己与下属销售人员的客户
*/
QueryWrapper<CopClient> copClientQueryWrapper = new QueryWrapper<>();
copClientQueryWrapper.in("client_principal",userId);
List<CopClient> data = copClientService.list(copClientQueryWrapper);
int count = data.size();
return ResultUtil.Success(data,count);
}
@GetMapping()
@ApiOperation("查询、分页返回")
public ResultDTO selectEntityPage(Authentication authentication,
@RequestParam(value = "page", defaultValue = "0") int pageNum,
@RequestParam(value = "limit", defaultValue = "8") int pageSize,
String clientName)throws Exception{
/*
查询下属销售人员的编号
*/
List<AuthUser> userAndChild = authUserService.getUserAndChildId(authentication);
Set<Long> userId = userAndChild.stream().map(AuthUser::getUserId).collect(Collectors.toSet());
/*
查询自己与下属销售人员的客户
*/
QueryWrapper<CopClient> copClientQueryWrapper = new QueryWrapper<>();
copClientQueryWrapper.in("client_principal",userId);
if (clientName != null && !clientName.isEmpty()) {
copClientQueryWrapper.like("client_name",clientName);
}
IPage<CopClient> page = copClientService.page(new Page<CopClient>(pageNum, pageSize), copClientQueryWrapper);
List<CopClient> data = page.getRecords();
/*
转化为DTO
*/
List<ClientDTO> clientDTOS = new ArrayList<>();
for (CopClient client : data) {
ClientDTO clientDTO = new ClientDTO();
BeanUtils.copyProperties(client,clientDTO);
clientDTOS.add(clientDTO);
}
for (ClientDTO clientDTO : clientDTOS) {
for (AuthUser authUser : userAndChild) {
if (clientDTO.getClientPrincipal().equals(authUser.getUserId())) {
clientDTO.setClientPrincipalName(authUser.getUserTrueName());
}
}
int now = LocalDateTime.now().getYear();
int year = clientDTO.getClientBirthday().getYear();
clientDTO.setClientAge(LocalDateTime.now().getYear() - clientDTO.getClientBirthday().getYear());
}
int count = (int) page.getTotal();
return ResultUtil.Success(clientDTOS,count);
}
@GetMapping("/{id:\\d+}")
@ApiOperation("ID查询")
public ResultDTO selectEntityPage(@PathVariable Long id)throws Exception{
return ResultUtil.Success(copClientService.getById(id));
}
}
订单管理控制器
@RestController
@RequestMapping("/copOrderDetail")
public class CopOrderDetailController {
@Autowired
private CopOrderDetailService copOrderDetailService;
@Autowired
private CopOrderService copOrderService;
@GetMapping()
@ApiOperation("根据订单编号查询")
public ResultDTO selectByOrderId(Long orderId) throws Exception{
List<OrderDetailDTO> orderDetailDTOS = copOrderDetailService.selectByOrderId(orderId);
return ResultUtil.Success(orderDetailDTOS,orderDetailDTOS.size());
}
@GetMapping("/{id:\\d+}")
@ApiOperation("ID查询")
public ResultDTO selectEntityPage(@PathVariable Long id) throws Exception{
return ResultUtil.Success(copOrderDetailService.getById(id));
}
@PostMapping
@ApiOperation(value = "插入")
@Transactional
public ResultDTO insertOne(@RequestBody CopOrderDetail copOrderDetail) throws Exception {
CopOrder order = copOrderService.getById(copOrderDetail.getOrderId());
order.setOrderTotalPrice(order.getOrderTotalPrice().add(copOrderDetail.getOrderDetailPrice()));
copOrderService.updateById(order);
copOrderDetailService.save(copOrderDetail);
return ResultUtil.Success(copOrderDetail);
}
@PutMapping
@ApiOperation(value = "按ID修改")
@Transactional
public ResultDTO updateById(@RequestBody CopOrderDetail copOrderDetail) throws Exception {
CopOrderDetail oldDetail = copOrderDetailService.getById(copOrderDetail.getOrderDetailId());
BigDecimal price = copOrderDetail.getOrderDetailPrice().subtract(oldDetail.getOrderDetailPrice());
CopOrder order = copOrderService.getById(copOrderDetail.getOrderId());
order.setOrderTotalPrice(order.getOrderTotalPrice().add(price));
copOrderService.updateById(order);
copOrderDetailService.updateById(copOrderDetail);
return ResultUtil.Success();
}
@DeleteMapping("/{id:\\d+}")
@ApiOperation("按ID删除")
public ResultDTO deleteById(@PathVariable Long id) throws Exception {
copOrderDetailService.removeById((long) id);
return ResultUtil.Success();
}
}
商品管理控制器
@RestController
@RequestMapping("/copProduct")
public class CopProductController {
@Autowired
private CopProductService copProductService;
@PostMapping
@ApiOperation(value = "插入")
public ResultDTO insertOne(@RequestBody CopProduct copProduct) throws Exception {
copProductService.save(copProduct);
return ResultUtil.Success(copProduct);
}
@PostMapping("/import")
@ApiOperation(value = "插入")
public ResultDTO importExcel(MultipartFile file) {
if (file.isEmpty()) {
return ResultUtil.Error("500","文件为空!");
}
copProductService.readExcel(file);
return ResultUtil.Success();
}
@PutMapping
@ApiOperation(value = "按ID修改")
public ResultDTO updateById(@RequestBody CopProduct copProduct) throws Exception {
copProductService.updateById(copProduct);
return ResultUtil.Success();
}
@DeleteMapping("/{id:\\d+}")
@ApiOperation("按ID删除")
public ResultDTO deleteById(@PathVariable Long id) throws Exception {
copProductService.removeById((long) id);
return ResultUtil.Success();
}
@GetMapping()
@ApiOperation("查询、分页返回")
public ResultDTO selectEntityPage(@RequestParam(value = "page", defaultValue = "0") int pageNum,
@RequestParam(value = "limit", defaultValue = "8") int pageSize,
String productName)throws Exception{
QueryWrapper<CopProduct> copProductQueryWrapper = new QueryWrapper<>();
if (productName != null && !productName.isEmpty()) {
copProductQueryWrapper.like("product_name",productName);
}
IPage<CopProduct> page = copProductService.page(new Page<CopProduct>(pageNum, pageSize),copProductQueryWrapper);
List<CopProduct> data = page.getRecords();
int count = (int) page.getTotal();
return ResultUtil.Success(data,count);
}
@GetMapping("/list")
@ApiOperation("查询")
public ResultDTO selectList()throws Exception{
List<CopProduct> data = copProductService.list();
int count = (int) data.size();
return ResultUtil.Success(data,count);
}
@GetMapping("/{id:\\d+}")
@ApiOperation("ID查询")
public ResultDTO selectEntityPage(@PathVariable Long id)throws Exception{
return ResultUtil.Success(copProductService.getById(id));
}
}