CRM Customer Relationship Management System Based on Servlet

1. Demand analysis

Customers are the most valuable resources of the company. In order to better explore the value of old customers and develop more new customers, the company implements a customer relationship management system. The function of the system is: complete the full sharing and standardized management of employee basic information, customer basic information, communication information, and customer service information through this system; improve the ability to develop new customers by tracking and recording sales opportunities and customer development processes ; When the customer is about to lose, the system gives a timely warning, so that the sales staff can take timely measures to reduce the loss.

The level of customer service determines the core competitiveness of the company. The customer relationship management system provides an online platform for customer service, enabling relevant personnel in the process of customer service processing to complete service processing and recording work online.

1.1 Analysis of Functional Requirements

The purpose of functional requirements analysis is to plan and design each module and each small function point within the module, and prepare for the information foundation for subsequent development. According to the collected user inquiries and feedback, it is necessary to design the overall layout of the front end and back end of the system.

This customer relationship management system aims to provide all users with the following functions:

(1) It is necessary to conduct unified management of enterprise information in order to improve the company's management standards and make personnel information management more standardized;

(2) When enterprise users discover new customers, they need to enter the customers into the system and manage the customer contacts, so as to facilitate follow-up visits to customers;

(3) When the employees of the enterprise visit the customer, they need to enter the visit information into the system to facilitate the management of their own tracking of the customer; it is also convenient for the system to remind themselves of the time of the next visit to the customer, and the current status of the customer can be analyzed according to each visit record wait;

(4) According to the existing data of the system, the visual statistical chart is presented, and the results are presented with pictures and texts, so that managers can clearly see the data they are interested in.

1.2 User needs analysis

CRM system refers to the use of information technology to manage customers and visit records, so as to improve work efficiency, performance and company management level. Therefore, to develop a customer relationship management system, it is first necessary to clarify the functions that the entire system needs to realize at this stage. This system is mainly used by enterprise users.

After the user logs in, he can perform customer management, contact management, visit customers, and statistics viewing operations.

(1) User login

Users who enter the correct user name and password can log in successfully and automatically obtain the corresponding access rights granted. Logout should remove the user status.

(2) User functions

·Customer management

Add, delete, modify, and check customer information.

·Contact management

Add, delete, modify and check contacts.

·Visit Tracking

Record and inquire about the visit tracking information of the entered customers.

·statistics

Visual statistical display of information by source, industry, etc.

2. ER diagram and relational schema design

2.1 ER Diagram

2.1.1 Entity Analysis Description

From the user's point of view, the needs of the database are mainly reflected in the addition, deletion, modification and query of database tables. Therefore, the database structure needs to meet two elements at the same time: input and output. When doing data design, you first need to collect data, then analyze the data structure, and finally process the data. According to the requirements of this system, the following main data items and data structures are designed:

(1) User entity: user id, user account, user name, user password, user status.

(2) Contact entity: contact number, contact name, customer id, contact gender, contact office phone, contact mobile phone, contact email, contact qq, contact position, contact notes.

(3) Customer entity: customer number, customer name (company name), source of customer information, industry to which the customer belongs, customer level, fixed telephone, mobile telephone.

(4) Customer details entity: customer number, customer region, customer zip code, customer contact address, customer fax, customer website, customer business license registration number, corporate legal person, customer registered capital, bank and account number, customer qualification picture, customer profile.

(5) Data dictionary entity: data dictionary id, data dictionary category code, data dictionary category name, data dictionary item name, data dictionary item, sorting field, status, remarks.

2.1.2 Entity ER Diagram

The user entity is shown in Figure 1.1.

Figure 1.1 User entity

The Contact entity is shown in Figure 1.2.

Figure 1.2 Contact entity

The customer entity is shown in Figure 1.3.

Figure 1.3 Customer entity

The customer details entity is shown in Figure 1.4.

Figure 1.4 Customer Details Entity

2.1.3 Overall ER Diagram

Figure 1.5 Overall ER Diagram

2. 2 Relational schema

Relationship mode: user information (user id, user account, user name, user password, user status)

Mode determination: user information ∈ 2NF, and each non-primary attribute does not transfer function depends on employee informationThe primary relationship key of information, so user information ∈ 3NF

Relationship mode: contact information (contact number, contact name, customer id, contact gender, contact office phone, contact mobile phone, contact email, contact qq, contact position, contact note)

Mode judgment: contact information ∈ 2NF, and each non-primary attribute does not transfer function depends on the primary relationship key of department information, so contact information ∈ 3NF

Relationship model: customer information (customer number, customer name (company name), customer information source, customer industry, customer level, fixed phone, mobile phone)

