添加:部分内容优化

This commit is contained in:
wuhui_zzw 2023-10-07 08:55:40 +08:00
parent 562172a579
commit 54e1ba3dc9
15 changed files with 111 additions and 20 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -852,36 +852,115 @@ class SurveyController extends BaseController{
'ims_yz_sys_msg_type',
'ims_yz_system_setting',
'ims_yz_virtual_coin',
// 分销商相关
'ims_yz_agent_level',
// 商品相关
'ims_yz_category',
'ims_yz_diyform_order',
'ims_yz_goods',
'ims_yz_goods_advertising',
'ims_yz_goods_category',
'ims_yz_goods_commission',
'ims_yz_goods_contact_tel',
'ims_yz_goods_coupon',
'ims_yz_goods_discount',
'ims_yz_goods_dispatch',
'ims_yz_goods_div_from',
'ims_yz_goods_image_link',
'ims_yz_goods_limitbuy',
'ims_yz_goods_option',
'ims_yz_goods_point_activity',
'ims_yz_goods_privilege',
'ims_yz_goods_sale',
'ims_yz_goods_service',
'ims_yz_goods_share',
'ims_yz_goods_shareholder_dividend',
'ims_yz_goods_small_code_url',
'ims_yz_goods_spec',
'ims_yz_goods_spec_item',
'ims_yz_goods_team_dividend',
'ims_yz_goods_video',
'ims_yz_invite_page',
'ims_yz_point_mall_goods',
'ims_yz_red_packet_goods',
// 附件相关
'ims_yz_core_attachment',
'ims_yz_core_attachment_tags',
// 装修相关
'ims_yz_decorate',
'ims_yz_decorate_advertising',
'ims_yz_decorate_footer',
'ims_yz_decorate_templet',
// 其他 | 系统相关
'ims_yz_order_invoice',
'ims_yz_setting',
'ims_yz_uniacid_app',
'ims_yz_options',
'ims_yz_app_user',
'ims_failed_jobs',
'ims_migrations',
'ims_yz_wechat_rule',
'ims_yz_wechat_rule_keyword',
'ims_yz_withdraw_rich_text',
// 经销商相关
'ims_yz_team_dividend_level',
'ims_yz_team_dividend_level_redpack',
'ims_yz_team_dividend_level_upgrade',
// 文章相关
'ims_yz_plugin_article',
'ims_yz_plugin_article_category',
'ims_yz_plugin_article_log',
// 红包相关
'ims_yz_red_packet_logs',
// 海报相关
'ims_yz_new_poster',
'ims_yz_new_poster_supplement',
// 用户相关
'ims_yz_member_relation',
// 微社区
'ims_yz_micro_communities_category',
'ims_yz_micro_communities_set',
// 视频分享
'ims_yz_video_share_category',
];
// 获取全部数据库列表
$tables = $this->getAllTable();
// 获取存在数据的表
$hasTable = $this->getHasDataTable($tables,$notCleanUp);
debug($hasTable);
// 执行清除操作
foreach($tables as $name){
if(!in_array($name,$notCleanUp)){
// 判断是否操作uniacid=0的数据 存在则执行删除存在,不存在则执行清除操作
$tableName = str_replace('ims_','',$name);
if($this->isHasZeroData($name)){
// echo $name."=有","<br />";
$columns = \DB::select('SHOW COLUMNS FROM '.$name);
$fields = array_column($columns,'Field');
$primaryKey = $fields[0];
$max = \DB::table($tableName)->where('uniacid',0)->max($primaryKey);
\DB::table($tableName)->where('uniacid','>',0)->delete();
\DB::select('alter table '.$name.' AUTO_INCREMENT='.$max);
}else{
\DB::select('TRUNCATE TABLE '.$name.';');
}
}
}
// foreach($tables as $name){
// if(!in_array($name,$notCleanUp)){
// // 判断是否操作uniacid=0的数据 存在则执行删除存在,不存在则执行清除操作
// $tableName = str_replace('ims_','',$name);
// if($this->isHasZeroData($name)){
// // echo $name."=有","<br />";
// $columns = \DB::select('SHOW COLUMNS FROM '.$name);
// $fields = array_column($columns,'Field');
// $primaryKey = $fields[0];
// $max = \DB::table($tableName)->where('uniacid',0)->max($primaryKey);
// \DB::table($tableName)->where('uniacid','>',0)->delete();
// \DB::select('alter table '.$name.' AUTO_INCREMENT='.$max);
// }else{
// \DB::select('TRUNCATE TABLE '.$name.';');
// }
// }
// }
debug("处理完成");
}
// 数据库处理 - 获取全部数据库
private function getAllTable(){
$database = \DB::select('SELECT DATABASE() as database_name')[0]['database_name'];
$tables = \DB::select('SHOW TABLES');
return array_column($tables,'Tables_in_bztang_cdlfjy_co');
return array_column($tables,'Tables_in_'.$database);
}
// 数据库处理 - 获取存在数据的表
private function getHasDataTable($tables,$notCleanUp){
@ -889,7 +968,9 @@ class SurveyController extends BaseController{
foreach($tables as $name){
if(!in_array($name,$notCleanUp)){
$tableName = str_replace('ims_','',$name);
$count = \DB::table($tableName)->count();
$table = \DB::table($tableName);
if($this->isHasZeroData($name)) $table->where('uniacid','>',0);
$count = $table->count();
if($count > 0) $tableList[] = $name;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 9.8 KiB