发送卡券消息

@param string $group_id
@param string $card_id
@param array $card_ext
@return array
968391
public function sendWxcardByGroup($group_id, $card_id, array $card_ext = array())
    {
        $ret = array();
        $ret['filter']['group_id'] = $group_id;
        if (! empty($this->is_to_all)) {
            $ret['filter']['is_to_all'] = $this->is_to_all;
        }
        $ret['msgtype'] = 'wxcard';
        $ret['wxcard']['card_id'] = $card_id;
        if (! empty($card_ext)) {
            $ret['wxcard']['card_ext'] = json_encode($card_ext);
        }
        return $this->sendAll($ret);
    }
758300
public function updateCard($card_id, array $member_card)
    {
        $url = "https://api.weixin.qq.com/card/update?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['card_id' => $card_id, 'member_card' => $member_card]);
    }
1021658
public static function cnIdcard($id_card)
    {
        /**
         * 计算身份证校验码，根据国家标准GB 11643-1999
         * @access protected static
         * @param string $idcard_base
         * @return int
         */
        $idcard_verify_number = function () use(&$id_card)
        {
            if (17 !== strlen($id_card))
            {
                return false;
            }
            // 加权因子
            $factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
            // 校验码对应值
            $verify_number_list = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
            $checksum = 0;
            $len = strlen($id_card);
            for ($i = 0; $i < $len; ++ $i)
            {
                $checksum += substr($id_card, $i, 1) * $factor[$i];
            }
            $mod = $checksum % 11;
            $verify_number = $verify_number_list[$mod];
            return $verify_number;
        };
        /**
         * 18位身份证校验码有效性检查
         * @access protected static
         * @param string $idcard
         * @return bool
         */
        $idcard_checksum18 = function () use(&$id_card, $idcard_verify_number)
        {
            if (18 !== strlen($id_card))
            {
                return false;
            }
            $id_card1 = $id_card;
            $id_card = substr($id_card, 0, 17);
            if ($idcard_verify_number() !== strtoupper(substr($id_card1, 17, 1)))
            {
                return false;
            }
            else
            {
                return true;
            }
        };
        /**
         * 将15位身份证升级到18位
         * @access protected static
         * @param string $idcard
         * @return string
         */
        $idcard_15to18 = function () use(&$id_card, $idcard_verify_number)
        {
            if (15 !== strlen($id_card))
            {
                return false;
            }
            else
            {
                // 如果身份证顺序码是996 997 998 999，这些是为百岁以上老人的特殊编码
                if (false !== array_search(substr($id_card, 12, 3), ['996','997','998','999']))
                {
                    $id_card = substr($id_card, 0, 6) . '18' . substr($id_card, 6, 9);
                }
                else
                {
                    $id_card = substr($id_card, 0, 6) . '19' . substr($id_card, 6, 9);
                }
            }
            $id_card = $id_card . $idcard_verify_number();
            return $id_card;
        };
        $len = strlen($id_card);
        if (18 === $len)
        {
            return $idcard_checksum18();
        }
        else if (15 === $len)
        {
            $id_card = $idcard_15to18();
            return $idcard_checksum18();
        }
        else
        {
            return false;
        }
    }
