Java项目:ssm客户关系管理系统

作者主页:夜未央5788

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

文末获取源码

项目介绍

客户关系管理系统主要功能包括:

系统管理:
用户管理
日志管理
权限管理
角色管理
系统信息
客户管理
我的客户
联系跟进
客户流失
销售机会
客户服务
我的服务
服务统计
客户关怀
统计

个人中心

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

更多项目源码,请到“源码空间站”,地址:http://www.shuyue.fun/

环境需要

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版本;

系统框架

spring框架

springmvc框架
mybatis框架
Logback日志框架
安全验证框架
maven框架
layui前端框架

shiro安全框架

系统关键性技术

基于角色的权限访问控制RBCA(Role-Based Access Control)
Spring+Springmvc+Mybatis三大框架
Ajax技术
springmvc文件上传
shiro安全框架
Redis缓存
JavaMail邮件
基于aop切面的日志管理
Layui前端框架
登录验证码
富文本输入框

md5加密加盐

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件,sql文件命名为crm2.sql,其中‘user’表为账户表;

2. 部署项目前,需要配置好MqSQL数据库,Redis数据库、mail邮箱,这三个配置文件都在crm/src/main/resources/properties
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4.项目登录帐号:malizhi(管理员级别),密码123456,部署项目后,可以到测试类中(test包下的TestUserService)进行添加账户,密码经过md5加密加盐
5.登录页:如果是本地部署 http://localhost:8080/crm2/pages/login.jsp ,端口号以及项目名要与部署的环境一致

6.订单可以在客户流失(客户是否流失由Spring定时器定时检测)模块中,点击客户详情,可以查看到此客户的历史订单,关于订单的数据问题,因为在企业模式中,订单数据是从销售系统中获取的,但由于没有外接销售系统,所以订单数据以及产品定价的数据是自个插入数据库的。

部署过程异常错误解决方法

1.权限,菜单都会缓存到redis中,如果redis无法连接,将会报空指针错误或登陆后首页会显示404,请确保能连接上redis数据库
2.如果有报此异常org/hyperic/sigar/SigarException,可以将WEB-INF/lib下的文件(根据你的系统以及位数选择)放在你的JDK/bin目录下

3.在发布出来前,由于隐私关系删除了部分登录帐号(客户经理),如果出现此客户找不到对应的客户经理,删掉此客户即可

运行截图

 

 

 

 

 

 

 

相关代码 

CustomerCareController

/**
 * 
 */
package com.neuedu.crm.controller;


import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.ResponseBody;

import com.neuedu.crm.pojo.CustomerCare;
import com.neuedu.crm.pojo.CustomerCareExample;

import com.neuedu.crm.pojo.Linkman;
import com.neuedu.crm.pojo.User;
import com.neuedu.crm.service.ICustomerCareService;
import com.neuedu.crm.service.ICustomerService;
import com.neuedu.crm.service.ILinkmanService;
import com.neuedu.crm.utils.Operation;

/**
 * @author wanghaoyu
 *
 */
@Controller
@RequestMapping("/customerCare")
public class CustomerCareController {
    
    Logger logger = LoggerFactory.getLogger(CustomerCareController.class);
    
    @Autowired
    ICustomerService customerService;
    
    @Autowired
    ILinkmanService linkmanService;
    
    @Autowired
    ICustomerCareService customerCareService;

