ToolCommand.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?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->generateUserMiniProgramCode($user);
});
});
}
}