12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Order;
- use Illuminate\Console\Command;
- class orderRepair extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'order:repair';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '添加预约时间';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $count = Order::whereIn('product_type',[3,4,5])->count();
- $page = ceil($count /1000);
- for ($i=1;$i<=$page;$i++){
- $list = Order::leftjoin('order_patients','order_patients.order_id','=','orders.id')
- ->select(['orders.id','order_patients.appoint_start_time','order_patients.appoint_end_time'])
- ->where('orders.appoint_start_time','=', 0)
- ->whereIn('product_type',[3,4,5])->limit(($i-1)*1000,$i*1000)->get()->toArray();
- foreach ($list as $info){
- $data = ['appoint_date'=>strtotime('today'),'appoint_start_time'=>$info['appoint_start_time'],'appoint_end_time'=>$info['appoint_end_time']];
- Order::where('id',$info['id'])->update($data);
- unset($data);
- }
- echo '第'.$i.'页'.PHP_EOL;
- unset($list);
- }
- dd('end');
- }
- }
|