CREATE TABLE public.tb_customer_follow (
	id varchar(32) NOT NULL,
	project_id varchar(32) NULL,
	template_part_id varchar(32) NULL,
	review_type varchar(2) NULL DEFAULT 1,
	review_time timestamp NULL,
	remark text NULL,
	file_url text NULL,
	review_user_id text NULL,
	result_status varchar(2) NULL DEFAULT 1,
	sys_org_code varchar(16) NULL,
	create_time timestamp NULL,
	update_time timestamp NULL,
	create_by varchar(32) NULL,
	update_by varchar(32) NULL,
	del_flag int2 NULL DEFAULT 0,
	CONSTRAINT tb_customer_follow_pk PRIMARY KEY (id)
);
COMMENT ON TABLE public.tb_customer_follow IS '客户回访台账';

-- Column comments

COMMENT ON COLUMN public.tb_customer_follow.id IS 'id';
COMMENT ON COLUMN public.tb_customer_follow.project_id IS '所属项目';
COMMENT ON COLUMN public.tb_customer_follow.template_part_id IS '回访模板';
COMMENT ON COLUMN public.tb_customer_follow.review_type IS '回访类型（1上门回访，2电话回访）';
COMMENT ON COLUMN public.tb_customer_follow.review_time IS '回访时间';
COMMENT ON COLUMN public.tb_customer_follow.remark IS '备注';
COMMENT ON COLUMN public.tb_customer_follow.file_url IS '附件';
COMMENT ON COLUMN public.tb_customer_follow.review_user_id IS '回访人';
COMMENT ON COLUMN public.tb_customer_follow.result_status IS '回访结果（0未开始，1未完成，2已完成）';
COMMENT ON COLUMN public.tb_customer_follow.sys_org_code IS '所属机构';
COMMENT ON COLUMN public.tb_customer_follow.create_time IS '创建时间';
COMMENT ON COLUMN public.tb_customer_follow.update_time IS '更新时间';
COMMENT ON COLUMN public.tb_customer_follow.create_by IS '创建人';
COMMENT ON COLUMN public.tb_customer_follow.update_by IS '更新人';
COMMENT ON COLUMN public.tb_customer_follow.del_flag IS '删除标志';

CREATE TABLE public.tb_customer_follow_part (
	id varchar(32) NOT NULL,
	category_name varchar(64) NULL,
	follow_name varchar(64) NULL,
	sort int2 NOT NULL DEFAULT 1,
	template_part_id varchar(32) NULL,
	follow_id varchar(32) NULL,
	pleased_status varchar(2) NULL,
	remark text NULL,
	sys_org_code varchar(16) NULL,
	create_time timestamp NULL,
	update_time timestamp NULL,
	create_by varchar(32) NULL,
	update_by varchar(32) NULL,
	del_flag int2 NULL DEFAULT 0,
	CONSTRAINT tb_customer_follow_part_pk PRIMARY KEY (id)
);
COMMENT ON TABLE public.tb_customer_follow_part IS '客户回访详情';

-- Column comments

COMMENT ON COLUMN public.tb_customer_follow_part.id IS '主键id';
COMMENT ON COLUMN public.tb_customer_follow_part.category_name IS '回访类别';
COMMENT ON COLUMN public.tb_customer_follow_part.follow_name IS '回访题目';
COMMENT ON COLUMN public.tb_customer_follow_part.sort IS '排序';
COMMENT ON COLUMN public.tb_customer_follow_part.template_part_id IS '回访模板详情id';
COMMENT ON COLUMN public.tb_customer_follow_part.follow_id IS '回访台账id';
COMMENT ON COLUMN public.tb_customer_follow_part.pleased_status IS '回访结果（1满意，2不满意）';
COMMENT ON COLUMN public.tb_customer_follow_part.remark IS '备注';
COMMENT ON COLUMN public.tb_customer_follow_part.sys_org_code IS '所属机构';
COMMENT ON COLUMN public.tb_customer_follow_part.create_time IS '创建时间';
COMMENT ON COLUMN public.tb_customer_follow_part.update_time IS '更新时间';
COMMENT ON COLUMN public.tb_customer_follow_part.create_by IS '创建人';
COMMENT ON COLUMN public.tb_customer_follow_part.update_by IS '更新人';
COMMENT ON COLUMN public.tb_customer_follow_part.del_flag IS '删除标志';

ALTER TABLE public.tb_customer_follow ADD follow_no varchar(32) NULL;
COMMENT ON COLUMN public.tb_customer_follow.follow_no IS '回访单号';
ALTER TABLE public.tb_customer_follow ADD source_type varchar(2) NULL DEFAULT 1;
COMMENT ON COLUMN public.tb_customer_follow.source_type IS '来源（1用户，2计划）';

