作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -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
@@ -120,8 +120,6 @@ class ProjectUpdateTdk extends Base @@ -120,8 +120,6 @@ class ProjectUpdateTdk extends Base
120 120
121 $data->save(); 121 $data->save();
122 122
123 - self::where('project_id', $data['project_id'])->where('status', self::STATUS_PENDING)->update(['status' => self::STATUS_SUCCESS]);  
124 -  
125 DB::commit(); 123 DB::commit();
126 } catch (\Exception $e) { 124 } catch (\Exception $e) {
127 DB::rollback(); 125 DB::rollback();