|
@@ -0,0 +1,38 @@
|
|
|
+-- 新建临时表,用来记录用户信息,减少步骤
|
|
|
+DROP TABLE IF EXISTS tp_user;
|
|
|
+CREATE TABLE tp_user (
|
|
|
+ user_id bigint(20) NOT NULL DEFAULT 0 COMMENT '用户ID',
|
|
|
+ uptown_id bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID',
|
|
|
+ linkman varchar(10) NOT NULL DEFAULT '' COMMENT '联系人名称',
|
|
|
+ phone varchar(20) NOT NULL DEFAULT '' COMMENT '联系人电话',
|
|
|
+ time_create datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
|
|
|
+ time_update datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
|
|
|
+ PRIMARY KEY (user_id) USING BTREE
|
|
|
+) ENGINE = InnoDB default charset=utf8 comment = '用户ID临时表';
|
|
|
+
|
|
|
+-- 在临时表插入user_id,之后直接使用插入的user_id
|
|
|
+insert into tp_user
|
|
|
+(select ur.user_id,u.uptown_id,aa.linkman,aa.phone,now(),now() from sys_user_role ur
|
|
|
+left join sys_uptown_house up on up.house_id = ur.property_id
|
|
|
+left join sys_uptown_unit uu on uu.unit_id = up.unit_id
|
|
|
+left join sys_uptown u on u.uptown_id = uu.uptown_id
|
|
|
+left join (
|
|
|
+select ur.user_id,up.linkman,up.phone from sys_user_role ur
|
|
|
+left join sys_uptown_home up on up.house_id = ur.property_id
|
|
|
+where ur.role_id = 1 and up.phone = '17771809480') aa on aa.user_id = ur.user_id
|
|
|
+where ur.role_id = 1 and ur.user_id = (select user_id from sys_user_role where property_id = (select house_id from sys_uptown_home where phone = '17771809480') and role_id = 1))
|
|
|
+
|
|
|
+-- 插入业委会表,根据已有的最大ID加1生成新的ID
|
|
|
+insert into sys_owner
|
|
|
+select (select owner_id from (
|
|
|
+(select ifnull(max(owner_id+0)+1,1) as owner_id from sys_owner)
|
|
|
+) as tmp),uptown_id,linkman,phone,user_id,now(),user_id,now() from tp_user order by time_create desc limit 1;
|
|
|
+
|
|
|
+
|
|
|
+-- 插入权限表(不需要任何修改),根据已有的最大ID加1生成新的ID
|
|
|
+insert into sys_user_role
|
|
|
+select (select ur_id from (
|
|
|
+(select ifnull(max(ur_id+0)+1,1) as ur_id from sys_user_role)
|
|
|
+) as tmp),user_id, 2,
|
|
|
+(select owner_id from sys_owner where user_create = (select user_id from tp_user order by time_create desc limit 1))
|
|
|
+,user_id,now(),user_id,now() from tp_user order by time_create desc limit 1;
|