3 changed files with 402 additions and 0 deletions
Split View
Diff Options
-
18653项目部署说明书/v2.4.0_sql/1hjz_表创建.sql
-
19153项目部署说明书/v2.4.0_sql/1hjz_视图SQL.sql
-
2553项目部署说明书/v2.4.0_sql/说明.txt
@ -0,0 +1,186 @@ |
|||
/*==============================================================*/ |
|||
/* DBMS name: MySQL 5.0 */ |
|||
/* Created on: 2018/8/24 18:10:25 */ |
|||
/*==============================================================*/ |
|||
drop table if exists consumer_follow_overview; |
|||
|
|||
drop table if exists feedback_order; |
|||
|
|||
drop table if exists follow_detail; |
|||
|
|||
drop table if exists rel_admin_follow_consumer; |
|||
|
|||
drop table if exists service_finish_push_log; |
|||
|
|||
drop table if exists consumer_detail_info; |
|||
|
|||
drop table if exists rel_consumer_merchant; |
|||
|
|||
/*==============================================================*/ |
|||
/* Table: consumer_follow_overview */ |
|||
/*==============================================================*/ |
|||
create table consumer_follow_overview |
|||
( |
|||
id int not null auto_increment, |
|||
follow_no varchar(32) comment '跟进客户编号', |
|||
user_id bigint not null comment '客户id', |
|||
feedback_num int default 0 comment '回访次数', |
|||
follow_num int default 0 comment '跟进次数', |
|||
last_follow_at bigint default 0 comment '最近跟进时间', |
|||
status tinyint default 1 comment '状态:0-待跟进,1-跟进中', |
|||
create_source tinyint comment '来源:1-回访工单,2-用户跟进', |
|||
create_at bigint comment '创建时间', |
|||
create_by varchar(32) comment '创建人', |
|||
update_at bigint comment '更新时间', |
|||
update_by varchar(32) comment '更新人', |
|||
primary key (id) |
|||
); |
|||
|
|||
alter table consumer_follow_overview comment '客户跟进状况'; |
|||
|
|||
/*==============================================================*/ |
|||
/* Table: feedback_order */ |
|||
/*==============================================================*/ |
|||
create table feedback_order |
|||
( |
|||
id int not null auto_increment, |
|||
book_detail_id bigint not null, |
|||
feedback_no varchar(32) comment '回访编号', |
|||
book_no varchar(32) comment '预约编号', |
|||
user_id varchar(32) comment '客户id', |
|||
merchant_no national varchar(32) not null comment '商家编号', |
|||
card_type tinyint default 0 comment '服务卡类型', |
|||
book_time date comment '预约日期', |
|||
book_week tinyint default 0 comment '预约星期', |
|||
time_type tinyint default 0 comment '时间类型', |
|||
address_telephone national varchar(16) comment '联系人号码', |
|||
linkman national varchar(16) comment '联系人姓名', |
|||
cleaner_name national varchar(32) comment '保洁师名称', |
|||
address_id bigint unsigned not null comment '地址id', |
|||
full_address national varchar(128) comment '服务地址', |
|||
channel_id bigint comment '渠道id', |
|||
channel_name varchar(50) comment '渠道名称', |
|||
serviced_cnt int comment '已服务次数', |
|||
total_service_cnt int comment '服务卡总次数', |
|||
created_at bigint unsigned default 0 comment '创建时间', |
|||
created_by national varchar(32) comment '创建者', |
|||
updated_at bigint unsigned default 0 comment '更新时间', |
|||
updated_by national varchar(32) comment '更新者', |
|||
attitude_score int comment '服务态度评分', |
|||
quality_score int comment '服务质量评分', |
|||
efficiency_score int comment '服务速度评分', |
|||
level varchar(10) comment '意愿等级', |
|||
answers_status tinyint default 0 comment '应答状态:0-待处理,1-未接听,2-正常', |
|||
feedback_status tinyint default 0 comment '回访状态:0-未回访,1-已回访', |
|||
feedback_content varchar(255) comment '回访内容', |
|||
feedback_by varchar(32) comment '回访人', |
|||
feedback_at bigint comment '回访时间', |
|||
primary key (id) |
|||
); |
|||
|
|||
alter table feedback_order comment '回访工单'; |
|||
|
|||
/*==============================================================*/ |
|||
/* Table: follow_detail */ |
|||
/*==============================================================*/ |
|||
create table follow_detail |
|||
( |
|||
id int not null auto_increment, |
|||
follow_overview_id int not null, |
|||
follow_no varchar(32) comment '跟进客户编号', |
|||
level varchar(10) comment '意愿等级', |
|||
follow_context varchar(255) comment '跟进内容', |
|||
create_at bigint comment '创建时间', |
|||
create_by varchar(32) comment '创建人', |
|||
primary key (id) |
|||
); |
|||
|
|||
alter table follow_detail comment '跟进明细'; |
|||
|
|||
/*==============================================================*/ |
|||
/* Table: rel_admin_follow_consumer */ |
|||
/*==============================================================*/ |
|||
create table rel_admin_follow_consumer |
|||
( |
|||
id int not null auto_increment, |
|||
follow_overview_id int not null comment '跟进客户id', |
|||
follow_no varchar(32) comment '跟进客户编号', |
|||
admin_id bigint not null comment '跟进人员id', |
|||
status tinyint default 0 comment '跟进状态:1-跟进中,2-已移除', |
|||
feedback_num int default 0 comment '回访次数', |
|||
follow_num int default 0 comment '跟进次数', |
|||
create_source tinyint comment '来源:1-回访工单,2-用户跟进', |
|||
create_at bigint comment '创建时间', |
|||
create_by varchar(32) comment '创建人', |
|||
update_at bigint comment '更新时间', |
|||
update_by varchar(32) comment '更新人', |
|||
primary key (id) |
|||
); |
|||
|
|||
alter table rel_admin_follow_consumer comment '员工与客户跟进情况'; |
|||
|
|||
|
|||
/*==============================================================*/ |
|||
/* Table: service_finish_push_log */ |
|||
/*==============================================================*/ |
|||
create table service_finish_push_log |
|||
( |
|||
id int not null auto_increment, |
|||
book_detail_id bigint not null comment '预约id', |
|||
book_no varchar(32) comment '预约编号', |
|||
feedback_msg varchar(255) comment '回访工单创建信息', |
|||
sms_msg varchar(255) comment '短信推送信息', |
|||
tmpl_msg varchar(255) comment '消息模版推送信息', |
|||
create_dt datetime comment '创建时间', |
|||
code tinyint comment '状态码', |
|||
primary key (id) |
|||
); |
|||
|
|||
alter table service_finish_push_log comment '服务完成推送日志'; |
|||
|
|||
|
|||
/*==============================================================*/ |
|||
/* Table: consumer_detail_info */ |
|||
/*==============================================================*/ |
|||
create table consumer_detail_info |
|||
( |
|||
user_id varchar(32) not null comment '用户id', |
|||
nick_name varchar(50) comment '用户昵称', |
|||
register_at bigint comment '注册时间', |
|||
register_mobile varchar(12) comment '注册手机号', |
|||
level varchar(10) comment '意愿等级', |
|||
channel_no varchar(32) comment '渠道编号', |
|||
channel_name varchar(255) comment '渠道名称', |
|||
card_detail varchar(255) comment '服务卡明细', |
|||
max_card_type tinyint comment '最高等级服务卡类型', |
|||
sum_total_service_cnt int comment '服务卡总次数', |
|||
sum_serviced_cnt int comment '已服务总次数', |
|||
sum_booked_cnt int comment '已预约总次数', |
|||
last_evaluation_status tinyint default 0 comment '最新用户评价状态', |
|||
last_feedback_evaluation_status tinyint default 0 comment '最新回访状态', |
|||
follow_no varchar(32) comment '跟进客户编号', |
|||
feedback_num int default 0 comment '已回访总次数', |
|||
follow_num int default 0 comment '跟进总次数', |
|||
last_follow_at bigint comment '最新跟进时间', |
|||
admin_id varchar(32) comment '跟进人id', |
|||
follow_name varchar(50) comment '跟进人名称', |
|||
primary key (user_id) |
|||
); |
|||
|
|||
alter table consumer_detail_info comment '客户详细信息'; |
|||
|
|||
|
|||
/*==============================================================*/ |
|||
/* Table: rel_consumer_merchant */ |
|||
/*==============================================================*/ |
|||
create table rel_consumer_merchant |
|||
( |
|||
user_id varchar(32) not null, |
|||
merchant_no varchar(100), |
|||
primary key (user_id) |
|||
); |
|||
|
|||
alter table rel_consumer_merchant comment '客户商户关系'; |
|||
|
|||
-- 更新用户表level字段类型 |
|||
alter table consumer_info modify column level varchar(10) comment '意愿等级' |
|||
@ -0,0 +1,191 @@ |
|||
-- 用户基本信息视图 |
|||
CREATE VIEW consumer_base_info_view AS |
|||
SELECT |
|||
t1.*, cl.channel_name |
|||
FROM |
|||
( |
|||
SELECT |
|||
c.user_id, |
|||
c.nick_name, |
|||
c.created_at register_at, |
|||
c.mobile register_mobile, |
|||
c.level, |
|||
c.channel_no |
|||
FROM |
|||
consumer_info c |
|||
LEFT JOIN `user` u ON c.user_id = u.user_id |
|||
) t1 |
|||
LEFT JOIN channel cl ON t1.channel_no = cl.channel_no; |
|||
|
|||
-- 创建用户服务卡视图 |
|||
CREATE VIEW consumer_service_card_view AS |
|||
SELECT |
|||
t1.user_id, |
|||
t1.card_detail, |
|||
t2.max_card_type, |
|||
t2.sum_total_service_cnt, |
|||
t2.sum_serviced_cnt, |
|||
t2.sum_booked_cnt |
|||
FROM |
|||
( |
|||
SELECT |
|||
user_id, |
|||
GROUP_CONCAT(card_name, ':', card_cnt) card_detail |
|||
FROM |
|||
( |
|||
SELECT |
|||
user_id, |
|||
CASE card_type |
|||
WHEN 10 THEN |
|||
'单次卡' |
|||
WHEN 20 THEN |
|||
'月卡' |
|||
WHEN 30 THEN |
|||
'季卡' |
|||
WHEN 40 THEN |
|||
'半年卡' |
|||
WHEN 50 THEN |
|||
'年卡' |
|||
ELSE |
|||
'' |
|||
END AS card_name, |
|||
COUNT(card_type) AS card_cnt |
|||
FROM |
|||
service_card |
|||
GROUP BY |
|||
user_id, |
|||
card_type |
|||
) ot |
|||
GROUP BY |
|||
user_id |
|||
) t1, |
|||
( |
|||
SELECT |
|||
user_id, |
|||
MAX(card_type) max_card_type, |
|||
SUM(total_service_cnt) sum_total_service_cnt, |
|||
SUM(booked_cnt) sum_booked_cnt, |
|||
SUM(serviced_cnt) sum_serviced_cnt |
|||
FROM |
|||
service_card -- WHERE sc.user_id = '180515171015928100' |
|||
GROUP BY |
|||
user_id |
|||
) t2 |
|||
WHERE |
|||
t1.user_id = t2.user_id; |
|||
|
|||
-- 创建用户服务评价视图 |
|||
CREATE VIEW service_evaluation_view AS |
|||
SELECT |
|||
*, |
|||
IF ( |
|||
( |
|||
time_score + service_score + profession_score = '15' |
|||
AND content != '' |
|||
), |
|||
1, |
|||
0 |
|||
) evaluation_status |
|||
FROM |
|||
service_evaluation; |
|||
|
|||
-- 创建人员回访列表视图 |
|||
CREATE VIEW feedback_order_view AS |
|||
SELECT |
|||
f.*, |
|||
IF ( |
|||
( |
|||
attitude_score + quality_score + efficiency_score = '15' |
|||
AND feedback_content != '' |
|||
), |
|||
1, |
|||
0 |
|||
) feedback_evaluation_status, |
|||
a.nick_name feedback_name |
|||
FROM |
|||
feedback_order f |
|||
LEFT JOIN admin_info a ON f.feedback_by = a.user_id; |
|||
|
|||
-- 创建客户商家关系视图 |
|||
CREATE VIEW rel_consumer_merchant_view AS |
|||
SELECT t3.user_id, |
|||
IF ( |
|||
t3.merchant_no = t4.coupon_merchant_no, |
|||
t3.merchant_no, |
|||
GROUP_CONCAT( |
|||
t3.merchant_no, |
|||
'&', |
|||
t4.coupon_merchant_no |
|||
) |
|||
) merchant_no |
|||
FROM |
|||
( |
|||
SELECT |
|||
t1.user_id, |
|||
IF ( |
|||
t1.order_merchant = t2.card_merchant_no, |
|||
t1.order_merchant, |
|||
GROUP_CONCAT( |
|||
t1.order_merchant, |
|||
'&', |
|||
t2.card_merchant_no |
|||
) |
|||
) merchant_no |
|||
FROM |
|||
( |
|||
select t.user_id, GROUP_CONCAT(t.merchant_no ORDER BY t.merchant_no asc separator '&') order_merchant from |
|||
( |
|||
select DISTINCT c.user_id, v.merchant_no FROM consumer_info c, vorder v |
|||
WHERE c.user_id = v.user_id |
|||
GROUP BY c.user_id, v.merchant_no |
|||
) t |
|||
|
|||
GROUP BY t.user_id |
|||
) t1, |
|||
( |
|||
select t.user_id, GROUP_CONCAT(t.merchant_no ORDER BY t.merchant_no asc separator '&') card_merchant_no FROM |
|||
( |
|||
select DISTINCT c.user_id, s.merchant_no FROM consumer_info c, service_card s |
|||
WHERE c.user_id = s.user_id |
|||
|
|||
GROUP BY c.user_id,s.merchant_no |
|||
) t |
|||
|
|||
GROUP BY t.user_id |
|||
) t2 |
|||
where t1.user_id = t2.user_id |
|||
GROUP BY t1.user_id |
|||
) t3, |
|||
( |
|||
select t.user_id, GROUP_CONCAT(t.merchant_no ORDER BY t.merchant_no asc separator '&') coupon_merchant_no FROM |
|||
( |
|||
select DISTINCT c.user_id, cp.merchant_no FROM consumer_info c, coupon cp |
|||
WHERE c.user_id = cp.user_id |
|||
|
|||
GROUP BY c.user_id,cp.merchant_no |
|||
) t |
|||
|
|||
GROUP BY t.user_id |
|||
) t4 |
|||
WHERE t3.user_id = t4.user_id |
|||
GROUP BY t3.user_id; |
|||
|
|||
-- 创建服务卡与预约明细关系视图 |
|||
CREATE VIEW rel_service_card_book_detail AS SELECT |
|||
s.card_no, |
|||
s.card_name, |
|||
b.book_no |
|||
FROM |
|||
service_card s, |
|||
book_detail b |
|||
WHERE |
|||
s.card_no = b.card_no; |
|||
|
|||
|
|||
-- SELECT * FROM CONSUMER_BASE_INFO_VIEW; |
|||
-- SELECT * FROM CONSUMER_SERVICE_CARD_VIEW; |
|||
-- SELECT * FROM FEEDBACK_ORDER_VIEW; |
|||
-- SELECT * FROM REL_CONSUMER_MERCHANT_VIEW; |
|||
-- SELECT * FROM SERVICE_EVALUATION_VIEW; |
|||
-- SELECT * FROM REL_SERVICE_CARD_BOOK_DETAIL; |
|||
|
|||
@ -0,0 +1,25 @@ |
|||
1、数据库备份 |
|||
2、执行创建表SQL脚本 |
|||
3、执行视图SQL脚本 |
|||
4、添加菜单,权限 |
|||
5、手动生成客户跟进列表数据,在系统更新脚本中 |
|||
|
|||
|
|||
-- 菜单管理 |
|||
-- 回访管理,'/admin/web/evaluateList',193,194,195 |
|||
-- 跟进管理,'/admin/web/myFollowUp',196,197,198,199 |
|||
|
|||
|
|||
|
|||
-- 功能权限数据插入 |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('193', '获取回访工单列表', '/admin/web/feedbackOrders', 'GET', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('194', '编辑回访工单', '(/admin/web/feedbackOrders/).*', 'PUT', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('195', '添加我的跟进', '(/admin/web/consumer).*(/follow)', 'POST', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('196', '获取跟进列表', '/admin/web/followConsumers', 'GET', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('197', '添加跟进记录', '(/admin/web/followConsumers/).*(/records)', 'POST', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('198', '移除我的跟进', '(/admin/web/consumer).*(/follow)', 'DELETE', '0', '0'); |
|||
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('199', '获取用户轨迹', '(admin/web/consumer).*(/traces)', 'GET', '0', '0'); |
|||
|
|||
|
|||
|
|||
|
|||
Write
Preview
Loading…
Cancel
Save