app/Console/Commands/FanGroups.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $accountId = $this->argument('account_id');
        $account = $this->getAccount($accountId);
        $fanGroupModel = new FanGroupModel();
        $groupService = new Group($account->app_id, $account->app_secret);
        $groups = $groupService->lists();
        if ($groups) {
            $insert = [];
            $this->output->progressStart(count($groups));
            foreach ($groups as $groupKey => $group) {
                $insert[$groupKey]['group_id'] = $group['id'];
                $insert[$groupKey]['account_id'] = $account->id;
                $insert[$groupKey]['title'] = $group['name'];
                $insert[$groupKey]['fan_count'] = $group['count'];
                $insert[$groupKey]['is_default'] = in_array($group['name'], ['默认组', '屏蔽组', '星标组']) ? 1 : 0;
                $this->info("\t{$group['name']} created!");
                $this->output->progressAdvance();
            }
            $fanGroupModel->where('account_id', $account->id)->forceDelete();
            $result = $fanGroupModel->insert($insert);
        }
        $this->output->progressFinish();
    }
public function handle ( ) { $ accountId = $ this -> argument ( 'account_id' ) ; $ account = $ this -> getAccount ( $ accountId ) ; $ fanGroupModel = new FanGroupModel ( ) ; $ groupService = new Group ( $ account -> app_id , $ account -> app_secret ) ; $ groups = $ groupService -> lists ( ) ; if ( $ groups ) { $ insert = [ ] ; $ this -> output -> progressStart ( count ( $ groups ) ) ; foreach ( $ groups as $ groupKey => $ group ) { $ insert [ $ groupKey ] [ 'group_id' ] = $ group [ 'id' ] ; $ insert [ $ groupKey ] [ 'account_id' ] = $ account -> id ; $ insert [ $ groupKey ] [ 'title' ] = $ group [ 'name' ] ; $ insert [ $ groupKey ] [ 'fan_count' ] = $ group [ 'count' ] ; $ insert [ $ groupKey ] [ 'is_default' ] = in_array ( $ group [ 'name' ] , [ '默认组', '屏蔽组 '  '星标组']) ?  1 : 0; $ this -> info ( " \t { $ group [ 'name' ] }  created! " ) ; $ this -> output -> progressAdvance ( ) ; } $ fanGroupModel -> where ( 'account_id' , $ account -> id ) -> forceDelete ( ) ; $ result = $ fanGroupModel -> insert ( $ insert ) ; } $ this -> output -> progressFinish ( ) ; }
Execute the console command.
Execute the console command .
/*
         * 1 获取Account
         */ /*
         * 2 初始化 SDK Config, 构建 SDK 对象
         */ /*
             * clean
             */