| @@ -2,681 +2,79 @@ | |||||
| --合并用户数据 | --合并用户数据 | ||||
| insert into wx_c_user_basic_info_37 select * from wx_c_user_basic_info_35; | insert into wx_c_user_basic_info_37 select * from wx_c_user_basic_info_35; | ||||
| select * from | |||||
| select * from wx_c_user_basic_info_36 | |||||
| 电话 旧 新 | |||||
| 18570345630 583458531634216960 580642237342838784 | |||||
| 17600293031 591086539688669184 591070121967120384 | |||||
| 18872592633 592214731579621376 592214458949861376 | |||||
| 17671632874 592593958720925696 580193387804655616 | |||||
| 18229726686 593019803154935808 580638946724048896 | |||||
| 18711137438 606740647732740096 590076655776727040 | |||||
| wx_c_user_tags | |||||
| --groupTenantId 集团tenantId | --groupTenantId 集团tenantId | ||||
| --tenantIds--子广场, 拼接 | --tenantIds--子广场, 拼接 | ||||
| --备份关键表数据, | --备份关键表数据, | ||||
| wx_c_user_36 | |||||
| update wx_c_user_36 set user_id = 580642237342838784 where user_id = 583458531634216960; | |||||
| update wx_c_user_36 set user_id = 591070121967120384 where user_id = 591086539688669184; | |||||
| update wx_c_user_36 set user_id = 592214458949861376 where user_id = 592214731579621376; | |||||
| update wx_c_user_36 set user_id = 580193387804655616 where user_id = 592593958720925696; | |||||
| update wx_c_user_36 set user_id = 580638946724048896 where user_id = 593019803154935808; | |||||
| update wx_c_user_36 set user_id = 590076655776727040 where user_id = 606740647732740096; | |||||
| wx_order_36 | |||||
| wx_coupon_order_36 | |||||
| --所有数据改成集团的数据 | |||||
| --tenantId 集团tenantId | |||||
| --subTenantIds 子广场,拼接 | |||||
| --el: call init_after_group('1025', '1008,1020'); | |||||
| call init_after_group(varchar tenantId,varchar subTenantIds); | |||||
| --合并子广场重复会员 清缓存 | |||||
| --tenantIds 子广场,拼接 | |||||
| --el: call move_after_group('1008,1020'); | |||||
| --call move_after_group(tenantIds); | |||||
| --单独处理 wx_c_user_basic_info,wx_c_user_tags 归属集团 | |||||
| --UPDATE wx_c_user_basic_info SET final_tenant_id = groupTenantId WHERE FIND_IN_SET(final_tenant_id,tenantIds); | |||||
| --UPDATE wx_c_user_tags SET tenant_id = groupTenantId WHERE FIND_IN_SET(tenant_id,tenantIds); | |||||
| --活动报名表 wx_activity_join(如果新旧会员同时报名一个活动会导致数据重复) | |||||
| --用户车牌表 wx_c_user_car 新旧会员都绑定了同一车牌的情况 | |||||
| create table wx_c_user_car_20201117_1008_1020 like wx_c_user_car; | |||||
| create table wx_c_user_car_20201117_1008_1020_merge like wx_c_user_car; | |||||
| insert into wx_c_user_car_20201117_1008_1020 select * from wx_c_user_car where tenant_id in (1008,1020); | |||||
| insert into wx_c_user_car_20201117_1008_1020_merge select * from wx_c_user_car_20201117_1008_1020 where c_user_id in (select id from wx_c_user_basic_info_20201117_1008_1020_merge); | |||||
| --shang 707 | |||||
| select car_number from wx_c_user_car_20201117_1008_1020_merge GROUP BY car_number having count(car_number) > 1;--164 | |||||
| delete from wx_c_user_car_20201117_1008_1020_merge a where c_user_id in (select old_user_id from wx_c_user_basic_info_middle_20201117_1008_1020_merge) and car_number in (select car_number from wx_c_user_car_20201117_1008_1020_merge GROUP BY car_number having count(car_number) > 1); | |||||
| update wx_c_user_car_20201117_1008_1020_merge a LEFT JOIN wx_c_user_basic_info_middle_20201117_1008_1020_merge b on FIND_IN_SET(a.c_user_id,b.old_user_id) SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null; | |||||
| delete from wx_c_user_car where id in (select id from wx_c_user_car_20201117_1008_1020_merge); | |||||
| insert into wx_c_user_car select * from wx_c_user_car_20201117_1008_1020_merge; | |||||
| CREATE DEFINER=`root`@`%` PROCEDURE `back_up_and_move`(IN tenantIds VARCHAR(125),IN groupTenantId VARCHAR(125)) | |||||
| BEGIN | |||||
| select concat('_',date_format(now(),'%Y%m%d'),'_',REPLACE(tenantIds,',','_')) into @backUpSuffix; | |||||
| select concat(@backUpSuffix,'_merge') into @mergeSuffix; | |||||
| set @backUpSql1_0 = concat('create table wx_c_user_basic_info',@backUpSuffix,' like wx_c_user_basic_info;'); | |||||
| PREPARE back_up_sql1_0 FROM @backUpSql1_0; | |||||
| EXECUTE back_up_sql1_0; | |||||
| DEALLOCATE PREPARE back_up_sql1_0; | |||||
| set @backUpSql2_0 = concat('insert into wx_c_user_basic_info',@backUpSuffix,' select * from wx_c_user_basic_info where FIND_IN_SET(final_tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql2_0 FROM @backUpSql2_0; | |||||
| EXECUTE back_up_sql2_0; | |||||
| DEALLOCATE PREPARE back_up_sql2_0; | |||||
| set @backUpSql1_1 = concat('create table wx_c_user_basic_info',@mergeSuffix,' like wx_c_user_basic_info;'); | |||||
| PREPARE back_up_sql1_1 FROM @backUpSql1_1; | |||||
| EXECUTE back_up_sql1_1; | |||||
| DEALLOCATE PREPARE back_up_sql1_1; | |||||
| set @backUpSql2_1 = concat('insert into wx_c_user_basic_info',@mergeSuffix,' select * from wx_c_user_basic_info',@backUpSuffix,' where phone in (SELECT phone FROM wx_c_user_basic_info',@backUpSuffix,' GROUP BY phone HAVING COUNT(1) > 1);'); | |||||
| PREPARE back_up_sql2_1 FROM @backUpSql2_1; | |||||
| EXECUTE back_up_sql2_1; | |||||
| DEALLOCATE PREPARE back_up_sql2_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_basic_info表备份处理数据成功',null); | |||||
| set @backUpSql3_0 = concat('create table wx_c_user',@backUpSuffix,' like wx_c_user;'); | |||||
| PREPARE back_up_sql3_0 FROM @backUpSql3_0; | |||||
| EXECUTE back_up_sql3_0; | |||||
| DEALLOCATE PREPARE back_up_sql3_0; | |||||
| set @backUpSql4_0 = concat('insert into wx_c_user',@backUpSuffix,' select * from wx_c_user where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql4_0 FROM @backUpSql4_0; | |||||
| EXECUTE back_up_sql4_0; | |||||
| DEALLOCATE PREPARE back_up_sql4_0; | |||||
| set @backUpSql3_1 = concat('create table wx_c_user',@mergeSuffix,' like wx_c_user;'); | |||||
| PREPARE back_up_sql3_1 FROM @backUpSql3_1; | |||||
| EXECUTE back_up_sql3_1; | |||||
| DEALLOCATE PREPARE back_up_sql3_1; | |||||
| set @backUpSql4_1 = concat('insert into wx_c_user',@mergeSuffix,' select * from wx_c_user',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql4_1 FROM @backUpSql4_1; | |||||
| EXECUTE back_up_sql4_1; | |||||
| DEALLOCATE PREPARE back_up_sql4_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user表备份、处理数据成功',null); | |||||
| set @backUpSql5_0 = concat('create table wx_order',@backUpSuffix,' like wx_order;'); | |||||
| PREPARE back_up_sql5_0 FROM @backUpSql5_0; | |||||
| EXECUTE back_up_sql5_0; | |||||
| DEALLOCATE PREPARE back_up_sql5_0; | |||||
| set @backUpSql6_0 = concat('insert into wx_order',@backUpSuffix,' select * from wx_order where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql6_0 FROM @backUpSql6_0; | |||||
| EXECUTE back_up_sql6_0; | |||||
| DEALLOCATE PREPARE back_up_sql6_0; | |||||
| set @backUpSql5_1 = concat('create table wx_order',@mergeSuffix,' like wx_order;'); | |||||
| PREPARE back_up_sql5_1 FROM @backUpSql5_1; | |||||
| EXECUTE back_up_sql5_1; | |||||
| DEALLOCATE PREPARE back_up_sql5_1; | |||||
| set @backUpSql6_1 = concat('insert into wx_order',@mergeSuffix,' select * from wx_order',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql6_1 FROM @backUpSql6_1; | |||||
| EXECUTE back_up_sql6_1; | |||||
| DEALLOCATE PREPARE back_up_sql6_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order表备份、处理数据成功',null); | |||||
| set @backUpSql7_0 = concat('create table wx_coupon_order',@backUpSuffix,' like wx_coupon_order;'); | |||||
| PREPARE back_up_sql7_0 FROM @backUpSql7_0; | |||||
| EXECUTE back_up_sql7_0; | |||||
| DEALLOCATE PREPARE back_up_sql7_0; | |||||
| set @backUpSql8_0 = concat('insert into wx_coupon_order',@backUpSuffix,' select * from wx_coupon_order where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql8_0 FROM @backUpSql8_0; | |||||
| EXECUTE back_up_sql8_0; | |||||
| DEALLOCATE PREPARE back_up_sql8_0; | |||||
| set @backUpSql7_1 = concat('create table wx_coupon_order',@mergeSuffix,' like wx_coupon_order;'); | |||||
| PREPARE back_up_sql7_1 FROM @backUpSql7_1; | |||||
| EXECUTE back_up_sql7_1; | |||||
| DEALLOCATE PREPARE back_up_sql7_1; | |||||
| set @backUpSql8_1 = concat('insert into wx_coupon_order',@mergeSuffix,' select * from wx_coupon_order',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,') or owner_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql8_1 FROM @backUpSql8_1; | |||||
| EXECUTE back_up_sql8_1; | |||||
| DEALLOCATE PREPARE back_up_sql8_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_coupon_order表备份、处理数据成功',null); | |||||
| set @backUpSql9_0 = concat('create table wx_pay_order',@backUpSuffix,' like wx_pay_order;'); | |||||
| PREPARE back_up_sql9_0 FROM @backUpSql9_0; | |||||
| EXECUTE back_up_sql9_0; | |||||
| DEALLOCATE PREPARE back_up_sql9_0; | |||||
| set @backUpSql10_0 = concat('insert into wx_pay_order',@backUpSuffix,' select * from wx_pay_order where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql10_0 FROM @backUpSql10_0; | |||||
| EXECUTE back_up_sql10_0; | |||||
| DEALLOCATE PREPARE back_up_sql10_0; | |||||
| set @backUpSql9_1 = concat('create table wx_pay_order',@mergeSuffix,' like wx_pay_order;'); | |||||
| PREPARE back_up_sql9_1 FROM @backUpSql9_1; | |||||
| EXECUTE back_up_sql9_1; | |||||
| DEALLOCATE PREPARE back_up_sql9_1; | |||||
| set @backUpSql10_1 = concat('insert into wx_pay_order',@mergeSuffix,' select * from wx_pay_order',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql10_1 FROM @backUpSql10_1; | |||||
| EXECUTE back_up_sql10_1; | |||||
| DEALLOCATE PREPARE back_up_sql10_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_pay_order表备份、处理数据成功',null); | |||||
| set @backUpSql11_0 = concat('create table wx_refund_order',@backUpSuffix,' like wx_refund_order;'); | |||||
| PREPARE back_up_sql11_0 FROM @backUpSql11_0; | |||||
| EXECUTE back_up_sql11_0; | |||||
| DEALLOCATE PREPARE back_up_sql11_0; | |||||
| set @backUpSql12_0 = concat('insert into wx_refund_order',@backUpSuffix,' select * from wx_refund_order where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql12_0 FROM @backUpSql12_0; | |||||
| EXECUTE back_up_sql12_0; | |||||
| DEALLOCATE PREPARE back_up_sql12_0; | |||||
| set @backUpSql11_1 = concat('create table wx_refund_order',@mergeSuffix,' like wx_refund_order;'); | |||||
| PREPARE back_up_sql11_1 FROM @backUpSql11_1; | |||||
| EXECUTE back_up_sql11_1; | |||||
| DEALLOCATE PREPARE back_up_sql11_1; | |||||
| set @backUpSql12_1 = concat('insert into wx_refund_order',@mergeSuffix,' select * from wx_refund_order',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql12_1 FROM @backUpSql12_1; | |||||
| EXECUTE back_up_sql12_1; | |||||
| DEALLOCATE PREPARE back_up_sql12_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_refund_order表备份、处理数据成功',null); | |||||
| set @backUpSql13_0 = concat('create table wx_order_group',@backUpSuffix,' like wx_order_group;'); | |||||
| PREPARE back_up_sql13_0 FROM @backUpSql13_0; | |||||
| EXECUTE back_up_sql13_0; | |||||
| DEALLOCATE PREPARE back_up_sql13_0; | |||||
| set @backUpSql14_0 = concat('insert into wx_order_group',@backUpSuffix,' select * from wx_order_group where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql14_0 FROM @backUpSql14_0; | |||||
| EXECUTE back_up_sql14_0; | |||||
| DEALLOCATE PREPARE back_up_sql14_0; | |||||
| set @backUpSql13_1 = concat('create table wx_order_group',@mergeSuffix,' like wx_order_group;'); | |||||
| PREPARE back_up_sql13_1 FROM @backUpSql13_1; | |||||
| EXECUTE back_up_sql13_1; | |||||
| DEALLOCATE PREPARE back_up_sql13_1; | |||||
| set @backUpSql14_1 = concat('insert into wx_order_group',@mergeSuffix,' select * from wx_order_group',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql14_1 FROM @backUpSql14_1; | |||||
| EXECUTE back_up_sql14_1; | |||||
| DEALLOCATE PREPARE back_up_sql14_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order_group表备份、处理数据成功',null); | |||||
| set @backUpSql15_0 = concat('create table wx_order_press',@backUpSuffix,' like wx_order_press;'); | |||||
| PREPARE back_up_sql15_0 FROM @backUpSql15_0; | |||||
| EXECUTE back_up_sql15_0; | |||||
| DEALLOCATE PREPARE back_up_sql15_0; | |||||
| set @backUpSql16_0 = concat('insert into wx_order_press',@backUpSuffix,' select * from wx_order_press where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql16_0 FROM @backUpSql16_0; | |||||
| EXECUTE back_up_sql16_0; | |||||
| DEALLOCATE PREPARE back_up_sql16_0; | |||||
| set @backUpSql15_1 = concat('create table wx_order_press',@mergeSuffix,' like wx_order_press;'); | |||||
| PREPARE back_up_sql15_1 FROM @backUpSql15_1; | |||||
| EXECUTE back_up_sql15_1; | |||||
| DEALLOCATE PREPARE back_up_sql15_1; | |||||
| set @backUpSql16_1 = concat('insert into wx_order_press',@mergeSuffix,' select * from wx_order_press',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql16_1 FROM @backUpSql16_1; | |||||
| EXECUTE back_up_sql16_1; | |||||
| DEALLOCATE PREPARE back_up_sql16_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order_press表备份、处理数据成功',null); | |||||
| set @backUpSql17_0 = concat('create table wx_c_user_from_b',@backUpSuffix,' like wx_c_user_from_b;'); | |||||
| PREPARE back_up_sql17_0 FROM @backUpSql17_0; | |||||
| EXECUTE back_up_sql17_0; | |||||
| DEALLOCATE PREPARE back_up_sql17_0; | |||||
| set @backUpSql18_0 = concat('insert into wx_c_user_from_b',@backUpSuffix,' select * from wx_c_user_from_b where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql18_0 FROM @backUpSql18_0; | |||||
| EXECUTE back_up_sql18_0; | |||||
| DEALLOCATE PREPARE back_up_sql18_0; | |||||
| set @backUpSql17_1 = concat('create table wx_c_user_from_b',@mergeSuffix,' like wx_c_user_from_b;'); | |||||
| PREPARE back_up_sql17_1 FROM @backUpSql17_1; | |||||
| EXECUTE back_up_sql17_1; | |||||
| DEALLOCATE PREPARE back_up_sql17_1; | |||||
| set @backUpSql18_1 = concat('insert into wx_c_user_from_b',@mergeSuffix,' select * from wx_c_user_from_b',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql18_1 FROM @backUpSql18_1; | |||||
| EXECUTE back_up_sql18_1; | |||||
| DEALLOCATE PREPARE back_up_sql18_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_from_b表备份、处理数据成功',null); | |||||
| set @backUpSql19_0 = concat('create table wx_activity_join',@backUpSuffix,' like wx_activity_join;'); | |||||
| PREPARE back_up_sql19_0 FROM @backUpSql19_0; | |||||
| EXECUTE back_up_sql19_0; | |||||
| DEALLOCATE PREPARE back_up_sql19_0; | |||||
| set @backUpSql20_0 = concat('insert into wx_activity_join',@backUpSuffix,' select * from wx_activity_join where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql20_0 FROM @backUpSql20_0; | |||||
| EXECUTE back_up_sql20_0; | |||||
| DEALLOCATE PREPARE back_up_sql20_0; | |||||
| set @backUpSql19_1 = concat('create table wx_activity_join',@mergeSuffix,' like wx_activity_join;'); | |||||
| PREPARE back_up_sql19_1 FROM @backUpSql19_1; | |||||
| EXECUTE back_up_sql19_1; | |||||
| DEALLOCATE PREPARE back_up_sql19_1; | |||||
| set @backUpSql20_1 = concat('insert into wx_activity_join',@mergeSuffix,' select * from wx_activity_join',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql20_1 FROM @backUpSql20_1; | |||||
| EXECUTE back_up_sql20_1; | |||||
| DEALLOCATE PREPARE back_up_sql20_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_activity_join表备份、处理数据成功',null); | |||||
| set @backUpSql21_0 = concat('create table wx_question_log',@backUpSuffix,' like wx_question_log;'); | |||||
| PREPARE back_up_sql21_0 FROM @backUpSql21_0; | |||||
| EXECUTE back_up_sql21_0; | |||||
| DEALLOCATE PREPARE back_up_sql21_0; | |||||
| set @backUpSql22_0 = concat('insert into wx_question_log',@backUpSuffix,' select * from wx_question_log where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql22_0 FROM @backUpSql22_0; | |||||
| EXECUTE back_up_sql22_0; | |||||
| DEALLOCATE PREPARE back_up_sql22_0; | |||||
| set @backUpSql21_1 = concat('create table wx_question_log',@mergeSuffix,' like wx_question_log;'); | |||||
| PREPARE back_up_sql21_1 FROM @backUpSql21_1; | |||||
| EXECUTE back_up_sql21_1; | |||||
| DEALLOCATE PREPARE back_up_sql21_1; | |||||
| set @backUpSql22_1 = concat('insert into wx_question_log',@mergeSuffix,' select * from wx_question_log',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql22_1 FROM @backUpSql22_1; | |||||
| EXECUTE back_up_sql22_1; | |||||
| DEALLOCATE PREPARE back_up_sql22_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_question_log表备份、处理数据成功',null); | |||||
| set @backUpSql23_0 = concat('create table wx_game_action_log',@backUpSuffix,' like wx_game_action_log;'); | |||||
| PREPARE back_up_sql23_0 FROM @backUpSql23_0; | |||||
| EXECUTE back_up_sql23_0; | |||||
| DEALLOCATE PREPARE back_up_sql23_0; | |||||
| set @backUpSql24_0 = concat('insert into wx_game_action_log',@backUpSuffix,' select * from wx_game_action_log where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql24_0 FROM @backUpSql24_0; | |||||
| EXECUTE back_up_sql24_0; | |||||
| DEALLOCATE PREPARE back_up_sql24_0; | |||||
| wx_pay_order_36 | |||||
| set @backUpSql23_1 = concat('create table wx_game_action_log',@mergeSuffix,' like wx_game_action_log;'); | |||||
| PREPARE back_up_sql23_1 FROM @backUpSql23_1; | |||||
| EXECUTE back_up_sql23_1; | |||||
| DEALLOCATE PREPARE back_up_sql23_1; | |||||
| set @backUpSql24_1 = concat('insert into wx_game_action_log',@mergeSuffix,' select * from wx_game_action_log',@backUpSuffix,' where user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql24_1 FROM @backUpSql24_1; | |||||
| EXECUTE back_up_sql24_1; | |||||
| DEALLOCATE PREPARE back_up_sql24_1; | |||||
| wx_order_group_36 | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_game_action_log表备份、处理数据成功',null); | |||||
| wx_order_press_36 | |||||
| set @backUpSql25_0 = concat('create table wx_credit_history',@backUpSuffix,' like wx_credit_history;'); | |||||
| PREPARE back_up_sql25_0 FROM @backUpSql25_0; | |||||
| EXECUTE back_up_sql25_0; | |||||
| DEALLOCATE PREPARE back_up_sql25_0; | |||||
| set @backUpSql26_0 = concat('insert into wx_credit_history',@backUpSuffix,' select * from wx_credit_history where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql26_0 FROM @backUpSql26_0; | |||||
| EXECUTE back_up_sql26_0; | |||||
| DEALLOCATE PREPARE back_up_sql26_0; | |||||
| wx_credit_history_36 | |||||
| set @backUpSql25_0 = concat('create table wx_credit_history',@mergeSuffix,' like wx_credit_history;'); | |||||
| PREPARE back_up_sql25_0 FROM @backUpSql25_0; | |||||
| EXECUTE back_up_sql25_0; | |||||
| DEALLOCATE PREPARE back_up_sql25_0; | |||||
| set @backUpSql26_0 = concat('insert into wx_credit_history',@mergeSuffix,' select * from wx_credit_history',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,') or operator_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql26_0 FROM @backUpSql26_0; | |||||
| EXECUTE back_up_sql26_0; | |||||
| DEALLOCATE PREPARE back_up_sql26_0; | |||||
| wx_score_history_36 | |||||
| wx_c_user_basic_child_36 | |||||
| wx_c_user_from_36 | |||||
| wx_c_user_basic_sign_36 | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_credit_history表备份、处理数据成功',null); | |||||
| wx_business_circle_order_36 | |||||
| ali_business_circle_order_36 | |||||
| wx_third_party_orders_36 | |||||
| user_basic_info_address_36 | |||||
| set @backUpSql27_0 = concat('create table wx_score_history',@backUpSuffix,' like wx_score_history;'); | |||||
| PREPARE back_up_sql27_0 FROM @backUpSql27_0; | |||||
| EXECUTE back_up_sql27_0; | |||||
| DEALLOCATE PREPARE back_up_sql27_0; | |||||
| set @backUpSql28_0 = concat('insert into wx_score_history',@backUpSuffix,' select * from wx_score_history where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql28_0 FROM @backUpSql28_0; | |||||
| EXECUTE back_up_sql28_0; | |||||
| DEALLOCATE PREPARE back_up_sql28_0; | |||||
| wx_refund_order | |||||
| wx_c_user_from_b | |||||
| wx_activity_join | |||||
| set @backUpSql27_1 = concat('create table wx_score_history',@mergeSuffix,' like wx_score_history;'); | |||||
| PREPARE back_up_sql27_1 FROM @backUpSql27_1; | |||||
| EXECUTE back_up_sql27_1; | |||||
| DEALLOCATE PREPARE back_up_sql27_1; | |||||
| set @backUpSql28_1 = concat('insert into wx_score_history',@mergeSuffix,' select * from wx_score_history',@backUpSuffix,' where c_user_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql28_1 FROM @backUpSql28_1; | |||||
| EXECUTE back_up_sql28_1; | |||||
| DEALLOCATE PREPARE back_up_sql28_1; | |||||
| wx_question_log | |||||
| wx_game_action_log | |||||
| wx_card_spend | |||||
| wx_question_oneself_user | |||||
| wx_opinion | |||||
| alipay_c_user | |||||
| jm_sport_order | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_score_history表备份、处理数据成功',null); | |||||
| set @backUpSql29_0 = concat('create table wx_card_spend',@backUpSuffix,' like wx_card_spend;'); | |||||
| PREPARE back_up_sql29_0 FROM @backUpSql29_0; | |||||
| EXECUTE back_up_sql29_0; | |||||
| DEALLOCATE PREPARE back_up_sql29_0; | |||||
| set @backUpSql30_0 = concat('insert into wx_card_spend',@backUpSuffix,' select * from wx_card_spend where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql30_0 FROM @backUpSql30_0; | |||||
| EXECUTE back_up_sql30_0; | |||||
| DEALLOCATE PREPARE back_up_sql30_0; | |||||
| set @backUpSql29_1 = concat('create table wx_card_spend',@mergeSuffix,' like wx_card_spend;'); | |||||
| PREPARE back_up_sql29_1 FROM @backUpSql29_1; | |||||
| EXECUTE back_up_sql29_1; | |||||
| DEALLOCATE PREPARE back_up_sql29_1; | |||||
| set @backUpSql30_1 = concat('insert into wx_card_spend',@mergeSuffix,' select * from wx_card_spend',@backUpSuffix,' where owner_id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql30_1 FROM @backUpSql30_1; | |||||
| EXECUTE back_up_sql30_1; | |||||
| DEALLOCATE PREPARE back_up_sql30_1; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_card_spend表备份、处理数据成功',null); | |||||
| set @backUpSql31_0 = concat('create table wx_c_user_tags',@backUpSuffix,' like wx_c_user_tags;'); | |||||
| PREPARE back_up_sql31_0 FROM @backUpSql31_0; | |||||
| EXECUTE back_up_sql31_0; | |||||
| DEALLOCATE PREPARE back_up_sql31_0; | |||||
| set @backUpSql32_0 = concat('insert into wx_c_user_tags',@backUpSuffix,' select * from wx_c_user_tags where FIND_IN_SET(tenant_id,\'',tenantIds,'\');'); | |||||
| PREPARE back_up_sql32_0 FROM @backUpSql32_0; | |||||
| EXECUTE back_up_sql32_0; | |||||
| DEALLOCATE PREPARE back_up_sql32_0; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_tags表备份、处理数据成功','无关键SQL操作'); | |||||
| set @handleSql_00 = concat('CREATE TABLE `wx_c_user_basic_info_middle',@mergeSuffix,'` ( | |||||
| `new_user_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `old_user_id` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `tenant_ids` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `user_ids` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||||
| `sum_poins` int(11) DEFAULT NULL, | |||||
| `sum_credit` int(11) DEFAULT NULL, | |||||
| `sum_login_count` int(11) DEFAULT NULL, | |||||
| UNIQUE INDEX `new_user_id`(`new_user_id`) USING BTREE, | |||||
| UNIQUE INDEX `old_user_id`(`old_user_id`) USING BTREE | |||||
| ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;'); | |||||
| PREPARE handle_sql_00 FROM @handleSql_00; | |||||
| EXECUTE handle_sql_00; | |||||
| DEALLOCATE PREPARE handle_sql_00; | |||||
| set @handleSql_01 = concat('insert into wx_c_user_basic_info_middle',@mergeSuffix,' (phone,tenant_ids,user_ids,sum_poins,sum_credit,sum_login_count) select phone,CONCAT(\',\',GROUP_CONCAT(final_tenant_id),\',\'),GROUP_CONCAT(id),SUM(poins),SUM(credit),SUM(login_count) from wx_c_user_basic_info',@mergeSuffix,' GROUP BY phone;'); | |||||
| PREPARE handle_sql_01 FROM @handleSql_01; | |||||
| EXECUTE handle_sql_01; | |||||
| DEALLOCATE PREPARE handle_sql_01; | |||||
| set @handleSql_02 = concat('UPDATE wx_c_user_basic_info_middle',@mergeSuffix,' SET new_user_id = SUBSTRING_INDEX(user_ids,\',\',1);'); | |||||
| PREPARE handle_sql_02 FROM @handleSql_02; | |||||
| EXECUTE handle_sql_02; | |||||
| DEALLOCATE PREPARE handle_sql_02; | |||||
| set @handleSql_03 = concat('UPDATE wx_c_user_basic_info_middle',@mergeSuffix,' SET old_user_id = SUBSTRING_INDEX(user_ids,CONCAT(new_user_id,\',\'),-1);'); | |||||
| PREPARE handle_sql_03 FROM @handleSql_03; | |||||
| EXECUTE handle_sql_03; | |||||
| DEALLOCATE PREPARE handle_sql_03; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_basic_info_middle所有会员重复数据整理成功','无关键SQL操作'); | |||||
| set @handleSql_10 = concat('UPDATE wx_c_user',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) SET a.token = null,a.expire_time=now(),a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_10 FROM @handleSql_10; | |||||
| EXECUTE handle_sql_10; | |||||
| DEALLOCATE PREPARE handle_sql_10; | |||||
| set @backUpSql3 = concat('delete from wx_c_user where id in (select id from wx_c_user',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql3 FROM @backUpSql3; | |||||
| EXECUTE back_up_sql3; | |||||
| DEALLOCATE PREPARE back_up_sql3; | |||||
| set @handleSql_11 = concat('insert into wx_c_user select * from wx_c_user',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_11 FROM @handleSql_11; | |||||
| EXECUTE handle_sql_11; | |||||
| DEALLOCATE PREPARE handle_sql_11; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user表所有会员重复关联数据处理成功',concat(@backUpSql3,@handleSql_11)); | |||||
| set @handleSql_20 = concat('UPDATE wx_order',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_20 FROM @handleSql_20; | |||||
| EXECUTE handle_sql_20; | |||||
| DEALLOCATE PREPARE handle_sql_20; | |||||
| set @backUpSql5 = concat('delete from wx_order where id in (select id from wx_order',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql5 FROM @backUpSql5; | |||||
| EXECUTE back_up_sql5; | |||||
| DEALLOCATE PREPARE back_up_sql5; | |||||
| set @handleSql_21 = concat('insert into wx_order select * from wx_order',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_21 FROM @handleSql_21; | |||||
| EXECUTE handle_sql_21; | |||||
| DEALLOCATE PREPARE handle_sql_21; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order表所有会员重复关联数据处理成功',concat(@backUpSql5,@handleSql_21)); | |||||
| set @handleSql_30 = concat('UPDATE wx_coupon_order',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_30 FROM @handleSql_30; | |||||
| EXECUTE handle_sql_30; | |||||
| DEALLOCATE PREPARE handle_sql_30; | |||||
| set @handleSql_31 = concat('UPDATE wx_coupon_order',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.owner_id,b.old_user_id) | |||||
| SET a.owner_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_31 FROM @handleSql_31; | |||||
| EXECUTE handle_sql_31; | |||||
| DEALLOCATE PREPARE handle_sql_31; | |||||
| set @backUpSql7 = concat('delete from wx_coupon_order where id in (select id from wx_coupon_order',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql7 FROM @backUpSql7; | |||||
| EXECUTE back_up_sql7; | |||||
| DEALLOCATE PREPARE back_up_sql7; | |||||
| set @handleSql_32 = concat('insert into wx_coupon_order select * from wx_coupon_order',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_32 FROM @handleSql_32; | |||||
| EXECUTE handle_sql_32; | |||||
| DEALLOCATE PREPARE handle_sql_32; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_coupon_order表所有会员重复关联数据处理成功',concat(@backUpSql7,@handleSql_32)); | |||||
| set @handleSql_40 = concat('UPDATE wx_pay_order',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_40 FROM @handleSql_40; | |||||
| EXECUTE handle_sql_40; | |||||
| DEALLOCATE PREPARE handle_sql_40; | |||||
| set @backUpSql9 = concat('delete from wx_pay_order where id in (select id from wx_pay_order',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql9 FROM @backUpSql9; | |||||
| EXECUTE back_up_sql9; | |||||
| DEALLOCATE PREPARE back_up_sql9; | |||||
| set @handleSql_41 = concat('insert into wx_pay_order select * from wx_pay_order',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_41 FROM @handleSql_41; | |||||
| EXECUTE handle_sql_41; | |||||
| DEALLOCATE PREPARE handle_sql_41; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_pay_order表所有会员重复关联数据处理成功',concat(@backUpSql9,@handleSql_41)); | |||||
| set @handleSql_50 = concat('UPDATE wx_refund_order',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_50 FROM @handleSql_50; | |||||
| EXECUTE handle_sql_50; | |||||
| DEALLOCATE PREPARE handle_sql_50; | |||||
| set @backUpSql11 = concat('delete from wx_refund_order where id in (select id from wx_refund_order',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql11 FROM @backUpSql11; | |||||
| EXECUTE back_up_sql11; | |||||
| DEALLOCATE PREPARE back_up_sql11; | |||||
| set @handleSql_51 = concat('insert into wx_refund_order select * from wx_refund_order',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_51 FROM @handleSql_51; | |||||
| EXECUTE handle_sql_51; | |||||
| DEALLOCATE PREPARE handle_sql_51; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_refund_order表所有会员重复关联数据处理成功',concat(@backUpSql11,@handleSql_51)); | |||||
| set @handleSql_60 = concat('UPDATE wx_order_group',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) | |||||
| SET a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_60 FROM @handleSql_60; | |||||
| EXECUTE handle_sql_60; | |||||
| DEALLOCATE PREPARE handle_sql_60; | |||||
| set @backUpSql13 = concat('delete from wx_order_group where id in (select id from wx_order_group',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql13 FROM @backUpSql13; | |||||
| EXECUTE back_up_sql13; | |||||
| DEALLOCATE PREPARE back_up_sql13; | |||||
| set @handleSql_61 = concat('insert into wx_order_group select * from wx_order_group',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_61 FROM @handleSql_61; | |||||
| EXECUTE handle_sql_61; | |||||
| DEALLOCATE PREPARE handle_sql_61; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order_group表所有会员重复关联数据处理成功',concat(@backUpSql13,@handleSql_61)); | |||||
| set @handleSql_70 = concat('UPDATE wx_order_press',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) | |||||
| SET a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_70 FROM @handleSql_70; | |||||
| EXECUTE handle_sql_70; | |||||
| DEALLOCATE PREPARE handle_sql_70; | |||||
| set @backUpSql15 = concat('delete from wx_order_press where id in (select id from wx_order_press',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql15 FROM @backUpSql15; | |||||
| EXECUTE back_up_sql15; | |||||
| DEALLOCATE PREPARE back_up_sql15; | |||||
| set @handleSql_71 = concat('insert into wx_order_press select * from wx_order_press',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_71 FROM @handleSql_71; | |||||
| EXECUTE handle_sql_71; | |||||
| DEALLOCATE PREPARE handle_sql_71; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_order_press表所有会员重复关联数据处理成功',concat(@backUpSql15,@handleSql_71)); | |||||
| set @handleSql_80 = concat('UPDATE wx_c_user_from_b',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_80 FROM @handleSql_80; | |||||
| EXECUTE handle_sql_80; | |||||
| DEALLOCATE PREPARE handle_sql_80; | |||||
| set @backUpSql17 = concat('delete from wx_c_user_from_b where id in (select id from wx_c_user_from_b',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql17 FROM @backUpSql17; | |||||
| EXECUTE back_up_sql17; | |||||
| DEALLOCATE PREPARE back_up_sql17; | |||||
| set @handleSql_81 = concat('insert into wx_c_user_from_b select * from wx_c_user_from_b',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_81 FROM @handleSql_81; | |||||
| EXECUTE handle_sql_81; | |||||
| DEALLOCATE PREPARE handle_sql_81; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_from_b表所有会员重复关联数据处理成功',concat(@backUpSql17,@handleSql_81)); | |||||
| set @handleSql_90 = concat('UPDATE wx_activity_join',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) | |||||
| SET a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_90 FROM @handleSql_90; | |||||
| EXECUTE handle_sql_90; | |||||
| DEALLOCATE PREPARE handle_sql_90; | |||||
| set @backUpSql19 = concat('delete from wx_activity_join where id in (select id from wx_activity_join',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql19 FROM @backUpSql19; | |||||
| EXECUTE back_up_sql19; | |||||
| DEALLOCATE PREPARE back_up_sql19; | |||||
| set @handleSql_91 = concat('insert into wx_activity_join select * from wx_activity_join',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_91 FROM @handleSql_91; | |||||
| EXECUTE handle_sql_91; | |||||
| DEALLOCATE PREPARE handle_sql_91; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_activity_join表所有会员重复关联数据处理成功',concat(@backUpSql19,@handleSql_91)); | |||||
| set @handleSql_100 = concat('UPDATE wx_question_log',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) | |||||
| SET a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_100 FROM @handleSql_100; | |||||
| EXECUTE handle_sql_100; | |||||
| DEALLOCATE PREPARE handle_sql_100; | |||||
| set @backUpSql21 = concat('delete from wx_question_log where id in (select id from wx_question_log',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql21 FROM @backUpSql21; | |||||
| EXECUTE back_up_sql21; | |||||
| DEALLOCATE PREPARE back_up_sql21; | |||||
| set @handleSql_101 = concat('insert into wx_question_log select * from wx_question_log',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_101 FROM @handleSql_101; | |||||
| EXECUTE handle_sql_101; | |||||
| DEALLOCATE PREPARE handle_sql_101; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_question_log表所有会员重复关联数据处理成功',concat(@backUpSql21,@handleSql_101)); | |||||
| set @handleSql_110 = concat('UPDATE wx_game_action_log',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.user_id,b.old_user_id) | |||||
| SET a.user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_110 FROM @handleSql_110; | |||||
| EXECUTE handle_sql_110; | |||||
| DEALLOCATE PREPARE handle_sql_110; | |||||
| set @backUpSql23 = concat('delete from wx_game_action_log where id in (select id from wx_game_action_log',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql23 FROM @backUpSql23; | |||||
| EXECUTE back_up_sql23; | |||||
| DEALLOCATE PREPARE back_up_sql23; | |||||
| set @handleSql_111 = concat('insert into wx_game_action_log select * from wx_game_action_log',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_111 FROM @handleSql_111; | |||||
| EXECUTE handle_sql_111; | |||||
| DEALLOCATE PREPARE handle_sql_111; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_game_action_log表所有会员重复关联数据处理成功',concat(@backUpSql23,@handleSql_111)); | |||||
| set @handleSql_120 = concat('UPDATE wx_credit_history',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_120 FROM @handleSql_120; | |||||
| EXECUTE handle_sql_120; | |||||
| DEALLOCATE PREPARE handle_sql_120; | |||||
| set @handleSql_121 = concat('UPDATE wx_credit_history',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.operator_id,b.old_user_id) | |||||
| SET a.operator_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_121 FROM @handleSql_121; | |||||
| EXECUTE handle_sql_121; | |||||
| DEALLOCATE PREPARE handle_sql_121; | |||||
| set @backUpSql25 = concat('delete from wx_credit_history where id in (select id from wx_credit_history',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql25 FROM @backUpSql25; | |||||
| EXECUTE back_up_sql25; | |||||
| DEALLOCATE PREPARE back_up_sql25; | |||||
| set @handleSql_122 = concat('insert into wx_credit_history select * from wx_credit_history',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_122 FROM @handleSql_122; | |||||
| EXECUTE handle_sql_122; | |||||
| DEALLOCATE PREPARE handle_sql_122; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_credit_history表所有会员重复关联数据处理成功',concat(@backUpSql25,@handleSql_122)); | |||||
| set @handleSql_130 = concat('UPDATE wx_score_history',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.c_user_id,b.old_user_id) | |||||
| SET a.c_user_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_130 FROM @handleSql_130; | |||||
| EXECUTE handle_sql_130; | |||||
| DEALLOCATE PREPARE handle_sql_130; | |||||
| set @backUpSql27 = concat('delete from wx_score_history where id in (select id from wx_score_history',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql27 FROM @backUpSql27; | |||||
| EXECUTE back_up_sql27; | |||||
| DEALLOCATE PREPARE back_up_sql27; | |||||
| set @handleSql_131 = concat('insert into wx_score_history select * from wx_score_history',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_131 FROM @handleSql_131; | |||||
| EXECUTE handle_sql_131; | |||||
| DEALLOCATE PREPARE handle_sql_131; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_score_history表所有会员重复关联数据处理成功',concat(@backUpSql27,@handleSql_131)); | |||||
| set @handleSql_140 = concat('UPDATE wx_card_spend',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.owner_id,b.old_user_id) | |||||
| SET a.owner_id = b.new_user_id WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_140 FROM @handleSql_140; | |||||
| EXECUTE handle_sql_140; | |||||
| DEALLOCATE PREPARE handle_sql_140; | |||||
| set @backUpSql29 = concat('delete from wx_card_spend where id in (select id from wx_card_spend',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql29 FROM @backUpSql29; | |||||
| EXECUTE back_up_sql29; | |||||
| DEALLOCATE PREPARE back_up_sql29; | |||||
| set @handleSql_141 = concat('insert into wx_card_spend select * from wx_card_spend',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_141 FROM @handleSql_141; | |||||
| EXECUTE handle_sql_141; | |||||
| DEALLOCATE PREPARE handle_sql_141; | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_card_spend表所有会员重复关联数据处理成功',concat(@backUpSql29,@handleSql_141)); | |||||
| set @handleSql_150 = concat('UPDATE wx_c_user_basic_info',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on a.id = b.new_user_id SET a.tenant_id = b.tenant_ids,a.poins = b.sum_poins,a.credit = b.sum_credit,a.login_count = b.sum_login_count WHERE b.new_user_id is not null;'); | |||||
| PREPARE handle_sql_150 FROM @handleSql_150; | |||||
| EXECUTE handle_sql_150; | |||||
| DEALLOCATE PREPARE handle_sql_150; | |||||
| set @handleSql_151 = concat('UPDATE wx_c_user_basic_info',@mergeSuffix,' a LEFT JOIN wx_c_user_basic_info_middle',@mergeSuffix,' b on FIND_IN_SET(a.id,b.old_user_id) SET a.phone = concat(a.phone,\'_del_\',date_format(now(),\'%Y%m%d%H%m%s\')),a.`status` = 1 WHERE b.old_user_id is not null;'); | |||||
| PREPARE handle_sql_151 FROM @handleSql_151; | |||||
| EXECUTE handle_sql_151; | |||||
| DEALLOCATE PREPARE handle_sql_151; | |||||
| set @backUpSql1 = concat('delete from wx_c_user_basic_info where id in (select id from wx_c_user_basic_info',@mergeSuffix,');'); | |||||
| PREPARE back_up_sql1 FROM @backUpSql1; | |||||
| EXECUTE back_up_sql1; | |||||
| DEALLOCATE PREPARE back_up_sql1; | |||||
| set @handleSql_152 = concat('insert into wx_c_user_basic_info select * from wx_c_user_basic_info',@mergeSuffix,';'); | |||||
| PREPARE handle_sql_152 FROM @handleSql_152; | |||||
| EXECUTE handle_sql_152; | |||||
| DEALLOCATE PREPARE handle_sql_152; | |||||
| --所有数据改成集团的数据 | |||||
| --tenantId 集团tenantId | |||||
| --subTenantIds 子广场,拼接 | |||||
| --el: call init_after_group('1025', '1008,1020'); | |||||
| call init_after_group(varchar tenantId,varchar subTenantIds); | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_basic_info表所有会员重复关联数据处理成功',concat(@backUpSql1,@handleSql_152)); | |||||
| UPDATE wx_c_user_basic_info SET final_tenant_id = groupTenantId WHERE FIND_IN_SET(final_tenant_id,tenantIds); | |||||
| UPDATE wx_c_user_tags SET tenant_id = groupTenantId WHERE FIND_IN_SET(tenant_id,tenantIds); | |||||
| INSERT into zz_process_log VALUES(NOW(),'back_up()','wx_c_user_basic_info表会员归属集团修改成功',concat('UPDATE wx_c_user_basic_info SET final_tenant_id = ',groupTenantId,' WHERE FIND_IN_SET(final_tenant_id,',tenantIds,');')); | |||||
| SELECT * from zz_process_log; | |||||
| --单独处理 wx_c_user_basic_info,wx_c_user_tags 归属集团 | |||||
| --UPDATE wx_c_user_basic_info SET final_tenant_id = groupTenantId WHERE FIND_IN_SET(final_tenant_id,tenantIds); | |||||
| --UPDATE wx_c_user_tags SET tenant_id = groupTenantId WHERE FIND_IN_SET(tenant_id,tenantIds); | |||||
| END | |||||
| --活动报名表 wx_activity_join(如果新旧会员同时报名一个活动会导致数据重复) | |||||
| --用户车牌表 wx_c_user_car 新旧会员都绑定了同一车牌的情况 | |||||