crm-table-保留.sql 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613
  1. /*
  2. Navicat Premium Dump SQL
  3. Source Server : 121.43.228.102 hn02le.34lkdLKD
  4. Source Server Type : MySQL
  5. Source Server Version : 50736 (5.7.36)
  6. Source Host : 121.43.228.102:3306
  7. Source Schema : sx
  8. Target Server Type : MySQL
  9. Target Server Version : 50736 (5.7.36)
  10. File Encoding : 65001
  11. Date: 09/05/2026 22:57:41
  12. */
  13. SET NAMES utf8mb4;
  14. SET FOREIGN_KEY_CHECKS = 0;
  15. -- ----------------------------
  16. -- Table structure for crm_clue
  17. -- ----------------------------
  18. DROP TABLE IF EXISTS `crm_clue`;
  19. CREATE TABLE `crm_clue` (
  20. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  21. `clue_name` varchar(100) NOT NULL COMMENT '线索姓名',
  22. `mobile` varchar(20) NOT NULL COMMENT '手机号',
  23. `company` varchar(200) DEFAULT NULL COMMENT '公司名称',
  24. `customer_type` varchar(20) DEFAULT NULL COMMENT '客户类型(company-企业/person-个人)',
  25. `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
  26. `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
  27. `title` varchar(10) DEFAULT NULL COMMENT '称呼(先生/女士/其他)',
  28. `position` varchar(50) DEFAULT NULL COMMENT '职位',
  29. `source` varchar(20) NOT NULL COMMENT '线索来源(网站留言/电话咨询/展会/市场活动/老客户推荐/广告投放/社交媒体/其他)',
  30. `level` varchar(10) DEFAULT 'unrated' COMMENT '线索等级(A/B/C/unrated)',
  31. `industry` varchar(50) DEFAULT NULL COMMENT '所属行业',
  32. `park_area` varchar(100) DEFAULT NULL COMMENT '所在园区',
  33. `province` varchar(50) DEFAULT NULL COMMENT '省',
  34. `city` varchar(50) DEFAULT NULL COMMENT '市',
  35. `district` varchar(50) DEFAULT NULL COMMENT '区',
  36. `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
  37. `website` varchar(500) DEFAULT NULL COMMENT '客户网站',
  38. `intent_products` varchar(500) DEFAULT NULL COMMENT '意向产品(多个用逗号分隔)',
  39. `expect_time` date DEFAULT NULL COMMENT '预计购买时间',
  40. `budget` varchar(20) DEFAULT NULL COMMENT '预算范围(1万以下/1-5万/5-10万/10-50万/50万以上/未知)',
  41. `requirement` text COMMENT '需求描述',
  42. `status` varchar(20) DEFAULT 'new' COMMENT '线索状态(new-新线索/follow-跟进中/invalid-无效/converted-已转化)',
  43. `owner_user_id` bigint(20) DEFAULT NULL COMMENT '负责人ID',
  44. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  45. `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
  46. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  47. `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数',
  48. `is_converted` tinyint(1) DEFAULT '0' COMMENT '是否已转化(0-否 1-是)',
  49. `converted_time` datetime DEFAULT NULL COMMENT '转化时间',
  50. `customer_id` bigint(20) DEFAULT NULL COMMENT '转化的客户ID',
  51. `converted_by` bigint(20) DEFAULT NULL COMMENT '转化操作人',
  52. `assign_time` datetime DEFAULT NULL COMMENT '分配时间',
  53. `assign_by` bigint(20) DEFAULT NULL COMMENT '分配人',
  54. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  55. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  56. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  57. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  58. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  59. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  60. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  61. `version` int(11) DEFAULT '0' COMMENT '版本号',
  62. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  63. PRIMARY KEY (`id`) USING BTREE,
  64. KEY `idx_mobile` (`mobile`) USING BTREE,
  65. KEY `idx_owner` (`owner_user_id`) USING BTREE,
  66. KEY `idx_status` (`status`) USING BTREE,
  67. KEY `idx_level` (`level`) USING BTREE,
  68. KEY `idx_source` (`source`) USING BTREE,
  69. KEY `idx_create_time` (`create_time`) USING BTREE,
  70. KEY `idx_next_time` (`next_time`) USING BTREE,
  71. KEY `idx_tenant` (`tenant_id`) USING BTREE,
  72. KEY `idx_park_area` (`park_area`) USING BTREE
  73. ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-线索主表';
  74. -- ----------------------------
  75. -- Table structure for crm_clue_follow
  76. -- ----------------------------
  77. DROP TABLE IF EXISTS `crm_clue_follow`;
  78. CREATE TABLE `crm_clue_follow` (
  79. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  80. `clue_id` bigint(20) NOT NULL COMMENT '线索ID',
  81. `clue_name` varchar(100) DEFAULT NULL COMMENT '线索姓名(冗余)',
  82. `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(电话/微信/邮件/拜访/其他)',
  83. `follow_content` text NOT NULL COMMENT '跟进内容',
  84. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  85. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
  86. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  87. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  88. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
  89. `create_by_name` varchar(50) DEFAULT NULL COMMENT '跟进人姓名(冗余)',
  90. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
  91. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  92. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  93. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  94. `version` int(11) DEFAULT '0' COMMENT '版本号',
  95. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  96. PRIMARY KEY (`id`) USING BTREE,
  97. KEY `idx_clue_id` (`clue_id`) USING BTREE,
  98. KEY `idx_create_by` (`create_by`) USING BTREE,
  99. KEY `idx_create_time` (`create_time`) USING BTREE,
  100. KEY `idx_next_time` (`next_time`) USING BTREE,
  101. KEY `idx_tenant` (`tenant_id`) USING BTREE
  102. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-线索跟进记录表';
  103. -- ----------------------------
  104. -- Table structure for crm_contact
  105. -- ----------------------------
  106. DROP TABLE IF EXISTS `crm_contact`;
  107. CREATE TABLE `crm_contact` (
  108. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  109. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  110. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
  111. `contact_name` varchar(100) NOT NULL COMMENT '联系人姓名',
  112. `gender` varchar(10) DEFAULT NULL COMMENT '性别(male-男/female-女)',
  113. `mobile` varchar(20) DEFAULT NULL COMMENT '手机号',
  114. `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
  115. `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
  116. `wechat` varchar(100) DEFAULT NULL COMMENT '微信号',
  117. `qq` varchar(20) DEFAULT NULL COMMENT 'QQ号',
  118. `department` varchar(100) DEFAULT NULL COMMENT '部门',
  119. `position` varchar(50) DEFAULT NULL COMMENT '职位',
  120. `role` varchar(20) DEFAULT NULL COMMENT '角色(decision-决策人/manager-管理者/user-使用者/other-其他)',
  121. `birthday` date DEFAULT NULL COMMENT '生日',
  122. `address` varchar(255) DEFAULT NULL COMMENT '住址',
  123. `is_key` tinyint(1) DEFAULT '0' COMMENT '是否关键决策人(0-否 1-是)',
  124. `is_primary` tinyint(1) DEFAULT '0' COMMENT '是否主要联系人(0-否 1-是)',
  125. `status` varchar(20) DEFAULT 'active' COMMENT '状态(active-在职/leave-离职)',
  126. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  127. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  128. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  129. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  130. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  131. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  132. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  133. `version` int(11) DEFAULT '0' COMMENT '版本号',
  134. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  135. PRIMARY KEY (`id`) USING BTREE,
  136. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  137. KEY `idx_mobile` (`mobile`) USING BTREE,
  138. KEY `idx_is_key` (`is_key`) USING BTREE,
  139. KEY `idx_tenant` (`tenant_id`) USING BTREE
  140. ) ENGINE=InnoDB AUTO_INCREMENT=2048203394065793027 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-联系人表';
  141. -- ----------------------------
  142. -- Table structure for crm_contract
  143. -- ----------------------------
  144. DROP TABLE IF EXISTS `crm_contract`;
  145. CREATE TABLE `crm_contract` (
  146. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  147. `contract_no` varchar(50) NOT NULL COMMENT '合同编号(CON+yyyyMMdd+4位流水号)',
  148. `contract_name` varchar(200) NOT NULL COMMENT '合同名称',
  149. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  150. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  151. `opportunity_id` bigint(20) DEFAULT NULL COMMENT '商机ID',
  152. `quote_id` bigint(20) DEFAULT NULL COMMENT '报价单ID',
  153. `parent_contract_id` bigint(20) DEFAULT NULL COMMENT '原合同ID(续签时关联)',
  154. `renewal_count` int(11) DEFAULT '0' COMMENT '续签次数',
  155. `template_id` bigint(20) DEFAULT NULL COMMENT '合同模板ID',
  156. `contract_template` varchar(50) DEFAULT 'shanxia' COMMENT '合同模版(shanxia-山峡模版/customer-客户模版)',
  157. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  158. `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
  159. `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机(冗余字段)',
  160. `contract_type` varchar(20) NOT NULL DEFAULT 'sale' COMMENT '合同类型(sale-销售合同/service-服务合同/lease-租赁合同/other-其他)',
  161. `contract_nature` varchar(20) DEFAULT 'new' COMMENT '合同性质(new-新签/renewal-续签/change-变更)',
  162. `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '合同金额',
  163. `currency` varchar(10) DEFAULT 'CNY' COMMENT '币种(CNY-人民币/USD-美元/EUR-欧元)',
  164. `tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '税率(%)',
  165. `amount_with_tax` decimal(15,2) DEFAULT '0.00' COMMENT '含税金额',
  166. `sign_date` date DEFAULT NULL COMMENT '签订日期',
  167. `actual_sign_date` date DEFAULT NULL COMMENT '实际签订日期',
  168. `start_date` date DEFAULT NULL COMMENT '开始日期',
  169. `end_date` date DEFAULT NULL COMMENT '结束日期',
  170. `contract_period` int(11) DEFAULT NULL COMMENT '合同期限(月)',
  171. `status` varchar(20) NOT NULL DEFAULT 'draft' COMMENT '合同状态(draft-草稿/approving-审批中/approved-已审批/executing-执行中/finished-已完成/invalid-已作废)',
  172. `performance_status` varchar(20) DEFAULT 'normal' COMMENT '履约状态(normal-正常/delayed-延期/abnormal-异常/completed-已完成)',
  173. `performance_rate` decimal(5,2) DEFAULT '0.00' COMMENT '履约完成度(%)',
  174. `customer_satisfaction` int(11) DEFAULT NULL COMMENT '客户满意度(1-5星)',
  175. `approval_status` varchar(20) DEFAULT NULL COMMENT '审批状态(pending-待审批/approved-已通过/rejected-已驳回)',
  176. `approval_flow_id` bigint(20) DEFAULT NULL COMMENT '审批流程ID(关联工作流)',
  177. `contract_file` varchar(500) DEFAULT NULL COMMENT '合同文件路径(扫描件或电子版)',
  178. `attachment_files` varchar(1000) DEFAULT NULL COMMENT '附件文件(多个文件用逗号分隔)',
  179. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
  180. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  181. `received_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已回款金额',
  182. `unreceived_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未回款金额',
  183. `invoice_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已开票金额',
  184. `uninvoice_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未开票金额',
  185. `party_a` varchar(200) DEFAULT NULL COMMENT '甲方(客户方)',
  186. `party_a_address` varchar(255) DEFAULT NULL COMMENT '甲方地址',
  187. `party_a_contact` varchar(50) DEFAULT NULL COMMENT '甲方联系人',
  188. `party_a_mobile` varchar(20) DEFAULT NULL COMMENT '甲方联系电话',
  189. `party_a_legal_person` varchar(50) DEFAULT NULL COMMENT '甲方法定代表人',
  190. `party_a_agent` varchar(50) DEFAULT NULL COMMENT '甲方代理人',
  191. `party_a_phone_fax` varchar(50) DEFAULT NULL COMMENT '甲方电话/传真',
  192. `party_a_bank` varchar(100) DEFAULT NULL COMMENT '甲方开户银行',
  193. `party_a_account` varchar(50) DEFAULT NULL COMMENT '甲方银行账号',
  194. `party_b` varchar(200) DEFAULT NULL COMMENT '乙方(我方)',
  195. `party_b_address` varchar(255) DEFAULT NULL COMMENT '乙方地址',
  196. `party_b_contact` varchar(50) DEFAULT NULL COMMENT '乙方联系人',
  197. `party_b_mobile` varchar(20) DEFAULT NULL COMMENT '乙方联系电话',
  198. `party_b_legal_person` varchar(100) DEFAULT NULL COMMENT '乙方法定代表人',
  199. `party_b_agent` varchar(100) DEFAULT NULL COMMENT '乙方代理人',
  200. `party_b_phone_fax` varchar(100) DEFAULT NULL COMMENT '乙方电话/传真',
  201. `party_b_bank` varchar(200) DEFAULT NULL COMMENT '乙方开户银行',
  202. `party_b_account` varchar(100) DEFAULT NULL COMMENT '乙方银行账号',
  203. `payment_terms` text COMMENT '付款条款',
  204. `delivery_terms` text COMMENT '交付条款',
  205. `contract_terms` text COMMENT '合同条款',
  206. `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
  207. `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
  208. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  209. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  210. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  211. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  212. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  213. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  214. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  215. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  216. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  217. `template_content` longtext COMMENT '合同模板内容(富文本HTML)',
  218. `settlement_clause_drafts` longtext COMMENT '第五条结算方式草稿(按结算方式区分的JSON)',
  219. `supplier_id` bigint(20) DEFAULT NULL COMMENT '供方主体ID(关联crm_supplier_info表)',
  220. `settlement_method` varchar(50) DEFAULT NULL COMMENT '结算方式(arrive_payment-货到付款,advance_payment-款到发货)',
  221. PRIMARY KEY (`id`) USING BTREE,
  222. UNIQUE KEY `uk_contract_no_del_flag` (`contract_no`,`del_flag`) USING BTREE,
  223. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  224. KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
  225. KEY `idx_quote_id` (`quote_id`) USING BTREE,
  226. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  227. KEY `idx_status` (`status`) USING BTREE,
  228. KEY `idx_approval_status` (`approval_status`) USING BTREE,
  229. KEY `idx_sign_date` (`sign_date`) USING BTREE,
  230. KEY `idx_end_date` (`end_date`) USING BTREE,
  231. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  232. KEY `idx_create_time` (`create_time`) USING BTREE,
  233. KEY `idx_contract_nature` (`contract_nature`) USING BTREE,
  234. KEY `idx_parent_contract_id` (`parent_contract_id`) USING BTREE,
  235. KEY `idx_performance_status` (`performance_status`) USING BTREE,
  236. KEY `idx_supplier_id` (`supplier_id`)
  237. ) ENGINE=InnoDB AUTO_INCREMENT=2052978521227886595 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同主表';
  238. -- ----------------------------
  239. -- Table structure for crm_contract_approval
  240. -- ----------------------------
  241. DROP TABLE IF EXISTS `crm_contract_approval`;
  242. CREATE TABLE `crm_contract_approval` (
  243. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  244. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  245. `flow_id` bigint(20) DEFAULT NULL COMMENT '审批流程ID(关联工作流)',
  246. `step` int(11) NOT NULL DEFAULT '1' COMMENT '审批步骤(第几步)',
  247. `step_name` varchar(100) DEFAULT NULL COMMENT '步骤名称',
  248. `approver_id` bigint(20) NOT NULL COMMENT '审批人ID',
  249. `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
  250. `approver_dept` varchar(100) DEFAULT NULL COMMENT '审批人部门',
  251. `approval_result` varchar(20) DEFAULT 'pending' COMMENT '审批结果(pending-待审批/approved-已通过/rejected-已驳回)',
  252. `approval_opinion` text COMMENT '审批意见',
  253. `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
  254. `approval_duration` int(11) DEFAULT NULL COMMENT '审批耗时(小时)',
  255. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件',
  256. `is_current` tinyint(1) DEFAULT '1' COMMENT '是否当前步骤(0否 1是)',
  257. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  258. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  259. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  260. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  261. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  262. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  263. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  264. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  265. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  266. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  267. PRIMARY KEY (`id`) USING BTREE,
  268. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  269. KEY `idx_approver_id` (`approver_id`) USING BTREE,
  270. KEY `idx_approval_result` (`approval_result`) USING BTREE,
  271. KEY `idx_is_current` (`is_current`) USING BTREE,
  272. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  273. ) ENGINE=InnoDB AUTO_INCREMENT=2049366907144601602 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同审批记录表';
  274. -- ----------------------------
  275. -- Table structure for crm_contract_change
  276. -- ----------------------------
  277. DROP TABLE IF EXISTS `crm_contract_change`;
  278. CREATE TABLE `crm_contract_change` (
  279. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  280. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  281. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余)',
  282. `change_type` varchar(50) NOT NULL COMMENT '变更类型(amount-金额变更/period-期限变更/product-产品变更/terms-条款变更/other-其他)',
  283. `change_reason` varchar(500) NOT NULL COMMENT '变更原因',
  284. `change_content` text COMMENT '变更内容描述',
  285. `old_value` text COMMENT '变更前值(JSON格式)',
  286. `new_value` text COMMENT '变更后值(JSON格式)',
  287. `change_amount` decimal(15,2) DEFAULT NULL COMMENT '变更金额(用于金额变更)',
  288. `approval_status` varchar(20) DEFAULT 'pending' COMMENT '审批状态(pending-待审批/approved-已通过/rejected-已驳回)',
  289. `approver_id` bigint(20) DEFAULT NULL COMMENT '审批人ID',
  290. `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
  291. `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
  292. `approval_opinion` varchar(500) DEFAULT NULL COMMENT '审批意见',
  293. `attachment_files` varchar(1000) DEFAULT NULL COMMENT '附件文件(变更协议等)',
  294. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  295. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  296. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  297. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  298. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  299. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  300. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  301. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  302. PRIMARY KEY (`id`) USING BTREE,
  303. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  304. KEY `idx_change_type` (`change_type`) USING BTREE,
  305. KEY `idx_approval_status` (`approval_status`) USING BTREE,
  306. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  307. KEY `idx_create_time` (`create_time`) USING BTREE
  308. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同变更记录表';
  309. -- ----------------------------
  310. -- Table structure for crm_contract_product
  311. -- ----------------------------
  312. DROP TABLE IF EXISTS `crm_contract_product`;
  313. CREATE TABLE `crm_contract_product` (
  314. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  315. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  316. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  317. `product_name` varchar(200) NOT NULL COMMENT '产品名称',
  318. `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号',
  319. `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
  320. `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称',
  321. `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
  322. `unit` varchar(20) DEFAULT '件' COMMENT '单位',
  323. `quantity` decimal(20,4) NOT NULL COMMENT '数量',
  324. `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价',
  325. `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比)',
  326. `tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '税率(%)',
  327. `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税费金额',
  328. `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '小计金额',
  329. `delivery_date` date DEFAULT NULL COMMENT '交付日期',
  330. `delivery_status` varchar(20) DEFAULT 'pending' COMMENT '交付状态(pending-待交付/partial-部分交付/delivered-已交付)',
  331. `delivered_quantity` decimal(20,4) DEFAULT '0.0000' COMMENT '已交付数量',
  332. `description` varchar(1000) DEFAULT NULL COMMENT '产品描述',
  333. `package_spec` varchar(200) DEFAULT NULL COMMENT '包装规格',
  334. `delivery_method` varchar(100) DEFAULT NULL COMMENT '送货方式',
  335. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  336. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  337. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  338. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  339. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  340. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  341. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  342. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  343. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  344. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  345. PRIMARY KEY (`id`) USING BTREE,
  346. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  347. KEY `idx_product_id` (`product_id`) USING BTREE,
  348. KEY `idx_delivery_status` (`delivery_status`) USING BTREE,
  349. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  350. ) ENGINE=InnoDB AUTO_INCREMENT=2052978521328549890 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同产品明细表';
  351. -- ----------------------------
  352. -- Table structure for crm_contract_product_price_tier
  353. -- ----------------------------
  354. DROP TABLE IF EXISTS `crm_contract_product_price_tier`;
  355. CREATE TABLE `crm_contract_product_price_tier` (
  356. `id` bigint(20) NOT NULL COMMENT '主键ID',
  357. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  358. `contract_product_id` bigint(20) NOT NULL COMMENT '合同产品明细ID',
  359. `start_date` date NOT NULL COMMENT '区间开始日期',
  360. `end_date` date NOT NULL COMMENT '区间结束日期',
  361. `price` decimal(15,2) NOT NULL COMMENT '含税单价',
  362. `letter_oss_ids` varchar(4000) DEFAULT NULL COMMENT '调价函OSS ID列表(JSON字符串数组,如["id1","id2"])',
  363. `letter_oss_id` bigint(20) DEFAULT NULL COMMENT '调价函单附件OSS ID(废弃,请使用 letter_oss_ids)',
  364. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  365. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  366. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  367. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  368. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  369. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  370. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  371. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  372. PRIMARY KEY (`id`),
  373. KEY `idx_contract_id` (`contract_id`),
  374. KEY `idx_contract_product_id` (`contract_product_id`)
  375. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-框架合同产品调价区间';
  376. -- ----------------------------
  377. -- Table structure for crm_contract_template
  378. -- ----------------------------
  379. DROP TABLE IF EXISTS `crm_contract_template`;
  380. CREATE TABLE `crm_contract_template` (
  381. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  382. `template_no` varchar(50) NOT NULL COMMENT '模板编号',
  383. `template_name` varchar(200) NOT NULL COMMENT '模板名称',
  384. `contract_type` varchar(20) DEFAULT NULL COMMENT '适用合同类型(sale-销售/service-服务等)',
  385. `template_content` text COMMENT '模板内容(富文本)',
  386. `payment_terms` text COMMENT '付款条款模板',
  387. `delivery_terms` text COMMENT '交付条款模板',
  388. `contract_terms` text COMMENT '合同条款模板',
  389. `party_b` varchar(200) DEFAULT NULL COMMENT '乙方(我方)默认名称',
  390. `party_b_address` varchar(255) DEFAULT NULL COMMENT '乙方地址',
  391. `party_b_contact` varchar(50) DEFAULT NULL COMMENT '乙方联系人',
  392. `party_b_mobile` varchar(20) DEFAULT NULL COMMENT '乙方联系电话',
  393. `default_currency` varchar(10) DEFAULT 'CNY' COMMENT '默认币种',
  394. `default_tax_rate` decimal(5,2) DEFAULT '6.00' COMMENT '默认税率(%)',
  395. `default_period` int(11) DEFAULT '12' COMMENT '默认合同期限(月)',
  396. `is_active` tinyint(1) DEFAULT '1' COMMENT '是否启用(0-停用 1-启用)',
  397. `usage_count` int(11) DEFAULT '0' COMMENT '使用次数',
  398. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  399. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  400. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  401. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  402. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  403. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  404. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  405. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  406. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  407. PRIMARY KEY (`id`) USING BTREE,
  408. UNIQUE KEY `uk_template_no` (`template_no`) USING BTREE,
  409. KEY `idx_contract_type` (`contract_type`) USING BTREE,
  410. KEY `idx_is_active` (`is_active`) USING BTREE,
  411. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  412. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-合同模板表';
  413. -- ----------------------------
  414. -- Table structure for crm_customer
  415. -- ----------------------------
  416. DROP TABLE IF EXISTS `crm_customer`;
  417. CREATE TABLE `crm_customer` (
  418. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  419. `customer_no` varchar(50) NOT NULL COMMENT '客户编号(唯一)',
  420. `customer_name` varchar(200) NOT NULL COMMENT '客户名称',
  421. `short_name` varchar(100) DEFAULT NULL COMMENT '客户简称',
  422. `customer_type` varchar(20) DEFAULT 'company' COMMENT '客户类型(company-企业/person-个人)',
  423. `mobile` varchar(20) DEFAULT NULL COMMENT '手机号',
  424. `telephone` varchar(30) DEFAULT NULL COMMENT '固定电话',
  425. `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
  426. `website` varchar(500) DEFAULT NULL COMMENT '客户网站',
  427. `level` varchar(20) DEFAULT 'normal' COMMENT '客户级别(key-重点/normal-普通/potential-潜在)',
  428. `source` varchar(20) DEFAULT NULL COMMENT '客户来源',
  429. `industry` varchar(50) DEFAULT NULL COMMENT '所属行业',
  430. `park_area` varchar(100) DEFAULT NULL COMMENT '所在园区',
  431. `payment_terms` varchar(500) DEFAULT NULL COMMENT '收付款条件(如:预付30%、账期30天等)',
  432. `scale` varchar(20) DEFAULT NULL COMMENT '企业规模(1-50人/50-200人/200-500人/500人以上)',
  433. `province` varchar(50) DEFAULT NULL COMMENT '省',
  434. `city` varchar(50) DEFAULT NULL COMMENT '市',
  435. `district` varchar(50) DEFAULT NULL COMMENT '区',
  436. `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
  437. `status` varchar(20) DEFAULT 'normal' COMMENT '客户状态(normal-正常/pool-公海/invalid-无效)',
  438. `deal_status` varchar(20) DEFAULT 'not_deal' COMMENT '成交状态(not_deal-未成交/dealed-已成交/lost-已流失)',
  439. `owner_user_id` bigint(20) DEFAULT NULL COMMENT '负责人ID',
  440. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余)',
  441. `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
  442. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  443. `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数',
  444. `deal_time` datetime DEFAULT NULL COMMENT '成交时间',
  445. `deal_amount` decimal(15,2) DEFAULT '0.00' COMMENT '累计成交金额',
  446. `contact_count` int(11) DEFAULT '0' COMMENT '联系人数量',
  447. `opportunity_count` int(11) DEFAULT '0' COMMENT '商机数量',
  448. `contract_count` int(11) DEFAULT '0' COMMENT '合同数量',
  449. `into_pool_time` datetime DEFAULT NULL COMMENT '进入公海时间',
  450. `into_pool_by` bigint(20) DEFAULT NULL COMMENT '进入公海操作人ID',
  451. `into_pool_reason` varchar(500) DEFAULT NULL COMMENT '进入公海原因',
  452. `claim_time` datetime DEFAULT NULL COMMENT '领取时间',
  453. `assign_time` datetime DEFAULT NULL COMMENT '分配时间',
  454. `assign_by` bigint(20) DEFAULT NULL COMMENT '分配人ID',
  455. `protect_time` datetime DEFAULT NULL COMMENT '保护到期时间',
  456. `clue_id` bigint(20) DEFAULT NULL COMMENT '关联线索ID(从线索转化)',
  457. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  458. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  459. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  460. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  461. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  462. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  463. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  464. `version` int(11) DEFAULT '0' COMMENT '版本号',
  465. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  466. `business_license_images` varchar(1000) DEFAULT NULL COMMENT '营业执照图片OSS ID(多个用逗号分隔)',
  467. `business_permit_images` varchar(1000) DEFAULT NULL COMMENT '经营许可证图片OSS ID(多个用逗号分隔)',
  468. `other_cert_images` varchar(1000) DEFAULT NULL COMMENT '其他证件图片OSS ID(多个用逗号分隔)',
  469. PRIMARY KEY (`id`) USING BTREE,
  470. UNIQUE KEY `uk_customer_no_del_flag` (`customer_no`,`del_flag`) USING BTREE,
  471. KEY `idx_mobile` (`mobile`) USING BTREE,
  472. KEY `idx_owner` (`owner_user_id`) USING BTREE,
  473. KEY `idx_status` (`status`) USING BTREE,
  474. KEY `idx_level` (`level`) USING BTREE,
  475. KEY `idx_deal_status` (`deal_status`) USING BTREE,
  476. KEY `idx_source` (`source`) USING BTREE,
  477. KEY `idx_create_time` (`create_time`) USING BTREE,
  478. KEY `idx_next_time` (`next_time`) USING BTREE,
  479. KEY `idx_clue` (`clue_id`) USING BTREE,
  480. KEY `idx_tenant` (`tenant_id`) USING BTREE,
  481. KEY `idx_park_area` (`park_area`) USING BTREE
  482. ) ENGINE=InnoDB AUTO_INCREMENT=2047862937284673538 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户主表';
  483. -- ----------------------------
  484. -- Table structure for crm_customer_follow
  485. -- ----------------------------
  486. DROP TABLE IF EXISTS `crm_customer_follow`;
  487. CREATE TABLE `crm_customer_follow` (
  488. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  489. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  490. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
  491. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  492. `contact_name` varchar(100) DEFAULT NULL COMMENT '联系人姓名(冗余)',
  493. `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(电话/微信/邮件/拜访/其他)',
  494. `follow_content` text NOT NULL COMMENT '跟进内容',
  495. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  496. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
  497. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  498. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  499. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
  500. `create_by_name` varchar(50) DEFAULT NULL COMMENT '跟进人姓名(冗余)',
  501. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
  502. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  503. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  504. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  505. `version` int(11) DEFAULT '0' COMMENT '版本号',
  506. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  507. PRIMARY KEY (`id`) USING BTREE,
  508. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  509. KEY `idx_contact_id` (`contact_id`) USING BTREE,
  510. KEY `idx_create_by` (`create_by`) USING BTREE,
  511. KEY `idx_create_time` (`create_time`) USING BTREE,
  512. KEY `idx_next_time` (`next_time`) USING BTREE,
  513. KEY `idx_tenant` (`tenant_id`) USING BTREE
  514. ) ENGINE=InnoDB AUTO_INCREMENT=1985641912854016003 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户跟进记录表';
  515. -- ----------------------------
  516. -- Table structure for crm_customer_pool
  517. -- ----------------------------
  518. DROP TABLE IF EXISTS `crm_customer_pool`;
  519. CREATE TABLE `crm_customer_pool` (
  520. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  521. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  522. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
  523. `operation_type` varchar(20) NOT NULL COMMENT '操作类型(into-进入公海/claim-领取/assign-分配/recycle-回收)',
  524. `from_user_id` bigint(20) DEFAULT NULL COMMENT '原负责人ID',
  525. `from_user_name` varchar(50) DEFAULT NULL COMMENT '原负责人姓名(冗余)',
  526. `to_user_id` bigint(20) DEFAULT NULL COMMENT '新负责人ID',
  527. `to_user_name` varchar(50) DEFAULT NULL COMMENT '新负责人姓名(冗余)',
  528. `reason` varchar(500) DEFAULT NULL COMMENT '操作原因',
  529. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  530. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  531. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(操作人)',
  532. `create_by_name` varchar(50) DEFAULT NULL COMMENT '操作人姓名(冗余)',
  533. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(操作时间)',
  534. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  535. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  536. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  537. `version` int(11) DEFAULT '0' COMMENT '版本号',
  538. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  539. PRIMARY KEY (`id`) USING BTREE,
  540. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  541. KEY `idx_operation_type` (`operation_type`) USING BTREE,
  542. KEY `idx_from_user` (`from_user_id`) USING BTREE,
  543. KEY `idx_to_user` (`to_user_id`) USING BTREE,
  544. KEY `idx_create_time` (`create_time`) USING BTREE,
  545. KEY `idx_tenant` (`tenant_id`) USING BTREE
  546. ) ENGINE=InnoDB AUTO_INCREMENT=1991718802157080578 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户公海池记录表';
  547. -- ----------------------------
  548. -- Table structure for crm_customer_pool_rule
  549. -- ----------------------------
  550. DROP TABLE IF EXISTS `crm_customer_pool_rule`;
  551. CREATE TABLE `crm_customer_pool_rule` (
  552. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  553. `pool_name` varchar(100) NOT NULL COMMENT '规则名称',
  554. `rule_type` varchar(20) NOT NULL COMMENT '规则类型(no_follow-未跟进/no_deal-未成交)',
  555. `timeout_days` int(11) NOT NULL COMMENT '超时天数(多少天未跟进/未成交)',
  556. `protect_days` int(11) NOT NULL DEFAULT '0' COMMENT '保护期天数(领取后保护多少天)',
  557. `status` varchar(20) DEFAULT 'enable' COMMENT '状态(enable-启用/disable-禁用)',
  558. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  559. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  560. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  561. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  562. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  563. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  564. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  565. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  566. `version` int(11) DEFAULT '0' COMMENT '版本号',
  567. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  568. PRIMARY KEY (`id`) USING BTREE,
  569. KEY `idx_status` (`status`) USING BTREE,
  570. KEY `idx_rule_type` (`rule_type`) USING BTREE,
  571. KEY `idx_sort` (`sort`) USING BTREE,
  572. KEY `idx_tenant` (`tenant_id`) USING BTREE
  573. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户公海池规则表';
  574. -- ----------------------------
  575. -- Table structure for crm_customer_tag
  576. -- ----------------------------
  577. DROP TABLE IF EXISTS `crm_customer_tag`;
  578. CREATE TABLE `crm_customer_tag` (
  579. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  580. `tag_name` varchar(50) NOT NULL COMMENT '标签名称',
  581. `tag_color` varchar(20) DEFAULT '#409EFF' COMMENT '标签颜色(十六进制颜色值)',
  582. `tag_type` varchar(20) DEFAULT 'custom' COMMENT '标签类型(system-系统预设/custom-自定义)',
  583. `sort_order` int(11) DEFAULT '0' COMMENT '排序号',
  584. `share_scope` varchar(20) DEFAULT 'private' COMMENT '共享范围(private-个人/dept-部门/company-公司)',
  585. `create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
  586. `create_user_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
  587. `use_count` int(11) DEFAULT '0' COMMENT '使用次数',
  588. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  589. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  590. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  591. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  592. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  593. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  594. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  595. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  596. PRIMARY KEY (`id`) USING BTREE,
  597. UNIQUE KEY `uk_tag_name` (`tag_name`,`tenant_id`,`del_flag`) USING BTREE,
  598. KEY `idx_tag_type` (`tag_type`) USING BTREE,
  599. KEY `idx_share_scope` (`share_scope`) USING BTREE,
  600. KEY `idx_create_user` (`create_user_id`) USING BTREE,
  601. KEY `idx_tenant` (`tenant_id`) USING BTREE
  602. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户标签表';
  603. -- ----------------------------
  604. -- Table structure for crm_customer_tag_relation
  605. -- ----------------------------
  606. DROP TABLE IF EXISTS `crm_customer_tag_relation`;
  607. CREATE TABLE `crm_customer_tag_relation` (
  608. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  609. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  610. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
  611. `tag_id` bigint(20) NOT NULL COMMENT '标签ID',
  612. `tag_name` varchar(50) DEFAULT NULL COMMENT '标签名称(冗余)',
  613. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  614. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(打标签的人)',
  615. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  616. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  617. PRIMARY KEY (`id`) USING BTREE,
  618. UNIQUE KEY `uk_customer_tag` (`customer_id`,`tag_id`,`del_flag`) USING BTREE,
  619. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  620. KEY `idx_tag_id` (`tag_id`) USING BTREE,
  621. KEY `idx_tenant` (`tenant_id`) USING BTREE
  622. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-客户标签关联表';
  623. -- ----------------------------
  624. -- Table structure for crm_invoice
  625. -- ----------------------------
  626. DROP TABLE IF EXISTS `crm_invoice`;
  627. CREATE TABLE `crm_invoice` (
  628. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  629. `invoice_no` varchar(50) NOT NULL COMMENT '发票编号(INV+yyyyMMdd+4位流水号)',
  630. `invoice_code` varchar(50) DEFAULT NULL COMMENT '发票代码(税务发票代码)',
  631. `invoice_number` varchar(50) DEFAULT NULL COMMENT '发票号码(税务发票号码)',
  632. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  633. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
  634. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  635. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  636. `payment_id` bigint(20) DEFAULT NULL COMMENT '回款ID',
  637. `payment_no` varchar(50) DEFAULT NULL COMMENT '回款编号(冗余字段)',
  638. `invoice_type` varchar(20) NOT NULL DEFAULT 'special' COMMENT '发票类型(special-增值税专用发票/normal-增值税普通发票/electronic-电子发票)',
  639. `invoice_title` varchar(200) NOT NULL COMMENT '发票抬头',
  640. `tax_no` varchar(50) NOT NULL COMMENT '纳税人识别号',
  641. `company_address` varchar(255) DEFAULT NULL COMMENT '企业地址',
  642. `company_phone` varchar(50) DEFAULT NULL COMMENT '企业电话',
  643. `bank_name` varchar(100) DEFAULT NULL COMMENT '开户银行',
  644. `bank_account` varchar(100) DEFAULT NULL COMMENT '银行账号',
  645. `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '开票金额(不含税)',
  646. `tax_rate` decimal(5,2) NOT NULL DEFAULT '6.00' COMMENT '税率(百分比,如6.00表示6%)',
  647. `is_tax_included` tinyint(1) DEFAULT '0' COMMENT '是否含税: 0-不含税 1-含税',
  648. `tax_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '税额',
  649. `total_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '价税合计',
  650. `invoice_content` varchar(200) DEFAULT NULL COMMENT '开票内容',
  651. `invoice_date` date DEFAULT NULL COMMENT '开票日期',
  652. `status` varchar(20) NOT NULL DEFAULT 'applying' COMMENT '发票状态(applying-申请中/approved-已审批/invoiced-已开票/delivered-已寄出/received-已签收/rejected-已驳回/invalid-已作废)',
  653. `reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
  654. `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
  655. `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
  656. `invoice_file` varchar(500) DEFAULT NULL COMMENT '发票PDF文件',
  657. `invoice_image` varchar(500) DEFAULT NULL COMMENT '发票图片(扫描件)',
  658. `express_company` varchar(50) DEFAULT NULL COMMENT '快递公司',
  659. `express_no` varchar(100) DEFAULT NULL COMMENT '快递单号',
  660. `express_status` varchar(20) DEFAULT 'no' COMMENT '快递状态(no-未寄出/sent-已寄出/received-已签收)',
  661. `express_time` datetime DEFAULT NULL COMMENT '寄出时间',
  662. `receive_time` datetime DEFAULT NULL COMMENT '签收时间',
  663. `mail_address` varchar(255) DEFAULT NULL COMMENT '邮寄地址',
  664. `mail_contact` varchar(50) DEFAULT NULL COMMENT '收件人',
  665. `mail_mobile` varchar(20) DEFAULT NULL COMMENT '收件电话',
  666. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
  667. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  668. `apply_by` bigint(20) DEFAULT NULL COMMENT '申请人ID',
  669. `apply_by_name` varchar(50) DEFAULT NULL COMMENT '申请人姓名',
  670. `apply_time` datetime DEFAULT NULL COMMENT '申请时间',
  671. `approve_by` bigint(20) DEFAULT NULL COMMENT '审批人ID',
  672. `approve_by_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
  673. `approve_time` datetime DEFAULT NULL COMMENT '审批时间',
  674. `invoice_by` bigint(20) DEFAULT NULL COMMENT '开票人ID',
  675. `invoice_by_name` varchar(50) DEFAULT NULL COMMENT '开票人姓名',
  676. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  677. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  678. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  679. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  680. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  681. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  682. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  683. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  684. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  685. PRIMARY KEY (`id`) USING BTREE,
  686. UNIQUE KEY `uk_invoice_no_del_flag` (`invoice_no`,`del_flag`) USING BTREE,
  687. KEY `uk_invoice_number` (`invoice_number`) USING BTREE,
  688. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  689. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  690. KEY `idx_payment_id` (`payment_id`) USING BTREE,
  691. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  692. KEY `idx_status` (`status`) USING BTREE,
  693. KEY `idx_invoice_date` (`invoice_date`) USING BTREE,
  694. KEY `idx_express_status` (`express_status`) USING BTREE,
  695. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  696. KEY `idx_create_time` (`create_time`) USING BTREE
  697. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-发票主表';
  698. -- ----------------------------
  699. -- Table structure for crm_invoice_info
  700. -- ----------------------------
  701. DROP TABLE IF EXISTS `crm_invoice_info`;
  702. CREATE TABLE `crm_invoice_info` (
  703. `id` bigint(20) NOT NULL COMMENT '主键ID',
  704. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  705. `company_name` varchar(200) DEFAULT NULL COMMENT '单位名称(章)',
  706. `company_address` varchar(500) DEFAULT NULL COMMENT '单位地址',
  707. `legal_representative` varchar(100) DEFAULT NULL COMMENT '法定代表人',
  708. `agent` varchar(100) DEFAULT NULL COMMENT '代理人',
  709. `phone_fax` varchar(100) DEFAULT NULL COMMENT '电话/传真',
  710. `bank_name` varchar(200) DEFAULT NULL COMMENT '开户银行',
  711. `bank_account` varchar(100) DEFAULT NULL COMMENT '账号',
  712. `is_default` char(1) DEFAULT '0' COMMENT '是否默认(0否 1是)',
  713. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  714. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  715. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  716. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  717. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  718. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  719. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  720. `del_flag` int(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
  721. PRIMARY KEY (`id`) USING BTREE,
  722. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  723. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  724. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户开票信息表';
  725. -- ----------------------------
  726. -- Table structure for crm_invoice_item
  727. -- ----------------------------
  728. DROP TABLE IF EXISTS `crm_invoice_item`;
  729. CREATE TABLE `crm_invoice_item` (
  730. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  731. `invoice_id` bigint(20) NOT NULL COMMENT '发票ID',
  732. `item_name` varchar(200) NOT NULL COMMENT '项目名称',
  733. `spec` varchar(100) DEFAULT NULL COMMENT '规格型号',
  734. `unit` varchar(50) DEFAULT NULL COMMENT '单位',
  735. `quantity` decimal(15,2) DEFAULT '0.00' COMMENT '数量',
  736. `unit_price` decimal(15,2) DEFAULT '0.00' COMMENT '单价',
  737. `amount` decimal(15,2) DEFAULT '0.00' COMMENT '金额',
  738. `tax_rate` decimal(5,2) DEFAULT '0.00' COMMENT '税率(百分比)',
  739. `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税额',
  740. `total_amount` decimal(15,2) DEFAULT '0.00' COMMENT '价税合计',
  741. `sort` int(11) DEFAULT '0' COMMENT '排序',
  742. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  743. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  744. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  745. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  746. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  747. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  748. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  749. PRIMARY KEY (`id`) USING BTREE,
  750. KEY `idx_invoice_id` (`invoice_id`) USING BTREE,
  751. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  752. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-发票明细表';
  753. -- ----------------------------
  754. -- Table structure for crm_opportunity
  755. -- ----------------------------
  756. DROP TABLE IF EXISTS `crm_opportunity`;
  757. CREATE TABLE `crm_opportunity` (
  758. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  759. `opportunity_no` varchar(50) NOT NULL COMMENT '商机编号(OPP+yyyyMMdd+4位流水号)',
  760. `opportunity_name` varchar(200) NOT NULL COMMENT '商机名称',
  761. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  762. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  763. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  764. `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
  765. `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '商机金额',
  766. `stage` varchar(20) NOT NULL DEFAULT 'initial' COMMENT '商机阶段(initial-初步接触/requirement-需求分析/solution-方案制定/quote-报价/negotiate-谈判审核/contract-合同签订/won-赢单)',
  767. `stage_percent` int(11) DEFAULT '10' COMMENT '阶段进度百分比(10/20/40/60/80/90/100)',
  768. `status` varchar(20) NOT NULL DEFAULT 'following' COMMENT '商机状态(following-跟进中/won-赢单/lost-输单/invalid-无效)',
  769. `win_rate` decimal(5,2) DEFAULT '50.00' COMMENT '赢单率(百分比,如50.00表示50%)',
  770. `expect_deal_date` date DEFAULT NULL COMMENT '预计成交日期',
  771. `actual_deal_date` date DEFAULT NULL COMMENT '实际成交日期',
  772. `lost_reason` varchar(500) DEFAULT NULL COMMENT '输单原因',
  773. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(销售人员)',
  774. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  775. `product_count` int(11) DEFAULT '0' COMMENT '产品数量(冗余字段)',
  776. `last_time` datetime DEFAULT NULL COMMENT '最后跟进时间',
  777. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  778. `follow_count` int(11) DEFAULT '0' COMMENT '跟进次数(冗余字段)',
  779. `contract_id` bigint(20) DEFAULT NULL COMMENT '关联合同ID(赢单后生成)',
  780. `source` varchar(20) DEFAULT NULL COMMENT '商机来源(同线索来源)',
  781. `type` varchar(20) DEFAULT NULL COMMENT '商机类型(new_customer-新客户新业务/renewal-老客户续约/upgrade-老客户升级)',
  782. `description` text COMMENT '商机描述(详细说明商机背景、客户需求等)',
  783. `competitors` varchar(500) DEFAULT NULL COMMENT '竞争对手(多个竞争对手用逗号分隔)',
  784. `key_factors` varchar(500) DEFAULT NULL COMMENT '关键决策因素(客户关注的核心要素)',
  785. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  786. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  787. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  788. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  789. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  790. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  791. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  792. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  793. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  794. PRIMARY KEY (`id`) USING BTREE,
  795. UNIQUE KEY `uk_opportunity_no_del_flag` (`opportunity_no`,`del_flag`) USING BTREE,
  796. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  797. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  798. KEY `idx_stage` (`stage`) USING BTREE,
  799. KEY `idx_status` (`status`) USING BTREE,
  800. KEY `idx_expect_deal_date` (`expect_deal_date`) USING BTREE,
  801. KEY `idx_next_time` (`next_time`) USING BTREE,
  802. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  803. KEY `idx_create_time` (`create_time`) USING BTREE
  804. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机主表';
  805. -- ----------------------------
  806. -- Table structure for crm_opportunity_follow
  807. -- ----------------------------
  808. DROP TABLE IF EXISTS `crm_opportunity_follow`;
  809. CREATE TABLE `crm_opportunity_follow` (
  810. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  811. `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
  812. `follow_type` varchar(20) NOT NULL COMMENT '跟进方式(phone-电话/wechat-微信/email-邮件/visit-拜访/meeting-会议/other-其他)',
  813. `follow_content` text NOT NULL COMMENT '跟进内容',
  814. `follow_time` datetime DEFAULT NULL COMMENT '跟进时间',
  815. `stage` varchar(20) DEFAULT NULL COMMENT '当前商机阶段',
  816. `stage_percent` int(11) DEFAULT NULL COMMENT '阶段进度百分比',
  817. `next_time` datetime DEFAULT NULL COMMENT '下次联系时间',
  818. `next_content` varchar(500) DEFAULT NULL COMMENT '下次联系计划',
  819. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个文件用逗号分隔)',
  820. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  821. `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名',
  822. `location` varchar(200) DEFAULT NULL COMMENT '跟进地点(拜访时填写)',
  823. `duration` int(11) DEFAULT NULL COMMENT '跟进时长(分钟)',
  824. `follow_by` bigint(20) DEFAULT NULL COMMENT '跟进人ID',
  825. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  826. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  827. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(跟进人)',
  828. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(跟进时间)',
  829. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  830. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  831. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  832. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  833. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  834. PRIMARY KEY (`id`) USING BTREE,
  835. KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
  836. KEY `idx_create_by` (`create_by`) USING BTREE,
  837. KEY `idx_create_time` (`create_time`) USING BTREE,
  838. KEY `idx_next_time` (`next_time`) USING BTREE,
  839. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  840. KEY `idx_follow_time` (`follow_time`) USING BTREE
  841. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机跟进记录表';
  842. -- ----------------------------
  843. -- Table structure for crm_opportunity_product
  844. -- ----------------------------
  845. DROP TABLE IF EXISTS `crm_opportunity_product`;
  846. CREATE TABLE `crm_opportunity_product` (
  847. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  848. `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
  849. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  850. `product_name` varchar(200) DEFAULT NULL COMMENT '产品名称(冗余字段)',
  851. `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号(冗余字段)',
  852. `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
  853. `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称(冗余字段)',
  854. `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
  855. `unit` varchar(20) DEFAULT '件' COMMENT '单位',
  856. `quantity` decimal(20,4) NOT NULL COMMENT '数量',
  857. `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '单价',
  858. `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比,如10.00表示9折)',
  859. `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '小计金额(数量*单价*折扣后)',
  860. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  861. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  862. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  863. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  864. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  865. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  866. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  867. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  868. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  869. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  870. PRIMARY KEY (`id`) USING BTREE,
  871. KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
  872. KEY `idx_product_id` (`product_id`) USING BTREE,
  873. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  874. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机产品关联表';
  875. -- ----------------------------
  876. -- Table structure for crm_opportunity_stage_log
  877. -- ----------------------------
  878. DROP TABLE IF EXISTS `crm_opportunity_stage_log`;
  879. CREATE TABLE `crm_opportunity_stage_log` (
  880. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  881. `opportunity_id` bigint(20) NOT NULL COMMENT '商机ID',
  882. `from_stage` varchar(20) DEFAULT NULL COMMENT '原阶段',
  883. `from_stage_name` varchar(50) DEFAULT NULL COMMENT '原阶段名称',
  884. `from_percent` int(11) DEFAULT NULL COMMENT '原进度百分比',
  885. `to_stage` varchar(20) NOT NULL COMMENT '新阶段',
  886. `to_stage_name` varchar(50) DEFAULT NULL COMMENT '新阶段名称',
  887. `to_percent` int(11) DEFAULT NULL COMMENT '新进度百分比',
  888. `change_type` varchar(20) DEFAULT 'forward' COMMENT '变更类型(forward-推进/backward-后退)',
  889. `change_reason` varchar(500) DEFAULT NULL COMMENT '变更原因',
  890. `change_amount` decimal(15,2) DEFAULT NULL COMMENT '变更时的商机金额',
  891. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  892. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  893. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者(变更人)',
  894. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(变更时间)',
  895. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  896. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  897. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  898. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  899. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  900. `lost_detail` varchar(2000) DEFAULT NULL COMMENT '输单详细说明',
  901. `competitor_info` varchar(1000) DEFAULT NULL COMMENT '竞争对手信息',
  902. `improvement` varchar(1000) DEFAULT NULL COMMENT '改进建议',
  903. `won_remark` varchar(2000) DEFAULT NULL COMMENT '赢单说明',
  904. PRIMARY KEY (`id`) USING BTREE,
  905. KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
  906. KEY `idx_create_time` (`create_time`) USING BTREE,
  907. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  908. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-商机阶段变更日志表';
  909. -- ----------------------------
  910. -- Table structure for crm_payment
  911. -- ----------------------------
  912. DROP TABLE IF EXISTS `crm_payment`;
  913. CREATE TABLE `crm_payment` (
  914. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  915. `payment_no` varchar(50) NOT NULL COMMENT '回款编号(PAY+yyyyMMdd+4位流水号)',
  916. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  917. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
  918. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  919. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  920. `plan_id` bigint(20) DEFAULT NULL COMMENT '回款计划ID',
  921. `plan_no` varchar(50) DEFAULT NULL COMMENT '计划编号(冗余字段)',
  922. `period` int(11) DEFAULT NULL COMMENT '期数(冗余字段)',
  923. `amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '回款金额',
  924. `payment_date` date NOT NULL COMMENT '回款日期',
  925. `payment_method` varchar(20) DEFAULT 'bank' COMMENT '付款方式(bank-银行转账/cash-现金/check-支票/alipay-支付宝/wechat-微信/other-其他)',
  926. `payment_account` varchar(100) DEFAULT NULL COMMENT '付款账户',
  927. `voucher_no` varchar(100) DEFAULT NULL COMMENT '凭证号(流水号)',
  928. `voucher_file` varchar(500) DEFAULT NULL COMMENT '凭证文件(回款凭证扫描件)',
  929. `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '回款状态(pending-待确认/confirmed-已确认/invalid-已作废)',
  930. `confirm_by` bigint(20) DEFAULT NULL COMMENT '确认人ID',
  931. `confirm_by_name` varchar(50) DEFAULT NULL COMMENT '确认人姓名',
  932. `confirm_time` datetime DEFAULT NULL COMMENT '确认时间',
  933. `invalid_reason` varchar(500) DEFAULT NULL COMMENT '作废原因',
  934. `invalid_time` datetime DEFAULT NULL COMMENT '作废时间',
  935. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(录入人)',
  936. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  937. `bank_name` varchar(100) DEFAULT NULL COMMENT '收款银行',
  938. `bank_account` varchar(100) DEFAULT NULL COMMENT '收款账号',
  939. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  940. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  941. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  942. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  943. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  944. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  945. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  946. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  947. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  948. PRIMARY KEY (`id`) USING BTREE,
  949. UNIQUE KEY `uk_payment_no_del_flag` (`payment_no`,`del_flag`) USING BTREE,
  950. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  951. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  952. KEY `idx_plan_id` (`plan_id`) USING BTREE,
  953. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  954. KEY `idx_status` (`status`) USING BTREE,
  955. KEY `idx_payment_date` (`payment_date`) USING BTREE,
  956. KEY `idx_confirm_by` (`confirm_by`) USING BTREE,
  957. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  958. KEY `idx_create_time` (`create_time`) USING BTREE
  959. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回款记录表';
  960. -- ----------------------------
  961. -- Table structure for crm_payment_collection
  962. -- ----------------------------
  963. DROP TABLE IF EXISTS `crm_payment_collection`;
  964. CREATE TABLE `crm_payment_collection` (
  965. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  966. `plan_id` bigint(20) NOT NULL COMMENT '回款计划ID',
  967. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  968. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余)',
  969. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  970. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余)',
  971. `collection_date` datetime NOT NULL COMMENT '催收日期时间',
  972. `collection_method` varchar(20) NOT NULL COMMENT '催收方式(phone/email/message/visit/legal/other)',
  973. `contact_person` varchar(100) DEFAULT NULL COMMENT '联系人姓名',
  974. `contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
  975. `collection_content` text NOT NULL COMMENT '催收内容(最少20字)',
  976. `customer_feedback` varchar(20) NOT NULL COMMENT '客户反馈类型(promise/processing/difficulty/refuse/no_contact/other)',
  977. `feedback_detail` varchar(500) DEFAULT NULL COMMENT '反馈详情',
  978. `promise_date` date DEFAULT NULL COMMENT '承诺付款日期',
  979. `collector_user_id` bigint(20) NOT NULL COMMENT '催收人ID',
  980. `collector_user_name` varchar(50) DEFAULT NULL COMMENT '催收人姓名(冗余)',
  981. `attachment` varchar(500) DEFAULT NULL COMMENT '附件(催收邮件截图等)',
  982. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  983. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  984. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  985. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  986. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  987. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  988. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  989. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  990. PRIMARY KEY (`id`) USING BTREE,
  991. KEY `idx_plan_id` (`plan_id`) USING BTREE,
  992. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  993. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  994. KEY `idx_collection_date` (`collection_date`) USING BTREE,
  995. KEY `idx_collector_user_id` (`collector_user_id`) USING BTREE,
  996. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  997. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-催收记录表';
  998. -- ----------------------------
  999. -- Table structure for crm_payment_plan
  1000. -- ----------------------------
  1001. DROP TABLE IF EXISTS `crm_payment_plan`;
  1002. CREATE TABLE `crm_payment_plan` (
  1003. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1004. `plan_no` varchar(50) NOT NULL COMMENT '计划编号(PLAN+yyyyMMdd+4位流水号)',
  1005. `contract_id` bigint(20) NOT NULL COMMENT '合同ID',
  1006. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
  1007. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  1008. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  1009. `period` int(11) NOT NULL DEFAULT '1' COMMENT '期数(第几期)',
  1010. `plan_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '计划回款金额',
  1011. `plan_date` date NOT NULL COMMENT '计划回款日期',
  1012. `plan_percent` decimal(5,2) DEFAULT NULL COMMENT '计划比例(占合同总金额的百分比)',
  1013. `received_amount` decimal(15,2) DEFAULT '0.00' COMMENT '已回款金额',
  1014. `unreceived_amount` decimal(15,2) DEFAULT '0.00' COMMENT '未回款金额',
  1015. `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '状态(pending-待回款/partial-部分回款/finished-已完成/overdue-已逾期)',
  1016. `is_overdue` tinyint(1) DEFAULT '0' COMMENT '是否逾期(0否 1是)',
  1017. `overdue_days` int(11) DEFAULT '0' COMMENT '逾期天数',
  1018. `remind_days` int(11) DEFAULT '7' COMMENT '提前提醒天数(默认7天)',
  1019. `remind_status` varchar(20) DEFAULT 'no' COMMENT '提醒状态(no-未提醒/reminded-已提醒)',
  1020. `last_remind_time` datetime DEFAULT NULL COMMENT '最后提醒时间',
  1021. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
  1022. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  1023. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1024. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1025. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1026. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1027. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1028. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1029. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1030. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1031. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1032. PRIMARY KEY (`id`) USING BTREE,
  1033. UNIQUE KEY `uk_plan_no_del_flag` (`plan_no`,`del_flag`) USING BTREE,
  1034. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  1035. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  1036. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  1037. KEY `idx_status` (`status`) USING BTREE,
  1038. KEY `idx_plan_date` (`plan_date`) USING BTREE,
  1039. KEY `idx_is_overdue` (`is_overdue`) USING BTREE,
  1040. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1041. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回款计划表';
  1042. -- ----------------------------
  1043. -- Table structure for crm_product
  1044. -- ----------------------------
  1045. DROP TABLE IF EXISTS `crm_product`;
  1046. CREATE TABLE `crm_product` (
  1047. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1048. `product_no` varchar(50) NOT NULL COMMENT '产品编号(唯一)',
  1049. `product_name` varchar(200) NOT NULL COMMENT '产品名称',
  1050. `category_id` bigint(20) DEFAULT NULL COMMENT '分类ID',
  1051. `category_name` varchar(100) DEFAULT NULL COMMENT '分类名称(冗余)',
  1052. `model` varchar(100) DEFAULT NULL COMMENT '型号/规格',
  1053. `unit` varchar(20) DEFAULT '个' COMMENT '单位',
  1054. `barcode` varchar(100) DEFAULT NULL COMMENT '条码',
  1055. `price` decimal(15,2) DEFAULT '0.00' COMMENT '标准价格',
  1056. `cost` decimal(15,2) DEFAULT '0.00' COMMENT '成本价',
  1057. `min_price` decimal(15,2) DEFAULT NULL COMMENT '最低价格',
  1058. `stock` int(11) DEFAULT '0' COMMENT '库存数量',
  1059. `low_stock` int(11) DEFAULT '10' COMMENT '库存预警值',
  1060. `status` varchar(20) DEFAULT 'on' COMMENT '状态(on-上架/off-下架)',
  1061. `tax_rate` decimal(5,2) NOT NULL DEFAULT '13.00' COMMENT '税率(百分比)',
  1062. `description` text COMMENT '产品描述',
  1063. `images` varchar(1000) DEFAULT NULL COMMENT '产品图片(多个用逗号分隔)',
  1064. `sale_count` int(11) DEFAULT '0' COMMENT '销售次数',
  1065. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1066. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1067. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1068. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1069. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1070. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1071. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1072. `version` int(11) DEFAULT '0' COMMENT '版本号',
  1073. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1074. PRIMARY KEY (`id`) USING BTREE,
  1075. UNIQUE KEY `uk_product_no_del_flag` (`product_no`,`del_flag`) USING BTREE,
  1076. KEY `idx_category` (`category_id`) USING BTREE,
  1077. KEY `idx_status` (`status`) USING BTREE,
  1078. KEY `idx_tenant` (`tenant_id`) USING BTREE
  1079. ) ENGINE=InnoDB AUTO_INCREMENT=2052931567194177538 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-产品主表';
  1080. -- ----------------------------
  1081. -- Table structure for crm_product_attachment
  1082. -- ----------------------------
  1083. DROP TABLE IF EXISTS `crm_product_attachment`;
  1084. CREATE TABLE `crm_product_attachment` (
  1085. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1086. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1087. `file_name` varchar(200) NOT NULL COMMENT '文件名称',
  1088. `file_path` varchar(500) NOT NULL COMMENT '文件路径',
  1089. `file_type` varchar(50) DEFAULT NULL COMMENT '文件类型(pdf/doc/xls/ppt/jpg等)',
  1090. `file_size` bigint(20) DEFAULT NULL COMMENT '文件大小(字节)',
  1091. `attachment_type` varchar(50) DEFAULT 'other' COMMENT '资料类型(manual-产品手册/whitepaper-技术白皮书/guide-用户指南/demo-演示PPT/case-案例资料/video-视频教程/other-其他)',
  1092. `download_count` int(11) DEFAULT '0' COMMENT '下载次数',
  1093. `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
  1094. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1095. `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
  1096. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1097. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1098. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1099. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  1100. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1101. PRIMARY KEY (`id`) USING BTREE,
  1102. KEY `idx_product_id` (`product_id`) USING BTREE,
  1103. KEY `idx_attachment_type` (`attachment_type`) USING BTREE,
  1104. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1105. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品附件表';
  1106. -- ----------------------------
  1107. -- Table structure for crm_product_category
  1108. -- ----------------------------
  1109. DROP TABLE IF EXISTS `crm_product_category`;
  1110. CREATE TABLE `crm_product_category` (
  1111. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1112. `category_name` varchar(100) NOT NULL COMMENT '分类名称',
  1113. `parent_id` bigint(20) DEFAULT '0' COMMENT '父级ID(0为顶级)',
  1114. `ancestors` varchar(500) DEFAULT NULL COMMENT '祖级列表(如: 0,1,2)',
  1115. `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
  1116. `status` varchar(10) DEFAULT '0' COMMENT '状态(0-正常 1-停用)',
  1117. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1118. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1119. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1120. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1121. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1122. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1123. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1124. `version` int(11) DEFAULT '0' COMMENT '版本号',
  1125. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1126. PRIMARY KEY (`id`) USING BTREE,
  1127. KEY `idx_parent_id` (`parent_id`) USING BTREE,
  1128. KEY `idx_tenant` (`tenant_id`) USING BTREE
  1129. ) ENGINE=InnoDB AUTO_INCREMENT=1975766650771238914 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-产品分类表';
  1130. -- ----------------------------
  1131. -- Table structure for crm_product_price
  1132. -- ----------------------------
  1133. DROP TABLE IF EXISTS `crm_product_price`;
  1134. CREATE TABLE `crm_product_price` (
  1135. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1136. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1137. `price_type` varchar(20) NOT NULL COMMENT '价格类型(standard/cost/minimum/vip/wholesale/promotion)',
  1138. `price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  1139. `start_date` datetime DEFAULT NULL COMMENT '生效日期',
  1140. `end_date` datetime DEFAULT NULL COMMENT '失效日期',
  1141. `status` varchar(10) DEFAULT 'active' COMMENT '状态(active-生效中/inactive-已失效)',
  1142. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1143. `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
  1144. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1145. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1146. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1147. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1148. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  1149. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1150. PRIMARY KEY (`id`) USING BTREE,
  1151. KEY `idx_product_id` (`product_id`) USING BTREE,
  1152. KEY `idx_price_type` (`price_type`) USING BTREE,
  1153. KEY `idx_status` (`status`) USING BTREE,
  1154. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1155. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品价格表';
  1156. -- ----------------------------
  1157. -- Table structure for crm_product_price_history
  1158. -- ----------------------------
  1159. DROP TABLE IF EXISTS `crm_product_price_history`;
  1160. CREATE TABLE `crm_product_price_history` (
  1161. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1162. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1163. `price_type` varchar(20) NOT NULL COMMENT '价格类型',
  1164. `old_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '调整前价格',
  1165. `new_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '调整后价格',
  1166. `price_change` decimal(12,2) DEFAULT '0.00' COMMENT '调整金额',
  1167. `change_percent` decimal(5,2) DEFAULT '0.00' COMMENT '调整百分比',
  1168. `adjust_reason` varchar(500) DEFAULT NULL COMMENT '调价原因',
  1169. `effective_date` datetime DEFAULT NULL COMMENT '生效日期',
  1170. `create_by` bigint(20) DEFAULT NULL COMMENT '操作人',
  1171. `create_time` datetime DEFAULT NULL COMMENT '操作时间',
  1172. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1173. PRIMARY KEY (`id`) USING BTREE,
  1174. KEY `idx_product_id` (`product_id`) USING BTREE,
  1175. KEY `idx_create_time` (`create_time`) USING BTREE,
  1176. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1177. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品价格历史表';
  1178. -- ----------------------------
  1179. -- Table structure for crm_product_stock_log
  1180. -- ----------------------------
  1181. DROP TABLE IF EXISTS `crm_product_stock_log`;
  1182. CREATE TABLE `crm_product_stock_log` (
  1183. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1184. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1185. `operation_type` varchar(20) NOT NULL COMMENT '操作类型(in-入库/out-出库/adjust-调整/check-盘点)',
  1186. `quantity` int(11) NOT NULL DEFAULT '0' COMMENT '变动数量(正数-增加/负数-减少)',
  1187. `before_stock` int(11) NOT NULL DEFAULT '0' COMMENT '变动前库存',
  1188. `after_stock` int(11) NOT NULL DEFAULT '0' COMMENT '变动后库存',
  1189. `unit_price` decimal(12,2) DEFAULT NULL COMMENT '单价',
  1190. `total_amount` decimal(12,2) DEFAULT NULL COMMENT '总金额',
  1191. `related_no` varchar(100) DEFAULT NULL COMMENT '关联单号(入库单/出库单/合同编号等)',
  1192. `related_type` varchar(50) DEFAULT NULL COMMENT '关联类型(purchase-采购/sale-销售/sample-样品/other-其他)',
  1193. `supplier` varchar(200) DEFAULT NULL COMMENT '供应商(入库时)',
  1194. `operator` varchar(100) DEFAULT NULL COMMENT '操作人',
  1195. `operation_date` datetime DEFAULT NULL COMMENT '操作日期',
  1196. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1197. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1198. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1199. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1200. PRIMARY KEY (`id`) USING BTREE,
  1201. KEY `idx_product_id` (`product_id`) USING BTREE,
  1202. KEY `idx_operation_type` (`operation_type`) USING BTREE,
  1203. KEY `idx_operation_date` (`operation_date`) USING BTREE,
  1204. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1205. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品库存记录表';
  1206. -- ----------------------------
  1207. -- Table structure for crm_product_tag
  1208. -- ----------------------------
  1209. DROP TABLE IF EXISTS `crm_product_tag`;
  1210. CREATE TABLE `crm_product_tag` (
  1211. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1212. `tag_name` varchar(50) NOT NULL COMMENT '标签名称',
  1213. `tag_color` varchar(20) DEFAULT NULL COMMENT '标签颜色',
  1214. `sort` int(11) DEFAULT '0' COMMENT '显示顺序',
  1215. `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
  1216. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1217. `del_flag` int(11) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
  1218. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1219. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1220. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1221. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  1222. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1223. PRIMARY KEY (`id`) USING BTREE,
  1224. UNIQUE KEY `uk_tag_name` (`tag_name`,`tenant_id`) USING BTREE,
  1225. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1226. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品标签表';
  1227. -- ----------------------------
  1228. -- Table structure for crm_product_tag_relation
  1229. -- ----------------------------
  1230. DROP TABLE IF EXISTS `crm_product_tag_relation`;
  1231. CREATE TABLE `crm_product_tag_relation` (
  1232. `id` bigint(20) NOT NULL COMMENT '主键ID',
  1233. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1234. `tag_id` bigint(20) NOT NULL COMMENT '标签ID',
  1235. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1236. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1237. PRIMARY KEY (`id`) USING BTREE,
  1238. UNIQUE KEY `uk_product_tag` (`product_id`,`tag_id`,`tenant_id`) USING BTREE,
  1239. KEY `idx_product_id` (`product_id`) USING BTREE,
  1240. KEY `idx_tag_id` (`tag_id`) USING BTREE,
  1241. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1242. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品标签关联表';
  1243. -- ----------------------------
  1244. -- Table structure for crm_quote
  1245. -- ----------------------------
  1246. DROP TABLE IF EXISTS `crm_quote`;
  1247. CREATE TABLE `crm_quote` (
  1248. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1249. `quote_no` varchar(50) NOT NULL COMMENT '报价单编号(QUO+yyyyMMdd+4位流水号)',
  1250. `quote_title` varchar(200) NOT NULL COMMENT '报价单标题',
  1251. `quote_type` varchar(20) NOT NULL DEFAULT 'sales' COMMENT '报价单类型(sales-销售/purchase-采购)',
  1252. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  1253. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  1254. `opportunity_id` bigint(20) DEFAULT NULL COMMENT '商机ID',
  1255. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  1256. `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名(冗余字段)',
  1257. `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机(冗余字段)',
  1258. `contact_email` varchar(100) DEFAULT NULL COMMENT '联系人邮箱(冗余字段)',
  1259. `version` varchar(20) DEFAULT 'V1.0' COMMENT '版本号(如V1.0,V1.1,V2.0)',
  1260. `parent_id` bigint(20) DEFAULT NULL COMMENT '父版本ID(版本管理,0表示首版)',
  1261. `is_latest` tinyint(1) DEFAULT '1' COMMENT '是否最新版本(0否 1是)',
  1262. `total_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '总金额(未折扣前)',
  1263. `discount_rate` decimal(5,2) DEFAULT '0.00' COMMENT '整单折扣率(百分比)',
  1264. `discount_amount` decimal(15,2) DEFAULT '0.00' COMMENT '折扣金额',
  1265. `final_amount` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '最终金额(折扣后)',
  1266. `validity_days` int(11) DEFAULT '30' COMMENT '有效期(天数)',
  1267. `quote_date` date DEFAULT NULL COMMENT '报价日期',
  1268. `expire_date` date DEFAULT NULL COMMENT '到期日期',
  1269. `status` varchar(20) NOT NULL DEFAULT 'draft' COMMENT '状态(draft-草稿/submitted-已提交/accepted-已接受/rejected-已拒绝/expired-已过期/contract-已转合同)',
  1270. `reject_reason` varchar(500) DEFAULT NULL COMMENT '拒绝原因',
  1271. `pdf_url` varchar(500) DEFAULT NULL COMMENT 'PDF文件路径',
  1272. `pdf_generated` tinyint(1) DEFAULT '0' COMMENT 'PDF是否已生成(0否 1是)',
  1273. `share_link` varchar(500) DEFAULT NULL COMMENT '分享链接',
  1274. `share_code` varchar(50) DEFAULT NULL COMMENT '分享码',
  1275. `share_password` varchar(100) DEFAULT NULL COMMENT '分享密码(可选)',
  1276. `share_expire_time` datetime DEFAULT NULL COMMENT '分享链接过期时间',
  1277. `view_count` int(11) DEFAULT '0' COMMENT '查看次数',
  1278. `last_view_time` datetime DEFAULT NULL COMMENT '最后查看时间',
  1279. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID',
  1280. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  1281. `supplier_id` bigint(20) DEFAULT NULL COMMENT '报价主体ID(关联crm_supplier_info表)',
  1282. `supplier_name` varchar(200) DEFAULT NULL COMMENT '报价主体名称(冗余字段)',
  1283. `contract_id` bigint(20) DEFAULT NULL COMMENT '关联合同ID(转合同后)',
  1284. `payment_terms` varchar(500) DEFAULT NULL COMMENT '付款条款',
  1285. `delivery_terms` varchar(500) DEFAULT NULL COMMENT '交付条款',
  1286. `freight` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '运费(元)',
  1287. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个用逗号分隔)',
  1288. `template_content` longtext COMMENT '报价单模板内容(富文本HTML)',
  1289. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1290. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1291. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1292. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1293. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1294. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1295. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1296. `version_no` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1297. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1298. PRIMARY KEY (`id`) USING BTREE,
  1299. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  1300. KEY `idx_opportunity_id` (`opportunity_id`) USING BTREE,
  1301. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  1302. KEY `idx_status` (`status`) USING BTREE,
  1303. KEY `idx_parent_id` (`parent_id`) USING BTREE,
  1304. KEY `idx_expire_date` (`expire_date`) USING BTREE,
  1305. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  1306. KEY `idx_create_time` (`create_time`) USING BTREE,
  1307. KEY `idx_share_code` (`share_code`) USING BTREE,
  1308. KEY `idx_supplier_id` (`supplier_id`)
  1309. ) ENGINE=InnoDB AUTO_INCREMENT=2053033084869902339 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单主表';
  1310. -- ----------------------------
  1311. -- Table structure for crm_quote_approval
  1312. -- ----------------------------
  1313. DROP TABLE IF EXISTS `crm_quote_approval`;
  1314. CREATE TABLE `crm_quote_approval` (
  1315. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1316. `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
  1317. `quote_no` varchar(50) DEFAULT NULL COMMENT '报价单编号(冗余)',
  1318. `step` int(11) NOT NULL COMMENT '审批步骤(1/2/3...)',
  1319. `approver_id` bigint(20) NOT NULL COMMENT '审批人ID',
  1320. `approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名(冗余)',
  1321. `approval_result` varchar(20) DEFAULT 'pending' COMMENT '审批结果(pending-待审批/approved-通过/rejected-拒绝)',
  1322. `approval_opinion` text COMMENT '审批意见',
  1323. `approval_time` datetime DEFAULT NULL COMMENT '审批时间',
  1324. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1325. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1326. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1327. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1328. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1329. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1330. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1331. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1332. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1333. PRIMARY KEY (`id`) USING BTREE,
  1334. KEY `idx_quote_id` (`quote_id`) USING BTREE,
  1335. KEY `idx_approver_id` (`approver_id`) USING BTREE,
  1336. KEY `idx_approval_time` (`approval_time`) USING BTREE,
  1337. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  1338. KEY `idx_approval_result` (`approval_result`) USING BTREE
  1339. ) ENGINE=InnoDB AUTO_INCREMENT=2052978058952671234 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单审批记录表';
  1340. -- ----------------------------
  1341. -- Table structure for crm_quote_product
  1342. -- ----------------------------
  1343. DROP TABLE IF EXISTS `crm_quote_product`;
  1344. CREATE TABLE `crm_quote_product` (
  1345. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1346. `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
  1347. `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  1348. `product_name` varchar(200) NOT NULL COMMENT '产品名称',
  1349. `product_no` varchar(50) DEFAULT NULL COMMENT '产品编号',
  1350. `category_id` bigint(20) DEFAULT NULL COMMENT '产品分类ID',
  1351. `category_name` varchar(100) DEFAULT NULL COMMENT '产品分类名称',
  1352. `model` varchar(100) DEFAULT NULL COMMENT '规格型号',
  1353. `unit` varchar(20) DEFAULT '件' COMMENT '单位',
  1354. `quantity` decimal(20,4) NOT NULL COMMENT '数量',
  1355. `price` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '含税单价/元',
  1356. `discount` decimal(5,2) DEFAULT '0.00' COMMENT '折扣(百分比)',
  1357. `subtotal` decimal(15,2) NOT NULL DEFAULT '0.00' COMMENT '含税总价/元',
  1358. `tax_amount` decimal(15,2) DEFAULT '0.00' COMMENT '税费/元',
  1359. `tax_rate` decimal(5,2) DEFAULT '13.00' COMMENT '税率(%)',
  1360. `package_spec` varchar(200) DEFAULT NULL COMMENT '包装规格',
  1361. `delivery_method` varchar(200) DEFAULT NULL COMMENT '送货方式',
  1362. `description` varchar(1000) DEFAULT NULL COMMENT '产品描述',
  1363. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  1364. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1365. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1366. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1367. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1368. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1369. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1370. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1371. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1372. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1373. PRIMARY KEY (`id`) USING BTREE,
  1374. KEY `idx_quote_id` (`quote_id`) USING BTREE,
  1375. KEY `idx_product_id` (`product_id`) USING BTREE,
  1376. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1377. ) ENGINE=InnoDB AUTO_INCREMENT=2053033084941205506 DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单产品明细表';
  1378. -- ----------------------------
  1379. -- Table structure for crm_quote_share_log
  1380. -- ----------------------------
  1381. DROP TABLE IF EXISTS `crm_quote_share_log`;
  1382. CREATE TABLE `crm_quote_share_log` (
  1383. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1384. `quote_id` bigint(20) NOT NULL COMMENT '报价单ID',
  1385. `share_code` varchar(50) NOT NULL COMMENT '分享码',
  1386. `visit_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '访问时间',
  1387. `ip_address` varchar(50) DEFAULT NULL COMMENT 'IP地址',
  1388. `location` varchar(200) DEFAULT NULL COMMENT '地理位置(省市)',
  1389. `device_type` varchar(50) DEFAULT NULL COMMENT '设备类型(PC/Mobile/Tablet)',
  1390. `browser` varchar(100) DEFAULT NULL COMMENT '浏览器信息',
  1391. `stay_duration` int(11) DEFAULT '0' COMMENT '停留时长(秒)',
  1392. `page_views` int(11) DEFAULT '1' COMMENT '浏览页数',
  1393. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1394. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1395. PRIMARY KEY (`id`) USING BTREE,
  1396. KEY `idx_quote_id` (`quote_id`) USING BTREE,
  1397. KEY `idx_share_code` (`share_code`) USING BTREE,
  1398. KEY `idx_visit_time` (`visit_time`) USING BTREE,
  1399. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1400. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-报价单分享访问日志表';
  1401. -- ----------------------------
  1402. -- Table structure for crm_supplier_info
  1403. -- ----------------------------
  1404. DROP TABLE IF EXISTS `crm_supplier_info`;
  1405. CREATE TABLE `crm_supplier_info` (
  1406. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1407. `supplier_name` varchar(200) NOT NULL COMMENT '供方名称(章)',
  1408. `short_name` varchar(100) DEFAULT NULL COMMENT '简称',
  1409. `supplier_code` varchar(50) DEFAULT NULL COMMENT '编码',
  1410. `supplier_address` varchar(500) DEFAULT NULL COMMENT '单位地址',
  1411. `legal_person` varchar(100) DEFAULT NULL COMMENT '法定代表人',
  1412. `agent` varchar(100) DEFAULT NULL COMMENT '代理人',
  1413. `phone_fax` varchar(100) DEFAULT NULL COMMENT '电话/传真',
  1414. `bank_name` varchar(200) DEFAULT NULL COMMENT '开户银行',
  1415. `bank_account` varchar(100) DEFAULT NULL COMMENT '账号',
  1416. `status` char(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
  1417. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1418. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1419. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1420. `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  1421. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1422. `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  1423. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1424. `del_flag` char(1) DEFAULT '0' COMMENT '逻辑删除标志(0存在 1删除)',
  1425. PRIMARY KEY (`id`),
  1426. KEY `idx_tenant_id` (`tenant_id`),
  1427. KEY `idx_del_flag` (`del_flag`)
  1428. ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='供方信息表';
  1429. -- ----------------------------
  1430. -- Table structure for crm_visit
  1431. -- ----------------------------
  1432. DROP TABLE IF EXISTS `crm_visit`;
  1433. CREATE TABLE `crm_visit` (
  1434. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1435. `visit_no` varchar(50) NOT NULL COMMENT '回访编号(VIS+yyyyMMdd+4位流水号)',
  1436. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  1437. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  1438. `contract_id` bigint(20) DEFAULT NULL COMMENT '合同ID',
  1439. `contract_no` varchar(50) DEFAULT NULL COMMENT '合同编号(冗余字段)',
  1440. `contact_id` bigint(20) DEFAULT NULL COMMENT '联系人ID',
  1441. `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名',
  1442. `contact_mobile` varchar(20) DEFAULT NULL COMMENT '联系人手机',
  1443. `visit_type` varchar(20) NOT NULL DEFAULT 'regular' COMMENT '回访类型(contract-合同回访/delivery-交付回访/regular-定期回访/renew-续约回访/complaint-投诉回访/other-其他)',
  1444. `plan_visit_date` datetime DEFAULT NULL COMMENT '计划回访时间',
  1445. `visit_date` datetime NOT NULL COMMENT '实际回访时间(执行回访时填写)',
  1446. `visit_method` varchar(20) NOT NULL DEFAULT 'phone' COMMENT '回访方式(phone-电话/wechat-微信/email-邮件/visit-上门拜访/other-其他)',
  1447. `visit_purpose` text COMMENT '回访目的(多个用逗号分隔: understand_usage,collect_feedback等)',
  1448. `visit_script` text COMMENT '回访话术模板',
  1449. `visit_content` text NOT NULL COMMENT '回访内容',
  1450. `visit_summary` varchar(1000) DEFAULT NULL COMMENT '回访小结',
  1451. `satisfaction` varchar(20) DEFAULT NULL COMMENT '满意度(very_satisfied-非常满意/satisfied-满意/general-一般/dissatisfied-不满意/very_dissatisfied-非常不满意)',
  1452. `satisfaction_score` int(11) DEFAULT NULL COMMENT '满意度评分(1-5分,5分最高)',
  1453. `usage_status` varchar(20) DEFAULT NULL COMMENT '使用情况(normal-正常/occasional-偶尔/rarely-很少/not_used-未使用)',
  1454. `dissatisfaction_reason` varchar(500) DEFAULT NULL COMMENT '不满意原因(满意度<3星时必填)',
  1455. `has_problem` tinyint(1) DEFAULT '0' COMMENT '是否有问题(0否 1是)',
  1456. `problem_count` int(11) DEFAULT '0' COMMENT '问题数量(冗余字段)',
  1457. `problem_summary` varchar(500) DEFAULT NULL COMMENT '问题概述',
  1458. `has_opportunity` tinyint(1) DEFAULT '0' COMMENT '是否有商机(0否 1是)',
  1459. `opportunity_desc` text COMMENT '商机描述',
  1460. `opportunity_amount` decimal(15,2) DEFAULT NULL COMMENT '预估商机金额',
  1461. `next_visit_date` date DEFAULT NULL COMMENT '下次回访日期',
  1462. `next_visit_content` varchar(500) DEFAULT NULL COMMENT '下次回访计划',
  1463. `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '回访状态(pending-待回访/visiting-回访中/completed-已完成/cancelled-已取消)',
  1464. `cancel_reason` varchar(500) DEFAULT NULL COMMENT '取消原因',
  1465. `cancel_time` datetime DEFAULT NULL COMMENT '取消时间',
  1466. `owner_user_id` bigint(20) NOT NULL COMMENT '负责人ID(回访人)',
  1467. `owner_user_name` varchar(50) DEFAULT NULL COMMENT '负责人姓名(冗余字段)',
  1468. `duration` int(11) DEFAULT NULL COMMENT '回访时长(分钟)',
  1469. `attachments` varchar(1000) DEFAULT NULL COMMENT '附件(多个文件用逗号分隔)',
  1470. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1471. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1472. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1473. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1474. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1475. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1476. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1477. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1478. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1479. PRIMARY KEY (`id`) USING BTREE,
  1480. UNIQUE KEY `uk_visit_no_del_flag` (`visit_no`,`del_flag`) USING BTREE,
  1481. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  1482. KEY `idx_contract_id` (`contract_id`) USING BTREE,
  1483. KEY `idx_owner_user_id` (`owner_user_id`) USING BTREE,
  1484. KEY `idx_visit_type` (`visit_type`) USING BTREE,
  1485. KEY `idx_status` (`status`) USING BTREE,
  1486. KEY `idx_visit_date` (`visit_date`) USING BTREE,
  1487. KEY `idx_satisfaction` (`satisfaction`) USING BTREE,
  1488. KEY `idx_has_problem` (`has_problem`) USING BTREE,
  1489. KEY `idx_has_opportunity` (`has_opportunity`) USING BTREE,
  1490. KEY `idx_tenant_id` (`tenant_id`) USING BTREE,
  1491. KEY `idx_create_time` (`create_time`) USING BTREE
  1492. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访记录表';
  1493. -- ----------------------------
  1494. -- Table structure for crm_visit_plan
  1495. -- ----------------------------
  1496. DROP TABLE IF EXISTS `crm_visit_plan`;
  1497. CREATE TABLE `crm_visit_plan` (
  1498. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1499. `rule_name` varchar(200) NOT NULL COMMENT '规则名称',
  1500. `trigger_type` varchar(20) NOT NULL COMMENT '触发类型(contract_signed-合同签订后/last_visit-上次回访后/product_expire-产品到期前/fixed_period-固定周期)',
  1501. `delay_days` int(11) NOT NULL DEFAULT '0' COMMENT '延迟天数(合同签订/上次回访后多少天回访)',
  1502. `visit_type` varchar(20) NOT NULL COMMENT '回访类型(参考crm_visit_type字典)',
  1503. `visit_method` varchar(20) DEFAULT 'phone' COMMENT '回访方式(参考crm_visit_method字典)',
  1504. `visit_content_template` text COMMENT '回访内容模板',
  1505. `status` varchar(20) NOT NULL DEFAULT 'enabled' COMMENT '状态(enabled-启用/disabled-禁用)',
  1506. `execute_count` int(11) DEFAULT '0' COMMENT '执行次数',
  1507. `last_execute_time` datetime DEFAULT NULL COMMENT '最后执行时间',
  1508. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  1509. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1510. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1511. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1512. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1513. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1514. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1515. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1516. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1517. PRIMARY KEY (`id`) USING BTREE,
  1518. KEY `idx_trigger_type` (`trigger_type`) USING BTREE,
  1519. KEY `idx_status` (`status`) USING BTREE,
  1520. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1521. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访计划规则表';
  1522. -- ----------------------------
  1523. -- Table structure for crm_visit_problem
  1524. -- ----------------------------
  1525. DROP TABLE IF EXISTS `crm_visit_problem`;
  1526. CREATE TABLE `crm_visit_problem` (
  1527. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  1528. `visit_id` bigint(20) NOT NULL COMMENT '回访ID',
  1529. `visit_no` varchar(50) DEFAULT NULL COMMENT '回访编号(冗余字段)',
  1530. `customer_id` bigint(20) NOT NULL COMMENT '客户ID',
  1531. `customer_name` varchar(200) DEFAULT NULL COMMENT '客户名称(冗余字段)',
  1532. `problem_type` varchar(20) NOT NULL DEFAULT 'product' COMMENT '问题类型(product-产品问题/service-服务问题/delivery-交付问题/quality-质量问题/price-价格问题/other-其他)',
  1533. `problem_desc` text NOT NULL COMMENT '问题描述',
  1534. `problem_images` varchar(1000) DEFAULT NULL COMMENT '问题图片(多个图片用逗号分隔)',
  1535. `severity` varchar(20) NOT NULL DEFAULT 'medium' COMMENT '严重程度(low-低/medium-中/high-高/urgent-紧急)',
  1536. `solution` text COMMENT '解决方案',
  1537. `status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '问题状态(pending-待处理/processing-处理中/solved-已解决/closed-已关闭)',
  1538. `solve_by` bigint(20) DEFAULT NULL COMMENT '处理人ID',
  1539. `solve_by_name` varchar(50) DEFAULT NULL COMMENT '处理人姓名',
  1540. `solve_time` datetime DEFAULT NULL COMMENT '处理时间',
  1541. `solve_duration` int(11) DEFAULT NULL COMMENT '处理耗时(小时)',
  1542. `close_by` bigint(20) DEFAULT NULL COMMENT '关闭人ID',
  1543. `close_by_name` varchar(50) DEFAULT NULL COMMENT '关闭人姓名',
  1544. `close_time` datetime DEFAULT NULL COMMENT '关闭时间',
  1545. `close_reason` varchar(500) DEFAULT NULL COMMENT '关闭原因',
  1546. `customer_feedback` text COMMENT '客户反馈',
  1547. `is_satisfied` tinyint(1) DEFAULT NULL COMMENT '客户是否满意(0否 1是)',
  1548. `sort` int(11) DEFAULT '0' COMMENT '排序号',
  1549. `tenant_id` varchar(20) DEFAULT '000000' COMMENT '租户编号',
  1550. `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
  1551. `create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
  1552. `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  1553. `update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
  1554. `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  1555. `del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标志(0存在 1删除)',
  1556. `version` int(11) DEFAULT '0' COMMENT '版本号(乐观锁)',
  1557. `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  1558. PRIMARY KEY (`id`) USING BTREE,
  1559. KEY `idx_visit_id` (`visit_id`) USING BTREE,
  1560. KEY `idx_customer_id` (`customer_id`) USING BTREE,
  1561. KEY `idx_problem_type` (`problem_type`) USING BTREE,
  1562. KEY `idx_severity` (`severity`) USING BTREE,
  1563. KEY `idx_status` (`status`) USING BTREE,
  1564. KEY `idx_solve_by` (`solve_by`) USING BTREE,
  1565. KEY `idx_tenant_id` (`tenant_id`) USING BTREE
  1566. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CRM-回访问题记录表';
  1567. SET FOREIGN_KEY_CHECKS = 1;