作者 邓超

email

@@ -146,33 +146,36 @@ class Home extends Base { @@ -146,33 +146,36 @@ class Home extends Base {
146 // 通过时间来搜索uid 146 // 通过时间来搜索uid
147 $uids = $mail->client->search(['SINCE'=>date('d-M-Y',$udate)],true); 147 $uids = $mail->client->search(['SINCE'=>date('d-M-Y',$udate)],true);
148 if ($uids){ 148 if ($uids){
149 - // 已有的uid  
150 - $useuids = db()->all(  
151 - sprintf(  
152 - "select `uid` from `%s` where `email_id` = %d and `folder_id` = %d and `uid` in (%s)",  
153 - listsSql::$table,  
154 - $email['id'],  
155 - $folder['id'],  
156 - implode(',',$uids)  
157 - )  
158 - );  
159 - $useuids = $useuids ? array_column($useuids,'uid') : [];  
160 - if($useuids){  
161 - // 删除多余的  
162 - foreach ($uids as $k=>$uid){  
163 - if(in_array($uid,$useuids)){  
164 - unset($uids[$k]);  
165 - }  
166 - } 149 +
  150 + $us = [];
  151 + foreach ($uids as $k=>$uid){
  152 + if(!isset($us[intval($k/100)])) $us[intval($k/100)] = [];
  153 + $us[intval($k/100)][] = $uid;
167 } 154 }
168 - if($uids){  
169 - $us = [];  
170 - foreach ($uids as $k=>$uid){  
171 - if(!isset($us[intval($k/100)])) $us[intval($k/100)] = [];  
172 - $us[intval($k/100)][] = $uid; 155 +
  156 + foreach ($us as $u){
  157 + // 已有的uid
  158 + $useuids = db()->all(
  159 + sprintf(
  160 + "select `uid` from `%s` where `email_id` = %d and `folder_id` = %d and `uid` in (%s)",
  161 + listsSql::$table,
  162 + $email['id'],
  163 + $folder['id'],
  164 + implode(',',$u)
  165 + )
  166 + );
  167 + $useuids = $useuids ? array_column($useuids,'uid') : [];
  168 + if($useuids){
  169 + // 删除多余的
  170 + foreach ($u as $k=>$ui){
  171 + if(in_array($ui,$useuids)){
  172 + unset($u[$k]);
  173 + }
  174 + }
173 } 175 }
174 176
175 - foreach ($us as $u){ 177 +
  178 + if($u){
176 // 进行同步 179 // 进行同步
177 $mail->syncUidEmail( 180 $mail->syncUidEmail(
178 array_values($u), 181 array_values($u),
@@ -185,8 +188,11 @@ class Home extends Base { @@ -185,8 +188,11 @@ class Home extends Base {
185 ); 188 );
186 } 189 }
187 190
  191 +
188 } 192 }
189 193
  194 +
  195 +
190 } 196 }
191 197
192 } 198 }