链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. class MigrateStore extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'migrateData:store';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Command 迁移店铺数据';
  19. /**
  20. * Create a new command instance.
  21. *
  22. * @return void
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. }
  28. /**
  29. * Execute the console command.
  30. *
  31. * @return int
  32. */
  33. public function handle()
  34. {
  35. // 如果表不存在则创建
  36. // if(!Schema::hasTable('lanzu_store_users')){
  37. // Schema::create('lanzu_store_users',function (Blueprint $table){
  38. // $table->id();
  39. // });
  40. // }
  41. $oldData = DB::table('ims_cjdc_store_new')->get();
  42. $bar = $this->output->createProgressBar(count($oldData));
  43. $bar->start();
  44. $newData = [];
  45. foreach ($oldData as $ka => $va){
  46. // $storeUsers = DB::table('lanzu_store_users')->find($va->uid);
  47. // if(!empty($storeUsers)){
  48. $newData =[
  49. 'user_category'=>$va->role,
  50. 'store_id'=>$va->storeid
  51. ];
  52. // DB::table('lanzu_store_users')->where('id',$va->uid)->update($data);
  53. // }
  54. $bar->advance();
  55. }
  56. DB::table('lanzu_store_new')->insert($newData);
  57. $bar->finish();
  58. return 0;
  59. }
  60. }