drop table if exists ta_custom_img;
CREATE TABLE ta_custom_img(
    `img_id` INT NOT NULL AUTO_INCREMENT  COMMENT '图片id' ,
    `img_url` TEXT    COMMENT '图片地址' ,
    `img_type` VARCHAR(128)    COMMENT '图片类型' ,
    `img_desc` VARCHAR(128)    COMMENT '图片说明' ,
    `img_document` VARCHAR(128)    COMMENT '文案' ,
    `org_id` INT    COMMENT '公司id' ,
    `status` INT    COMMENT '状态' ,
    `create_time` DATETIME    COMMENT '创建时间' ,
    `update_time` DATETIME    COMMENT '更新时间' ,
    PRIMARY KEY (img_id)
) COMMENT = 'ta_custom_img 自定义配图表';;


alter table ta_building_dynamic add  column home int(1);


INSERT INTO `td_person_from`(`from_id`, `from_code`, `from_name`, `status`, `create_date`) VALUES (10, 'h5_share', 'H5分享', 1, NULL);
--- 森哥sql

ALTER TABLE `ta_miniapp_template` 
ADD COLUMN `is_subscribe` tinyint(1) NULL COMMENT '是否订阅消息' AFTER `field_num`,
ADD COLUMN `tpl_fields` varchar(1024) NULL COMMENT '模板字段列表 | 分隔' AFTER `is_subscribe`;


CREATE TABLE `sys_sms_setting`  (
  `serial_no` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键序号',
  `sms_name` varchar(255) NULL COMMENT '描述',
  `sms_type` varchar(128) NULL COMMENT '类型',
  `tpl_code` varchar(64) NULL COMMENT '短信模板号',
  `tpl_sign` varchar(255) NULL COMMENT '模板签名',
  `status` tinyint NULL COMMENT '状态',
  PRIMARY KEY (`serial_no`)
);

CREATE TABLE ta_person_message_rule(
    `serial_no` INT NOT NULL AUTO_INCREMENT  COMMENT '序号' ,
    `person_id` VARCHAR(64) NOT NULL   COMMENT '人员ID 消息接收人' ,
    `message_type` VARCHAR(32) NOT NULL   COMMENT '消息发送类型 短信,邮件,小程序消息等' ,
    `content_type` VARCHAR(128) NOT NULL   COMMENT '内容类型 通知,活动等,来源td_miniapp_template_type表' ,
    `limit_num` TINYINT(4)    COMMENT '限制条数' ,
    `left_num` TINYINT(4)    COMMENT '当前使用' ,
    `last_send_time` DATETIME    COMMENT '上次发送时间' ,
    `last_message_id` VARCHAR(64)    COMMENT '上次消息ID' ,
    `org_id` INT NOT NULL   COMMENT '公司id' ,
    `building_id` VARCHAR(64)    COMMENT '项目id' ,
    PRIMARY KEY (serial_no)
) COMMENT = '用户消息规则 ';;

ALTER TABLE ta_person_message_rule ADD UNIQUE uq_person_message(person_id,message_type,content_type,org_id);;

INSERT INTO `sys_sms_setting`(`serial_no`, `sms_name`, `sms_type`, `tpl_code`, `tpl_sign`, `status`) VALUES (1, '未读消息通知', 'notice', '0801', '橙蕉', 1);
INSERT INTO `sys_sms_setting`(`serial_no`, `sms_name`, `sms_type`, `tpl_code`, `tpl_sign`, `status`) VALUES (2, '助理活动', 'help-result', '0802', '橙蕉', 1);
INSERT INTO `sys_sms_setting`(`serial_no`, `sms_name`, `sms_type`, `tpl_code`, `tpl_sign`, `status`) VALUES (3, '拼团活动', 'group-result', '0802', '橙蕉', 1);


INSERT INTO `sys_org_params`(`param_name`, `param_desc`, `param_value`, `status`, `create_date`, `org_id`, `param_code`) VALUES ('订阅消息时间间隔', '连续2次发送消息的时间间隔: 单位分钟', '5', 1, NULL, 0, 'notice_message_interval');

INSERT INTO `sys_org_params` (
  `param_name`,
  `param_desc`,
  `param_value`,
  `status`,
  `create_date`,
  `org_id`,
  `param_code`
)
SELECT
  t.param_name,
  t.param_desc,
  t.param_value,
  t.status,
  now( ),
  s.org_id,
  t.param_code 
FROM
	sys_org_params t,
	ta_org s 
WHERE
	t.org_id = 0;



					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/cff400dab32e9230f6bf7498b8291d7.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '23', '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E5%98%89%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '27',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E6%B5%B7%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '33',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E8%B6%8A%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '25',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E9%87%91%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '24',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E9%83%91%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '37',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );
					insert into ta_custom_img(img_url, img_type, img_desc, img_document, org_id, create_time, update_time) VALUES ('https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/%E6%A9%99%E8%95%89%E5%AE%81%E6%88%BF.jpg', 'index', '小程序首页分享配图','橙蕉 精准获客平台', '36',  '2019-12-25 13:22:44', '2019-12-25 13:22:44' );