ToolCommand.php 2.1 KB
<?php
/**
 * +-----------------------------------------------------------------------------------------------------------------------
 * Command :工具类相关
 * +-----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Console\Commands
 * @package   App\Console\Commands
 * @author    Richer <yangzi1028@163.com>
 * @date      2022年9月20日11:07:50
 * @copyright 2022-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Console\Commands;

use App\Models\Traits\ChatTrait;
use App\Models\User\User;
use Illuminate\Console\Command;

class ToolCommand extends Command
{
    use ChatTrait;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:tool';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '';

    /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $this->generateWallet();
        // 批量创建用户的小程序二维码
        $this->generateQrCode();

    }

    /**
     * 批量创建用户的小程序二维码
     */
    public function generateWallet()
    {
        User::chunkById(100, function ($users)  {
            $users->each(function ($user) {
                // 生成用户小程序码
                $this->generateUserWallet($user);
            });
        });
    }

    /**
     * 批量创建用户的小程序二维码
     */
    public function generateQrCode()
    {
        User::where(function ($query) {
//            $query->whereNull('invite_qr_code')->orWhere('invite_qr_code', '');
        })->chunkById(100, function ($users)  {
            $users->each(function ($user) {
                // 生成用户小程序码
                $this->generateUserQrCode($user);
            });
        });
    }
}