作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !3126
@@ -244,20 +244,18 @@ class CopyProject extends Command @@ -244,20 +244,18 @@ class CopyProject extends Command
244 if (!$exists) { 244 if (!$exists) {
245 @file_put_contents( 245 @file_put_contents(
246 storage_path('logs/copy_mysql_error.log'), 246 storage_path('logs/copy_mysql_error.log'),
247 - "源库中不存在表:{$table}" . PHP_EOL, 247 + date('Y-m-d H:i:s')."源库中不存在表:{$table}" . PHP_EOL,
248 FILE_APPEND 248 FILE_APPEND
249 ); 249 );
250 continue; 250 continue;
251 } 251 }
252 // 2. 删除目标数据库中的表 252 // 2. 删除目标数据库中的表
253 $result = DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS `{$table}`"); 253 $result = DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS `{$table}`");
254 - @file_put_contents(storage_path('logs/copy_mysql_error.log'), "删除旧表:{$table} => {$result}" . PHP_EOL, FILE_APPEND);  
255 // 3. 复制建表 SQL 254 // 3. 复制建表 SQL
256 $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`"); 255 $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`");
257 $createSql = get_object_vars($sql[0])['Create Table']; 256 $createSql = get_object_vars($sql[0])['Create Table'];
258 $result1 = DB::connection('custom_mysql')->statement($createSql); 257 $result1 = DB::connection('custom_mysql')->statement($createSql);
259 - @file_put_contents(storage_path('logs/copy_mysql_error.log'), "创建表:{$table} => {$result1}" . PHP_EOL, FILE_APPEND);  
260 - 258 + @file_put_contents(storage_path('logs/copy_mysql_error.log'), date('Y-m-d H:i:s')."创建表:{$table} => {$result1}" . PHP_EOL, FILE_APPEND);
261 // 4. 跳过指定表 259 // 4. 跳过指定表
262 if (in_array($table, [ 260 if (in_array($table, [
263 'gl_customer_visit', 'gl_customer_visit_item', 261 'gl_customer_visit', 'gl_customer_visit_item',
@@ -268,14 +266,13 @@ class CopyProject extends Command @@ -268,14 +266,13 @@ class CopyProject extends Command
268 } 266 }
269 // 5. 插入数据前,再次确认源表存在(双保险) 267 // 5. 插入数据前,再次确认源表存在(双保险)
270 if (!Schema::connection('custom_tmp_mysql_copy')->hasTable($table)) { 268 if (!Schema::connection('custom_tmp_mysql_copy')->hasTable($table)) {
271 - @file_put_contents(storage_path('logs/copy_mysql_error.log'), "插入数据前发现表不存在:{$table}" . PHP_EOL, FILE_APPEND);  
272 continue; 269 continue;
273 } 270 }
274 // 6. 原生 SQL 插入数据(完全复制) 271 // 6. 原生 SQL 插入数据(完全复制)
275 $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`"; 272 $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`";
276 try { 273 try {
277 $result2 = DB::connection('custom_mysql')->statement($insert_sql); 274 $result2 = DB::connection('custom_mysql')->statement($insert_sql);
278 - @file_put_contents(storage_path('logs/copy_mysql_error.log'), "插入数据成功:{$table} => {$result2}" . PHP_EOL, FILE_APPEND); 275 + @file_put_contents(storage_path('logs/copy_mysql_error.log'), date('Y-m-d H:i:s')."插入数据成功:{$table} => {$result2}" . PHP_EOL, FILE_APPEND);
279 } catch (\Exception $e) { 276 } catch (\Exception $e) {
280 @file_put_contents(storage_path('logs/copy_mysql_error.log'), 277 @file_put_contents(storage_path('logs/copy_mysql_error.log'),
281 "插入数据失败:{$table} => " . $e->getMessage() . PHP_EOL, 278 "插入数据失败:{$table} => " . $e->getMessage() . PHP_EOL,
@@ -11,6 +11,7 @@ namespace App\Http\Logic\Aside\Geo; @@ -11,6 +11,7 @@ namespace App\Http\Logic\Aside\Geo;
11 11
12 use App\Console\Commands\Geo\GeoQuestionRes; 12 use App\Console\Commands\Geo\GeoQuestionRes;
13 use App\Http\Logic\Aside\BaseLogic; 13 use App\Http\Logic\Aside\BaseLogic;
  14 +use App\Models\Geo\GeoArticle;
14 use App\Models\Geo\GeoConf; 15 use App\Models\Geo\GeoConf;
15 use App\Models\Geo\GeoLink; 16 use App\Models\Geo\GeoLink;
16 use App\Models\Geo\GeoQuestion; 17 use App\Models\Geo\GeoQuestion;
@@ -122,6 +123,7 @@ class GeoLogic extends BaseLogic @@ -122,6 +123,7 @@ class GeoLogic extends BaseLogic
122 } 123 }
123 $geo_pr_count = GeoLink::where('project_id',$this->param['project_id'])->count(); 124 $geo_pr_count = GeoLink::where('project_id',$this->param['project_id'])->count();
124 $geo_writings_count = GeoWritings::where('project_id',$this->param['project_id'])->count(); 125 $geo_writings_count = GeoWritings::where('project_id',$this->param['project_id'])->count();
  126 + $geo_writings_count += GeoArticle::where('project_id',$this->param['project_id'])->count();
125 return $this->success(['geo_writings_count'=>$geo_writings_count,'geo_pr_count'=>$geo_pr_count,'geo_question_count'=>$geo_question_count]); 127 return $this->success(['geo_writings_count'=>$geo_writings_count,'geo_pr_count'=>$geo_pr_count,'geo_question_count'=>$geo_question_count]);
126 } 128 }
127 129