<?php

namespace Tests\Console\Commands\Jiesuan;

use App\Console\Commands\Jiesuan\CompanyChargeDayJiesuan;
use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\TestCase;

class CompanyChargeDayJiesuanTest extends \Tests\TestCase
{

    public function testHandle()
    {
        $this->prepareData();
    }

    private function prepareData() {

        $startTimestamp = strtotime('yesterday') - 24 * 3600;

        foreach (range(1, 100) as $i) {
            $orders[] = [
                'uid' => 100000+$i,
                'promotion_id' => 1000,
                'user_id' => 50 + $i,
                'puser_id' => [2, 15][rand(0,1)],
                'price' => rand(20, 100),
                'miniprogram_id' => 1,
                'pay_product_id' => 1,
                'create_ip' => '192.168.0.1',
                'status' => ['PAID', 'UNPAID'][rand(0,1)],
                'trade_no' => uniqid('fake-1-'),
                'transaction_id' => uniqid('fake-2-'),
                'third_orderid' => uniqid('fake-3-'),
                'order_type' => 'COIN',
                'pay_merchant_source' => 'PALMPAY',
                'video_id' => 0,
                'video_series_sequence' => 0,
                'created_at' => date('Y-m-d H:i:s', $startTimestamp + $i * 800),
                'updated_at' => date('Y-m-d H:i:s', $startTimestamp + $i * 800),
            ];
        }

        DB::table('orders')->insert($orders);
    }
}