CREATE TABLE public.tb_customer_opinion (
	id varchar(32) NOT NULL,
	project_id varchar(32) NULL,
	register_time timestamp NULL,
	name varchar(64) NULL,
	opinion_type varchar(2) NULL DEFAULT 1,
	propose_name varchar(32) NULL,
	phone varchar(20) NULL,
	registrant text NULL,
	"content" text NULL,
	handle_id varchar(32) NULL,
	file_url text NULL,
	follow_id varchar(32) NULL,
	remark text NULL,
	opinion_status varchar(2) NULL DEFAULT 1,
	sys_org_code varchar(16) NULL,
	create_time timestamp NULL,
	update_time timestamp NULL,
	create_by varchar(32) NULL,
	update_by varchar(32) NULL,
	del_flag int2 NULL DEFAULT 0
);
COMMENT ON TABLE public.tb_customer_opinion IS '客户反馈意见';

-- Column comments

COMMENT ON COLUMN public.tb_customer_opinion.id IS 'id';
COMMENT ON COLUMN public.tb_customer_opinion.project_id IS '所属项目';
COMMENT ON COLUMN public.tb_customer_opinion.register_time IS '登记时间';
COMMENT ON COLUMN public.tb_customer_opinion.name IS '意见标题';
COMMENT ON COLUMN public.tb_customer_opinion.opinion_type IS '意见分类（1客户服务，2服务需求，3其他）';
COMMENT ON COLUMN public.tb_customer_opinion.propose_name IS '提议人';
COMMENT ON COLUMN public.tb_customer_opinion.phone IS '联系电话';
COMMENT ON COLUMN public.tb_customer_opinion.registrant IS '登记人';
COMMENT ON COLUMN public.tb_customer_opinion."content" IS '意见内容';
COMMENT ON COLUMN public.tb_customer_opinion.handle_id IS '处理人';
COMMENT ON COLUMN public.tb_customer_opinion.file_url IS '附件';
COMMENT ON COLUMN public.tb_customer_opinion.follow_id IS '客户回访id';
COMMENT ON COLUMN public.tb_customer_opinion.remark IS '备注';
COMMENT ON COLUMN public.tb_customer_opinion.opinion_status IS '状态（1未完成，2已完成）';
COMMENT ON COLUMN public.tb_customer_opinion.sys_org_code IS '所属机构';
COMMENT ON COLUMN public.tb_customer_opinion.create_time IS '创建时间';
COMMENT ON COLUMN public.tb_customer_opinion.update_time IS '更新时间';
COMMENT ON COLUMN public.tb_customer_opinion.create_by IS '创建人';
COMMENT ON COLUMN public.tb_customer_opinion.update_by IS '更新人';
COMMENT ON COLUMN public.tb_customer_opinion.del_flag IS '删除标志';

ALTER TABLE public.tb_customer_opinion ADD CONSTRAINT tb_customer_opinion_pk PRIMARY KEY (id);
CREATE TABLE public.tb_customer_opinion_handle (
	id varchar(32) NOT NULL,
	opinion_id varchar(32) NULL,
	"content" text NULL,
	handle_time timestamp NULL,
	pleased_status varchar(2) NULL,
	sys_org_code varchar(16) NULL,
	create_time timestamp NULL,
	update_time timestamp NULL,
	create_by varchar(32) NULL,
	update_by varchar(32) NULL,
	del_flag int2 NULL DEFAULT 0,
	CONSTRAINT tb_customer_opinion_handle_pk PRIMARY KEY (id)
);
COMMENT ON TABLE public.tb_customer_opinion_handle IS '客户反馈意见处理';

-- Column comments

COMMENT ON COLUMN public.tb_customer_opinion_handle.id IS 'id';
COMMENT ON COLUMN public.tb_customer_opinion_handle.opinion_id IS '客户意见id';
COMMENT ON COLUMN public.tb_customer_opinion_handle."content" IS '处理方案';
COMMENT ON COLUMN public.tb_customer_opinion_handle.handle_time IS '处理时间';
COMMENT ON COLUMN public.tb_customer_opinion_handle.pleased_status IS '客户满意度（1满意，2不满意）';
COMMENT ON COLUMN public.tb_customer_opinion_handle.sys_org_code IS '所属机构';
COMMENT ON COLUMN public.tb_customer_opinion_handle.create_time IS '创建时间';
COMMENT ON COLUMN public.tb_customer_opinion_handle.update_time IS '更新时间';
COMMENT ON COLUMN public.tb_customer_opinion_handle.create_by IS '创建人';
COMMENT ON COLUMN public.tb_customer_opinion_handle.update_by IS '更新人';
COMMENT ON COLUMN public.tb_customer_opinion_handle.del_flag IS '删除标志';

ALTER TABLE public.tb_vehicle_check_project ALTER COLUMN sort DROP NOT NULL;
ALTER TABLE public.tb_vehicle_check_project ALTER COLUMN check_status DROP NOT NULL;

