Group.php 1.3 KB
<?php

namespace app\admin\controller\qywx;

use addons\qyexternal\model\GroupChat;
use app\common\controller\Backend;
use think\Model;

/**
 * 企业微信客户群管理
 *
 * @icon fa fa-circle-o
 */
class Group extends Backend
{
    /**
     * @var null | Model
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new GroupChat();
    }

    /**
     * 列表
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $total = $this->model
                ->where($where)
                ->order($sort, $order)
                ->count();

            $list = $this->model
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();

            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }

        return $this->view->fetch();
    }

    public function member($ids)
    {
        $group = $this->model->get($ids);

        $corp = new \Weasy\Core\Corp(0, $group->corp_id);
        $members = $corp->getGroupMembers($group->chat_id);

        $this->assign("members", $members);
        return $this->view->fetch();
    }
}