删除卡券
@param $card_id
@return bool
@throws HttpException
193079
public function deleteCard($card_id)
    {
        if (empty($card_id)) {
            return false;
        }

        $result = $this->httpPost(static::WECHAT_DELETE_CARD_URL . 'access_token=' . $this->getAccessToken(), [
            'card_id' => $card_id
        ]);

        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? true : false;
    }
659141
public function qrcode($card)
    {
        if (!is_array($card)) {
            $this->setError('参数缺失');

            return false;
        }

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

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

        return $res;
    }
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;
        }
    }
210691
public function verifyCard(Card $card)
    {
        if ($this->verifySelfSignature) {
            if (!$this->validateSignerSignature($card, 'self', $card->getPublicKey())) {
                return false;
            }
        }

        if ($this->verifyVirgilSignature) {
            if (!$this->validateSignerSignature($card, 'virgil', $this->virgilPublicKey)) {
                return false;
            }
        }

        foreach ($this->whiteLists as $whiteList) {
            $isOk = false;
            foreach ($whiteList->getCredentials() as $credentials) {
                if ($this->validateSignerSignature($card, $credentials->getSigner(), $credentials->getPublicKey())) {
                    $isOk = true;
                    break;
                }
            }

            if (!$isOk) {
                return false;
            }
        }

        return true;
    }
525417
public static function load($cardId) {
    $card = Core::$store->read('otp-card', $cardId);
    if($card !== false) {
      if($card['hash'] !== hash(self::HASH_TYPE, $card['list'])) {
        return false;
      }
      $card['list'] = json_decode(base64_decode($card['list']), true);
      return $card;
    }
    return false;
  }
760855
public function wxCardPackage(array $card_list, $timestamp = null, $api_ticket = null)
    {
        if (!is_array($card_list)) {
            $this->setError('参数缺失');

            return false;
        }

        if (empty($timestamp) || $timestamp == '') {
            $timestamp = time();
        }

        if (empty($api_ticket) || $api_ticket == '') {
            $api_ticket = $this->cardApiTicket();
        }

        $resultArray = [];
        foreach ($card_list as $key => $value) {
            if (empty($value['code']) || !isset($value['code'])) {
                $value['code'] = '';
            }
            if (empty($value['openid']) || !isset($value['openid'])) {
                $value['openid'] = '';
            }
            $arrays = [$api_ticket, $timestamp, $value['card_id'], $value['code'], $value['openid']];
            sort($arrays, SORT_STRING);
            $string = sha1(implode($arrays));

            $resultArray['cardList'][$key]['cardId']            = $value['card_id'];
            $resultArray['cardList'][$key]['cardExt']['code']   = $value['code'];
            $resultArray['cardList'][$key]['cardExt']['openid'] = $value['openid'];

            $resultArray['cardList'][$key]['cardExt']['timestamp'] = $timestamp;
            $resultArray['cardList'][$key]['cardExt']['signature'] = $string;

            if (!empty($value['outer_id'])) {
                $resultArray['cardList'][$key]['cardExt']['outer_id'] = $value['outer_id'];
            }
            $resultArray['cardList'][$key]['cardExt'] = json_encode($resultArray['cardList'][$key]['cardExt']);
        }
        $resultJson = json_encode($resultArray);

        return $resultJson;
    }
1312212
public function updateStock($cardId, $amount)
    {
        if (!$amount) {
            return true;
        }

        $key = $amount > 0 ? 'increase_stock_value' : 'reduce_stock_value';

        $params = array(
            'card_id' => $cardId,
            $key => abs($amount),
        );

        return $this->http->jsonPost(self::API_UPDATE_STOCK, $params);
    }
1369750
public function setCard($id, $cardId)
    {
        return $this->put($this->getPath().'/'.rawurlencode($id).'/idCard', array('value' => $cardId));
    }
693539
public function deletePoi($poi_id)
    {
        if (empty($poi_id)) {
            return false;
        }
        $raw = Json::encode(['poi_id'=>$poi_id]);

        $result = $this->httpRaw(static::WECHAT_DEL_POI_URL . 'access_token=' . $this->getAccessToken(), $raw);

        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? true : false;
    }
860135
public function updateLuckyMoney($code,$balance,$card_id='') {
        $data = array(
                'code' => $code,
                'balance' => $balance
        );
        if ($card_id)
            $data['card_id'] = $card_id;
        if (!$this->access_token && !$this->checkAuth()) return false;
        $result = $this->http_post(self::API_BASE_URL_PREFIX . self::CARD_LUCKYMONEY_UPDATE . '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 true;
        }
        return false;
    }
68902
@Override
    public WxResp card_code_consume(String code, String cardId) {
    	NutMap body = NutMap.NEW().addv("code", code);
    	if (cardId != null) {
    		body.addv("card_id", cardId);
    	}

    	// 由于核销卡券API中没有“/cgi-bin”，所以uri不能只写“/card/code/consume”
    	return postJson("https://api.weixin.qq.com/card/code/consume", body);
    }
826946
public function payConfirm($card_id, $quantity, $order_id)
    {
        $data = ['card_id' => $card_id, 'quantity' => $quantity, 'order_id' => $order_id];
        $url = "https://api.weixin.qq.com/card/pay/confirm?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
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;
    }
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;
    }
1168813
public function getCode($code, $card_id = null, $check_consume = null)
    {
        $data = ['code' => $code];
        is_null($card_id) || $data['card_id'] = $card_id;
        is_null($check_consume) || $data['check_consume'] = $check_consume;
        $url = "https://api.weixin.qq.com/card/code/get?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
607237
def fetch(self, card_id, data={}, **kwargs):
        "
        return super(Card, self).fetch(card_id, data, **kwargs)