链街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.

111 lines
3.1 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. $startTime = time();
  45. $total = 0;
  46. $newData = [];
  47. foreach ($oldData as $value){
  48. $storeData =[
  49. 'id'=>$value->id,
  50. 'market_id'=>$value->market_id,
  51. 'is_open'=> $value->is_open == 1 ? 1 : 0,
  52. 'is_rest'=> $value->is_rest == 1 ? 1 : 0,
  53. 'status'=>$value->state,
  54. 'category_id'=>$value->md_type,
  55. 'user_id'=>$value->user_id,
  56. 'admin_id'=>$value->admin_id,
  57. 'mm_user_id'=>$value->mm_user_id,
  58. 'sort'=>$value->number,
  59. 'loudspeaker_imei'=>$value->loudspeaker_imei,
  60. 'is_infinite'=> $value->is_max == 1 ? 1 :0,
  61. 'name'=>$value->name,
  62. 'logo'=>$value->logo,
  63. 'announcement'=>$value->announcement,
  64. 'address' => $value->address,
  65. 'business_license'=>$value->yyzz,
  66. 'zm_img' => $value->zm_img,
  67. 'fm_img'=>$value->fm_img,
  68. 'tel' => $value->tel,
  69. 'link_name'=>$value->link_name,
  70. 'link_tel' => $value->link_tel,
  71. 'expire_time'=> strtotime($value->rzdq_time),
  72. 'time1' => $value->time1,
  73. 'time2'=>$value->time2,
  74. 'time3' => $value->time3,
  75. 'time4'=>$value->time4,
  76. 'award_money' => $value->award_money,
  77. 'sales'=>$value->score,
  78. 'grade' => $value->sales,
  79. 'code'=>$value->code,
  80. 'environment' => $value->environment,
  81. 'introduction'=> strip_tags($value->introduction),
  82. ];
  83. // preg_match('/[0-9]/', $string, $matches, PREG_OFFSET_CAPTURE);
  84. $storeData['stall_info'] = '';
  85. $storeData['lng'] = '';
  86. $storeData['lat'] = '';
  87. // DB::table('lanzu_store_new')->insert($newData);
  88. $bar->advance();
  89. }
  90. $bar->finish();
  91. echo '\r\n ';
  92. echo time()-$startTime;
  93. return 0;
  94. }
  95. }