    @Operation(name="查找客户关怀")
    @RequiresPermissions("19001")
    @RequestMapping("/findCustomerCare")
    @ResponseBody
    public Map<String, Object> findCustomerCare(HttpServletRequest request, Integer day){
        Map<String, Object> map = new HashMap<String, Object>(26);
        //从session域中获取当前用户
        User user = (User) request.getSession().getAttribute("user");
        List<CustomerCare> customerCares = null;
        //根据当前客户经理的编号查找联系人
        if(user.getRoleId() == 1) {
            customerCares =  customerCareService.selectCustomerCareByManagerId(user.getId());
        }else {
            customerCares =  customerCareService.selectCustomerCareByManagerId(null);
        }
        
        
        LocalDate now = LocalDate.now();
        Iterator<CustomerCare> it =  customerCares.iterator();
        //再根据天数内来筛选要显示的数据
        while(it.hasNext()){
            LocalDate dateOfBirthday = it.next().getBirthday();
            //把生日的年份换成今年,以方便计算天数
            LocalDate  birthday = LocalDate.of(now.getYear(), dateOfBirthday.getMonth(), dateOfBirthday.getDayOfMonth());
            //计算生日离今天还有多少天
            long betweenDays = now.until(birthday, ChronoUnit.DAYS);
            //判断是不是在天数以内
            if(  !(betweenDays >= 0 && betweenDays <= day)){
                //移除掉不符合的联系人
                it.remove();
            }
        }
        map.put("data", customerCares);
        map.put("msg", "success");
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:根据联系人id查找联系生日等信息
     * @author wanghaoyu
     * @version 1.0
     * @param id
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="根据联系人id查找联系生日等信息")
    @RequestMapping("/findLinkmanBirthdayInfoById")
    @ResponseBody
    public Map<String, Object> findLinkmanBirthdayInfoById(Integer id){
        
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        Linkman linkman = null;
        
        try {
            linkman = linkmanService.selectLinkmanByPrimaryKey(id);
            //计算年龄差
            long age = linkman.getBirthday().until(LocalDate.now()).getYears();
            linkman.setAge((int)age);
            success = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        map.put("linkman", linkman);
        map.put("success", success);
        map.put("code", 0);
        
        return map;
    }
    
    /**
     * 
     * 描述:添加客户关怀信息
     * @author wanghaoyu
     * @version 1.0
     * @param request
     * @param customerCare
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="添加客户关怀")
    @RequestMapping("/addCustomerCare")
    @ResponseBody
    public Map<String, Object> addCustomerCare(HttpServletRequest request , CustomerCare customerCare){
        
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        
        try {
            User user = (User) request.getSession().getAttribute("user");
            //对数据进行二次封装
            customerCare.setManagerId(user.getId());
            if(customerCareService.insertCustomerCare(customerCare)) {
                success = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        map.put("success", success);
        map.put("code", 0);
        return map;
    }
    
    
    /**
     * 
     * 描述:根据编号查找客户关怀记录
     * @author wanghaoyu
     * @version 1.0
     * @param id
     * @return 
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="根据编号查找客户关怀记录")
    @RequestMapping("/findCustomerCareById")
    @ResponseBody
    public Map<String, Object> findCustomerCareById(Integer id){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        CustomerCare customerCare = null;
        try {
            customerCare = customerCareService.selectCustomerCareByPrimaryKey(id);
            //封装联系人对象
            Linkman linkman = linkmanService.selectLinkmanByPrimaryKey(customerCare.getLinkmanId());
            customerCare.setLinkman(linkman);
            success = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("customerCare", customerCare);
        map.put("code", 0);
        map.put("success", success);
        return map;
    }
    
    /**
     * 
     * 描述:处理客户关怀
     * @author wanghaoyu
     * @version 1.0
     * @param customerCare
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="处理客户关怀")
    @RequestMapping("/handleCustomerCare")
    @RequiresPermissions("19002")
    @ResponseBody
    public Map<String, Object> handleCustomerCare(CustomerCare customerCare){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        logger.info("客户关怀" + customerCare.toString());
        try {
            customerCare.setStatus("已处理");
            //更新客户关怀记录
            if(customerCareService.updateCustomerCareByPrimaryKey(customerCare)) {
                success = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("success", success);
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:忽略客户的生日处理
     * @author wanghaoyu
     * @version 1.0
     * @param id
     * @return 
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="忽略客户关怀")
    @RequiresPermissions("19006")
    @RequestMapping("/skipCustomerCare")
    @ResponseBody
    public Map<String, Object> skipCustomerCare(Integer id){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        try {
            CustomerCare customerCare = new CustomerCare();
            customerCare.setId(id);
            customerCare.setStatus("已忽略");
            if(customerCareService.updateCustomerCareByPrimaryKeySelective(customerCare)) {
                success = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("success", success);
        map.put("code", 0);
        return map;
    }
    
}

CustomerController

package com.neuedu.crm.controller;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.shiro.authz.annotation.RequiresPermissions;
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.ResponseBody;

import com.neuedu.crm.pojo.Customer;
import com.neuedu.crm.pojo.CustomerExample;
import com.neuedu.crm.pojo.CustomerExample.Criteria;
import com.neuedu.crm.pojo.Linkman;
import com.neuedu.crm.pojo.User;
import com.neuedu.crm.service.ICustomerService;
import com.neuedu.crm.utils.Operation;

/**
 * 
 * @author huangwanzong
 * @date 2018年7月6日
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
    @Autowired
    private ICustomerService customerService;
    
    private User user = null;

    /**
     * @author huangwanzong
     * @date 2018年7月6日
     */
    private User getUser(HttpServletRequest request) {
        HttpSession session = request.getSession();
        user = (User)session.getAttribute("user");
        return user;
    }
    

    /**
     * 
     * 描述:分页查询客户
     * @author huangwanzong
     * @date 2018/07/06
     * @version 1.0
     * @param page 可选参数,查询的页数,默认值 1
     * @param limit 可选参数,分页的大小,默认值 10
     * @param customer 可选参数,查询的条件
     * @param findtype 可选参数,该参数值为 all 时不执行分页查询,返回全部符合条件的客户
     * @param request
     * @return Map<String,Object>
     * @since 1.8
     *
     */
    
    @RequiresPermissions("5001")
    @Operation(name="分页查询客户")
    @RequestMapping("list")
    @ResponseBody
    public Map<String, Object> listCustomer(Integer page,Integer limit,Customer customer,String findtype,HttpServletRequest request){
        Map<String, Object> map = new HashMap<String,Object>(16);
        
        //获取用户
        user = this.getUser(request);
        //检验用户正确性
        if(user == null || user.getId() == null) {
            map.put("code", -1);
            map.put("msg", "用户不存在,无法执行操作.");
            return map;
        }
        
        CustomerExample example = new CustomerExample();
        Criteria criteria = example.createCriteria();
        
        //设置分页参数
        if(page == null || page <= 0) {
            page = 1;
        }
        if(limit == null || limit <= 0) {
            limit = 10;
        }
        String all = "all";
        if(!all.equals(findtype)) {
            example.setLimit(limit);
            Long offset = new Long((page-1)*limit);
            example.setOffset(offset);
        }

        //设置管理者ID
        criteria.andManagerIdEqualTo(user.getId());
        //只查询未删除的客户
        criteria.andDeleteStatusEqualTo(0);
        System.out.println(customer);
        //检测属性是否存在,存在则进行条件查询
        if(customer != null) {
            if(customer.getName() != null) {
                criteria.andNameLike("%" + customer.getName() + "%");
            }
            
            if(customer.getType() != null && !"".equals(customer.getType())) {
                criteria.andTypeEqualTo(customer.getType()); 
            }
            if(customer.getStatus() != null && !"".equals(customer.getStatus())) {
                criteria.andStatusEqualTo(customer.getStatus());
            }
            if(customer.getSource() != null && !"".equals(customer.getSource())) {
                criteria.andSourceEqualTo(customer.getSource());
            }
            if(customer.getLevel() != null && !"".equals(customer.getLevel())) {
                criteria.andLevelEqualTo(customer.getLevel());
            }
            if(customer.getCredit() != null && !"".equals(customer.getCredit())) {
                criteria.andCreditEqualTo(customer.getCredit());
            }
            if(customer.getMaturity() != null && !"".equals(customer.getMaturity())) {
                criteria.andMaturityEqualTo(customer.getMaturity());
            }
        }
        
        Long count = customerService.countByCustomerExample(example);
        List<Customer> customers = customerService.selectByCustomerExample(example);
        
        map.put("data", customers);
        map.put("count", count);
        map.put("code", 0);
        
        return map;
    }
    
    
    /**
     * 
     * 描述:添加一个客户
     * @author huangwanzong
     * @date 2018/07/17
     * @version 1.0
     * @param customer 客户信息
     * @param linkman 联系人信息
     * @param customerName 客户名称
     * @param linkmanName 联系人名称
     * @param customerLevel 客户等级
     * @param request
     * @return Map<String,Object>
     * @since 1.8
     *
     */
    @RequiresPermissions("5002")
    @Operation(name="添加客户")
    @RequestMapping("add")
    @ResponseBody
    public Map<String, Object> addCustomer(Customer customer,Linkman linkman,String customerName,String linkmanName,String customerLevel,HttpServletRequest request){
        Map<String, Object> map = new HashMap<String,Object>(16);
        
        this.getUser(request);
        
        //检测是否存在customer对象
        if(customer == null || linkman == null) {
            map.put("msg", "参数为空");
            map.put("success", false);
            return map;
        }
        
        //检测客户名是否存在
        if(customerName == null || "".equals(customerName)) {
            map.put("msg", "用户名称参数不能为空");
            map.put("success", false);
            return map;
        }
        
        //检测联系人姓名是否存在
        if(linkmanName == null || "".equals(linkmanName)) {
            map.put("msg", "联系人名称参数不能为空");
            map.put("success", false);
            return map;
        }
        
        //客户所属者默认为创建者
        customer.setManagerId(user.getId());
        //设置创建者id
        customer.setCreater(user.getId());
        //设置创建时间
        customer.setCreateTime(LocalDateTime.now());
        //设置客户名称
        customer.setName(customerName);
        //设置客户等级
        customer.setLevel(customerLevel);
        //设置未删除
        customer.setDeleteStatus(0);
        
        //设置联系人名称
        linkman.setName(linkmanName);
     
        
        //进行数据插入
        if(customerService.insertSelective(customer,linkman)) {
            map.put("msg", "添加成功");
            map.put("success", true);
        }else {
            map.put("msg", "添加失败");
            map.put("success", false);
        }
        
        return map;
    }
    
    @RequiresPermissions("7009")
    @Operation(name="检测客户名称是否存在")
    @RequestMapping("checkname")
    @ResponseBody
    public boolean checkCustomerName(String name){
        
        CustomerExample example = new CustomerExample();
        example.createCriteria().andNameEqualTo(name);
        
        List<Customer> list = customerService.selectByCustomerExample(example);
        if(list.size()>0) {
            return true;
        }
        return false;
    }
    
    @RequiresPermissions("5003")
    @Operation(name="更新客户信息")
    @RequestMapping("update")
    @ResponseBody
    public Map<String, Object> updateCustomer(Customer customer){
        Map<String, Object> map = new HashMap<String,Object>(16);
 
        if(customerService.updateCustomerByPrimaryKeySelective(customer)) {
            map.put("msg", "更新成功");
            map.put("success", true);
        }else {
            map.put("msg", "更新失败");
            map.put("success", false); 
        }
        return map;
    }
    
    @RequiresPermissions("5004")
    @Operation(name="删除客户")
    @RequestMapping("delete")
    @ResponseBody
    public Map<String, Object> deleteCustomer(int[] ids){
        Map<String, Object> map = new HashMap<String,Object>(16);
        List<Integer> success = new ArrayList<Integer>();
        List<Integer> fail = new ArrayList<Integer>();
        for(int id : ids) {
            if(customerService.deleteByPrimaryKey(id)) {
                success.add(id);
            }else {
                fail.add(id);
            }
        }
        
        map.put("msg", "删除完成");
        map.put("status", true);
        map.put("success", success);
        map.put("fail", fail);
        
        return map;
    }
    
    @RequiresPermissions("7010")
    @Operation(name="id查找客户")
    @RequestMapping("find")
    @ResponseBody
    public Map<String, Object> findCustomer(Integer id){
        Map<String, Object> map = new HashMap<String,Object>(16);
        Customer customer = null;
        
        if(id == null) {
            map.put("msg", "非法操作");
            map.put("success", false); 
            return map;
        }
        
        customer = customerService.selectCustomerByPrimaryKey(id);
        
        if(customer != null) {
            map.put("msg", "查找成功");
            map.put("success", true);
            map.put("data", customer);
        }else {
            map.put("msg", "查找失败");
            map.put("success", false); 
        }
        return map;
    }
    
    
}

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值