YzDispatchSeeder.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/9
  6. * Time: 上午9:54
  7. */
  8. use Illuminate\Database\Seeder;
  9. class YzDispatchSeeder extends Seeder
  10. {
  11. protected $oldTable = 'sz_yi_dispatch';
  12. protected $newTable = 'yz_dispatch';
  13. public function run()
  14. {
  15. return;
  16. $newList = \Illuminate\Support\Facades\DB::table($this->newTable)->get();
  17. if ($newList->isNotEmpty()) {
  18. echo "yz_goods_share 已经有数据了跳过\n";
  19. return;
  20. }
  21. $list = \Illuminate\Support\Facades\DB::table($this->oldTable)->get();
  22. if ($list) {
  23. foreach ($list as $v) {
  24. \Illuminate\Support\Facades\DB::table($this->newTable)->insert([
  25. 'uniacid' => $v['uniacid'],
  26. 'dispatch_name' => $v['dispatchname'],
  27. 'display_order' => $v['displayorder'],
  28. 'first_weight_price' => $v['firstprice'],
  29. 'another_weight_price' => $v['secondprice'],
  30. 'first_weight' => $v['firstweight'],
  31. 'another_weight' => $v['secondweight'],
  32. 'areas' => $v['areas'],
  33. 'carriers' => $v['carriers'],
  34. 'enabled' => $v['enabled'],
  35. 'is_default' => $v['isdefault'],
  36. 'calculate_type' => $v['calculatetype'],
  37. 'first_piece' => $v['firstnum'],
  38. 'another_piece' => $v['secondnum'],
  39. 'first_piece_price' => $v['firstnumprice'],
  40. 'another_piece_price' => $v['secondnumprice'],
  41. ]);
  42. }
  43. }
  44. }
  45. }