浏览代码

修改微信黑名单处理

邹景立 3 年之前
父节点
当前提交
1e43ec64fa
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      app/wechat/command/Fans.php

+ 4 - 2
app/wechat/command/Fans.php

@@ -102,11 +102,13 @@ class Fans extends Command
      */
     public function _black(string $next = '', int $done = 0): string
     {
+        $wechat = WechatService::WeChatUser();
         $this->setQueueProgress("开始更新黑名单的微信用户");
-        [$map, $data, $wechat] = [['is_black' => 0], ['is_black' => 1], WechatService::WeChatUser()];
         while (!is_null($next) && is_array($result = $wechat->getBlackList($next)) && !empty($result['data']['openid'])) {
             foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
-                $this->app->db->name('WechatFans')->where($map)->whereIn('openid', $chunk)->update($data);
+                $done += count($chunk);
+                $map = [['is_black', '=', 0], ['openid', 'in', $chunk]];
+                $this->app->db->name('WechatFans')->where($map)->update(['is_black' => 1]);
             }
             $next = $result['total'] > $done ? $result['next_openid'] : null;
         }