get(); $account = DB::table($oldAccount)->select('uid','role','storeid')->get()->toArray(); $accountArr = array_column($account,null,'uid'); $bar = $this->output->createProgressBar(count($account)); $bar->start(); $accountStr = '已经存在的账号id:'; $newData = []; foreach ($oldData as $k => $v){ $exist = DB::table($newTable)->where('id',$v->uid)->exists(); if($exist){ $accountStr .= ','.$v->uid; }else{ $newData[] =[ 'id' => $v->uid, 'openid' => $v->openid ?? '', 'username' => $v->username ?? '', 'password' => $v->password ?? '', 'salt' => $v->salt ?? '', 'register_type' => 0, 'status' => $v->status ?? 0, 'join_ip' => $v->joinip ?? '', 'last_visit_time' => $v->lastvisit ?? 0, 'last_ip' => $v->lastip ?? '', 'token' => $v->token ?? '', 'token_expire' => $v->token_expire ?? '', 'remark' => $v->remark ?? '', 'created_at' => $v->joindate ?? 0, 'updated_at' => time(), 'user_category'=> isset($accountArr[$v->uid]) ? $accountArr[$v->uid]->role ?? 0 : 0, 'store_id'=> isset($accountArr[$v->uid]) ? $accountArr[$v->uid]->storeid ?? 0 : 0, ]; } } DB::table($newTable)->insert($newData); $bar->finish(); var_dump($accountStr); return 0; } }