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

96 lines
3.0 KiB

  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. class MigrateOrderMain extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'migrateData:orderMain';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'migrate order main data';
  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. // get old data from old table
  36. $oldData = DB::table('ims_cjdc_order_main')->get();
  37. $bar = $this->output->createProgressBar(count($oldData));
  38. $bar->start();
  39. $newData = [];
  40. foreach ($oldData as $key => $value) {
  41. $newData[] = [
  42. 'market_id' => $value->market_id ?? 0,
  43. 'order_num' => $value->order_num ?? '',
  44. 'global_order_id' => $value->global_order_id ?? 0,
  45. 'user_id' => $value->user_id ?? 0,
  46. 'pay_type' => $value->pay_type ?? 0,
  47. 'type' => $value->type ?? 0,
  48. 'order_type' => $value->order_type ?? 0,
  49. 'shipping_type' => $value->dada_status==0 ? 1 : 2,
  50. 'money' => $value->money ?? 0,
  51. 'total_money' => $value->total_money ?? 0,
  52. 'services_money' => 0,
  53. 'coupon_money' => $value->yhq_money2 ?? 0,
  54. 'delivery_money' => $value->dada_fee ?? 0,
  55. 'state' => $value->state ?? 0,
  56. 'pay_time' => $value->pay_time ? strtotime($value->pay_time) : 0,
  57. 'receive_time' => $value->jd_time ? strtotime($value->jd_time) : 0,
  58. 'delivery_time' => 0,
  59. 'complete_time' => $value->complete_time ? strtotime($value->complete_time) : 0,
  60. 'cancel_time' => $value->complete_time ? strtotime($value->complete_time) : 0,
  61. 'refund_time' => $value->refund_time ?? 0,
  62. 'tel' => $value->tel ?? '',
  63. 'address' => $value->address ?? '',
  64. 'lat' => $value->lat ?? '',
  65. 'lng' => $value->lng ?? '',
  66. 'name' => $value->name ?? '',
  67. 'print_num' => $value->print_num ?? 0,
  68. 'plat' => $value->plat ?? 0,
  69. 'refuse_refund_note' => $value->refuse_refund_note ?? '',
  70. 'delivery_time_note' => $value->delivery_time ?? '',
  71. 'total_refund_note' => $value->total_refund_note ?? '',
  72. 'note' => $value->note ?? '',
  73. 'created_at' => $value->time_add ?? 0,
  74. 'updated_at' => 0,
  75. ];
  76. $bar->advance();
  77. }
  78. // insert new data to new table
  79. DB::table('lanzu_order_main')->insert($newData);
  80. $bar->finish();
  81. return 0;
  82. }
  83. }