528484
public function modifyStock($card_id, $increase_stock_value = null, $reduce_stock_value = null)
    {
        $data = ['card_id' => $card_id];
        is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value;
        is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value;
        $url = "https://api.weixin.qq.com/card/modifystock?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
937834
public function attachExtension($cardId, array $extension = [])
    {
        $timestamp = time();
        $nonce = str_random(6);
        $ticket = $this->getTicket()['ticket'];

        $ext = array_merge(['timestamp' => $timestamp, 'nonce_str' => $nonce], Arr::only(
            $extension,
            ['code', 'openid', 'outer_id', 'balance', 'fixed_begintimestamp', 'outer_str']
        ));

        $ext['signature'] = $this->dictionaryOrderSignature($ticket, $timestamp, $cardId, $ext['code'] ?? '', $ext['openid'] ?? '', $nonce);

        return [
            'cardId' => $cardId,
            'cardExt' => json_encode($ext),
        ];
    }
531690
public function getCard($cardId)
    {
        $result = $this->wechat->httpPost(self::WECHAT_CARD_LIST_GET_PREFIX, [
            'card_id' => $cardId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? $result : false;
    }
98140
public function getcardlist($openid, $card_id = '')
    {
        if (empty($openid)) {
            $this->setError('缺少openid');

            return false;
        }

        $queryStr           = [];
        $queryStr['openid'] = $openid;

        if (!empty($card_id)) {
            $queryStr['card_id'] = $card_id;
        }

        $this->apitype = 'card';
        $this->module  = 'user';
        $res           = $this->_post('getcardlist', $queryStr);

        return $res;
    }
123557
public function previewWxcard($card_id = '', $userid = '', $type = 'openid')
    {
        $queryStr = [];

        if ($type == 'towxname') {
            $queryStr['towxname'] = $userid;
        } else {
            $queryStr['touser'] = $userid;
        }

        $queryStr['wxcard']['card_id'] = $card_id;
        $queryStr['msgtype']           = 'wxcard';

        $this->module = 'message';

        $res = $this->_post('mass/preview', $queryStr);

        return $res;
    }
1068716
public function create($type = 'member_card', $base_info = [], $especial = [], $advanced_info = [])
    {
        if (!is_string($type) || !is_array($base_info) || !is_array($especial)) {
            $this->setError('参数缺失');

            return false;
        }

        $card                      = [];
        $card['card']              = [];
        $card['card']['card_type'] = strtoupper($type);

        $type = strtolower($type);

        $card['card'][$type] = [];

        $card_info              = [];
        $card_info['base_info'] = $base_info;

        $card['card'][$type] = array_merge($card_info, $especial, $advanced_info);

        $this->apitype = 'card';
        $this->module  = 'create';

        $res = $this->_post('', $card);

        return $res;
    }
724654
public static function destroyByGroup($group_id)
	{
		$group_id = (is_array($group_id) ? $group_id : array($group_id));

		$blank = self::blank();

		$query = $blank->getQuery()
			->delete($blank->getTableName())
			->whereIn('group_id', $group_id);

		if (!$query->execute())
		{
			return false;
		}

		return true;
	}
970426
public function groupAddUsers($group_id, $users)
    {
        if (count($users) >= 60 || count($users) < 1) {
            throw new EasemobError('一次最多可以添加60位成员,最少为1个');
        }

        $url          = $this->url.'chatgroups/'.$group_id.'/users';
        $option       = [
            'usernames' => $users
        ];
        $access_token = $this->getToken();
        $header []    = 'Authorization: Bearer '.$access_token;

        return Http::postCurl($url, $option, $header, 'POST');
    }
306755
@Override
    public WxResp card_code_get(String code, String cardId, Boolean checkConsume) {
    	NutMap body = NutMap.NEW().addv("code", code);
    	if (cardId != null) {
    		body.addv("card_id", cardId);
    	}
    	if (checkConsume != null) {
    		body.addv("check_consume", checkConsume);
    	}

    	// 由于查询Code API中没有“/cgi-bin”，所以uri不能只写“/card/code/get”
    	return postJson("https://api.weixin.qq.com/card/code/get", body);
    }
86103
public function batchUpdateGroupMembers($groupid,$openid_list){
		if (!$this->access_token && !$this->checkAuth()) return false;
		$data = array(
				'openid_list'=>$openid_list,
				'to_groupid'=>$groupid
		);
		$result = $this->http_post(self::API_URL_PREFIX.self::GROUP_MEMBER_BATCHUPDATE_URL.'access_token='.$this->access_token,self::json_encode($data));
		if ($result)
		{
			$json = json_decode($result,true);
			if (!$json || !empty($json['errcode'])) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'];
				return false;
			}
			return $json;
		}
		return false;
	}
44694
public function modifystock($card_id, $stock = 'increase', $value = 0)
    {
        $queryStr            = [];
        $queryStr['card_id'] = $card_id;
        if ($stock == 'increase') {
            $queryStr['increase_stock_value'] = intval($value);
        } elseif ($stock == 'reduce') {
            $queryStr['reduce_stock_value'] = intval($value);
        } else {
            $this->setError('$stock 参数错误');

            return false;
        }

        $this->apitype = 'card';
        $this->module  = 'modifystock';

        $res = $this->_post('', $queryStr);

        return $res;
    }
772996
public function deleteCard($card_id)
    {
        $url = "https://api.weixin.qq.com/card/delete?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['card_id' => $card_id]);
    }
671311
public function groupGetdetail($group_id,$begin=0,$count=1000){
        $params=array(
            'begin'=>$begin,
            'count'=>$count,
            'group_id'=>$group_id,
        );
        $rst = $this->_request->post($this->_url . 'group/getdetail', $params);
        return $this->_client->rst($rst);
    }
457758
function add_to_group($group_id, $ids)
    {
        if (!is_array($ids)) {
            $ids = explode(self::SEPARATOR, $ids);
        }

        $added  = 0;
        $exists = array();

        // get existing assignments ...
        $sql_result = $this->db->query(
            "SELECT `contact_id` FROM " . $this->db->table_name($this->db_groupmembers, true).
            " WHERE `contactgroup_id` = ?".
                " AND `contact_id` IN (".$this->db->array2list($ids, 'integer').")",
            $group_id
        );

        while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
            $exists[] = $sql_arr['contact_id'];
        }

        // ... and remove them from the list
        $ids = array_diff($ids, $exists);

        foreach ($ids as $contact_id) {
            $this->db->query(
                "INSERT INTO " . $this->db->table_name($this->db_groupmembers, true).
                " (`contactgroup_id`, `contact_id`, `created`)".
                " VALUES (?, ?, ".$this->db->now().")",
                $group_id,
                $contact_id
            );

            if ($error = $this->db->is_error()) {
                $this->set_error(self::ERROR_SAVING, $error);
            }
            else {
                $added++;
            }
        }

        return $added;
    }