YzGoodsPrivilegeSeeder.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 YzGoodsPrivilegeSeeder extends Seeder
  10. {
  11. protected $oldTable = 'sz_yi_goods';
  12. protected $newTable = 'yz_goods_privilege';
  13. public function run()
  14. {
  15. return;
  16. if (!Schema::hasTable($this->oldTable)) {
  17. echo $this->oldTable." 不存在 跳过\n";
  18. return;
  19. }
  20. $newList = \Illuminate\Support\Facades\DB::table($this->newTable)->get();
  21. if($newList->isNotEmpty()){
  22. echo "yz_goods_share 已经有数据了跳过\n";
  23. return ;
  24. }
  25. $list = \Illuminate\Support\Facades\DB::table($this->oldTable)->get();
  26. if($list) {
  27. foreach ($list as $v) {
  28. \Illuminate\Support\Facades\DB::table($this->newTable)->insert([
  29. 'goods_id'=> $v['id'],
  30. 'show_levels'=> $v['showlevels'],
  31. 'show_groups'=> $v['showgroups'],
  32. 'buy_levels'=> $v['buylevels'],
  33. 'buy_groups'=> $v['buygroups'],
  34. 'once_buy_limit'=> $v['maxbuy'],
  35. 'total_buy_limit'=> $v['usermaxbuy'],
  36. 'time_begin_limit'=> $v['timestart'],
  37. 'time_end_limit'=> $v['timeend'],
  38. 'enable_time_limit'=> 0,
  39. ]);
  40. }
  41. }
  42. }
  43. }