20220328013854_create_customer_recycle_table.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use think\facade\Db;
  5. class CreateCustomerRecycleTable extends Migrator
  6. {
  7. /**
  8. * Change Method.
  9. *
  10. * Write your reversible migrations using this method.
  11. *
  12. * More information on writing migrations is available here:
  13. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14. *
  15. * The following commands can be used in this method and Phinx will
  16. * automatically reverse them when rolling back:
  17. *
  18. * createTable
  19. * renameTable
  20. * addColumn
  21. * renameColumn
  22. * addIndex
  23. * addForeignKey
  24. *
  25. * Remember to call "create()" or "update()" and NOT "save()" when working
  26. * with the Table class.
  27. */
  28. public function change()
  29. {
  30. /*$this->table('customer_recycle',['comment' => '客户回收表'])
  31. ->addColumn('customer_id', 'integer', ['limit'=> 11,'comment' => 'customer id'])
  32. ->addColumn('uid', 'integer', ['limit'=> 11,'comment' => 'user id'])
  33. ->addColumn('employee_id', 'integer', ['limit'=> 11,'comment' => '员工 id'])
  34. ->addColumn('changed_ori_info', 'text', ['comment' => '记录异动前上一次的老信息,旧employee_id,uid'])
  35. ->addColumn('designer_id', 'integer', ['limit'=> 11,'comment' => '设计师id'])
  36. ->addColumn('clue_id', 'integer', ['limit'=> 11,'comment' => '客户线索id'])
  37. ->addColumn('phone', 'string', ['limit'=> 255,'comment' => '客户电话'])
  38. ->addColumn('name', 'string', ['limit'=> 255,'comment' => '客户姓名'])
  39. ->addColumn('age_range', 'string', ['limit'=> 255,'comment' => '客户年龄'])
  40. ->addColumn('level', 'string', ['limit'=> 255,'comment' => '客户等级 A B C'])
  41. ->addColumn('state', 'string', ['limit'=> 255,'comment' => '客户状态:已到店,已交定,已签单'])
  42. ->addColumn('community_name', 'string', ['limit'=> 255,'comment' => '小区名'])
  43. ->addColumn('house_type', 'string', ['limit'=> 255,'comment' => '房屋类型 如 毛坯 精装 老房等'])
  44. ->addColumn('house_delivery_time', 'string', ['limit'=> 255,'comment' => '交房时间'])
  45. ->addColumn('plan_deco_time', 'string', ['limit'=> 255,'comment' => '预计装修时间'])
  46. ->addColumn('square', 'string', ['limit'=> 255,'comment' => '房屋大小'])
  47. ->addColumn('deco_style', 'string', ['limit'=> 255,'comment' => '装修风格'])
  48. ->addColumn('budget', 'string', ['limit'=> 255,'comment' => '预算'])
  49. ->addColumn('revisit_time', 'timestamp', ['comment' => '客户跟进,下次业务员回访时间(业务员填写)'])
  50. ->addColumn('addtime', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '添加时间'])
  51. ->addColumn('updatetime', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '修改时间', 'update'=> 'CURRENT_TIMESTAMP'])
  52. ->addColumn('protected_to', 'timestamp', ['comment' => '保护至xx日'])
  53. ->addColumn('org_id', 'integer', ['limit'=> 11,'comment' => '部门'])
  54. ->addColumn('crm_res_id', 'integer', ['limit'=> 11,'comment' => 'crm_import_log id'])
  55. ->addColumn('is_resource', 'integer', ['limit'=> 4,'comment' => '是否属于资源库'])
  56. ->addColumn('before_pool', 'string', ['limit'=> 255,'comment' => '入公海前操作信息'])
  57. ->addColumn('bad_phone', 'integer', ['limit'=> 4,'comment' => '电话无效 1为无效'])
  58. ->addColumn('fresh', 'integer', ['limit'=> 4,'comment' => '新客户'])
  59. ->addColumn('sex', 'tinyblob', ['comment' => '性别'])
  60. ->addColumn('first_visit_date', 'timestamp', ['comment' => '首次到访时间'])
  61. ->addColumn('last_contact_date', 'timestamp', ['comment' => '上次沟通时间'])
  62. ->addColumn('product', 'string', ['limit'=> 50,'comment' => '关注点'])
  63. ->addColumn('source_id', 'integer', ['limit'=> 11,'comment' => '来源'])
  64. ->addColumn('remark', 'string', ['limit'=> 255, 'comment'=>'备注'])
  65. ->addColumn('ext', 'json', ['comment'=>'扩展字段', 'default' => 'NULL'])
  66. ->addColumn('deletetime', 'timestamp', ['comment'=>'删除时间', 'default' => 'CURRENT_TIMESTAMP'])
  67. ->create();*/
  68. Db::execute("CREATE TABLE `fl_customer_recycle` (
  69. `id` int(11) NOT NULL,
  70. `customer_id` int(11) DEFAULT NULL COMMENT 'customer id',
  71. `uid` int(11) DEFAULT NULL COMMENT 'user id',
  72. `employee_id` int(11) DEFAULT NULL COMMENT '员工 id',
  73. `changed_ori_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '记录异动前上一次的老信息,旧employee_id,uid',
  74. `designer_id` int(11) DEFAULT NULL COMMENT '设计师id',
  75. `clue_id` int(11) DEFAULT NULL COMMENT '客户线索id',
  76. `phone` varchar(255) DEFAULT NULL COMMENT '客户电话',
  77. `name` varchar(255) DEFAULT NULL COMMENT '客户姓名',
  78. `age_range` varchar(255) DEFAULT NULL COMMENT '客户年龄',
  79. `level` varchar(255) DEFAULT NULL COMMENT '客户等级 A B C',
  80. `state` varchar(255) DEFAULT NULL COMMENT '客户状态:已到店,已交定,已签单',
  81. `community_name` varchar(255) DEFAULT NULL COMMENT '小区名',
  82. `house_type` varchar(255) DEFAULT NULL COMMENT '房屋类型 如 毛坯 精装 老房等',
  83. `house_delivery_time` varchar(255) DEFAULT NULL COMMENT '交房时间',
  84. `plan_deco_time` varchar(255) DEFAULT NULL COMMENT '预计装修时间',
  85. `square` varchar(255) DEFAULT NULL COMMENT '房屋大小',
  86. `deco_style` varchar(255) DEFAULT NULL COMMENT '装修风格',
  87. `budget` varchar(255) DEFAULT NULL COMMENT '预算',
  88. `revisit_time` timestamp NULL DEFAULT NULL COMMENT '客户跟进,下次业务员回访时间(业务员填写)',
  89. `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
  90. `updatetime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  91. `protected_to` timestamp NULL DEFAULT NULL COMMENT '保护至xx日',
  92. `org_id` int(11) NOT NULL COMMENT '部门',
  93. `crm_res_id` int(11) DEFAULT NULL COMMENT 'crm_import_log id',
  94. `is_resource` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否属于资源库',
  95. `before_pool` varchar(255) DEFAULT NULL COMMENT '入公海前操作信息',
  96. `bad_phone` tinyint(4) NOT NULL DEFAULT '0' COMMENT '电话无效 1为无效',
  97. `fresh` tinyint(4) NOT NULL DEFAULT '1' COMMENT '新客户',
  98. `sex` tinyblob NOT NULL COMMENT '性别',
  99. `first_visit_date` date DEFAULT NULL COMMENT '首次到访时间',
  100. `last_contact_date` date DEFAULT NULL COMMENT '上次沟通时间',
  101. `product` varchar(50) DEFAULT NULL COMMENT '关注点',
  102. `source_id` int(11) DEFAULT NULL COMMENT '来源',
  103. `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  104. `ext` json DEFAULT NULL COMMENT '扩展字段',
  105. `deposit_money` int(11) DEFAULT NULL COMMENT '收定金额',
  106. `signed_money` INT(11) DEFAULT NULL COMMENT '签单金额',
  107. `deletetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '删除时间'
  108. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='客户回收表' ROW_FORMAT=DYNAMIC;");
  109. Db::execute("ALTER TABLE `fl_customer_recycle` ADD PRIMARY KEY (`id`) USING BTREE;");
  110. Db::execute("ALTER TABLE `fl_customer_recycle` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
  111. Db::execute("INSERT INTO `fl_permission` (`id`, `pid`, `auth_name`, `uri`, `is_menu`, `icon`, `sort`, `relation`) VALUES (NULL, '7', '回收站', 'crm/recycle', '1', NULL, '50', 'crm/recycle,crm/undelete');");
  112. Db::execute("UPDATE `fl_permission` SET `relation` = 'crm/withdrawl,crm/addpool,crm/distribute,crm/distributing,crm/delete' WHERE `fl_permission`.`id` = 10;");
  113. }
  114. }