创建会员卡之前，附加会员卡的资料

@param WechatCardRecord $card
@param $data
503976
public function onPreWechatCreateCard(WechatCardRecord $card, &$data)
    {
        if ($card['type'] != WechatCardRecord::TYPE_MEMBER_CARD) {
            return;
        }

        $data = wei()->wechatMemberCard->addWechatCardData($card, $data);
    }
312222
public function payGiftCard(array $data)
    {
        $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
192058
public function unAvailable($code, $card_id, $reason = null)
    {
        $data = ['code' => $code, 'card_id' => $card_id];
        is_null($reason) || $data['reason'] = $reason;
        $url = "https://api.weixin.qq.com/card/code/unavailable?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
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;
        }
    }
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]);
    }
338840
public function populateCard($card, CreditCardPaymentForm $paymentForm)
    {
        if (!$card instanceof CreditCard) {
            return;
        }

        $card->setFirstName($paymentForm->firstName);
        $card->setLastName($paymentForm->lastName);
        $card->setNumber($paymentForm->number);
        $card->setExpiryMonth($paymentForm->month);
        $card->setExpiryYear($paymentForm->year);
        $card->setCvv($paymentForm->cvv);
    }
1265519
public function createAddCardJsPackage($cardid = null, $data = array())
    {
        $cardList = array();
        if (is_array($cardid)) {
            foreach ($cardid as $id) {
                $cardList[] = array('cardId' => $id, 'cardExt' => json_encode($this->_cardSign($id, $data)));
            }
        } else {
            $cardList[] = array('cardId' => $cardid, 'cardExt' => json_encode($this->_cardSign($cardid, $data)));
        }
        return array('cardList' => $cardList);
    }
1329109
public function deposit($card_id, array $code)
    {
        $url = "https://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
    }
606384
public function getCardMemberCardDetail($begin_date, $end_date, $card_id)
    {
        $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'card_id' => $card_id];
        $url = "https://api.weixin.qq.com/datacube/getcardmembercarddetail?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
1137134
public function createCard( CustomerVault\Card $card )
    {
        $card->setRequiredFields(array('profileID'));
        $card->checkRequiredFields();
        $card->setRequiredFields(array(
            'cardNum',
            'cardExpiry'
        ));
        $card->setOptionalFields(array(
            'nickName',
            'merchantRefNum',
            'holderName',
            'billingAddressId',
        ));

        $request = new Request(array(
            'method' => Request::POST,
            'uri' => $this->prepareURI("/profiles/" . $card->profileID . "/cards"),
            'body' => $card
        ));
        $response = $this->client->processRequest($request);
        $response['profileID'] = $card->profileID;

        return new CustomerVault\Card($response);
    }
536589
final function cards($c) {return array_map(function($data) {return
		Card::create($this, $data)
	;}, $this->cardsData($c));}
740545
public function sendWxcardByTag($tag_id, $card_id, array $card_ext = array(), $is_to_all = false)
    {
        $ret = array();
        $ret['filter']['group_id'] = $tag_id;
        $ret['filter']['is_to_all'] = $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);
    }
1222641
public function activateuserform($card_id, $required_form = [], $optional_form = [])
    {
        if (empty($card_id) || !is_array($required_form) || !is_array($optional_form)) {
            $this->setError('参数错误');

            return false;
        }

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

        $queryStr = array_merge($queryStr, $required_form, $optional_form);

        $this->apitype = 'card';
        $this->module  = 'membercard';
        $res           = $this->_post('activateuserform/set', $queryStr);

        return $res;
    }
422809
protected function fillCardDetails($card)
    {
        if ($card) {
            $this->card_brand = $card->brand;
            $this->card_last_four = $card->last4;
        }

        return $this;
    }
1361598
public static function set($id, array $data)
    {
        self::init();
        //无id调用临时id
        $id = self::getID($id);
        if ($id === null) {
            self::setTmpID(); //临时id也不存则新写临时id
            $id = self::getID($id);
        }

        if (isset(self::$data[$id])) {
            self::$data[$id] = array_merge(self::$data[$id], $data); //合并多个场景数据
        } else {
            self::$data[$id] = $data;
        }
        self::$modified[$id] = 1; //标记该id的场景部分修改

        return true;
    }
1075246
public function setCodeUnavailable($code, $card_id = null)
    {
        if (empty($code)) {
            return false;
        }
        $result = $this->httpRaw(static::WECHAT_SET_CARD_CODE_UNAVAILABLE_URL . 'access_token=' . $this->getAccessToken(), [
            'code' => $code,
            empty($card_id) && 'card_id' => $card_id
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? true : false;
    }
907486
public function getdepositcount($card_id)
    {
        if (!is_string($card_id)) {
            $this->setError('参数错误');

            return false;
        }

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

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

        return $res;
    }