Mode determination: customer information ∈ 2NF, and each non-primary attribute does not transfer function dependent on the primary relationship key of salary information, so customer information ∈ 3NF

Relationship model: customer details (customer number, customer region, customer zip code, customer contact address, customer fax, customer website, customer business license registration number, corporate legal person, customer registered capital, bank and account number, customer qualification picture, customer Introduction)

Mode judgment: customer details ∈ 2NF, and each non-primary attribute does not transfer function depends on the primary relationship key of attendance information, so customer details ∈ 3NF

Relational mode: data dictionary information (data dictionary id, data dictionary category code, data dictionary category name, data dictionary item name, data dictionary item, sort field, status, remarks)

Mode determination: data dictionary information ∈ 2NF, and each non-primary attribute does not transfer the primary relationship key whose function depends on allowance information, so data dictionary information ∈ 3NF

Relationship mode: customer visit information (customer visit id, customer id, user id, visit time, visit address, visit details, next visit time)

Mode determination: customer visit information ∈ 2NF, and each non-primary attribute does not transfer function dependent on the primary relationship key of the subsidy information, so the data dictionary information ∈ 3NF

2.3 Database table structure

Table 2.1 user table sys_user

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

user id

user_id

bigint

0

not allowed

yes

user account

user_code

varchar

32

allow

no

user name

user_name

varchar

64

allow

no

user password

user_password

varchar

32

allow

no

user status

user_state

varchar

2

allow

no

Table 2.2 Contact table cst_linkman

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

contact number

lkm_id

int

0

not allowed

yes

Contact name

lkm_name

varchar

16

allow

no

customer id

lkm_cust_id

bigint

16

allow

no

Contact gender

lkm_gender

varchar

0

allow

no

Contact Office Phone

lkm_phone

varchar

16

allow

no

contact phone

lkm_mobile

varchar

16

allow

no

Contact email

lkm_email

varchar

16

allow

no

Contact qq

lkm_qq

varchar

16

allow

no

contact position

lkm_position

varchar

16

allow

no

contact notes

lkm_memo

varchar

512

allow

no

Table 2.3 Customer table cst_customer

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

Customer Number

cust_id

int

0

not allowed

yes

Customer name (company name)

cust_name

varchar

32

allow

no

Customer Information Sources

cust_source

varchar

32

allow

no

Customer's industry

cust_industry

varchar

32

allow

no

customer level

cust_level

varchar

32

allow

no

Fixed telephone

cust_phone

varchar

32

allow

no

mobile phone

cust_mobile

varchar

32

allow

no

Table 2.4 Customer Details Table cst_customer_detail

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

Customer Number

cust_id

int

0

not allowed

yes

Customer area

cust_region

varchar

64

allow

no

Customer zip code

cust_zip

varchar

16

allow

no

Customer contact address

cust_address

varchar

128

allow

no

customer fax

cust_fax

varchar

64

allow

no

Customer URL

cust_website

varchar

128

allow

no

Customer business license registration number

cust_licence

varchar

64

allow

no

Corporate

cust_corporation

varchar

64

allow

no

Customer registered capital

cust_capital

bigint

0

allow

no

Opening bank and account number

cust_bank

varchar

20

allow

no

Customer qualification picture

cust_pic

varchar

64

allow

no

Customer Profile

cust_memo

longtext

0

allow

no

Table 2.5 Basic data dictionary table base_dict

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

data dictionary id

dict_id

int

0

not allowed

yes

Data Dictionary Category Code

dict_type_code

varchar

32

allow

no

Data dictionary category name

dict_type_name

varchar

10

allow

no

Data Dictionary Item Name

dict_item_name

varchar

64

allow

no

Data Dictionary Project

dict_item_code

varchar

64

allow

no

sort field

dict_sort

varchar

10

allow

no

state

dict_enable

varchar

1

allow

no

Remark

dict_memo

varchar

64

allow

no

Table 2.6 Customer visit table sale_visit

attribute name

field name

type of data

length

Is it allowed to be empty

Whether primary key

customer visit id

visit_id

int

0

not allowed

yes

customer id

visit_cust_id

bigint

0

allow

no

user id

visit_user_id

bigint

0

allow

no

visiting hours

visit_time

date

0

allow

no

visiting address

visit_addr

varchar

128

allow

no

Visit Details

visit_detail

varchar

256

allow

no

next visit time

visit_nexttime

date

0

allow

no

3. Realize the effect

(1) login

(2) System main interface

(3) New customers

 (4) Customer list

(5) Add new contacts

 (6) Contact list

(7) New customer visit

(8) Customer visit list

