File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -46,13 +46,14 @@ public function onOpen($server, $request)
46
46
47
47
$ action = $ req ['action ' ] ?? '' ;
48
48
switch ($ action ) {
49
- case 'api_excel ' :
49
+ case 'api_excel ' : // api_excel 列表完成率
50
50
while (true ) {
51
- $ data = $ this -> apiExcel () ;
52
- $ server ->push ($ request ->fd , $ data );
51
+ $ user_id = auth ( ' api ' )-> user ()[ ' id ' ] ;
52
+ $ server ->push ($ request ->fd , $ this -> apiExcel ( $ user_id ) );
53
53
sleep (5 );
54
54
$ state = ApiExcel::where ('state ' , 1 )->first ();
55
55
if (!$ state ) {
56
+ $ server ->push ($ request ->fd , $ this ->apiExcel ($ user_id ));
56
57
break ;
57
58
}
58
59
// 每个用户 fd 限制请求次数
@@ -65,7 +66,7 @@ public function onOpen($server, $request)
65
66
$ count = $ this ->redis ->incr ($ redisKey );
66
67
if ($ count == 1 ) {
67
68
// 设置过期时间
68
- $ this ->redis ->expire ($ redisKey , 600 );
69
+ $ this ->redis ->expire ($ redisKey , 6000 );
69
70
}
70
71
if ($ count > 200 ) { // 防止刷单的安全拦截
71
72
break ; // 超出就跳出循环
@@ -137,12 +138,12 @@ protected function getRateById($id)
137
138
/**
138
139
* 获取api_excel 列表-完成率
139
140
*
141
+ * @param int $user_id 用户 id
142
+ *
140
143
* @return array
141
144
*/
142
- private function apiExcel ()
145
+ private function apiExcel ($ user_id )
143
146
{
144
- $ user_id = auth ('api ' )->user ()['id ' ];
145
-
146
147
// 查询对应用户的上传数据
147
148
$ where = [];
148
149
if ($ user_id != 1 ) {
You can’t perform that action at this time.
0 commit comments