正在显示
1 个修改的文件
包含
15 行增加
和
3 行删除
| @@ -167,13 +167,25 @@ class UpdateSeoTdk extends Command | @@ -167,13 +167,25 @@ class UpdateSeoTdk extends Command | ||
| 167 | $ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray(); | 167 | $ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray(); |
| 168 | $ai_commands = Arr::setValueToKey($ai_commands, 'key'); | 168 | $ai_commands = Arr::setValueToKey($ai_commands, 'key'); |
| 169 | foreach ($this->maps as $table => $map) { | 169 | foreach ($this->maps as $table => $map) { |
| 170 | - $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0]; | 170 | + $total_page = DB::connection('custom_mysql')->table($table)->count(); |
| 171 | + $update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0]; | ||
| 171 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL; | 172 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL; |
| 172 | - $list = DB::connection('custom_mysql')->table($table)->select('id')->get(); | 173 | + $list = DB::connection('custom_mysql')->table($table) |
| 174 | + ->where(function ($query) use ($table, $map){ | ||
| 175 | + if($table == 'gl_product'){ | ||
| 176 | + foreach ($map as $field){ | ||
| 177 | + $field_arr = explode('.', $field); | ||
| 178 | + $query->orWhereRaw('JSON_EXTRACT('.$field_arr[0].', "$.'.$field_arr[1].'") IS NULL OR JSON_EXTRACT('.$field_arr[0].', "$.'.$field_arr[1].'") = ""'); | ||
| 179 | + } | ||
| 180 | + }else{ | ||
| 181 | + foreach ($map as $field){ | ||
| 182 | + $query->orWhereRaw($field . " IS NULL OR ".$field." = ''"); | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + })->select('id')->get(); | ||
| 173 | if (!empty($list)) { | 186 | if (!empty($list)) { |
| 174 | $list = $list->toArray(); | 187 | $list = $list->toArray(); |
| 175 | foreach ($list as $v) { | 188 | foreach ($list as $v) { |
| 176 | - $update[$table]['total_page']++; | ||
| 177 | $v = (array)$v; | 189 | $v = (array)$v; |
| 178 | 190 | ||
| 179 | //缓存 在处理的项目数据 id | 191 | //缓存 在处理的项目数据 id |
-
请 注册 或 登录 后发表评论