| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613 |
- /*
- Navicat Premium Dump SQL
- Source Server : 121.43.228.102 hn02le.34lkdLKD
- Source Server Type : MySQL
- Source Server Version : 50736 (5.7.36)
- Source Host : 121.43.228.102:3306
- Source Schema : sx
- Target Server Type : MySQL
- Target Server Version : 50736 (5.7.36)
- File Encoding : 65001
- Date: 09/05/2026 22:57:41
- */
- SET NAMES utf8mb4;
- SET FOREIGN_KEY_CHECKS = 0;
- -- ----------------------------
- -- Table structure for crm_clue
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_clue`;
- CREATE TABLE `crm_clue` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `clue_name` varchar(100) NOT NULL COMMENT '线索姓名',
- `mobile` varchar(20) NOT NULL COMMENT '手机号',
- `company` varchar(200) DEFAULT NULL COMMENT '公司名称',
- `customer_type` varchar(20) DEFAULT NULL COMMENT '客户类型(company-企业/person-个人)',
- `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
- `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
- `title` varchar(10) DEFAULT NULL COMMENT '称呼(先生/女士/其他)',
- `position` varchar(50) DEFAULT NULL COMMENT '职位',
- `source` varchar(20) NOT NULL COMMENT '线索来源(网站留言/电话咨询/展会/市场活动/老客户推荐/广告投放/社交媒体/其他)',
- `level` varchar(10) DEFAULT 'unrated' COMMENT '线索等级(A/B/C/unrated)',
- `industry` varchar(50) DEFAULT NULL COMMENT '所属行业',
- `park_area` varchar(100) DEFAULT NULL COMMENT '所在园区',
- `province` varchar(50) DEFAULT NULL COMMENT '省',
- `city` varchar(50) DEFAULT NULL COMMENT '市',
- `district` varchar(50) DEFAULT NULL COMMENT '区',
- `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
- `website` varchar(500) DEFAULT NULL COMMENT '客户网站',
- `intent_products` varchar(500) DEFAULT NULL COMMENT '意向产品(多个用逗号分隔)',
- `expect_time` date DEFAULT NULL COMMENT '预计购买时间',
- `budget` varchar(20) DEFAULT NULL COMMENT '预算范围(1万以下/1-5万/5-10万/10-50万/50万以上/未知)',
- `requirement` text COMMENT '需求描述',
- `status` varchar(20) DEFAULT 'new' COMMENT '线索状态(new-新线索/follow-跟进中/invalid-无效/converted-已转化)',
- `owner_user_id` bigint(20) DEFAULT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数',
- `is_converted` tinyint(1) DEFAULT '0' COMMENT '是否已转化(0-否 1-是)',
- `converted_time` datetime DEFAULT NULL COMMENT '转化时间',
- `customer_id` bigint(20) DEFAULT NULL COMMENT '转化的客户ID',
- `converted_by` bigint(20) DEFAULT NULL COMMENT '转化操作人',
- `assign_time` datetime DEFAULT NULL COMMENT '分配时间',
- `assign_by` bigint(20) DEFAULT NULL COMMENT '分配人',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_mobile` (`mobile`) USING BTREE,
- KEY `idx_owner` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_level` (`level`) USING BTREE,
- KEY `idx_source` (`source`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE,
- KEY `idx_park_area` (`park_area`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-线索主表';
- -- ----------------------------
- -- Table structure for crm_clue_follow
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_clue_follow`;
- CREATE TABLE `crm_clue_follow` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `clue_id` bigint(20) NOT NULL COMMENT '线索ID',
- `clue_name` varchar(100) DEFAULT NULL COMMENT '线索姓名(冗余)',
- `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(电话/微信/邮件/拜访/其他)',
- `follow_content` text NOT NULL COMMENT '跟进内容',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
- `create_by_name` varchar(50) DEFAULT NULL COMMENT '跟进人姓名(冗余)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_clue_id` (`clue_id`) USING BTREE,
- KEY `idx_create_by` (`create_by`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-线索跟进记录表';
- -- ----------------------------
- -- Table structure for crm_contact
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contact`;
- CREATE TABLE `crm_contact` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
- `contact_name` varchar(100) NOT NULL COMMENT '联系人姓名',
- `gender` varchar(10) DEFAULT NULL COMMENT '性别(male-男/female-女)',
- `mobile` varchar(20) DEFAULT NULL COMMENT '手机号',
- `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
- `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
- `wechat` varchar(100) DEFAULT NULL COMMENT '微信号',
- `qq` varchar(20) DEFAULT NULL COMMENT 'QQ号',
- `department` varchar(100) DEFAULT NULL COMMENT '部门',
- `position` varchar(50) DEFAULT NULL COMMENT '职位',
- `role` varchar(20) DEFAULT NULL COMMENT '角色(decision-决策人/manager-管理者/user-使用者/other-其他)',
- `birthday` date DEFAULT NULL COMMENT '生日',
- `address` varchar(255) DEFAULT NULL COMMENT '住址',
- `is_key` tinyint(1) DEFAULT '0' COMMENT '是否关键决策人(0-否 1-是)',
- `is_primary` tinyint(1) DEFAULT '0' COMMENT '是否主要联系人(0-否 1-是)',
- `status` varchar(20) DEFAULT 'active' COMMENT '状态(active-在职/leave-离职)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_mobile` (`mobile`) USING BTREE,
- KEY `idx_is_key` (`is_key`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2048203394065793027 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-联系人表';
- -- ----------------------------
- -- Table structure for crm_contract
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract`;
- CREATE TABLE `crm_contract` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `contract_no` varchar(50) NOT NULL COMMENT '合同编号(CON+yyyyMMdd+4位流水号)',
- `contract_name` varchar(200) NOT NULL COMMENT '合同名称',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `opportunity_id` bigint(20) DEFAULT NULL COMMENT '商机ID',
- `quote_id` bigint(20) DEFAULT NULL COMMENT '报价单ID',
- `parent_contract_id` bigint(20) DEFAULT NULL COMMENT '原合同ID(续签时关联)',
- `renewal_count` int(11) DEFAULT '0' COMMENT '续签次数',
- `template_id` bigint(20) DEFAULT NULL COMMENT '合同模板ID',
- `contract_template` varchar(50) DEFAULT 'shanxia' COMMENT '合同模版(shanxia-山峡模版/customer-客户模版)',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
- `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机(冗余字段)',
- `contract_type` varchar(20) NOT NULL DEFAULT 'sale' COMMENT '合同类型(sale-销售合同/service-服务合同/lease-租赁合同/other-其他)',
- `contract_nature` varchar(20) DEFAULT 'new' COMMENT '合同性质(new-新签/renewal-续签/change-变更)',
- `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '合同金额',
- `currency` varchar(10) DEFAULT 'CNY' COMMENT '币种(CNY-人民币/USD-美元/EUR-欧元)',
- `tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '税率(%)',
- `amount_with_tax` decimal(15,2) DEFAULT '0.00' COMMENT '含税金额',
- `sign_date` date DEFAULT NULL COMMENT '签订日期',
- `actual_sign_date` date DEFAULT NULL COMMENT '实际签订日期',
- `start_date` date DEFAULT NULL COMMENT '开始日期',
- `end_date` date DEFAULT NULL COMMENT '结束日期',
- `contract_period` int(11) DEFAULT NULL COMMENT '合同期限(月)',
- `status` varchar(20) NOT NULL DEFAULT 'draft' COMMENT '合同状态(draft-草稿/approving-审批中/approved-已审批/executing-执行中/finished-已完成/invalid-已作废)',
- `performance_status` varchar(20) DEFAULT 'normal' COMMENT '履约状态(normal-正常/delayed-延期/abnormal-异常/completed-已完成)',
- `performance_rate` decimal(5,2) DEFAULT '0.00' COMMENT '履约完成度(%)',
- `customer_satisfaction` int(11) DEFAULT NULL COMMENT '客户满意度(1-5星)',
- `approval_status` varchar(20) DEFAULT NULL COMMENT '审批状态(pending-待审批/approved-已通过/rejected-已驳回)',
- `approval_flow_id` bigint(20) DEFAULT NULL COMMENT '审批流程ID(关联工作流)',
- `contract_file` varchar(500) DEFAULT NULL COMMENT '合同文件路径(扫描件或电子版)',
- `attachment_files` varchar(1000) DEFAULT NULL COMMENT '附件文件(多个文件用逗号分隔)',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `received_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已回款金额',
- `unreceived_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未回款金额',
- `invoice_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已开票金额',
- `uninvoice_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未开票金额',
- `party_a` varchar(200) DEFAULT NULL COMMENT '甲方(客户方)',
- `party_a_address` varchar(255) DEFAULT NULL COMMENT '甲方地址',
- `party_a_contact` varchar(50) DEFAULT NULL COMMENT '甲方联系人',
- `party_a_mobile` varchar(20) DEFAULT NULL COMMENT '甲方联系电话',
- `party_a_legal_person` varchar(50) DEFAULT NULL COMMENT '甲方法定代表人',
- `party_a_agent` varchar(50) DEFAULT NULL COMMENT '甲方代理人',
- `party_a_phone_fax` varchar(50) DEFAULT NULL COMMENT '甲方电话/传真',
- `party_a_bank` varchar(100) DEFAULT NULL COMMENT '甲方开户银行',
- `party_a_account` varchar(50) DEFAULT NULL COMMENT '甲方银行账号',
- `party_b` varchar(200) DEFAULT NULL COMMENT '乙方(我方)',
- `party_b_address` varchar(255) DEFAULT NULL COMMENT '乙方地址',
- `party_b_contact` varchar(50) DEFAULT NULL COMMENT '乙方联系人',
- `party_b_mobile` varchar(20) DEFAULT NULL COMMENT '乙方联系电话',
- `party_b_legal_person` varchar(100) DEFAULT NULL COMMENT '乙方法定代表人',
- `party_b_agent` varchar(100) DEFAULT NULL COMMENT '乙方代理人',
- `party_b_phone_fax` varchar(100) DEFAULT NULL COMMENT '乙方电话/传真',
- `party_b_bank` varchar(200) DEFAULT NULL COMMENT '乙方开户银行',
- `party_b_account` varchar(100) DEFAULT NULL COMMENT '乙方银行账号',
- `payment_terms` text COMMENT '付款条款',
- `delivery_terms` text COMMENT '交付条款',
- `contract_terms` text COMMENT '合同条款',
- `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
- `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `template_content` longtext COMMENT '合同模板内容(富文本HTML)',
- `settlement_clause_drafts` longtext COMMENT '第五条结算方式草稿(按结算方式区分的JSON)',
- `supplier_id` bigint(20) DEFAULT NULL COMMENT '供方主体ID(关联crm_supplier_info表)',
- `settlement_method` varchar(50) DEFAULT NULL COMMENT '结算方式(arrive_payment-货到付款,advance_payment-款到发货)',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_contract_no_del_flag` (`contract_no`,`del_flag`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
- KEY `idx_quote_id` (`quote_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_approval_status` (`approval_status`) USING BTREE,
- KEY `idx_sign_date` (`sign_date`) USING BTREE,
- KEY `idx_end_date` (`end_date`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_contract_nature` (`contract_nature`) USING BTREE,
- KEY `idx_parent_contract_id` (`parent_contract_id`) USING BTREE,
- KEY `idx_performance_status` (`performance_status`) USING BTREE,
- KEY `idx_supplier_id` (`supplier_id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=2052978521227886595 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同主表';
- -- ----------------------------
- -- Table structure for crm_contract_approval
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract_approval`;
- CREATE TABLE `crm_contract_approval` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `flow_id` bigint(20) DEFAULT NULL COMMENT '审批流程ID(关联工作流)',
- `step` int(11) NOT NULL DEFAULT '1' COMMENT '审批步骤(第几步)',
- `step_name` varchar(100) DEFAULT NULL COMMENT '步骤名称',
- `approver_id` bigint(20) NOT NULL COMMENT '审批人ID',
- `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
- `approver_dept` varchar(100) DEFAULT NULL COMMENT '审批人部门',
- `approval_result` varchar(20) DEFAULT 'pending' COMMENT '审批结果(pending-待审批/approved-已通过/rejected-已驳回)',
- `approval_opinion` text COMMENT '审批意见',
- `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
- `approval_duration` int(11) DEFAULT NULL COMMENT '审批耗时(小时)',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件',
- `is_current` tinyint(1) DEFAULT '1' COMMENT '是否当前步骤(0否 1是)',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_approver_id` (`approver_id`) USING BTREE,
- KEY `idx_approval_result` (`approval_result`) USING BTREE,
- KEY `idx_is_current` (`is_current`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2049366907144601602 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同审批记录表';
- -- ----------------------------
- -- Table structure for crm_contract_change
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract_change`;
- CREATE TABLE `crm_contract_change` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余)',
- `change_type` varchar(50) NOT NULL COMMENT '变更类型(amount-金额变更/period-期限变更/product-产品变更/terms-条款变更/other-其他)',
- `change_reason` varchar(500) NOT NULL COMMENT '变更原因',
- `change_content` text COMMENT '变更内容描述',
- `old_value` text COMMENT '变更前值(JSON格式)',
- `new_value` text COMMENT '变更后值(JSON格式)',
- `change_amount` decimal(15,2) DEFAULT NULL COMMENT '变更金额(用于金额变更)',
- `approval_status` varchar(20) DEFAULT 'pending' COMMENT '审批状态(pending-待审批/approved-已通过/rejected-已驳回)',
- `approver_id` bigint(20) DEFAULT NULL COMMENT '审批人ID',
- `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
- `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
- `approval_opinion` varchar(500) DEFAULT NULL COMMENT '审批意见',
- `attachment_files` varchar(1000) DEFAULT NULL COMMENT '附件文件(变更协议等)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_change_type` (`change_type`) USING BTREE,
- KEY `idx_approval_status` (`approval_status`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同变更记录表';
- -- ----------------------------
- -- Table structure for crm_contract_product
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract_product`;
- CREATE TABLE `crm_contract_product` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `product_name` varchar(200) NOT NULL COMMENT '产品名称',
- `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号',
- `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
- `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称',
- `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
- `unit` varchar(20) DEFAULT '件' COMMENT '单位',
- `quantity` decimal(20,4) NOT NULL COMMENT '数量',
- `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价',
- `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比)',
- `tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '税率(%)',
- `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税费金额',
- `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '小计金额',
- `delivery_date` date DEFAULT NULL COMMENT '交付日期',
- `delivery_status` varchar(20) DEFAULT 'pending' COMMENT '交付状态(pending-待交付/partial-部分交付/delivered-已交付)',
- `delivered_quantity` decimal(20,4) DEFAULT '0.0000' COMMENT '已交付数量',
- `description` varchar(1000) DEFAULT NULL COMMENT '产品描述',
- `package_spec` varchar(200) DEFAULT NULL COMMENT '包装规格',
- `delivery_method` varchar(100) DEFAULT NULL COMMENT '送货方式',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_delivery_status` (`delivery_status`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2052978521328549890 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同产品明细表';
- -- ----------------------------
- -- Table structure for crm_contract_product_price_tier
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract_product_price_tier`;
- CREATE TABLE `crm_contract_product_price_tier` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_product_id` bigint(20) NOT NULL COMMENT '合同产品明细ID',
- `start_date` date NOT NULL COMMENT '区间开始日期',
- `end_date` date NOT NULL COMMENT '区间结束日期',
- `price` decimal(15,2) NOT NULL COMMENT '含税单价',
- `letter_oss_ids` varchar(4000) DEFAULT NULL COMMENT '调价函OSS ID列表(JSON字符串数组,如["id1","id2"])',
- `letter_oss_id` bigint(20) DEFAULT NULL COMMENT '调价函单附件OSS ID(废弃,请使用 letter_oss_ids)',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- PRIMARY KEY (`id`),
- KEY `idx_contract_id` (`contract_id`),
- KEY `idx_contract_product_id` (`contract_product_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-框架合同产品调价区间';
- -- ----------------------------
- -- Table structure for crm_contract_template
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_contract_template`;
- CREATE TABLE `crm_contract_template` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `template_no` varchar(50) NOT NULL COMMENT '模板编号',
- `template_name` varchar(200) NOT NULL COMMENT '模板名称',
- `contract_type` varchar(20) DEFAULT NULL COMMENT '适用合同类型(sale-销售/service-服务等)',
- `template_content` text COMMENT '模板内容(富文本)',
- `payment_terms` text COMMENT '付款条款模板',
- `delivery_terms` text COMMENT '交付条款模板',
- `contract_terms` text COMMENT '合同条款模板',
- `party_b` varchar(200) DEFAULT NULL COMMENT '乙方(我方)默认名称',
- `party_b_address` varchar(255) DEFAULT NULL COMMENT '乙方地址',
- `party_b_contact` varchar(50) DEFAULT NULL COMMENT '乙方联系人',
- `party_b_mobile` varchar(20) DEFAULT NULL COMMENT '乙方联系电话',
- `default_currency` varchar(10) DEFAULT 'CNY' COMMENT '默认币种',
- `default_tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '默认税率(%)',
- `default_period` int(11) DEFAULT '12' COMMENT '默认合同期限(月)',
- `is_active` tinyint(1) DEFAULT '1' COMMENT '是否启用(0-停用 1-启用)',
- `usage_count` int(11) DEFAULT '0' COMMENT '使用次数',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_template_no` (`template_no`) USING BTREE,
- KEY `idx_contract_type` (`contract_type`) USING BTREE,
- KEY `idx_is_active` (`is_active`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同模板表';
- -- ----------------------------
- -- Table structure for crm_customer
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer`;
- CREATE TABLE `crm_customer` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `customer_no` varchar(50) NOT NULL COMMENT '客户编号(唯一)',
- `customer_name` varchar(200) NOT NULL COMMENT '客户名称',
- `short_name` varchar(100) DEFAULT NULL COMMENT '客户简称',
- `customer_type` varchar(20) DEFAULT 'company' COMMENT '客户类型(company-企业/person-个人)',
- `mobile` varchar(20) DEFAULT NULL COMMENT '手机号',
- `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
- `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
- `website` varchar(500) DEFAULT NULL COMMENT '客户网站',
- `level` varchar(20) DEFAULT 'normal' COMMENT '客户级别(key-重点/normal-普通/potential-潜在)',
- `source` varchar(20) DEFAULT NULL COMMENT '客户来源',
- `industry` varchar(50) DEFAULT NULL COMMENT '所属行业',
- `park_area` varchar(100) DEFAULT NULL COMMENT '所在园区',
- `payment_terms` varchar(500) DEFAULT NULL COMMENT '收付款条件(如:预付30%、账期30天等)',
- `scale` varchar(20) DEFAULT NULL COMMENT '企业规模(1-50人/50-200人/200-500人/500人以上)',
- `province` varchar(50) DEFAULT NULL COMMENT '省',
- `city` varchar(50) DEFAULT NULL COMMENT '市',
- `district` varchar(50) DEFAULT NULL COMMENT '区',
- `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
- `status` varchar(20) DEFAULT 'normal' COMMENT '客户状态(normal-正常/pool-公海/invalid-无效)',
- `deal_status` varchar(20) DEFAULT 'not_deal' COMMENT '成交状态(not_deal-未成交/dealed-已成交/lost-已流失)',
- `owner_user_id` bigint(20) DEFAULT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余)',
- `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数',
- `deal_time` datetime DEFAULT NULL COMMENT '成交时间',
- `deal_amount` decimal(15,2) DEFAULT '0.00' COMMENT '累计成交金额',
- `contact_count` int(11) DEFAULT '0' COMMENT '联系人数量',
- `opportunity_count` int(11) DEFAULT '0' COMMENT '商机数量',
- `contract_count` int(11) DEFAULT '0' COMMENT '合同数量',
- `into_pool_time` datetime DEFAULT NULL COMMENT '进入公海时间',
- `into_pool_by` bigint(20) DEFAULT NULL COMMENT '进入公海操作人ID',
- `into_pool_reason` varchar(500) DEFAULT NULL COMMENT '进入公海原因',
- `claim_time` datetime DEFAULT NULL COMMENT '领取时间',
- `assign_time` datetime DEFAULT NULL COMMENT '分配时间',
- `assign_by` bigint(20) DEFAULT NULL COMMENT '分配人ID',
- `protect_time` datetime DEFAULT NULL COMMENT '保护到期时间',
- `clue_id` bigint(20) DEFAULT NULL COMMENT '关联线索ID(从线索转化)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `business_license_images` varchar(1000) DEFAULT NULL COMMENT '营业执照图片OSS ID(多个用逗号分隔)',
- `business_permit_images` varchar(1000) DEFAULT NULL COMMENT '经营许可证图片OSS ID(多个用逗号分隔)',
- `other_cert_images` varchar(1000) DEFAULT NULL COMMENT '其他证件图片OSS ID(多个用逗号分隔)',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_customer_no_del_flag` (`customer_no`,`del_flag`) USING BTREE,
- KEY `idx_mobile` (`mobile`) USING BTREE,
- KEY `idx_owner` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_level` (`level`) USING BTREE,
- KEY `idx_deal_status` (`deal_status`) USING BTREE,
- KEY `idx_source` (`source`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_clue` (`clue_id`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE,
- KEY `idx_park_area` (`park_area`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2047862937284673538 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户主表';
- -- ----------------------------
- -- Table structure for crm_customer_follow
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer_follow`;
- CREATE TABLE `crm_customer_follow` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(100) DEFAULT NULL COMMENT '联系人姓名(冗余)',
- `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(电话/微信/邮件/拜访/其他)',
- `follow_content` text NOT NULL COMMENT '跟进内容',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
- `create_by_name` varchar(50) DEFAULT NULL COMMENT '跟进人姓名(冗余)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_contact_id` (`contact_id`) USING BTREE,
- KEY `idx_create_by` (`create_by`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=1985641912854016003 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户跟进记录表';
- -- ----------------------------
- -- Table structure for crm_customer_pool
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer_pool`;
- CREATE TABLE `crm_customer_pool` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
- `operation_type` varchar(20) NOT NULL COMMENT '操作类型(into-进入公海/claim-领取/assign-分配/recycle-回收)',
- `from_user_id` bigint(20) DEFAULT NULL COMMENT '原负责人ID',
- `from_user_name` varchar(50) DEFAULT NULL COMMENT '原负责人姓名(冗余)',
- `to_user_id` bigint(20) DEFAULT NULL COMMENT '新负责人ID',
- `to_user_name` varchar(50) DEFAULT NULL COMMENT '新负责人姓名(冗余)',
- `reason` varchar(500) DEFAULT NULL COMMENT '操作原因',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(操作人)',
- `create_by_name` varchar(50) DEFAULT NULL COMMENT '操作人姓名(冗余)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(操作时间)',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_operation_type` (`operation_type`) USING BTREE,
- KEY `idx_from_user` (`from_user_id`) USING BTREE,
- KEY `idx_to_user` (`to_user_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=1991718802157080578 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户公海池记录表';
- -- ----------------------------
- -- Table structure for crm_customer_pool_rule
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer_pool_rule`;
- CREATE TABLE `crm_customer_pool_rule` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `pool_name` varchar(100) NOT NULL COMMENT '规则名称',
- `rule_type` varchar(20) NOT NULL COMMENT '规则类型(no_follow-未跟进/no_deal-未成交)',
- `timeout_days` int(11) NOT NULL COMMENT '超时天数(多少天未跟进/未成交)',
- `protect_days` int(11) NOT NULL DEFAULT '0' COMMENT '保护期天数(领取后保护多少天)',
- `status` varchar(20) DEFAULT 'enable' COMMENT '状态(enable-启用/disable-禁用)',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_rule_type` (`rule_type`) USING BTREE,
- KEY `idx_sort` (`sort`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户公海池规则表';
- -- ----------------------------
- -- Table structure for crm_customer_tag
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer_tag`;
- CREATE TABLE `crm_customer_tag` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `tag_name` varchar(50) NOT NULL COMMENT '标签名称',
- `tag_color` varchar(20) DEFAULT '#409EFF' COMMENT '标签颜色(十六进制颜色值)',
- `tag_type` varchar(20) DEFAULT 'custom' COMMENT '标签类型(system-系统预设/custom-自定义)',
- `sort_order` int(11) DEFAULT '0' COMMENT '排序号',
- `share_scope` varchar(20) DEFAULT 'private' COMMENT '共享范围(private-个人/dept-部门/company-公司)',
- `create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
- `create_user_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
- `use_count` int(11) DEFAULT '0' COMMENT '使用次数',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_tag_name` (`tag_name`,`tenant_id`,`del_flag`) USING BTREE,
- KEY `idx_tag_type` (`tag_type`) USING BTREE,
- KEY `idx_share_scope` (`share_scope`) USING BTREE,
- KEY `idx_create_user` (`create_user_id`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户标签表';
- -- ----------------------------
- -- Table structure for crm_customer_tag_relation
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_customer_tag_relation`;
- CREATE TABLE `crm_customer_tag_relation` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
- `tag_id` bigint(20) NOT NULL COMMENT '标签ID',
- `tag_name` varchar(50) DEFAULT NULL COMMENT '标签名称(冗余)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(打标签的人)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_customer_tag` (`customer_id`,`tag_id`,`del_flag`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_tag_id` (`tag_id`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户标签关联表';
- -- ----------------------------
- -- Table structure for crm_invoice
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_invoice`;
- CREATE TABLE `crm_invoice` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `invoice_no` varchar(50) NOT NULL COMMENT '发票编号(INV+yyyyMMdd+4位流水号)',
- `invoice_code` varchar(50) DEFAULT NULL COMMENT '发票代码(税务发票代码)',
- `invoice_number` varchar(50) DEFAULT NULL COMMENT '发票号码(税务发票号码)',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `payment_id` bigint(20) DEFAULT NULL COMMENT '回款ID',
- `payment_no` varchar(50) DEFAULT NULL COMMENT '回款编号(冗余字段)',
- `invoice_type` varchar(20) NOT NULL DEFAULT 'special' COMMENT '发票类型(special-增值税专用发票/normal-增值税普通发票/electronic-电子发票)',
- `invoice_title` varchar(200) NOT NULL COMMENT '发票抬头',
- `tax_no` varchar(50) NOT NULL COMMENT '纳税人识别号',
- `company_address` varchar(255) DEFAULT NULL COMMENT '企业地址',
- `company_phone` varchar(50) DEFAULT NULL COMMENT '企业电话',
- `bank_name` varchar(100) DEFAULT NULL COMMENT '开户银行',
- `bank_account` varchar(100) DEFAULT NULL COMMENT '银行账号',
- `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '开票金额(不含税)',
- `tax_rate` decimal(5,2) NOT NULL DEFAULT '6.00' COMMENT '税率(百分比,如6.00表示6%)',
- `is_tax_included` tinyint(1) DEFAULT '0' COMMENT '是否含税: 0-不含税 1-含税',
- `tax_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '税额',
- `total_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '价税合计',
- `invoice_content` varchar(200) DEFAULT NULL COMMENT '开票内容',
- `invoice_date` date DEFAULT NULL COMMENT '开票日期',
- `status` varchar(20) NOT NULL DEFAULT 'applying' COMMENT '发票状态(applying-申请中/approved-已审批/invoiced-已开票/delivered-已寄出/received-已签收/rejected-已驳回/invalid-已作废)',
- `reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
- `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
- `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
- `invoice_file` varchar(500) DEFAULT NULL COMMENT '发票PDF文件',
- `invoice_image` varchar(500) DEFAULT NULL COMMENT '发票图片(扫描件)',
- `express_company` varchar(50) DEFAULT NULL COMMENT '快递公司',
- `express_no` varchar(100) DEFAULT NULL COMMENT '快递单号',
- `express_status` varchar(20) DEFAULT 'no' COMMENT '快递状态(no-未寄出/sent-已寄出/received-已签收)',
- `express_time` datetime DEFAULT NULL COMMENT '寄出时间',
- `receive_time` datetime DEFAULT NULL COMMENT '签收时间',
- `mail_address` varchar(255) DEFAULT NULL COMMENT '邮寄地址',
- `mail_contact` varchar(50) DEFAULT NULL COMMENT '收件人',
- `mail_mobile` varchar(20) DEFAULT NULL COMMENT '收件电话',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `apply_by` bigint(20) DEFAULT NULL COMMENT '申请人ID',
- `apply_by_name` varchar(50) DEFAULT NULL COMMENT '申请人姓名',
- `apply_time` datetime DEFAULT NULL COMMENT '申请时间',
- `approve_by` bigint(20) DEFAULT NULL COMMENT '审批人ID',
- `approve_by_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
- `approve_time` datetime DEFAULT NULL COMMENT '审批时间',
- `invoice_by` bigint(20) DEFAULT NULL COMMENT '开票人ID',
- `invoice_by_name` varchar(50) DEFAULT NULL COMMENT '开票人姓名',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_invoice_no_del_flag` (`invoice_no`,`del_flag`) USING BTREE,
- KEY `uk_invoice_number` (`invoice_number`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_payment_id` (`payment_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_invoice_date` (`invoice_date`) USING BTREE,
- KEY `idx_express_status` (`express_status`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-发票主表';
- -- ----------------------------
- -- Table structure for crm_invoice_info
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_invoice_info`;
- CREATE TABLE `crm_invoice_info` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `company_name` varchar(200) DEFAULT NULL COMMENT '单位名称(章)',
- `company_address` varchar(500) DEFAULT NULL COMMENT '单位地址',
- `legal_representative` varchar(100) DEFAULT NULL COMMENT '法定代表人',
- `agent` varchar(100) DEFAULT NULL COMMENT '代理人',
- `phone_fax` varchar(100) DEFAULT NULL COMMENT '电话/传真',
- `bank_name` varchar(200) DEFAULT NULL COMMENT '开户银行',
- `bank_account` varchar(100) DEFAULT NULL COMMENT '账号',
- `is_default` char(1) DEFAULT '0' COMMENT '是否默认(0否 1是)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `del_flag` int(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户开票信息表';
- -- ----------------------------
- -- Table structure for crm_invoice_item
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_invoice_item`;
- CREATE TABLE `crm_invoice_item` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `invoice_id` bigint(20) NOT NULL COMMENT '发票ID',
- `item_name` varchar(200) NOT NULL COMMENT '项目名称',
- `spec` varchar(100) DEFAULT NULL COMMENT '规格型号',
- `unit` varchar(50) DEFAULT NULL COMMENT '单位',
- `quantity` decimal(15,2) DEFAULT '0.00' COMMENT '数量',
- `unit_price` decimal(15,2) DEFAULT '0.00' COMMENT '单价',
- `amount` decimal(15,2) DEFAULT '0.00' COMMENT '金额',
- `tax_rate` decimal(5,2) DEFAULT '0.00' COMMENT '税率(百分比)',
- `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税额',
- `total_amount` decimal(15,2) DEFAULT '0.00' COMMENT '价税合计',
- `sort` int(11) DEFAULT '0' COMMENT '排序',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_invoice_id` (`invoice_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-发票明细表';
- -- ----------------------------
- -- Table structure for crm_opportunity
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_opportunity`;
- CREATE TABLE `crm_opportunity` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `opportunity_no` varchar(50) NOT NULL COMMENT '商机编号(OPP+yyyyMMdd+4位流水号)',
- `opportunity_name` varchar(200) NOT NULL COMMENT '商机名称',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
- `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '商机金额',
- `stage` varchar(20) NOT NULL DEFAULT 'initial' COMMENT '商机阶段(initial-初步接触/requirement-需求分析/solution-方案制定/quote-报价/negotiate-谈判审核/contract-合同签订/won-赢单)',
- `stage_percent` int(11) DEFAULT '10' COMMENT '阶段进度百分比(10/20/40/60/80/90/100)',
- `status` varchar(20) NOT NULL DEFAULT 'following' COMMENT '商机状态(following-跟进中/won-赢单/lost-输单/invalid-无效)',
- `win_rate` decimal(5,2) DEFAULT '50.00' COMMENT '赢单率(百分比,如50.00表示50%)',
- `expect_deal_date` date DEFAULT NULL COMMENT '预计成交日期',
- `actual_deal_date` date DEFAULT NULL COMMENT '实际成交日期',
- `lost_reason` varchar(500) DEFAULT NULL COMMENT '输单原因',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(销售人员)',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `product_count` int(11) DEFAULT '0' COMMENT '产品数量(冗余字段)',
- `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数(冗余字段)',
- `contract_id` bigint(20) DEFAULT NULL COMMENT '关联合同ID(赢单后生成)',
- `source` varchar(20) DEFAULT NULL COMMENT '商机来源(同线索来源)',
- `type` varchar(20) DEFAULT NULL COMMENT '商机类型(new_customer-新客户新业务/renewal-老客户续约/upgrade-老客户升级)',
- `description` text COMMENT '商机描述(详细说明商机背景、客户需求等)',
- `competitors` varchar(500) DEFAULT NULL COMMENT '竞争对手(多个竞争对手用逗号分隔)',
- `key_factors` varchar(500) DEFAULT NULL COMMENT '关键决策因素(客户关注的核心要素)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_opportunity_no_del_flag` (`opportunity_no`,`del_flag`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_stage` (`stage`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_expect_deal_date` (`expect_deal_date`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机主表';
- -- ----------------------------
- -- Table structure for crm_opportunity_follow
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_opportunity_follow`;
- CREATE TABLE `crm_opportunity_follow` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
- `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(phone-电话/wechat-微信/email-邮件/visit-拜访/meeting-会议/other-其他)',
- `follow_content` text NOT NULL COMMENT '跟进内容',
- `follow_time` datetime DEFAULT NULL COMMENT '跟进时间',
- `stage` varchar(20) DEFAULT NULL COMMENT '当前商机阶段',
- `stage_percent` int(11) DEFAULT NULL COMMENT '阶段进度百分比',
- `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
- `next_content` varchar(500) DEFAULT NULL COMMENT '下次联系计划',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个文件用逗号分隔)',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名',
- `location` varchar(200) DEFAULT NULL COMMENT '跟进地点(拜访时填写)',
- `duration` int(11) DEFAULT NULL COMMENT '跟进时长(分钟)',
- `follow_by` bigint(20) DEFAULT NULL COMMENT '跟进人ID',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
- KEY `idx_create_by` (`create_by`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_next_time` (`next_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_follow_time` (`follow_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机跟进记录表';
- -- ----------------------------
- -- Table structure for crm_opportunity_product
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_opportunity_product`;
- CREATE TABLE `crm_opportunity_product` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `product_name` varchar(200) DEFAULT NULL COMMENT '产品名称(冗余字段)',
- `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号(冗余字段)',
- `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
- `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称(冗余字段)',
- `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
- `unit` varchar(20) DEFAULT '件' COMMENT '单位',
- `quantity` decimal(20,4) NOT NULL COMMENT '数量',
- `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价',
- `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比,如10.00表示9折)',
- `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '小计金额(数量*单价*折扣后)',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机产品关联表';
- -- ----------------------------
- -- Table structure for crm_opportunity_stage_log
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_opportunity_stage_log`;
- CREATE TABLE `crm_opportunity_stage_log` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
- `from_stage` varchar(20) DEFAULT NULL COMMENT '原阶段',
- `from_stage_name` varchar(50) DEFAULT NULL COMMENT '原阶段名称',
- `from_percent` int(11) DEFAULT NULL COMMENT '原进度百分比',
- `to_stage` varchar(20) NOT NULL COMMENT '新阶段',
- `to_stage_name` varchar(50) DEFAULT NULL COMMENT '新阶段名称',
- `to_percent` int(11) DEFAULT NULL COMMENT '新进度百分比',
- `change_type` varchar(20) DEFAULT 'forward' COMMENT '变更类型(forward-推进/backward-后退)',
- `change_reason` varchar(500) DEFAULT NULL COMMENT '变更原因',
- `change_amount` decimal(15,2) DEFAULT NULL COMMENT '变更时的商机金额',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(变更人)',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(变更时间)',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `lost_detail` varchar(2000) DEFAULT NULL COMMENT '输单详细说明',
- `competitor_info` varchar(1000) DEFAULT NULL COMMENT '竞争对手信息',
- `improvement` varchar(1000) DEFAULT NULL COMMENT '改进建议',
- `won_remark` varchar(2000) DEFAULT NULL COMMENT '赢单说明',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机阶段变更日志表';
- -- ----------------------------
- -- Table structure for crm_payment
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_payment`;
- CREATE TABLE `crm_payment` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `payment_no` varchar(50) NOT NULL COMMENT '回款编号(PAY+yyyyMMdd+4位流水号)',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `plan_id` bigint(20) DEFAULT NULL COMMENT '回款计划ID',
- `plan_no` varchar(50) DEFAULT NULL COMMENT '计划编号(冗余字段)',
- `period` int(11) DEFAULT NULL COMMENT '期数(冗余字段)',
- `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '回款金额',
- `payment_date` date NOT NULL COMMENT '回款日期',
- `payment_method` varchar(20) DEFAULT 'bank' COMMENT '付款方式(bank-银行转账/cash-现金/check-支票/alipay-支付宝/wechat-微信/other-其他)',
- `payment_account` varchar(100) DEFAULT NULL COMMENT '付款账户',
- `voucher_no` varchar(100) DEFAULT NULL COMMENT '凭证号(流水号)',
- `voucher_file` varchar(500) DEFAULT NULL COMMENT '凭证文件(回款凭证扫描件)',
- `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '回款状态(pending-待确认/confirmed-已确认/invalid-已作废)',
- `confirm_by` bigint(20) DEFAULT NULL COMMENT '确认人ID',
- `confirm_by_name` varchar(50) DEFAULT NULL COMMENT '确认人姓名',
- `confirm_time` datetime DEFAULT NULL COMMENT '确认时间',
- `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
- `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(录入人)',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `bank_name` varchar(100) DEFAULT NULL COMMENT '收款银行',
- `bank_account` varchar(100) DEFAULT NULL COMMENT '收款账号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_payment_no_del_flag` (`payment_no`,`del_flag`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_plan_id` (`plan_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_payment_date` (`payment_date`) USING BTREE,
- KEY `idx_confirm_by` (`confirm_by`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回款记录表';
- -- ----------------------------
- -- Table structure for crm_payment_collection
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_payment_collection`;
- CREATE TABLE `crm_payment_collection` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `plan_id` bigint(20) NOT NULL COMMENT '回款计划ID',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
- `collection_date` datetime NOT NULL COMMENT '催收日期时间',
- `collection_method` varchar(20) NOT NULL COMMENT '催收方式(phone/email/message/visit/legal/other)',
- `contact_person` varchar(100) DEFAULT NULL COMMENT '联系人姓名',
- `contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
- `collection_content` text NOT NULL COMMENT '催收内容(最少20字)',
- `customer_feedback` varchar(20) NOT NULL COMMENT '客户反馈类型(promise/processing/difficulty/refuse/no_contact/other)',
- `feedback_detail` varchar(500) DEFAULT NULL COMMENT '反馈详情',
- `promise_date` date DEFAULT NULL COMMENT '承诺付款日期',
- `collector_user_id` bigint(20) NOT NULL COMMENT '催收人ID',
- `collector_user_name` varchar(50) DEFAULT NULL COMMENT '催收人姓名(冗余)',
- `attachment` varchar(500) DEFAULT NULL COMMENT '附件(催收邮件截图等)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_plan_id` (`plan_id`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_collection_date` (`collection_date`) USING BTREE,
- KEY `idx_collector_user_id` (`collector_user_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-催收记录表';
- -- ----------------------------
- -- Table structure for crm_payment_plan
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_payment_plan`;
- CREATE TABLE `crm_payment_plan` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `plan_no` varchar(50) NOT NULL COMMENT '计划编号(PLAN+yyyyMMdd+4位流水号)',
- `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `period` int(11) NOT NULL DEFAULT '1' COMMENT '期数(第几期)',
- `plan_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '计划回款金额',
- `plan_date` date NOT NULL COMMENT '计划回款日期',
- `plan_percent` decimal(5,2) DEFAULT NULL COMMENT '计划比例(占合同总金额的百分比)',
- `received_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已回款金额',
- `unreceived_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未回款金额',
- `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '状态(pending-待回款/partial-部分回款/finished-已完成/overdue-已逾期)',
- `is_overdue` tinyint(1) DEFAULT '0' COMMENT '是否逾期(0否 1是)',
- `overdue_days` int(11) DEFAULT '0' COMMENT '逾期天数',
- `remind_days` int(11) DEFAULT '7' COMMENT '提前提醒天数(默认7天)',
- `remind_status` varchar(20) DEFAULT 'no' COMMENT '提醒状态(no-未提醒/reminded-已提醒)',
- `last_remind_time` datetime DEFAULT NULL COMMENT '最后提醒时间',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_plan_no_del_flag` (`plan_no`,`del_flag`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_plan_date` (`plan_date`) USING BTREE,
- KEY `idx_is_overdue` (`is_overdue`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回款计划表';
- -- ----------------------------
- -- Table structure for crm_product
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product`;
- CREATE TABLE `crm_product` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `product_no` varchar(50) NOT NULL COMMENT '产品编号(唯一)',
- `product_name` varchar(200) NOT NULL COMMENT '产品名称',
- `category_id` bigint(20) DEFAULT NULL COMMENT '分类ID',
- `category_name` varchar(100) DEFAULT NULL COMMENT '分类名称(冗余)',
- `model` varchar(100) DEFAULT NULL COMMENT '型号/规格',
- `unit` varchar(20) DEFAULT '个' COMMENT '单位',
- `barcode` varchar(100) DEFAULT NULL COMMENT '条码',
- `price` decimal(15,2) DEFAULT '0.00' COMMENT '标准价格',
- `cost` decimal(15,2) DEFAULT '0.00' COMMENT '成本价',
- `min_price` decimal(15,2) DEFAULT NULL COMMENT '最低价格',
- `stock` int(11) DEFAULT '0' COMMENT '库存数量',
- `low_stock` int(11) DEFAULT '10' COMMENT '库存预警值',
- `status` varchar(20) DEFAULT 'on' COMMENT '状态(on-上架/off-下架)',
- `tax_rate` decimal(5,2) NOT NULL DEFAULT '13.00' COMMENT '税率(百分比)',
- `description` text COMMENT '产品描述',
- `images` varchar(1000) DEFAULT NULL COMMENT '产品图片(多个用逗号分隔)',
- `sale_count` int(11) DEFAULT '0' COMMENT '销售次数',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_product_no_del_flag` (`product_no`,`del_flag`) USING BTREE,
- KEY `idx_category` (`category_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2052931567194177538 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-产品主表';
- -- ----------------------------
- -- Table structure for crm_product_attachment
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_attachment`;
- CREATE TABLE `crm_product_attachment` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `file_name` varchar(200) NOT NULL COMMENT '文件名称',
- `file_path` varchar(500) NOT NULL COMMENT '文件路径',
- `file_type` varchar(50) DEFAULT NULL COMMENT '文件类型(pdf/doc/xls/ppt/jpg等)',
- `file_size` bigint(20) DEFAULT NULL COMMENT '文件大小(字节)',
- `attachment_type` varchar(50) DEFAULT 'other' COMMENT '资料类型(manual-产品手册/whitepaper-技术白皮书/guide-用户指南/demo-演示PPT/case-案例资料/video-视频教程/other-其他)',
- `download_count` int(11) DEFAULT '0' COMMENT '下载次数',
- `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_attachment_type` (`attachment_type`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品附件表';
- -- ----------------------------
- -- Table structure for crm_product_category
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_category`;
- CREATE TABLE `crm_product_category` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `category_name` varchar(100) NOT NULL COMMENT '分类名称',
- `parent_id` bigint(20) DEFAULT '0' COMMENT '父级ID(0为顶级)',
- `ancestors` varchar(500) DEFAULT NULL COMMENT '祖级列表(如: 0,1,2)',
- `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
- `status` varchar(10) DEFAULT '0' COMMENT '状态(0-正常 1-停用)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_parent_id` (`parent_id`) USING BTREE,
- KEY `idx_tenant` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=1975766650771238914 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-产品分类表';
- -- ----------------------------
- -- Table structure for crm_product_price
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_price`;
- CREATE TABLE `crm_product_price` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `price_type` varchar(20) NOT NULL COMMENT '价格类型(standard/cost/minimum/vip/wholesale/promotion)',
- `price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
- `start_date` datetime DEFAULT NULL COMMENT '生效日期',
- `end_date` datetime DEFAULT NULL COMMENT '失效日期',
- `status` varchar(10) DEFAULT 'active' COMMENT '状态(active-生效中/inactive-已失效)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_price_type` (`price_type`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品价格表';
- -- ----------------------------
- -- Table structure for crm_product_price_history
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_price_history`;
- CREATE TABLE `crm_product_price_history` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `price_type` varchar(20) NOT NULL COMMENT '价格类型',
- `old_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '调整前价格',
- `new_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '调整后价格',
- `price_change` decimal(12,2) DEFAULT '0.00' COMMENT '调整金额',
- `change_percent` decimal(5,2) DEFAULT '0.00' COMMENT '调整百分比',
- `adjust_reason` varchar(500) DEFAULT NULL COMMENT '调价原因',
- `effective_date` datetime DEFAULT NULL COMMENT '生效日期',
- `create_by` bigint(20) DEFAULT NULL COMMENT '操作人',
- `create_time` datetime DEFAULT NULL COMMENT '操作时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品价格历史表';
- -- ----------------------------
- -- Table structure for crm_product_stock_log
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_stock_log`;
- CREATE TABLE `crm_product_stock_log` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `operation_type` varchar(20) NOT NULL COMMENT '操作类型(in-入库/out-出库/adjust-调整/check-盘点)',
- `quantity` int(11) NOT NULL DEFAULT '0' COMMENT '变动数量(正数-增加/负数-减少)',
- `before_stock` int(11) NOT NULL DEFAULT '0' COMMENT '变动前库存',
- `after_stock` int(11) NOT NULL DEFAULT '0' COMMENT '变动后库存',
- `unit_price` decimal(12,2) DEFAULT NULL COMMENT '单价',
- `total_amount` decimal(12,2) DEFAULT NULL COMMENT '总金额',
- `related_no` varchar(100) DEFAULT NULL COMMENT '关联单号(入库单/出库单/合同编号等)',
- `related_type` varchar(50) DEFAULT NULL COMMENT '关联类型(purchase-采购/sale-销售/sample-样品/other-其他)',
- `supplier` varchar(200) DEFAULT NULL COMMENT '供应商(入库时)',
- `operator` varchar(100) DEFAULT NULL COMMENT '操作人',
- `operation_date` datetime DEFAULT NULL COMMENT '操作日期',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_operation_type` (`operation_type`) USING BTREE,
- KEY `idx_operation_date` (`operation_date`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品库存记录表';
- -- ----------------------------
- -- Table structure for crm_product_tag
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_tag`;
- CREATE TABLE `crm_product_tag` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `tag_name` varchar(50) NOT NULL COMMENT '标签名称',
- `tag_color` varchar(20) DEFAULT NULL COMMENT '标签颜色',
- `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
- `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_tag_name` (`tag_name`,`tenant_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品标签表';
- -- ----------------------------
- -- Table structure for crm_product_tag_relation
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_product_tag_relation`;
- CREATE TABLE `crm_product_tag_relation` (
- `id` bigint(20) NOT NULL COMMENT '主键ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `tag_id` bigint(20) NOT NULL COMMENT '标签ID',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_product_tag` (`product_id`,`tag_id`,`tenant_id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_tag_id` (`tag_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品标签关联表';
- -- ----------------------------
- -- Table structure for crm_quote
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_quote`;
- CREATE TABLE `crm_quote` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `quote_no` varchar(50) NOT NULL COMMENT '报价单编号(QUO+yyyyMMdd+4位流水号)',
- `quote_title` varchar(200) NOT NULL COMMENT '报价单标题',
- `quote_type` varchar(20) NOT NULL DEFAULT 'sales' COMMENT '报价单类型(sales-销售/purchase-采购)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `opportunity_id` bigint(20) DEFAULT NULL COMMENT '商机ID',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
- `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机(冗余字段)',
- `contact_email` varchar(100) DEFAULT NULL COMMENT '联系人邮箱(冗余字段)',
- `version` varchar(20) DEFAULT 'V1.0' COMMENT '版本号(如V1.0,V1.1,V2.0)',
- `parent_id` bigint(20) DEFAULT NULL COMMENT '父版本ID(版本管理,0表示首版)',
- `is_latest` tinyint(1) DEFAULT '1' COMMENT '是否最新版本(0否 1是)',
- `total_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额(未折扣前)',
- `discount_rate` decimal(5,2) DEFAULT '0.00' COMMENT '整单折扣率(百分比)',
- `discount_amount` decimal(15,2) DEFAULT '0.00' COMMENT '折扣金额',
- `final_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '最终金额(折扣后)',
- `validity_days` int(11) DEFAULT '30' COMMENT '有效期(天数)',
- `quote_date` date DEFAULT NULL COMMENT '报价日期',
- `expire_date` date DEFAULT NULL COMMENT '到期日期',
- `status` varchar(20) NOT NULL DEFAULT 'draft' COMMENT '状态(draft-草稿/submitted-已提交/accepted-已接受/rejected-已拒绝/expired-已过期/contract-已转合同)',
- `reject_reason` varchar(500) DEFAULT NULL COMMENT '拒绝原因',
- `pdf_url` varchar(500) DEFAULT NULL COMMENT 'PDF文件路径',
- `pdf_generated` tinyint(1) DEFAULT '0' COMMENT 'PDF是否已生成(0否 1是)',
- `share_link` varchar(500) DEFAULT NULL COMMENT '分享链接',
- `share_code` varchar(50) DEFAULT NULL COMMENT '分享码',
- `share_password` varchar(100) DEFAULT NULL COMMENT '分享密码(可选)',
- `share_expire_time` datetime DEFAULT NULL COMMENT '分享链接过期时间',
- `view_count` int(11) DEFAULT '0' COMMENT '查看次数',
- `last_view_time` datetime DEFAULT NULL COMMENT '最后查看时间',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `supplier_id` bigint(20) DEFAULT NULL COMMENT '报价主体ID(关联crm_supplier_info表)',
- `supplier_name` varchar(200) DEFAULT NULL COMMENT '报价主体名称(冗余字段)',
- `contract_id` bigint(20) DEFAULT NULL COMMENT '关联合同ID(转合同后)',
- `payment_terms` varchar(500) DEFAULT NULL COMMENT '付款条款',
- `delivery_terms` varchar(500) DEFAULT NULL COMMENT '交付条款',
- `freight` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '运费(元)',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
- `template_content` longtext COMMENT '报价单模板内容(富文本HTML)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version_no` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_parent_id` (`parent_id`) USING BTREE,
- KEY `idx_expire_date` (`expire_date`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE,
- KEY `idx_share_code` (`share_code`) USING BTREE,
- KEY `idx_supplier_id` (`supplier_id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=2053033084869902339 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单主表';
- -- ----------------------------
- -- Table structure for crm_quote_approval
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_quote_approval`;
- CREATE TABLE `crm_quote_approval` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
- `quote_no` varchar(50) DEFAULT NULL COMMENT '报价单编号(冗余)',
- `step` int(11) NOT NULL COMMENT '审批步骤(1/2/3...)',
- `approver_id` bigint(20) NOT NULL COMMENT '审批人ID',
- `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名(冗余)',
- `approval_result` varchar(20) DEFAULT 'pending' COMMENT '审批结果(pending-待审批/approved-通过/rejected-拒绝)',
- `approval_opinion` text COMMENT '审批意见',
- `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_quote_id` (`quote_id`) USING BTREE,
- KEY `idx_approver_id` (`approver_id`) USING BTREE,
- KEY `idx_approval_time` (`approval_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_approval_result` (`approval_result`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2052978058952671234 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单审批记录表';
- -- ----------------------------
- -- Table structure for crm_quote_product
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_quote_product`;
- CREATE TABLE `crm_quote_product` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
- `product_id` bigint(20) NOT NULL COMMENT '产品ID',
- `product_name` varchar(200) NOT NULL COMMENT '产品名称',
- `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号',
- `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
- `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称',
- `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
- `unit` varchar(20) DEFAULT '件' COMMENT '单位',
- `quantity` decimal(20,4) NOT NULL COMMENT '数量',
- `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '含税单价/元',
- `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比)',
- `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '含税总价/元',
- `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税费/元',
- `tax_rate` decimal(5,2) DEFAULT '13.00' COMMENT '税率(%)',
- `package_spec` varchar(200) DEFAULT NULL COMMENT '包装规格',
- `delivery_method` varchar(200) DEFAULT NULL COMMENT '送货方式',
- `description` varchar(1000) DEFAULT NULL COMMENT '产品描述',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_quote_id` (`quote_id`) USING BTREE,
- KEY `idx_product_id` (`product_id`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=2053033084941205506 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单产品明细表';
- -- ----------------------------
- -- Table structure for crm_quote_share_log
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_quote_share_log`;
- CREATE TABLE `crm_quote_share_log` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
- `share_code` varchar(50) NOT NULL COMMENT '分享码',
- `visit_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '访问时间',
- `ip_address` varchar(50) DEFAULT NULL COMMENT 'IP地址',
- `location` varchar(200) DEFAULT NULL COMMENT '地理位置(省市)',
- `device_type` varchar(50) DEFAULT NULL COMMENT '设备类型(PC/Mobile/Tablet)',
- `browser` varchar(100) DEFAULT NULL COMMENT '浏览器信息',
- `stay_duration` int(11) DEFAULT '0' COMMENT '停留时长(秒)',
- `page_views` int(11) DEFAULT '1' COMMENT '浏览页数',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_quote_id` (`quote_id`) USING BTREE,
- KEY `idx_share_code` (`share_code`) USING BTREE,
- KEY `idx_visit_time` (`visit_time`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单分享访问日志表';
- -- ----------------------------
- -- Table structure for crm_supplier_info
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_supplier_info`;
- CREATE TABLE `crm_supplier_info` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `supplier_name` varchar(200) NOT NULL COMMENT '供方名称(章)',
- `short_name` varchar(100) DEFAULT NULL COMMENT '简称',
- `supplier_code` varchar(50) DEFAULT NULL COMMENT '编码',
- `supplier_address` varchar(500) DEFAULT NULL COMMENT '单位地址',
- `legal_person` varchar(100) DEFAULT NULL COMMENT '法定代表人',
- `agent` varchar(100) DEFAULT NULL COMMENT '代理人',
- `phone_fax` varchar(100) DEFAULT NULL COMMENT '电话/传真',
- `bank_name` varchar(200) DEFAULT NULL COMMENT '开户银行',
- `bank_account` varchar(100) DEFAULT NULL COMMENT '账号',
- `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT NULL COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL COMMENT '更新时间',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `del_flag` char(1) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
- PRIMARY KEY (`id`),
- KEY `idx_tenant_id` (`tenant_id`),
- KEY `idx_del_flag` (`del_flag`)
- ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='供方信息表';
- -- ----------------------------
- -- Table structure for crm_visit
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_visit`;
- CREATE TABLE `crm_visit` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `visit_no` varchar(50) NOT NULL COMMENT '回访编号(VIS+yyyyMMdd+4位流水号)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `contract_id` bigint(20) DEFAULT NULL COMMENT '合同ID',
- `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
- `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
- `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名',
- `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机',
- `visit_type` varchar(20) NOT NULL DEFAULT 'regular' COMMENT '回访类型(contract-合同回访/delivery-交付回访/regular-定期回访/renew-续约回访/complaint-投诉回访/other-其他)',
- `plan_visit_date` datetime DEFAULT NULL COMMENT '计划回访时间',
- `visit_date` datetime NOT NULL COMMENT '实际回访时间(执行回访时填写)',
- `visit_method` varchar(20) NOT NULL DEFAULT 'phone' COMMENT '回访方式(phone-电话/wechat-微信/email-邮件/visit-上门拜访/other-其他)',
- `visit_purpose` text COMMENT '回访目的(多个用逗号分隔: understand_usage,collect_feedback等)',
- `visit_script` text COMMENT '回访话术模板',
- `visit_content` text NOT NULL COMMENT '回访内容',
- `visit_summary` varchar(1000) DEFAULT NULL COMMENT '回访小结',
- `satisfaction` varchar(20) DEFAULT NULL COMMENT '满意度(very_satisfied-非常满意/satisfied-满意/general-一般/dissatisfied-不满意/very_dissatisfied-非常不满意)',
- `satisfaction_score` int(11) DEFAULT NULL COMMENT '满意度评分(1-5分,5分最高)',
- `usage_status` varchar(20) DEFAULT NULL COMMENT '使用情况(normal-正常/occasional-偶尔/rarely-很少/not_used-未使用)',
- `dissatisfaction_reason` varchar(500) DEFAULT NULL COMMENT '不满意原因(满意度<3星时必填)',
- `has_problem` tinyint(1) DEFAULT '0' COMMENT '是否有问题(0否 1是)',
- `problem_count` int(11) DEFAULT '0' COMMENT '问题数量(冗余字段)',
- `problem_summary` varchar(500) DEFAULT NULL COMMENT '问题概述',
- `has_opportunity` tinyint(1) DEFAULT '0' COMMENT '是否有商机(0否 1是)',
- `opportunity_desc` text COMMENT '商机描述',
- `opportunity_amount` decimal(15,2) DEFAULT NULL COMMENT '预估商机金额',
- `next_visit_date` date DEFAULT NULL COMMENT '下次回访日期',
- `next_visit_content` varchar(500) DEFAULT NULL COMMENT '下次回访计划',
- `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '回访状态(pending-待回访/visiting-回访中/completed-已完成/cancelled-已取消)',
- `cancel_reason` varchar(500) DEFAULT NULL COMMENT '取消原因',
- `cancel_time` datetime DEFAULT NULL COMMENT '取消时间',
- `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(回访人)',
- `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
- `duration` int(11) DEFAULT NULL COMMENT '回访时长(分钟)',
- `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个文件用逗号分隔)',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- UNIQUE KEY `uk_visit_no_del_flag` (`visit_no`,`del_flag`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_contract_id` (`contract_id`) USING BTREE,
- KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
- KEY `idx_visit_type` (`visit_type`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_visit_date` (`visit_date`) USING BTREE,
- KEY `idx_satisfaction` (`satisfaction`) USING BTREE,
- KEY `idx_has_problem` (`has_problem`) USING BTREE,
- KEY `idx_has_opportunity` (`has_opportunity`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
- KEY `idx_create_time` (`create_time`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访记录表';
- -- ----------------------------
- -- Table structure for crm_visit_plan
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_visit_plan`;
- CREATE TABLE `crm_visit_plan` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `rule_name` varchar(200) NOT NULL COMMENT '规则名称',
- `trigger_type` varchar(20) NOT NULL COMMENT '触发类型(contract_signed-合同签订后/last_visit-上次回访后/product_expire-产品到期前/fixed_period-固定周期)',
- `delay_days` int(11) NOT NULL DEFAULT '0' COMMENT '延迟天数(合同签订/上次回访后多少天回访)',
- `visit_type` varchar(20) NOT NULL COMMENT '回访类型(参考crm_visit_type字典)',
- `visit_method` varchar(20) DEFAULT 'phone' COMMENT '回访方式(参考crm_visit_method字典)',
- `visit_content_template` text COMMENT '回访内容模板',
- `status` varchar(20) NOT NULL DEFAULT 'enabled' COMMENT '状态(enabled-启用/disabled-禁用)',
- `execute_count` int(11) DEFAULT '0' COMMENT '执行次数',
- `last_execute_time` datetime DEFAULT NULL COMMENT '最后执行时间',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_trigger_type` (`trigger_type`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访计划规则表';
- -- ----------------------------
- -- Table structure for crm_visit_problem
- -- ----------------------------
- DROP TABLE IF EXISTS `crm_visit_problem`;
- CREATE TABLE `crm_visit_problem` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
- `visit_id` bigint(20) NOT NULL COMMENT '回访ID',
- `visit_no` varchar(50) DEFAULT NULL COMMENT '回访编号(冗余字段)',
- `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
- `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
- `problem_type` varchar(20) NOT NULL DEFAULT 'product' COMMENT '问题类型(product-产品问题/service-服务问题/delivery-交付问题/quality-质量问题/price-价格问题/other-其他)',
- `problem_desc` text NOT NULL COMMENT '问题描述',
- `problem_images` varchar(1000) DEFAULT NULL COMMENT '问题图片(多个图片用逗号分隔)',
- `severity` varchar(20) NOT NULL DEFAULT 'medium' COMMENT '严重程度(low-低/medium-中/high-高/urgent-紧急)',
- `solution` text COMMENT '解决方案',
- `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '问题状态(pending-待处理/processing-处理中/solved-已解决/closed-已关闭)',
- `solve_by` bigint(20) DEFAULT NULL COMMENT '处理人ID',
- `solve_by_name` varchar(50) DEFAULT NULL COMMENT '处理人姓名',
- `solve_time` datetime DEFAULT NULL COMMENT '处理时间',
- `solve_duration` int(11) DEFAULT NULL COMMENT '处理耗时(小时)',
- `close_by` bigint(20) DEFAULT NULL COMMENT '关闭人ID',
- `close_by_name` varchar(50) DEFAULT NULL COMMENT '关闭人姓名',
- `close_time` datetime DEFAULT NULL COMMENT '关闭时间',
- `close_reason` varchar(500) DEFAULT NULL COMMENT '关闭原因',
- `customer_feedback` text COMMENT '客户反馈',
- `is_satisfied` tinyint(1) DEFAULT NULL COMMENT '客户是否满意(0否 1是)',
- `sort` int(11) DEFAULT '0' COMMENT '排序号',
- `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
- `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
- `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
- `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
- `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
- `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
- `remark` varchar(500) DEFAULT NULL COMMENT '备注',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_visit_id` (`visit_id`) USING BTREE,
- KEY `idx_customer_id` (`customer_id`) USING BTREE,
- KEY `idx_problem_type` (`problem_type`) USING BTREE,
- KEY `idx_severity` (`severity`) USING BTREE,
- KEY `idx_status` (`status`) USING BTREE,
- KEY `idx_solve_by` (`solve_by`) USING BTREE,
- KEY `idx_tenant_id` (`tenant_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访问题记录表';
- SET FOREIGN_KEY_CHECKS = 1;
|