4.数据库核心

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for base_dict
-- ----------------------------
DROP TABLE IF EXISTS `base_dict`;
CREATE TABLE `base_dict`  (
  `dict_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典id(主键)',
  `dict_type_code` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典类别代码',
  `dict_type_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典类别名称',
  `dict_item_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典项目名称',
  `dict_item_code` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据字典项目(可为空)',
  `dict_sort` int(10) NULL DEFAULT NULL COMMENT '排序字段',
  `dict_enable` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '1:使用 0:停用',
  `dict_memo` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of base_dict
-- ----------------------------
INSERT INTO `base_dict` VALUES ('1', '001', '客户行业', '教育培训 ', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('10', '003', '公司性质', '民企', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('12', '004', '年营业额', '1-10万', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('13', '004', '年营业额', '10-20万', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('14', '004', '年营业额', '20-50万', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('15', '004', '年营业额', '50-100万', NULL, 4, '1', NULL);
INSERT INTO `base_dict` VALUES ('16', '004', '年营业额', '100-500万', NULL, 5, '1', NULL);
INSERT INTO `base_dict` VALUES ('17', '004', '年营业额', '500-1000万', NULL, 6, '1', NULL);
INSERT INTO `base_dict` VALUES ('18', '005', '客户状态', '基础客户', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('19', '005', '客户状态', '潜在客户', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('2', '001', '客户行业', '电子商务', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('20', '005', '客户状态', '成功客户', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('21', '005', '客户状态', '无效客户', NULL, 4, '1', NULL);
INSERT INTO `base_dict` VALUES ('22', '006', '客户级别', '普通客户', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('23', '006', '客户级别', 'VIP客户', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('24', '007', '商机状态', '意向客户', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('25', '007', '商机状态', '初步沟通', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('26', '007', '商机状态', '深度沟通', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('27', '007', '商机状态', '签订合同', NULL, 4, '1', NULL);
INSERT INTO `base_dict` VALUES ('3', '001', '客户行业', '对外贸易', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('30', '008', '商机类型', '新业务', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('31', '008', '商机类型', '现有业务', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('32', '009', '商机来源', '电话营销', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('33', '009', '商机来源', '网络营销', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('34', '009', '商机来源', '推广活动', NULL, 3, '1', NULL);
INSERT INTO `base_dict` VALUES ('4', '001', '客户行业', '酒店旅游', NULL, 4, '1', NULL);
INSERT INTO `base_dict` VALUES ('5', '001', '客户行业', '房地产', NULL, 5, '1', NULL);
INSERT INTO `base_dict` VALUES ('6', '002', '客户信息来源', '电话营销', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('7', '002', '客户信息来源', '网络营销', NULL, 2, '1', NULL);
INSERT INTO `base_dict` VALUES ('8', '003', '公司性质', '合资', NULL, 1, '1', NULL);
INSERT INTO `base_dict` VALUES ('9', '003', '公司性质', '国企', NULL, 2, '1', NULL);

SET FOREIGN_KEY_CHECKS = 1;

5.核心代码

public class BaseDao {
    //驱动
    private static String driver = "com.mysql.jdbc.Driver";
    //url
    private static String url = "jdbc:mysql://localhost:3306/crm?characterEncoding=utf-8";
    //用户名
    private static String username = "root";
    //密码
    private static String pwd = "root";


    /**
     * 创建连接
     * @return
     */
    public static Connection getConnection(){
        Connection connection=null;
        //加载驱动
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //建立连接获取Connection对象
        try {
            connection= DriverManager.getConnection(url,username,pwd);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }

    /**
     * 关闭链接
     * @param connection
     * @param statement
     * @param resultSet
     */
    public static void closeAll(Connection connection, Statement statement, ResultSet resultSet){

        try {
            if(resultSet!=null){
                resultSet.close();
            }

            if(statement!=null){
                statement.close();
            }
            if (connection!=null){
                connection.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    /**
     * 执行增、删、改的方法
     * @param sql
     * @return
     */
    public static int execute(String sql){
        //获取链接
        Connection connection=getConnection();
        int flag=0;
        try {
            //创建Statement对象
            Statement statement=connection.createStatement();
            //执行sql语句
            flag=statement.executeUpdate(sql);
            //关闭链接
            closeAll(connection,statement,null);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return flag;
    }
    /*
      测试
     */
    public static void main(String[] args) {
        String sql = "SELECT * FROM `cm_cst`.`base_dict`  WHERE dict_id = 1";
        Connection connection = getConnection();
        Statement statement = null;
        try {
            statement= connection.createStatement();
            ResultSet resultSet = statement.executeQuery(sql);
            while(resultSet.next()){
                String typename = resultSet.getString(3);
                System.out.println("类别名称"+typename);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}

Guess you like

Origin blog.csdn.net/lf21qp/article/details/131509025