create_tables.sql 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. CREATE TABLE IF NOT EXISTS "crm_contract" (
  2. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  3. "name" varchar NOT NULL,
  4. "customer_id" bigint,
  5. "business_id" bigint,
  6. "process_instance_id" bigint,
  7. "order_date" varchar,
  8. "owner_user_id" bigint,
  9. "no" varchar,
  10. "start_time" varchar,
  11. "end_time" varchar,
  12. "price" int,
  13. "discount_percent" int,
  14. "product_price" int,
  15. "ro_user_ids" varchar,
  16. "rw_user_ids" varchar,
  17. "contact_id" bigint,
  18. "sign_user_id" bigint,
  19. "contact_last_time" varchar,
  20. "remark" varchar,
  21. "creator" varchar DEFAULT '',
  22. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  23. "updater" varchar DEFAULT '',
  24. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  25. "deleted" bit NOT NULL DEFAULT FALSE,
  26. PRIMARY KEY ("id")
  27. ) COMMENT '合同表';
  28. CREATE TABLE IF NOT EXISTS "crm_clue" (
  29. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  30. "transform_status" bit NOT NULL,
  31. "follow_up_status" bit NOT NULL,
  32. "name" varchar NOT NULL,
  33. "customer_id" bigint NOT NULL,
  34. "contact_next_time" varchar,
  35. "telephone" varchar,
  36. "mobile" varchar,
  37. "address" varchar,
  38. "owner_user_id" bigint,
  39. "contact_last_time" varchar,
  40. "remark" varchar,
  41. "creator" varchar DEFAULT '',
  42. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  43. "updater" varchar DEFAULT '',
  44. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  45. "deleted" bit NOT NULL DEFAULT FALSE,
  46. "tenant_id" bigint NOT NULL,
  47. PRIMARY KEY ("id")
  48. ) COMMENT '线索表';
  49. CREATE TABLE IF NOT EXISTS "crm_receivable" (
  50. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  51. "no" varchar,
  52. "plan_id" bigint,
  53. "customer_id" bigint,
  54. "contract_id" bigint,
  55. "check_status" int,
  56. "process_instance_id" bigint,
  57. "return_time" varchar,
  58. "return_type" varchar,
  59. "price" varchar,
  60. "owner_user_id" bigint,
  61. "batch_id" bigint,
  62. "sort" int,
  63. "data_scope" int,
  64. "data_scope_dept_ids" varchar,
  65. "status" int NOT NULL,
  66. "remark" varchar,
  67. "creator" varchar DEFAULT '',
  68. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  69. "updater" varchar DEFAULT '',
  70. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  71. "deleted" bit NOT NULL DEFAULT FALSE,
  72. PRIMARY KEY ("id")
  73. ) COMMENT '回款';
  74. CREATE TABLE IF NOT EXISTS "crm_receivable_plan" (
  75. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  76. "index_no" bigint,
  77. "receivable_id" bigint,
  78. "status" int NOT NULL,
  79. "check_status" varchar,
  80. "process_instance_id" bigint,
  81. "price" varchar,
  82. "return_time" varchar,
  83. "remind_days" bigint,
  84. "remind_time" varchar,
  85. "customer_id" bigint,
  86. "contract_id" bigint,
  87. "owner_user_id" bigint,
  88. "sort" int,
  89. "remark" varchar,
  90. "creator" varchar DEFAULT '',
  91. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  92. "updater" varchar DEFAULT '',
  93. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  94. "deleted" bit NOT NULL DEFAULT FALSE,
  95. PRIMARY KEY ("id")
  96. ) COMMENT '回款计划';
  97. CREATE TABLE IF NOT EXISTS "crm_customer" (
  98. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  99. "name" varchar(255),
  100. "follow_up_status" int NOT NULL,
  101. "lock_status" int NOT NULL,
  102. "deal_status" int NOT NULL,
  103. "industry_id" int,
  104. "level" int,
  105. "source" int,
  106. "mobile" varchar(255),
  107. "telephone" varchar(255),
  108. "website" varchar(255),
  109. "qq" varchar(255),
  110. "wechat" varchar(255),
  111. "email" varchar(255),
  112. "description" varchar(255),
  113. "remark" varchar(255),
  114. "owner_user_id" bigint,
  115. "area_id" int,
  116. "detail_address" varchar(255),
  117. "contact_last_time" datetime,
  118. "contact_next_time" datetime,
  119. "creator" varchar DEFAULT '',
  120. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  121. "updater" varchar DEFAULT '',
  122. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  123. "deleted" bit NOT NULL DEFAULT FALSE,
  124. "tenant_id" bigint NOT NULL,
  125. PRIMARY KEY ("id")
  126. ) COMMENT '客户表';
  127. CREATE TABLE IF NOT EXISTS "crm_customer_limit_config" (
  128. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  129. "type" int NOT NULL,
  130. "user_ids" varchar,
  131. "dept_ids" varchar,
  132. "max_count" int NOT NULL,
  133. "deal_count_enabled" varchar,
  134. "creator" varchar DEFAULT '',
  135. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  136. "updater" varchar DEFAULT '',
  137. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  138. "deleted" bit NOT NULL DEFAULT FALSE,
  139. "tenant_id" bigint NOT NULL,
  140. PRIMARY KEY ("id")
  141. ) COMMENT '客户限制配置表';
  142. CREATE TABLE IF NOT EXISTS "crm_permission"
  143. (
  144. "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  145. "biz_id" bigint NOT NULL,
  146. "biz_type" int NOT NULL,
  147. "user_id" bigint NOT NULL,
  148. "level" int NOT NULL,
  149. "creator" varchar DEFAULT '',
  150. "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  151. "updater" varchar DEFAULT '',
  152. "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  153. "deleted" bit NOT NULL DEFAULT FALSE,
  154. "tenant_id" bigint NOT NULL,
  155. PRIMARY KEY ("id")
  156. ) COMMENT '客户限制配置表';