Sfoglia il codice sorgente

合并微信同步指令

邹景立 5 anni fa
parent
commit
986da27207

+ 19 - 1
app/wechat/command/Fans.php

@@ -33,6 +33,11 @@ class Fans extends Command
      */
     protected $module = ['list', 'tags', 'black'];
 
+    protected function configure()
+    {
+        $this->setName('xadmin:fansall')->setDescription('[获取]同步远程的微信用户');
+    }
+
     /**
      * 执行指令
      * @param Input $input
@@ -41,8 +46,11 @@ class Fans extends Command
      */
     protected function execute(Input $input, Output $output)
     {
+        $message = '';
         foreach ($this->module as $m) {
-            if (method_exists($this, $fun = "_{$m}")) $this->$fun();
+            if (method_exists($this, $fun = "_{$m}")) {
+                $message .= $this->$fun();
+            }
         }
     }
 
@@ -50,6 +58,7 @@ class Fans extends Command
      * 同步微信粉丝列表
      * @param string $next
      * @param integer $done
+     * @return string
      * @throws \WeChat\Exceptions\InvalidResponseException
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\Exception
@@ -75,12 +84,14 @@ class Fans extends Command
         }
         $this->output->comment('微信粉丝数据同步完成!');
         $this->output->newLine();
+        return '';
     }
 
     /**
      * 同步粉丝黑名单列表
      * @param string $next
      * @param integer $done
+     * @return string
      * @throws \WeChat\Exceptions\InvalidResponseException
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\db\exception\DbException
@@ -99,11 +110,17 @@ class Fans extends Command
         }
         $this->output->comment('微信黑名单数据同步完成!');
         $this->output->newLine();
+        if (empty($result['total'])) {
+            return '同步微信用户0人';
+        } else {
+            return "同步微信用户{$result['total']}人";
+        }
     }
 
     /**
      * 同步粉丝标签列表
      * @param integer $index
+     * @return string
      * @throws \WeChat\Exceptions\InvalidResponseException
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\Exception
@@ -128,6 +145,7 @@ class Fans extends Command
         }
         $this->output->comment('微信粉丝标签数据同步完成!');
         $this->output->newLine();
+        return '';
     }
 
 }

+ 0 - 32
app/wechat/command/fans/FansAll.php

@@ -1,32 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | ThinkAdmin
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://demo.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
-// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
-// +----------------------------------------------------------------------
-
-namespace app\wechat\command\fans;
-
-use app\wechat\command\Fans;
-
-/**
- * 同步全部粉丝指令
- * Class FansAll
- * @package app\wechat\command\fans
- */
-class FansAll extends Fans
-{
-    protected function configure()
-    {
-        $this->module = ['list', 'black', 'tags'];
-        $this->setName('xsync:fansall')->setDescription('[同步]所有微信粉丝的数据');
-    }
-}

+ 0 - 32
app/wechat/command/fans/FansBlack.php

@@ -1,32 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | ThinkAdmin
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://demo.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
-// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
-// +----------------------------------------------------------------------
-
-namespace app\wechat\command\fans;
-
-use app\wechat\command\Fans;
-
-/**
- * 粉丝黑名单指令
- * Class FansBlack
- * @package app\wechat\command\fans
- */
-class FansBlack extends Fans
-{
-    protected function configure()
-    {
-        $this->module = ['black'];
-        $this->setName('xsync:fansblack')->setDescription('[同步]微信黑名单粉丝数据');
-    }
-}

+ 0 - 33
app/wechat/command/fans/FansList.php

@@ -1,33 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | ThinkAdmin
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://demo.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
-// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
-// +----------------------------------------------------------------------
-
-namespace app\wechat\command\fans;
-
-use app\wechat\command\Fans;
-
-/**
- * 粉丝列表指令管理
- * Class FansList
- * @package app\wechat\command\fans
- */
-class FansList extends Fans
-{
-    protected function configure()
-    {
-        $this->module = ['list'];
-        $this->setName('xsync:fanslist')->setDescription('[同步]微信粉丝的全部列表');
-    }
-
-}

+ 0 - 32
app/wechat/command/fans/FansTags.php

@@ -1,32 +0,0 @@
-<?php
-
-// +----------------------------------------------------------------------
-// | ThinkAdmin
-// +----------------------------------------------------------------------
-// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
-// +----------------------------------------------------------------------
-// | 官方网站: http://demo.thinkadmin.top
-// +----------------------------------------------------------------------
-// | 开源协议 ( https://mit-license.org )
-// +----------------------------------------------------------------------
-// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
-// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
-// +----------------------------------------------------------------------
-
-namespace app\wechat\command\fans;
-
-use app\wechat\command\Fans;
-
-/**
- * 粉丝标签指令
- * Class FansTags
- * @package app\wechat\command\fans
- */
-class FansTags extends Fans
-{
-    protected function configure()
-    {
-        $this->module = ['tags'];
-        $this->setName('xsync:fanstags')->setDescription('[同步]粉丝的标签记录数据');
-    }
-}

+ 1 - 1
app/wechat/controller/Fans.php

@@ -71,7 +71,7 @@ class Fans extends Controller
     public function sync()
     {
         try {
-            sysqueue('同步用户数据', "xsync:fansall", 1, [], 0);
+            sysqueue('同步用户数据', "xadmin:fansall", 1, [], 0);
             $this->success('创建任务成功,请等待完成!');
         } catch (HttpResponseException $exception) {
             throw $exception;

+ 1 - 6
app/wechat/sys.php

@@ -3,10 +3,5 @@
 use think\Console;
 
 Console::starting(function (Console $console) {
-    $console->addCommands([
-        'app\wechat\command\fans\fansAll',
-        'app\wechat\command\fans\fansBlack',
-        'app\wechat\command\fans\fansList',
-        'app\wechat\command\fans\fansTags',
-    ]);
+    $console->addCommand('app\wechat\command\Fans');
 });