123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Console\Commands;
- use App\Models\DepositOrder;
- use App\Models\RefundLog;
- use App\Models\User;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class TestInsertBigDataDepositCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'test:insert_big_data_deposit';
- /**
- * 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()
- {
- //
- // $deposit_orders = DepositOrder::query()->find(59)->toArray();
- $users = User::query()->whereBetween('id',[30020,40020])->get(['id']);
- // Log::info($users);
- $bar = $this->output->createProgressBar(count($users));
- $bar->start();
- // $datas = [];
- foreach ($users as $v){
- $rand = mt_rand(1,10);
- for ($rand;$rand>0;$rand--){
- $data = [
- 'user_id' => $v->id,
- 'no' => DepositOrder::makeNo(),
- 'money' => '59.00',
- 'type' => 0,
- 'area_id' => 1,
- 'pay_type' => 1,
- 'pay_money' => '59.00',
- 'pay_status' => 1,
- 'pay_time' => Carbon::now()->subDays(mt_rand(1,100))->subHours(mt_rand(1,24))->subMinutes(mt_rand(1,60))->format('Y-m-d H:i:s'),
- 'is_refund' => 1,
- 'status' => 1,
- ];
- $datas[] = $data;
- }
- if(count($datas) >=1000){
- DB::table('deposit_orders')->insert($datas);
- $datas = [];
- }
- $bar->advance();
- }
- $bar->finish();
- }
- }
|