|
1
|
<?php
|
1
|
<?php
|
|
2
|
|
2
|
|
|
3
|
namespace App\Console\Commands\AyrShare;
|
3
|
namespace App\Console\Commands\AyrShare;
|
|
|
|
4
|
+use App\Helper\AyrShare as AyrShareHelper;
|
|
|
|
5
|
+use App\Models\AyrShare\AyrRelease as AyrReleaseModel;
|
|
|
|
6
|
+use Carbon\Carbon;
|
|
|
|
7
|
+use App\Models\AyrShare\AyrShare as AyrShareModel;
|
|
4
|
use Illuminate\Console\Command;
|
8
|
use Illuminate\Console\Command;
|
|
5
|
|
9
|
|
|
6
|
class ShareUser extends Command
|
10
|
class ShareUser extends Command
|
|
7
|
{
|
11
|
{
|
|
|
|
12
|
+ public $error = 0;
|
|
|
|
13
|
+ /**
|
|
|
|
14
|
+ * The name and signature of the console command.
|
|
|
|
15
|
+ *
|
|
|
|
16
|
+ * @var string
|
|
|
|
17
|
+ */
|
|
|
|
18
|
+ protected $signature = 'share_user';
|
|
|
|
19
|
+
|
|
|
|
20
|
+ /**
|
|
|
|
21
|
+ * The console command description.
|
|
|
|
22
|
+ *
|
|
|
|
23
|
+ * @var string
|
|
|
|
24
|
+ */
|
|
|
|
25
|
+ protected $description = '用户一周内无记录清除Ayr_share';
|
|
8
|
/**
|
26
|
/**
|
|
9
|
* @name :(定时执行)handle
|
27
|
* @name :(定时执行)handle
|
|
10
|
* @author :lyh
|
28
|
* @author :lyh
|
|
@@ -13,6 +31,54 @@ class ShareUser extends Command |
|
@@ -13,6 +31,54 @@ class ShareUser extends Command |
|
13
|
*/
|
31
|
*/
|
|
14
|
public function handle()
|
32
|
public function handle()
|
|
15
|
{
|
33
|
{
|
|
|
|
34
|
+ $this->user_operator_record();
|
|
|
|
35
|
+ }
|
|
16
|
|
36
|
|
|
|
|
37
|
+ /**
|
|
|
|
38
|
+ * @name : 检测用户是否无操作记录
|
|
|
|
39
|
+ * @author :lyh
|
|
|
|
40
|
+ * @method :post
|
|
|
|
41
|
+ * @time :2023/5/12 14:55
|
|
|
|
42
|
+ */
|
|
|
|
43
|
+ protected function user_operator_record(){
|
|
|
|
44
|
+ //获取所有ayr_share用户
|
|
|
|
45
|
+ $ayr_share_model = new AyrShareModel();
|
|
|
|
46
|
+ $ayr_share_list = $ayr_share_model->list();
|
|
|
|
47
|
+ foreach ($ayr_share_list as $k => $v){
|
|
|
|
48
|
+ //查询当前用户是否有未推送的博文
|
|
|
|
49
|
+ $ayr_release = new AyrReleaseModel();
|
|
|
|
50
|
+ $release_info = $ayr_release->read(['idempotency_key'=>['<',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
|
|
|
|
51
|
+ //有推文时,直接跳出循环
|
|
|
|
52
|
+ if($release_info !== false){
|
|
|
|
53
|
+ continue;
|
|
|
|
54
|
+ }
|
|
|
|
55
|
+ //查看用户是否在一周内有发送博客
|
|
|
|
56
|
+ $start_at = Carbon::now()->modify('-7 days')->toDateString();
|
|
|
|
57
|
+ $end_at = Carbon::now()->toDateString();
|
|
|
|
58
|
+ $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]);
|
|
|
|
59
|
+ //有发送博文,则跳出循环
|
|
|
|
60
|
+ if($release_info == false){
|
|
|
|
61
|
+ continue;
|
|
|
|
62
|
+ }
|
|
|
|
63
|
+ //删除用户第三方配置
|
|
|
|
64
|
+ $ayr_share_helper = new AyrShareHelper();
|
|
|
|
65
|
+ $res = $ayr_share_helper->deleted_profiles();
|
|
|
|
66
|
+ if($res['status'] == 'fail'){
|
|
|
|
67
|
+ $this->error++;
|
|
|
|
68
|
+ continue;
|
|
|
|
69
|
+ }
|
|
|
|
70
|
+ //更新数据库
|
|
|
|
71
|
+ $data = [
|
|
|
|
72
|
+ 'title'=>null,
|
|
|
|
73
|
+ 'bind_plat_from'=>null,
|
|
|
|
74
|
+ 'profile_key'=>null,
|
|
|
|
75
|
+ 'ref_id'=>null,
|
|
|
|
76
|
+ ];
|
|
|
|
77
|
+ $res = $ayr_share_model->edit($data,['id'=>$v['id']]);
|
|
|
|
78
|
+ if($res == false){
|
|
|
|
79
|
+ $this->error++;
|
|
|
|
80
|
+ }
|
|
|
|
81
|
+ }
|
|
|
|
82
|
+ return $this->error;
|
|
17
|
}
|
83
|
}
|
|
18
|
} |
84
|
} |